├── Libraries
└── STM8S_StdPeriph_Driver
│ ├── Release_Notes.html
│ ├── inc
│ ├── stm8s.h
│ ├── stm8s_adc1.h
│ ├── stm8s_adc2.h
│ ├── stm8s_awu.h
│ ├── stm8s_beep.h
│ ├── stm8s_can.h
│ ├── stm8s_clk.h
│ ├── stm8s_exti.h
│ ├── stm8s_flash.h
│ ├── stm8s_gpio.h
│ ├── stm8s_i2c.h
│ ├── stm8s_itc.h
│ ├── stm8s_iwdg.h
│ ├── stm8s_rst.h
│ ├── stm8s_spi.h
│ ├── stm8s_tim1.h
│ ├── stm8s_tim2.h
│ ├── stm8s_tim3.h
│ ├── stm8s_tim4.h
│ ├── stm8s_tim5.h
│ ├── stm8s_tim6.h
│ ├── stm8s_uart1.h
│ ├── stm8s_uart2.h
│ ├── stm8s_uart3.h
│ ├── stm8s_uart4.h
│ └── stm8s_wwdg.h
│ ├── src
│ ├── stm8s_adc1.c
│ ├── stm8s_adc2.c
│ ├── stm8s_awu.c
│ ├── stm8s_beep.c
│ ├── stm8s_can.c
│ ├── stm8s_clk.c
│ ├── stm8s_exti.c
│ ├── stm8s_flash.c
│ ├── stm8s_gpio.c
│ ├── stm8s_i2c.c
│ ├── stm8s_itc.c
│ ├── stm8s_iwdg.c
│ ├── stm8s_rst.c
│ ├── stm8s_spi.c
│ ├── stm8s_tim1.c
│ ├── stm8s_tim2.c
│ ├── stm8s_tim3.c
│ ├── stm8s_tim4.c
│ ├── stm8s_tim5.c
│ ├── stm8s_tim6.c
│ ├── stm8s_uart1.c
│ ├── stm8s_uart2.c
│ ├── stm8s_uart3.c
│ ├── stm8s_uart4.c
│ └── stm8s_wwdg.c
│ └── stm8s-a_stdperiph_drivers_um.chm
├── MCD-ST Liberty SW License Agreement V2.pdf
├── Project
├── STM8S_StdPeriph_Examples
│ ├── ADC2
│ │ └── ADC2_ContinuousConversion
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── AWU
│ │ └── AWU_ActiveHaltMode
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── BEEP
│ │ └── BEEP_3SignalsGeneration
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── CAN
│ │ └── CAN_Networking
│ │ │ ├── main.c
│ │ │ ├── main.h
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── CLK
│ │ ├── CLK_ClockSecuritySystem
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── CLK_ClockSelection
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── CLK_MaxSpeed
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── EXTI
│ │ └── EXTI_InterruptPriority
│ │ │ ├── main.c
│ │ │ ├── main.h
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── FLASH
│ │ ├── FLASH_ByteReadWriteOperation
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── FLASH_DataProgram
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── FLASH_WriteWordOperation
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── GPIO
│ │ └── GPIO_Toggle
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── I2C
│ │ ├── I2C_EEPROM
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── I2C_TwoBoards
│ │ │ └── I2C_DataExchange
│ │ │ ├── Master
│ │ │ ├── main.c
│ │ │ ├── main.h
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ │ ├── Slave
│ │ │ ├── main.c
│ │ │ ├── main.h
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ │ └── readme.txt
│ ├── ITC
│ │ └── ITC_SoftwarePriority
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── IWDG
│ │ └── IWDG_Example
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── Library_Examples.html
│ ├── RST
│ │ └── RST_IllegalOpcode
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── Release_Notes.html
│ ├── SPI
│ │ ├── SPI_FastCommunicationMicroSD
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── SPI_FullDuplexUART1
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── SPI_SimplexLCD
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── TIM1
│ │ ├── TIM1_6Steps
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── TIM1_7PWM_Output
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── TIM1_ComplementarySignals_DeadTime_Break_Lock
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── TIM1_Input_Capture
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── TIM1_Sinewave_Generation
│ │ │ ├── main.c
│ │ │ ├── main.h
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── TIM2
│ │ ├── TIM2_OC_ActiveMode
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── TIM2_OC_InactiveMode
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── TIM2_PWM_DutyCycleConfiguration
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── TIM4
│ │ └── TIM4_TimeBase
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── TIM5
│ │ └── TIM5_Synchronisation_With_TIM6
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ ├── UART1
│ │ ├── UART1_HalfDuplex
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── UART1_HyperTerminal_Interrupt
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── UART1_Interrupt
│ │ │ ├── main.c
│ │ │ ├── main.h
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── UART1_IrDA
│ │ │ ├── Receive
│ │ │ │ ├── main.c
│ │ │ │ ├── stm8s_conf.h
│ │ │ │ ├── stm8s_it.c
│ │ │ │ └── stm8s_it.h
│ │ │ ├── Transmit
│ │ │ │ ├── main.c
│ │ │ │ ├── stm8s_conf.h
│ │ │ │ ├── stm8s_it.c
│ │ │ │ └── stm8s_it.h
│ │ │ └── readme.txt
│ │ ├── UART1_MultiProcessor
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── UART1_Printf
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ ├── UART1_SmartCard
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ │ └── UART1_Synchronous
│ │ │ ├── main.c
│ │ │ ├── readme.txt
│ │ │ ├── stm8s_conf.h
│ │ │ ├── stm8s_it.c
│ │ │ └── stm8s_it.h
│ └── WWDG
│ │ └── WWDG_Example
│ │ ├── main.c
│ │ ├── readme.txt
│ │ ├── stm8s_conf.h
│ │ ├── stm8s_it.c
│ │ └── stm8s_it.h
├── STM8S_StdPeriph_Template
│ ├── EWSTM8
│ │ ├── Project.ewd
│ │ ├── Project.ewp
│ │ ├── Project.eww
│ │ └── readme.txt
│ ├── RIDE
│ │ ├── STM8_OB.asm
│ │ ├── project.rprj
│ │ ├── readme.txt
│ │ ├── stm8af52ax.rapp
│ │ ├── stm8af622x.rapp
│ │ ├── stm8af626x.rapp
│ │ ├── stm8af62ax.rapp
│ │ ├── stm8s103.rapp
│ │ ├── stm8s105.rapp
│ │ ├── stm8s207.rapp
│ │ ├── stm8s208.rapp
│ │ └── stm8s903.rapp
│ ├── Release_Notes.html
│ ├── STVD
│ │ ├── Cosmic
│ │ │ ├── Project.stw
│ │ │ ├── readme.txt
│ │ │ ├── stm8_interrupt_vector.c
│ │ │ ├── stm8af52ax.stp
│ │ │ ├── stm8af622x.stp
│ │ │ ├── stm8af626x.stp
│ │ │ ├── stm8af62ax.stp
│ │ │ ├── stm8s003.stp
│ │ │ ├── stm8s005.stp
│ │ │ ├── stm8s007.stp
│ │ │ ├── stm8s103.stp
│ │ │ ├── stm8s105.stp
│ │ │ ├── stm8s207.stp
│ │ │ ├── stm8s208.stp
│ │ │ └── stm8s903.stp
│ │ └── Raisonance
│ │ │ ├── Project.stw
│ │ │ ├── readme.txt
│ │ │ ├── stm8af52ax.stp
│ │ │ ├── stm8af622x.stp
│ │ │ ├── stm8af626x.stp
│ │ │ ├── stm8af62ax.stp
│ │ │ ├── stm8s003.stp
│ │ │ ├── stm8s005.stp
│ │ │ ├── stm8s007.stp
│ │ │ ├── stm8s103.stp
│ │ │ ├── stm8s105.stp
│ │ │ ├── stm8s207.stp
│ │ │ ├── stm8s208.stp
│ │ │ └── stm8s903.stp
│ ├── main.c
│ ├── readme.txt
│ ├── stm8s_conf.h
│ ├── stm8s_it.c
│ └── stm8s_it.h
└── modbus
│ ├── .gitignore
│ ├── EWSTM8
│ ├── Project.ewd
│ ├── Project.ewp
│ ├── Project.eww
│ └── readme.txt
│ ├── RIDE
│ ├── STM8_OB.asm
│ ├── project.rprj
│ ├── readme.txt
│ ├── stm8af52ax.rapp
│ └── stm8af622x.rapp
│ ├── Release_Notes.html
│ ├── demo.c
│ ├── main.c
│ ├── modbus
│ ├── ascii
│ │ ├── mbascii.c
│ │ └── mbascii.h
│ ├── functions
│ │ ├── mbfunccoils.c
│ │ ├── mbfuncdiag.c
│ │ ├── mbfuncdisc.c
│ │ ├── mbfuncholding.c
│ │ ├── mbfuncinput.c
│ │ ├── mbfuncother.c
│ │ └── mbutils.c
│ ├── include
│ │ ├── mb.h
│ │ ├── mbconfig.h
│ │ ├── mbframe.h
│ │ ├── mbfunc.h
│ │ ├── mbport.h
│ │ ├── mbproto.h
│ │ └── mbutils.h
│ ├── mb.c
│ ├── rtu
│ │ ├── mbcrc.c
│ │ ├── mbcrc.h
│ │ ├── mbrtu.c
│ │ └── mbrtu.h
│ └── tcp
│ │ ├── mbtcp.c
│ │ └── mbtcp.h
│ ├── port
│ ├── port.h
│ ├── portevent.c
│ ├── portserial.c
│ └── porttimer.c
│ ├── readme.txt
│ ├── stm8s_conf.h
│ ├── stm8s_it.c
│ └── stm8s_it.h
├── README.md
├── Release_Notes.html
├── Utilities
└── STM8S_EVAL
│ ├── Common
│ ├── stm8s_eval_i2c_ee.c
│ ├── stm8s_eval_i2c_ee.h
│ ├── stm8s_eval_lcd.c
│ ├── stm8s_eval_lcd.h
│ ├── stm8s_eval_spi_sd.c
│ └── stm8s_eval_spi_sd.h
│ ├── Release_Notes.html
│ ├── STM8-128_EVAL
│ ├── stm8_128_eval.c
│ └── stm8_128_eval.h
│ ├── stm8s_eval.c
│ └── stm8s_eval.h
├── _htmresc
└── logo.bmp
├── doc
└── Modbus_Application_Protocol_V1_1b.pdf
└── stm8s-a_stdperiph_lib_um.chm
/Libraries/STM8S_StdPeriph_Driver/Release_Notes.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/Release_Notes.html
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/inc/stm8s_beep.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_beep.h
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains all functions prototype and macros for the BEEP peripheral.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | *
© COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM8S_BEEP_H
31 | #define __STM8S_BEEP_H
32 |
33 | /* Includes ------------------------------------------------------------------*/
34 | #include "stm8s.h"
35 |
36 | /* Exported types ------------------------------------------------------------*/
37 |
38 | /** @addtogroup BEEP_Exported_Types
39 | * @{
40 | */
41 |
42 | /**
43 | * @brief BEEP Frequency selection
44 | */
45 | typedef enum {
46 | BEEP_FREQUENCY_1KHZ = (uint8_t)0x00, /*!< Beep signal output frequency equals to 1 KHz */
47 | BEEP_FREQUENCY_2KHZ = (uint8_t)0x40, /*!< Beep signal output frequency equals to 2 KHz */
48 | BEEP_FREQUENCY_4KHZ = (uint8_t)0x80 /*!< Beep signal output frequency equals to 4 KHz */
49 | } BEEP_Frequency_TypeDef;
50 |
51 | /**
52 | * @}
53 | */
54 |
55 | /* Exported constants --------------------------------------------------------*/
56 |
57 | /** @addtogroup BEEP_Exported_Constants
58 | * @{
59 | */
60 |
61 | #define BEEP_CALIBRATION_DEFAULT ((uint8_t)0x0B) /*!< Default value when calibration is not done */
62 |
63 | #define LSI_FREQUENCY_MIN ((uint32_t)110000) /*!< LSI minimum value in Hertz */
64 | #define LSI_FREQUENCY_MAX ((uint32_t)150000) /*!< LSI maximum value in Hertz */
65 |
66 | /**
67 | * @}
68 | */
69 |
70 | /* Exported macros -----------------------------------------------------------*/
71 | /* Private macros ------------------------------------------------------------*/
72 |
73 | /** @addtogroup BEEP_Private_Macros
74 | * @{
75 | */
76 |
77 | /**
78 | * @brief Macro used by the assert function to check the different functions parameters.
79 | */
80 |
81 | /**
82 | * @brief Macro used by the assert function to check the BEEP frequencies.
83 | */
84 | #define IS_BEEP_FREQUENCY_OK(FREQ) \
85 | (((FREQ) == BEEP_FREQUENCY_1KHZ) || \
86 | ((FREQ) == BEEP_FREQUENCY_2KHZ) || \
87 | ((FREQ) == BEEP_FREQUENCY_4KHZ))
88 |
89 | /**
90 | * @brief Macro used by the assert function to check the LSI frequency (in Hz).
91 | */
92 | #define IS_LSI_FREQUENCY_OK(FREQ) \
93 | (((FREQ) >= LSI_FREQUENCY_MIN) && \
94 | ((FREQ) <= LSI_FREQUENCY_MAX))
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /* Exported functions ------------------------------------------------------- */
101 |
102 | /** @addtogroup BEEP_Exported_Functions
103 | * @{
104 | */
105 |
106 | void BEEP_DeInit(void);
107 | void BEEP_Init(BEEP_Frequency_TypeDef BEEP_Frequency);
108 | void BEEP_Cmd(FunctionalState NewState);
109 | void BEEP_LSICalibrationConfig(uint32_t LSIFreqHz);
110 |
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | #endif /* __STM8S_BEEP_H */
117 |
118 |
119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
120 |
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/inc/stm8s_rst.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_rst.h
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains all functions prototype and macros for the RST peripheral.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 | /* Define to prevent recursive inclusion -------------------------------------*/
28 | #ifndef __STM8S_RST_H
29 | #define __STM8S_RST_H
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm8s.h"
33 |
34 | /** @addtogroup STM8S_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup RST_Exported_Types
39 | * @{
40 | */
41 | typedef enum {
42 | RST_FLAG_EMCF = (uint8_t)0x10, /*!< EMC reset flag */
43 | RST_FLAG_SWIMF = (uint8_t)0x08, /*!< SWIM reset flag */
44 | RST_FLAG_ILLOPF = (uint8_t)0x04, /*!< Illigal opcode reset flag */
45 | RST_FLAG_IWDGF = (uint8_t)0x02, /*!< Independent watchdog reset flag */
46 | RST_FLAG_WWDGF = (uint8_t)0x01 /*!< Window watchdog reset flag */
47 | }RST_Flag_TypeDef;
48 |
49 | /**
50 | * @}
51 | */
52 |
53 | /* Exported constants --------------------------------------------------------*/
54 | /* Exported macros -----------------------------------------------------------*/
55 |
56 | /** @addtogroup RST_Private_Macros
57 | * @{
58 | */
59 |
60 | /**
61 | * @brief Macro used by the assert function to check the different functions parameters.
62 | */
63 | /**
64 | * @brief Macro used by the assert function to check the different RST flags.
65 | */
66 | #define IS_RST_FLAG_OK(FLAG) (((FLAG) == RST_FLAG_EMCF) || \
67 | ((FLAG) == RST_FLAG_SWIMF) ||\
68 | ((FLAG) == RST_FLAG_ILLOPF) ||\
69 | ((FLAG) == RST_FLAG_IWDGF) ||\
70 | ((FLAG) == RST_FLAG_WWDGF))
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @addtogroup RST_Exported_functions
77 | * @{
78 | */
79 | FlagStatus RST_GetFlagStatus(RST_Flag_TypeDef RST_Flag);
80 | void RST_ClearFlag(RST_Flag_TypeDef RST_Flag);
81 |
82 | /**
83 | * @}
84 | */
85 |
86 | #endif /* __STM8S_RST_H */
87 |
88 | /**
89 | * @}
90 | */
91 |
92 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
93 |
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/inc/stm8s_wwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ********************************************************************************
3 | * @file stm8s_wwdg.h
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains all functions prototype and macros for the WWDG peripheral.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __STM8S_WWDG_H
30 | #define __STM8S_WWDG_H
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | #include "stm8s.h"
34 |
35 | /** @addtogroup STM8S_StdPeriph_Driver
36 | * @{
37 | */
38 |
39 | /* Private macros ------------------------------------------------------------*/
40 |
41 | /** @addtogroup WWDG_Private_Macros
42 | * @{
43 | */
44 |
45 | /**
46 | * @brief Macro used by the assert function in order to check the
47 | * values of the window register.
48 | */
49 | #define IS_WWDG_WINDOWLIMITVALUE_OK(WindowLimitValue) ((WindowLimitValue) <= 0x7F)
50 |
51 | /**
52 | * @brief Macro used by the assert function in order to check the different
53 | * values of the counter register.
54 | */
55 | #define IS_WWDG_COUNTERVALUE_OK(CounterValue) ((CounterValue) <= 0x7F)
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /* Exported types ------------------------------------------------------------*/
62 |
63 | /* Exported functions ------------------------------------------------------- */
64 |
65 | /** @addtogroup WWDG_Exported_Functions
66 | * @{
67 | */
68 |
69 | void WWDG_Init(uint8_t Counter, uint8_t WindowValue);
70 | void WWDG_SetCounter(uint8_t Counter);
71 | uint8_t WWDG_GetCounter(void);
72 | void WWDG_SWReset(void);
73 | void WWDG_SetWindowValue(uint8_t WindowValue);
74 |
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | #endif /* __STM8S_WWDG_H */
81 |
82 | /**
83 | * @}
84 | */
85 |
86 |
87 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
88 |
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_can.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_can.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_clk.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_clk.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_flash.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_flash.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_i2c.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_i2c.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_iwdg.c:
--------------------------------------------------------------------------------
1 | /**
2 | ********************************************************************************
3 | * @file stm8s_iwdg.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains all the functions for the IWDG peripheral.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s_iwdg.h"
30 |
31 | /* Private define ------------------------------------------------------------*/
32 | /* Private macro -------------------------------------------------------------*/
33 | /* Private variables ---------------------------------------------------------*/
34 | /* Private function prototypes -----------------------------------------------*/
35 | /* Private functions ---------------------------------------------------------*/
36 | /* Public functions ----------------------------------------------------------*/
37 |
38 | /** @addtogroup IWDG_Public_Functions
39 | * @{
40 | */
41 |
42 | /**
43 | * @brief Enables or disables write access to Prescaler and Reload registers.
44 | * @param IWDG_WriteAccess : New state of write access to Prescaler and Reload
45 | * registers. This parameter can be a value of @ref IWDG_WriteAccess_TypeDef.
46 | * @retval None
47 | */
48 | void IWDG_WriteAccessCmd(IWDG_WriteAccess_TypeDef IWDG_WriteAccess)
49 | {
50 | /* Check the parameters */
51 | assert_param(IS_IWDG_WRITEACCESS_MODE_OK(IWDG_WriteAccess));
52 |
53 | IWDG->KR = (uint8_t)IWDG_WriteAccess; /* Write Access */
54 | }
55 |
56 | /**
57 | * @brief Sets IWDG Prescaler value.
58 | * @note Write access should be enabled
59 | * @param IWDG_Prescaler : Specifies the IWDG Prescaler value.
60 | * This parameter can be a value of @ref IWDG_Prescaler_TypeDef.
61 | * @retval None
62 | */
63 | void IWDG_SetPrescaler(IWDG_Prescaler_TypeDef IWDG_Prescaler)
64 | {
65 | /* Check the parameters */
66 | assert_param(IS_IWDG_PRESCALER_OK(IWDG_Prescaler));
67 |
68 | IWDG->PR = (uint8_t)IWDG_Prescaler;
69 | }
70 |
71 | /**
72 | * @brief Sets IWDG Reload value.
73 | * @note Write access should be enabled
74 | * @param IWDG_Reload : Reload register value.
75 | * This parameter must be a number between 0 and 0xFF.
76 | * @retval None
77 | */
78 | void IWDG_SetReload(uint8_t IWDG_Reload)
79 | {
80 | IWDG->RLR = IWDG_Reload;
81 | }
82 |
83 | /**
84 | * @brief Reloads IWDG counter
85 | * @note Write access should be enabled
86 | * @param None
87 | * @retval None
88 | */
89 | void IWDG_ReloadCounter(void)
90 | {
91 | IWDG->KR = IWDG_KEY_REFRESH;
92 | }
93 |
94 | /**
95 | * @brief Enables IWDG.
96 | * @param None
97 | * @retval None
98 | */
99 | void IWDG_Enable(void)
100 | {
101 | IWDG->KR = IWDG_KEY_ENABLE;
102 | }
103 |
104 | /**
105 | * @}
106 | */
107 |
108 | /**
109 | * @}
110 | */
111 |
112 |
113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
114 |
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_rst.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_rst.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains all the functions for the RST peripheral.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 |
30 | #include "stm8s_rst.h"
31 |
32 | /** @addtogroup STM8S_StdPeriph_Driver
33 | * @{
34 | */
35 | /* Private typedef -----------------------------------------------------------*/
36 | /* Private define ------------------------------------------------------------*/
37 | /* Private macro -------------------------------------------------------------*/
38 | /* Private variables ---------------------------------------------------------*/
39 | /* Private function prototypes -----------------------------------------------*/
40 | /* Private Constants ---------------------------------------------------------*/
41 | /* Public functions ----------------------------------------------------------*/
42 | /**
43 | * @addtogroup RST_Public_Functions
44 | * @{
45 | */
46 |
47 |
48 | /**
49 | * @brief Checks whether the specified RST flag is set or not.
50 | * @param RST_Flag : specify the reset flag to check.
51 | * This parameter can be a value of @ref RST_FLAG_TypeDef.
52 | * @retval FlagStatus: status of the given RST flag.
53 | */
54 | FlagStatus RST_GetFlagStatus(RST_Flag_TypeDef RST_Flag)
55 | {
56 | /* Check the parameters */
57 | assert_param(IS_RST_FLAG_OK(RST_Flag));
58 |
59 | /* Get flag status */
60 | return((FlagStatus)(((uint8_t)(RST->SR & RST_Flag) == (uint8_t)0x00) ? RESET : SET));
61 | }
62 |
63 | /**
64 | * @brief Clears the specified RST flag.
65 | * @param RST_Flag : specify the reset flag to clear.
66 | * This parameter can be a value of @ref RST_FLAG_TypeDef.
67 | * @retval None
68 | */
69 | void RST_ClearFlag(RST_Flag_TypeDef RST_Flag)
70 | {
71 | /* Check the parameters */
72 | assert_param(IS_RST_FLAG_OK(RST_Flag));
73 |
74 | RST->SR = (uint8_t)RST_Flag;
75 | }
76 |
77 | /**
78 | * @}
79 | */
80 |
81 | /**
82 | * @}
83 | */
84 |
85 |
86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
87 |
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim1.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim1.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim2.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim2.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim3.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim3.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim4.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim4.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim5.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim5.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim6.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_tim6.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_uart1.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_uart1.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_uart2.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_uart2.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_uart4.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/src/stm8s_uart4.c
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/src/stm8s_wwdg.c:
--------------------------------------------------------------------------------
1 | /**
2 | ********************************************************************************
3 | * @file stm8s_wwdg.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains all the functions for the WWDG peripheral.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s_wwdg.h"
30 |
31 | /** @addtogroup STM8S_StdPeriph_Driver
32 | * @{
33 | */
34 | /* Private define ------------------------------------------------------------*/
35 | #define BIT_MASK ((uint8_t)0x7F)
36 | /* Private macro -------------------------------------------------------------*/
37 | /* Private variables ---------------------------------------------------------*/
38 | /* Private function prototypes -----------------------------------------------*/
39 | /* Private functions ---------------------------------------------------------*/
40 |
41 | /** @addtogroup WWDG_Public_Functions
42 | * @{
43 | */
44 |
45 | /**
46 | * @brief Initializes the WWDG peripheral.
47 | * This function set Window Register = WindowValue, Counter Register
48 | * according to Counter and \b ENABLE \b WWDG
49 | * @param Counter : WWDG counter value
50 | * @param WindowValue : specifies the WWDG Window Register, range is 0x00 to 0x7F.
51 | * @retval None
52 | */
53 | void WWDG_Init(uint8_t Counter, uint8_t WindowValue)
54 | {
55 | /* Check the parameters */
56 | assert_param(IS_WWDG_WINDOWLIMITVALUE_OK(WindowValue));
57 |
58 | WWDG->WR = WWDG_WR_RESET_VALUE;
59 | WWDG->CR = (uint8_t)((uint8_t)(WWDG_CR_WDGA | WWDG_CR_T6) | (uint8_t)Counter);
60 | WWDG->WR = (uint8_t)((uint8_t)(~WWDG_CR_WDGA) & (uint8_t)(WWDG_CR_T6 | WindowValue));
61 | }
62 |
63 | /**
64 | * @brief Refreshes the WWDG peripheral.
65 | * @param Counter : WWDG Counter Value
66 | * This parameter must be a number between 0x40 and 0x7F.
67 | * @retval None
68 | */
69 | void WWDG_SetCounter(uint8_t Counter)
70 | {
71 | /* Check the parameters */
72 | assert_param(IS_WWDG_COUNTERVALUE_OK(Counter));
73 |
74 | /* Write to T[6:0] bits to configure the counter value, no need to do
75 | a read-modify-write; writing a 0 to WDGA bit does nothing */
76 | WWDG->CR = (uint8_t)(Counter & (uint8_t)BIT_MASK);
77 | }
78 |
79 | /**
80 | * @brief Gets the WWDG Counter Value.
81 | * This value could be used to check if WWDG is in the window, where
82 | * refresh is allowed.
83 | * @param None
84 | * @retval WWDG Counter Value
85 | */
86 | uint8_t WWDG_GetCounter(void)
87 | {
88 | return(WWDG->CR);
89 | }
90 |
91 | /**
92 | * @brief Generates immediate WWDG RESET.
93 | * @param None
94 | * @retval None
95 | */
96 | void WWDG_SWReset(void)
97 | {
98 | WWDG->CR = WWDG_CR_WDGA; /* Activate WWDG, with clearing T6 */
99 | }
100 |
101 | /**
102 | * @brief Sets the WWDG window value.
103 | * @param WindowValue: specifies the window value to be compared to the
104 | * downcounter.
105 | * This parameter value must be lower than 0x80.
106 | * @retval None
107 | */
108 | void WWDG_SetWindowValue(uint8_t WindowValue)
109 | {
110 | /* Check the parameters */
111 | assert_param(IS_WWDG_WINDOWLIMITVALUE_OK(WindowValue));
112 |
113 | WWDG->WR = (uint8_t)((uint8_t)(~WWDG_CR_WDGA) & (uint8_t)(WWDG_CR_T6 | WindowValue));
114 | }
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /**
121 | * @}
122 | */
123 |
124 |
125 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
126 |
--------------------------------------------------------------------------------
/Libraries/STM8S_StdPeriph_Driver/stm8s-a_stdperiph_drivers_um.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Libraries/STM8S_StdPeriph_Driver/stm8s-a_stdperiph_drivers_um.chm
--------------------------------------------------------------------------------
/MCD-ST Liberty SW License Agreement V2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/MCD-ST Liberty SW License Agreement V2.pdf
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/ADC2/ADC2_ContinuousConversion/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file ADC2_ContinuousConversion\main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains the main function for the ADC2 Continuous Conversion example.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s.h"
30 | #include "stm8s_eval.h"
31 |
32 | /**
33 | * @addtogroup ADC2_ContinuousConversion
34 | * @{
35 | */
36 |
37 | /* Private typedef -----------------------------------------------------------*/
38 | /* Private define ------------------------------------------------------------*/
39 | uint16_t Conversion_Value = 0;
40 | /* Private function prototypes -----------------------------------------------*/
41 | static void ADC_Config(void);
42 | static void GPIO_Config(void);
43 | /* Private functions ---------------------------------------------------------*/
44 |
45 | /**
46 | * @brief ADC2_ContinuousConversion main entry point.
47 | * @param None
48 | * @retval None
49 | */
50 | void main(void)
51 | {
52 | /* GPIO configuration ------------------------------------------*/
53 | GPIO_Config();
54 |
55 | /* ADC configuration -------------------------------------------*/
56 | ADC_Config();
57 |
58 | /* The LEDs state is changed in the interrupt routine */
59 | while (1);
60 | }
61 |
62 | /**
63 | * @brief Configure ADC2 Continuous Conversion with End Of Conversion interrupt
64 | * enabled .
65 | * @param None
66 | * @retval None
67 | */
68 | static void ADC_Config()
69 | {
70 | /* Init GPIO for ADC2 */
71 | GPIO_Init(GPIOE, GPIO_PIN_6, GPIO_MODE_IN_FL_NO_IT);
72 |
73 | /* De-Init ADC peripheral*/
74 | ADC2_DeInit();
75 |
76 | /* Init ADC2 peripheral */
77 | ADC2_Init(ADC2_CONVERSIONMODE_CONTINUOUS, ADC2_CHANNEL_9, ADC2_PRESSEL_FCPU_D2, \
78 | ADC2_EXTTRIG_TIM, DISABLE, ADC2_ALIGN_RIGHT, ADC2_SCHMITTTRIG_CHANNEL9,\
79 | DISABLE);
80 |
81 | /* Enable EOC interrupt */
82 | ADC2_ITConfig(ENABLE);
83 |
84 | /* Enable general interrupts */
85 | enableInterrupts();
86 |
87 | /*Start Conversion */
88 | ADC2_StartConversion();
89 | }
90 |
91 | /**
92 | * @brief Configure GPIO for LEDs and buttons available on the evaluation board
93 | * @param None
94 | * @retval None
95 | */
96 | static void GPIO_Config(void)
97 | {
98 | /* Initialize LEDs mounted on STM8-128 EVAL board */
99 | STM_EVAL_LEDInit(LED1);
100 | STM_EVAL_LEDInit(LED2);
101 | STM_EVAL_LEDInit(LED3);
102 | STM_EVAL_LEDInit(LED4);
103 |
104 | }
105 |
106 | #ifdef USE_FULL_ASSERT
107 |
108 | /**
109 | * @brief Reports the name of the source file and the source line number
110 | * where the assert_param error has occurred.
111 | * @param file: pointer to the source file name
112 | * @param line: assert_param error line source number
113 | * @retval None
114 | */
115 | void assert_failed(uint8_t* file, uint32_t line)
116 | {
117 | /* User can add his own implementation to report the file name and line number,
118 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
119 |
120 | /* Infinite loop */
121 | while (1)
122 | {
123 | }
124 | }
125 | #endif
126 |
127 | /**
128 | * @}
129 | */
130 |
131 |
132 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
133 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/ADC2/ADC2_ContinuousConversion/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page ADC2_ContinuousConversion Displaying the ADC2 conversion result using LEDs
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file ADC2/ADC2_ContinuousConversion/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief This file contains the description of ADC2 Continuous Conversion example.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides a short description of how to use the ADC peripheral
29 | to convert ADC2 Channel 9 input voltage in Continuous conversion mode with interrupt.
30 |
31 | In the STM8/128-EVAL board, ADC2 Channel 9 is connected to RV1 Adjuster.
32 | Turning RV1 adjuster provides a voltage which can vary from 0 Volt to 5 Volt.
33 | Depending on the voltage range, LEDs from 1 to 4 light up.
34 |
35 |
36 | @par Directory contents
37 |
38 | - ADC2\ADC2_ContinuousConversion\main.c Main file containing the "main" function
39 | - ADC2\ADC2_ContinuousConversion\stm8s_conf.h Library Configuration file
40 | - ADC2\ADC2_ContinuousConversion\stm8s_it.c Interrupt routines source
41 | - ADC2\ADC2_ContinuousConversion\stm8s_it.h Interrupt routines declaration
42 |
43 |
44 | @par Hardware and Software environment
45 |
46 | - This example runs on STM8S and STM8A high density devices.
47 |
48 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
49 | board and can be easily tailored to any other development board.
50 |
51 | - STM8/128-EVAL Set-up
52 | - RV1 adjuster
53 | - LD1..LD4
54 |
55 |
56 | @par How to use it ?
57 |
58 | In order to make the program work, you must do the following :
59 |
60 | - Copy all source files from this example folder to the template folder under
61 | Project\Template
62 | - Open your preferred toolchain
63 | - Rebuild all files and load your image into target memory
64 | - Run the example
65 | - Turn the potentiometer RV1 on the board to change the voltage to be converted
66 | - The four LEDs (LD1, LD2, LD3 and LD4) follow the ADC2 value
67 |
68 | @note
69 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
70 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
71 | density ranges between 32 to 128 Kbytes
72 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
73 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
74 | density ranges between 8 to 32 Kbytes
75 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
76 | where the Flash memory density ranges between 32 to 128 Kbytes.
77 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
78 | where the Flash memory density ranges between 16 to 32-Kbytes.
79 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
80 | where the Flash density is 8 Kbytes.
81 |
82 | * © COPYRIGHT STMicroelectronics
83 | */
84 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/CAN/CAN_Networking/main.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file CAN_Networking\main.h
4 | * @author MCD Application Team
5 | * @version V2.0.1
6 | * @date 18-November-2011
7 | * @brief This file contains the external declaration of main.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __MAIN_H
30 | #define __MAIN_H
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | #include "stm8s.h"
34 | #include "stm8s_eval.h"
35 | #include "stm8s_eval_lcd.h"
36 | /* Private variables ---------------------------------------------------------*/
37 | /* Exported types ------------------------------------------------------------*/
38 | /* Private typedef -----------------------------------------------------------*/
39 | /* Private define ------------------------------------------------------------*/
40 | #define Key_Pressed 0x01
41 | #define Key_NoPressed 0x00
42 | #define TIME 0x7FFF
43 |
44 | /* Public function prototypes -----------------------------------------------*/
45 | void CLK_Config(void);
46 | void CAN_Config(void);
47 | void GPIO_Config(void);
48 | void LCD_Config(void);
49 | void LED_Display(u8 Ledstatus);
50 | void LCD_Display(u8 Ledstatus);
51 | void Delay (uint16_t nCount);
52 |
53 |
54 | #endif /* __MAIN_H */
55 |
56 |
57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/CLK/CLK_MaxSpeed/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page CLK_MaxSpeed Configuring clocks for maximum speed
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file CLK/CLK_MaxSpeed/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief This file contains the description of Clock Max speed example.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides two optimal clock configurations
29 | - Fcpu running at 24Mhz (HSE)
30 | - Fcpu running at 16Mhz (HSI)
31 |
32 |
33 | @par Directory contents
34 |
35 | - CLK\CLK_MaxSpeed\main.c Main file containing the "main" function
36 | - CLK\CLK_MaxSpeed\main.h Main functions prototype
37 | - CLK\CLK_MaxSpeed\stm8s_conf.h Library Configuration file
38 | - CLK\CLK_MaxSpeed\stm8s_it.c Interrupt routines source
39 | - CLK\CLK_MaxSpeed\stm8s_it.h Interrupt routines declaration
40 |
41 |
42 | @par Hardware and Software environment
43 |
44 | - This example runs on STM8S and STM8A High density, Medium density and Low
45 | density devices.
46 |
47 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
48 | board and can be easily tailored to any other development board.
49 |
50 | - STM8/128-EVAL Set-up
51 | - KEY Button
52 |
53 |
54 | @par How to use it ?
55 |
56 | In order to make the program work, you must do the following :
57 |
58 | - Copy all source files from this example folder to the template folder under
59 | Project\Template
60 | - Open your preferred toolchain
61 | - Rebuild all files and load your image into target memory
62 | - Run the example
63 | - Using the KEY button switch from HSE to HSI.
64 | - The clock switching can be monitored by putting a scope on PE0 (CCO).
65 |
66 | @par Hint
67 |
68 | - Before using the HSE clock make sure that the "Flash_Wait_States" is set to 1.
69 | - To do so :
70 | - with STVD (menu: Debug Instrument -> MCU configuration -> Options)
71 | - with RIDE (edit the "STM8_OB.asm" file to configure the OPT7 & NOPT7 option bytes)
72 | - with EWSTM8 (menu: ST-LINK -> Option bytes ->Flash_Wait_States: 1)
73 |
74 | @note
75 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
76 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
77 | density ranges between 32 to 128 Kbytes
78 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
79 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
80 | density ranges between 8 to 32 Kbytes
81 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
82 | where the Flash memory density ranges between 32 to 128 Kbytes.
83 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
84 | where the Flash memory density ranges between 16 to 32-Kbytes.
85 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
86 | where the Flash density is 8 Kbytes.
87 |
88 | * © COPYRIGHT STMicroelectronics
89 | */
90 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/EXTI/EXTI_InterruptPriority/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file EXTI_InterruptPriority\main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains the main function for the EXTI Interrupt Priority example.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s.h"
30 | #include "main.h"
31 |
32 | /**
33 | * @addtogroup EXTI_InterruptPriority
34 | * @{
35 | */
36 |
37 | /* Private typedef -----------------------------------------------------------*/
38 | /* Private define ------------------------------------------------------------*/
39 | /* Public functions ----------------------------------------------------------*/
40 | /* Private function prototypes -----------------------------------------------*/
41 | static void GPIO_Config(void);
42 | /* Private functions ---------------------------------------------------------*/
43 |
44 | /**
45 | * @brief Main program.
46 | * @param None
47 | * @retval None
48 | */
49 | void main(void)
50 | {
51 |
52 | /* GPIO Configuration -----------------------------------------*/
53 | GPIO_Config();
54 |
55 | /* Initialize the Interrupt sensitivity */
56 | EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_ONLY);
57 | EXTI_SetTLISensitivity(EXTI_TLISENSITIVITY_FALL_ONLY);
58 |
59 | enableInterrupts();
60 |
61 | while (1)
62 | {
63 | /* The LED toggles in the interrupt routines */
64 | }
65 |
66 | }
67 |
68 | /**
69 | * @brief Configure GPIO for buttons and Leds available on the evaluation board
70 | * @param None
71 | * @retval None
72 | */
73 | static void GPIO_Config(void)
74 | {
75 | /* Initialize I/Os in Output Mode for LEDs */
76 | GPIO_Init(LEDS_PORT, (GPIO_Pin_TypeDef)(LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN),
77 | GPIO_MODE_OUT_PP_HIGH_FAST);
78 |
79 | /* Initialize I/O in Input Mode with Interrupt for Joystick */
80 | GPIO_Init(JOYSTICK_PORT, (GPIO_Pin_TypeDef)(JOYSTICK_LEFT_PIN|JOYSTICK_RIGHT_PIN|JOYSTICK_UP_PIN|JOYSTICK_DOWN_PIN),
81 | GPIO_MODE_IN_FL_IT);
82 |
83 | GPIO_Init(JOYSTICK_SEL_PORT, JOYSTICK_SEL_PIN, GPIO_MODE_IN_FL_IT);
84 | }
85 |
86 | #ifdef USE_FULL_ASSERT
87 |
88 | /**
89 | * @brief Reports the name of the source file and the source line number
90 | * where the assert_param error has occurred.
91 | * @param file: pointer to the source file name
92 | * @param line: assert_param error line source number
93 | * @retval None
94 | */
95 | void assert_failed(uint8_t* file, uint32_t line)
96 | {
97 | /* User can add his own implementation to report the file name and line number,
98 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
99 |
100 | /* Infinite loop */
101 | while (1)
102 | {
103 | }
104 | }
105 | #endif
106 |
107 | /**
108 | * @}
109 | */
110 |
111 |
112 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
113 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/EXTI/EXTI_InterruptPriority/main.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file EXTI_InterruptPriority\main.h
4 | * @author MCD Application Team
5 | * @version V2.0.1
6 | * @date 18-November-2011
7 | * @brief This file contains the external declaration for main.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __MAIN_H
30 | #define __MAIN_H
31 |
32 | /* Private typedef -----------------------------------------------------------*/
33 | /* Private define ------------------------------------------------------------*/
34 | /* Evalboard I/Os configuration */
35 |
36 | #define LEDS_PORT (GPIOH)
37 | #define LED1_PIN (GPIO_PIN_3)
38 | #define LED2_PIN (GPIO_PIN_2)
39 | #define LED3_PIN (GPIO_PIN_1)
40 | #define LED4_PIN (GPIO_PIN_0)
41 |
42 | #define BUTTON_PORT (GPIOC)
43 | #define BUTTON_PIN (GPIO_PIN_0)
44 |
45 | #define JOYSTICK_PORT (GPIOB)
46 | #define JOYSTICK_LEFT_PIN (GPIO_PIN_4)
47 | #define JOYSTICK_RIGHT_PIN (GPIO_PIN_5)
48 | #define JOYSTICK_UP_PIN (GPIO_PIN_6)
49 | #define JOYSTICK_DOWN_PIN (GPIO_PIN_7)
50 |
51 | #define JOYSTICK_SEL_PORT (GPIOD)
52 | #define JOYSTICK_SEL_PIN (GPIO_PIN_7)
53 | /* Private function prototypes -----------------------------------------------*/
54 | /* Private functions ---------------------------------------------------------*/
55 | /* Private function prototypes -----------------------------------------------*/
56 | /* Public functions ----------------------------------------------------------*/
57 |
58 | #endif /* __MAIN_H */
59 |
60 |
61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
62 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/EXTI/EXTI_InterruptPriority/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page EXTI_InterruptPriority Reading buttons state using external interrupts
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file EXTI/EXTI_InterruptPriority/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief This file contains the description of EXTI priority example.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides a short description of how to use the EXTI peripheral:
29 | - Configuration of External Interrupt / Falling edge and TLI
30 | - LEDs are toggling at each interrupt detection
31 |
32 |
33 | @par Directory contents
34 |
35 | - EXTI\EXTI_InterruptPriority\main.c Main file containing the "main" function
36 | - EXTI\EXTI_InterruptPriority\main.h Main file containing the "main" header function
37 | - EXTI\EXTI_InterruptPriority\stm8s_conf.h Library Configuration file
38 | - EXTI\EXTI_InterruptPriority\stm8s_it.c Interrupt routines source
39 | - EXTI\EXTI_InterruptPriority\stm8s_it.h Interrupt routines declaration
40 |
41 |
42 | @par Hardware and Software environment
43 |
44 | - This example runs on STM8S and STM8A High density, Medium density and Low
45 | density devices.
46 |
47 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
48 | board and can be easily tailored to any other development board.
49 |
50 | - STM8/128-EVAL Set-up
51 | - Four leds LD1 to LD4 are used.
52 | - Joystick LEFT, RIGHT, UP, DOWN and SEL buttons are used.
53 |
54 |
55 | @par How to use it ?
56 |
57 |
58 | In order to make the program work, you must do the following :
59 |
60 | - Copy all source files from this example folder to the template folder under
61 | Project\Template
62 | - Open your preferred toolchain
63 | - Rebuild all files and load your image into target memory
64 | - Run the example
65 | - The LD1, LD2, LD3 and LD4 are ON per default
66 | - Joystick LEFT pressed: toggle LED1
67 | - Joystick RIGHT pressed: toggle LED2
68 | - Joystick UP pressed: toggle LED3
69 | - Joystick DOWN pressed: toggle LED4
70 | - Joystick SEL pressed: toggle all LEDs
71 |
72 | @note
73 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
74 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
75 | density ranges between 32 to 128 Kbytes
76 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
77 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
78 | density ranges between 8 to 32 Kbytes
79 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
80 | where the Flash memory density ranges between 32 to 128 Kbytes.
81 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
82 | where the Flash memory density ranges between 16 to 32-Kbytes.
83 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
84 | where the Flash density is 8 Kbytes.
85 |
86 | * © COPYRIGHT STMicroelectronics
87 | */
88 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/FLASH/FLASH_ByteReadWriteOperation/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page FLASH_ByteReadWriteOperation Read, Write, Erase byte
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file FLASH/FLASH_ByteReadWriteOperation/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief This file contains the description of the FLASH byte read write
9 | * operation example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example provides a short description on how to use FLASH Read/Write/Erase
30 | operations on byte:
31 | - Read a byte at a specified address (0x40A5).
32 | - Write its complement value at address +1 (0x40A6).
33 | - Check programmed byte (using read function)
34 | - Erase 2 bytes at address & address+1
35 | - Check 2 bytes are erased (value must be equal to 0x00).
36 |
37 |
38 | @par Directory contents
39 |
40 | - FLASH\FLASH_ByteReadWriteOperation\main.c Main file containing the "main" function
41 | - FLASH\FLASH_ByteReadWriteOperation\stm8s_conf.h Library Configuration file
42 | - FLASH\FLASH_ByteReadWriteOperation\stm8s_it.c Interrupt routines source (not used in this example)
43 | - FLASH\FLASH_ByteReadWriteOperation\stm8s_it.h Interrupt routines declaration
44 |
45 |
46 | @par Hardware and Software environment
47 |
48 | - This example runs on STM8S and STM8A High density devices.
49 |
50 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
51 | board and can be easily tailored to any other development board.
52 |
53 |
54 | @par How to use it ?
55 |
56 | In order to make the program work, you must do the following :
57 |
58 | - Copy all source files from this example folder to the template folder under
59 | Project\Template
60 | - Open your preferred toolchain
61 | - Rebuild all files and load your image into target memory
62 | - Run the example
63 | - The data read from the data memory is compared with the expected values.
64 | The result of this comparison is stored in the "OperationStatus" variable.
65 |
66 | @note
67 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
68 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
69 | density ranges between 32 to 128 Kbytes
70 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
71 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
72 | density ranges between 8 to 32 Kbytes
73 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
74 | where the Flash memory density ranges between 32 to 128 Kbytes.
75 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
76 | where the Flash memory density ranges between 16 to 32-Kbytes.
77 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
78 | where the Flash density is 8 Kbytes.
79 |
80 | * © COPYRIGHT STMicroelectronics
81 | */
82 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/FLASH/FLASH_WriteWordOperation/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page FLASH_WriteWordOperation FLASH Write word, Erase byte
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file FLASH/FLASH_WriteWordOperation/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief This file contains the description of the FLASH write word example
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides a short description on how to use FLASH Program word mode
29 | and Erase byte modes:
30 | - Program a word at a specified address (0x4100).
31 | - Check program word (Read byte).
32 | - Erase word using Erase byte.
33 | - Check erase.
34 |
35 |
36 | @par Directory contents
37 |
38 | - FLASH\FLASH_WriteWordOperation\main.c Main file containing the "main" function
39 | - FLASH\FLASH_WriteWordOperation\stm8s_conf.h Library Configuration file
40 | - FLASH\FLASH_WriteWordOperation\stm8s_it.c Interrupt routines source
41 | - FLASH\FLASH_WriteWordOperation\stm8s_it.h Interrupt routines declaration
42 |
43 |
44 | @par Hardware and Software environment
45 |
46 | - This example runs on STM8S and STM8A High density devices.
47 |
48 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
49 | board and can be easily tailored to any other development board.
50 |
51 |
52 | @par How to use it ?
53 |
54 | In order to make the program work, you must do the following :
55 |
56 | - Copy all source files from this example folder to the template folder under
57 | Project\Template
58 | - Open your preferred toolchain
59 | - Rebuild all files and load your image into target memory
60 | - Run the example
61 | - Data read from the data memory is compared with the expected values.
62 | The result of this comparison is stored in the "OperationStatus" variable.
63 |
64 | @note
65 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
66 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
67 | density ranges between 32 to 128 Kbytes
68 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
69 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
70 | density ranges between 8 to 32 Kbytes
71 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
72 | where the Flash memory density ranges between 32 to 128 Kbytes.
73 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
74 | where the Flash memory density ranges between 16 to 32-Kbytes.
75 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
76 | where the Flash density is 8 Kbytes.
77 |
78 | * © COPYRIGHT STMicroelectronics
79 | */
80 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/GPIO/GPIO_Toggle/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file GPIO_Toggle\main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains the main function for GPIO Toggle example.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s.h"
30 |
31 | /**
32 | * @addtogroup GPIO_Toggle
33 | * @{
34 | */
35 |
36 | /* Private typedef -----------------------------------------------------------*/
37 | /* Private define ------------------------------------------------------------*/
38 | /* Evalboard I/Os configuration */
39 |
40 | #define LED_GPIO_PORT (GPIOH)
41 | #define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0)
42 |
43 | /* Private macro -------------------------------------------------------------*/
44 | /* Private variables ---------------------------------------------------------*/
45 | /* Private function prototypes -----------------------------------------------*/
46 | void Delay (uint16_t nCount);
47 |
48 | /* Private functions ---------------------------------------------------------*/
49 | /* Public functions ----------------------------------------------------------*/
50 |
51 | /**
52 | * @brief Main program.
53 | * @param None
54 | * @retval None
55 | */
56 | void main(void)
57 | {
58 |
59 | /* Initialize I/Os in Output Mode */
60 | GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST);
61 |
62 | while (1)
63 | {
64 | /* Toggles LEDs */
65 | GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS);
66 | Delay(0xFFFF);
67 | }
68 |
69 | }
70 |
71 | /**
72 | * @brief Delay
73 | * @param nCount
74 | * @retval None
75 | */
76 | void Delay(uint16_t nCount)
77 | {
78 | /* Decrement nCount value */
79 | while (nCount != 0)
80 | {
81 | nCount--;
82 | }
83 | }
84 |
85 | #ifdef USE_FULL_ASSERT
86 |
87 | /**
88 | * @brief Reports the name of the source file and the source line number
89 | * where the assert_param error has occurred.
90 | * @param file: pointer to the source file name
91 | * @param line: assert_param error line source number
92 | * @retval None
93 | */
94 | void assert_failed(uint8_t* file, uint32_t line)
95 | {
96 | /* User can add his own implementation to report the file name and line number,
97 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
98 |
99 | /* Infinite loop */
100 | while (1)
101 | {
102 | }
103 | }
104 | #endif
105 |
106 | /**
107 | * @}
108 | */
109 |
110 |
111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
112 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/GPIO/GPIO_Toggle/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page GPIO_Toggle Use GPIO to toggle Port Pins
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file GPIO/GPIO_Toggle/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the GPIO Toggle Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example provides a short description of how to use the GPIO peripheral to
30 | toggle Ports Pins infinitely.
31 |
32 |
33 | @par Directory contents
34 |
35 | - GPIO\GPIO_Toggle\main.c Main file containing the "main" function
36 | - GPIO\GPIO_Toggle\stm8s_conf.h Library Configuration file
37 | - GPIO\GPIO_Toggle\stm8s_it.c Interrupt routines source
38 | - GPIO\GPIO_Toggle\stm8s_it.h Interrupt routines declaration
39 |
40 |
41 | @par Hardware and Software environment
42 |
43 | - This example runs on STM8S and STM8A High density, Medium density and Low
44 | density devices.
45 |
46 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
47 | board and can be easily tailored to any other development board.
48 |
49 | - STM8/128-EVAL Set-up
50 | - LD1, LD2, LD3 and LD4 are already connected to PH3, PH2, PH1 and PH0
51 |
52 |
53 | @par How to use it ?
54 |
55 | In order to make the program work, you must do the following :
56 |
57 | - Copy all source files from this example folder to the template folder under
58 | Project\Template
59 | - Open your preferred toolchain
60 | - Rebuild all files and load your image into target memory
61 | - Run the example
62 | - The LD1 and LD4 blink continuously
63 |
64 | @note
65 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
66 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
67 | density ranges between 32 to 128 Kbytes
68 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
69 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
70 | density ranges between 8 to 32 Kbytes
71 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
72 | where the Flash memory density ranges between 32 to 128 Kbytes.
73 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
74 | where the Flash memory density ranges between 16 to 32-Kbytes.
75 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
76 | where the Flash density is 8 Kbytes.
77 |
78 | * © COPYRIGHT STMicroelectronics
79 | */
80 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/I2C/I2C_TwoBoards/I2C_DataExchange/Master/main.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file I2C/I2C_TwoBoards/I2C_DataExchange/Master/main.h
4 | * @author MCD Application Team
5 | * @version V2.0.1
6 | * @date 18-November-2011
7 | * @brief Main program header
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __MAIN_H
30 | #define __MAIN_H
31 |
32 | /* definition of fast or default standard mode (bus speed up to 400 or 100 kHz) */
33 | #define FAST_I2C_MODE
34 |
35 | #ifdef FAST_I2C_MODE
36 | #define I2C_SPEED 300000
37 | #else
38 | #define I2C_SPEED 100000
39 | #endif
40 |
41 | /* definition of 10-bit or default 7-bit slave address */
42 | /* #define TEN_BITS_ADDRESS */
43 |
44 | #ifdef TEN_BITS_ADDRESS
45 | #define SLAVE_ADDRESS 0x330
46 | #else
47 | #define SLAVE_ADDRESS 0x30
48 | #endif
49 |
50 | /* This define is used in master receiver */
51 | /* Uncomment the line below if you want to use the safe procedure */
52 | #define SAFE_PROCEDURE
53 |
54 |
55 | #define BUFFERSIZE 10
56 |
57 |
58 | typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;
59 |
60 |
61 | #endif /* __MAIN_H */
62 |
63 |
64 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/I2C/I2C_TwoBoards/I2C_DataExchange/Slave/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file I2C/I2C_TwoBoards/I2C_DataExchange/Slave/main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief Main program body
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s.h"
30 | #include "stm8s_eval.h"
31 | #include "main.h"
32 |
33 | /** @addtogroup I2C_TwoBoards
34 | * @{
35 | */
36 |
37 | /** @addtogroup I2C_DataExchange
38 | * @{
39 | */
40 |
41 | /* Private typedef -----------------------------------------------------------*/
42 | /* Private define ------------------------------------------------------------*/
43 | /* Private macro -------------------------------------------------------------*/
44 | /* Private variables ---------------------------------------------------------*/
45 | /* Private function prototypes -----------------------------------------------*/
46 | /* Private functions ---------------------------------------------------------*/
47 | /* Public functions ----------------------------------------------------------*/
48 |
49 | /**
50 | * @brief Main program.
51 | * @param None
52 | * @retval None
53 | */
54 | void main(void)
55 | {
56 |
57 | /* system_clock / 1 */
58 | CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
59 |
60 | /* Initialize LEDs mounted on STM8/128-EVAL board */
61 | STM_EVAL_LEDInit(LED2);
62 | STM_EVAL_LEDOff(LED2);
63 |
64 | I2C_DeInit();
65 | /* Initialize I2C peripheral */
66 |
67 | #ifdef I2C_slave_7Bits_Address
68 | I2C_Init(100000, SLAVE_ADDRESS, I2C_DUTYCYCLE_2, I2C_ACK_CURR, I2C_ADDMODE_7BIT, 16);
69 | #else
70 | I2C_Init(100000, SLAVE_ADDRESS, I2C_DUTYCYCLE_2, I2C_ACK_CURR,I2C_ADDMODE_10BIT, 16);
71 | #endif
72 |
73 | /* Enable Error Interrupt*/
74 | I2C_ITConfig((I2C_IT_TypeDef)(I2C_IT_ERR | I2C_IT_EVT | I2C_IT_BUF), ENABLE);
75 |
76 | /* Enable general interrupts */
77 | enableInterrupts();
78 |
79 | /*Main Loop */
80 | while (1)
81 | {
82 | /* infinite loop */
83 | }
84 | }
85 |
86 | #ifdef USE_FULL_ASSERT
87 | /**
88 | * @brief Reports the name of the source file and the source line number
89 | * where the assert_param error has occurred.
90 | * @param file: pointer to the source file name
91 | * @param line: assert_param error line source number
92 | * @retval None
93 | */
94 | void assert_failed(uint8_t* file, uint32_t line)
95 | {
96 | /* User can add his own implementation to report the file name and line number,
97 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
98 |
99 | /* Infinite loop */
100 | while (1)
101 | {}
102 | }
103 | #endif
104 |
105 | /**
106 | * @}
107 | */
108 |
109 | /**
110 | * @}
111 | */
112 |
113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
114 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/I2C/I2C_TwoBoards/I2C_DataExchange/Slave/main.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file I2C/I2C_TwoBoards/I2C_DataExchange/Slave/main.h
4 | * @author MCD Application Team
5 | * @version V2.0.1
6 | * @date 18-November-2011
7 | * @brief Main program body
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __MAIN_H
30 | #define __MAIN_H
31 |
32 |
33 | /* Define I2C Addressing mode ---------------------------------------------------*/
34 | /* Comment the line below if you want to use the 10-bit addressing mode */
35 | #define I2C_slave_7Bits_Address
36 |
37 | /* Define Slave Address ---------------------------------------------------*/
38 | #ifdef I2C_slave_7Bits_Address
39 | #define SLAVE_ADDRESS 0x30
40 | #else
41 | #define SLAVE_ADDRESS 0x330
42 | #endif
43 |
44 | #endif /* __MAIN_H*/
45 |
46 |
47 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
48 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/RST/RST_IllegalOpcode/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page RST_IllegalOpcode Illegal Opcode Reset
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file RST/RST_IllegalOpcode/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief Description of Illegal Opcode reset example
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides a short description of how to generate, detect and manage
29 | an illegal opcode reset.
30 | Pressing the KEY button will cause a jump to a specific memory address where
31 | an illegal opcode is written, so a reset is generated.
32 | LEDs from 1 to 4 start blinking fast signaling the ILLOP reset.
33 | When the reset flag is cleared they will blink slowly.
34 |
35 |
36 | @par Directory contents
37 |
38 | - RST\RST_IllegalOpcode\main.c Main file containing the "main" function
39 | - RST\RST_IllegalOpcode\stm8s_conf.h Library Configuration file
40 | - RST\RST_IllegalOpcode\stm8s_it.c Interrupt routines source
41 | - RST\RST_IllegalOpcode\stm8s_it.h Interrupt routines declaration
42 |
43 |
44 | @par Hardware and Software environment
45 |
46 | - This example runs on STM8S and STM8A High density, Medium density and Low
47 | density devices.
48 |
49 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
50 | board and can be easily tailored to any other development board.
51 |
52 | - STM8/128-EVAL Set-up
53 | - LED1..LED4
54 | - Key push button
55 |
56 |
57 | @par How to use it ?
58 |
59 | In order to make the program work, you must do the following :
60 |
61 | - Copy all source files from this example folder to the template folder under
62 | Project\Template
63 | - Open your preferred toolchain
64 | - Rebuild all files and load your image into target memory
65 | - Run the example
66 | - The LD1, LD2, LD3 and LD4 toggle slowly
67 | - If you press the button, a Reset occurs and LD1,2,3 and 4 blink fast
68 |
69 | @note
70 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
71 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
72 | density ranges between 32 to 128 Kbytes
73 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
74 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
75 | density ranges between 8 to 32 Kbytes
76 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
77 | where the Flash memory density ranges between 32 to 128 Kbytes.
78 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
79 | where the Flash memory density ranges between 16 to 32-Kbytes.
80 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
81 | where the Flash density is 8 Kbytes.
82 |
83 | * © COPYRIGHT STMicroelectronics
84 | */
85 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/Release_Notes.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/STM8S_StdPeriph_Examples/Release_Notes.html
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/SPI/SPI_FastCommunicationMicroSD/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page SPI_FastCommunicationMicroSD Fast communication with a MicroSD memory card
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file SPI/SPI_FastCommunicationMicroSD/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief Description of the SPI MSD Example.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides a short description of how to make a communication
29 | (Write & Read data) between the SPI and a MicroSD memory card like the one
30 | present on the STM8/128-EVAL evaluation board.
31 |
32 | First, Fill the Tx_Buffer with data to be written into the MicroSD memory
33 | followed by a read of that data.
34 | Then data read from the MicroSD memory stored in the Rx_Buffer are compared
35 | with the expected values of the Tx_Buffer. The result of this comparison is
36 | stored in the "TransferStatus" variable.
37 |
38 | @par Directory contents
39 |
40 | - SPI\SPI_FastCommunicationMicroSD\main.c Main file containing the "main" function
41 | - SPI\SPI_FastCommunicationMicroSD\stm8s_conf.h Library Configuration file
42 | - SPI\SPI_FastCommunicationMicroSD\stm8s_it.c Interrupt routines source
43 | - SPI\SPI_FastCommunicationMicroSD\stm8s_it.h Interrupt routines declaration
44 |
45 |
46 | @par Hardware and Software environment
47 |
48 | - This example runs on STM8S and STM8A High density, Medium density and Low
49 | density devices.
50 |
51 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
52 | board and can be easily tailored to any other development board.
53 |
54 | - STM8/128-EVAL Set-up
55 | - LED1..LED4
56 | - Plug a MicroSD memory card into the dedicated connector (CN9).
57 |
58 | @par How to use it ?
59 |
60 | In order to make the program work, you must do the following :
61 |
62 | - Copy all source files from this example folder to the template folder under
63 | Project\Template
64 | - Open your preferred toolchain
65 | - Add the required file:
66 | - stm8s_eval_spi_sd.c (under Utilities\STM8S_EVAL\Common)
67 | - Rebuild all files and load your image into target memory
68 | - Run the example
69 | - If the communication is held without errors, the four LEDs toggle.
70 | Otherwise only the LED1 toggles.
71 |
72 | @note
73 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
74 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
75 | density ranges between 32 to 128 Kbytes
76 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
77 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
78 | density ranges between 8 to 32 Kbytes
79 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
80 | where the Flash memory density ranges between 32 to 128 Kbytes.
81 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
82 | where the Flash memory density ranges between 16 to 32-Kbytes.
83 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
84 | where the Flash density is 8 Kbytes.
85 |
86 | * © COPYRIGHT STMicroelectronics
87 | */
88 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/SPI/SPI_FullDuplexUART1/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page SPI_FullDuplexUART1 Full duplex master/slave communication with UART1.
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file SPI/SPI_FullDuplexUART1/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief Description of the SPI Full Duplex with UART Example.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 |
27 | @par Example description
28 |
29 | This example provides a short description of how to make a master/slave full duplex
30 | communication between the SPI and the UART1, the last is configured in master
31 | synchronous mode.
32 |
33 | The UART1 sends data from TxBuffer1 buffer to SPI using TXE flag.
34 | Data received using RXNE flag by SPI is stored in RxBuffer2 then compared with
35 | the sent ones and the result of this comparison is stored in the "TransferStatus1"
36 | variable.
37 |
38 | In the same Time, the SPI sends data from TxBuffer2 buffer to UART1 using TXE flag.
39 | Data received using RXNE flag by UART1 is stored in RxBuffer1 then compared with
40 | the sent ones and the result of this comparison is stored in the "TransferStatus2"
41 | variable.
42 |
43 | @par Directory contents
44 |
45 | - SPI\SPI_FullDuplexUART1\main.c Main file containing the "main" function
46 | - SPI\SPI_FullDuplexUART1\stm8s_conf.h Library Configuration file
47 | - SPI\SPI_FullDuplexUART1\stm8s_it.c Interrupt routines source
48 | - SPI\SPI_FullDuplexUART1\stm8s_it.h Interrupt routines declaration
49 |
50 |
51 | @par Hardware and Software environment
52 |
53 | - This example runs on STM8S and STM8A High density,Low density devices.
54 | - For medium density devices, UART1 should be replaced by UART2
55 |
56 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
57 | board and can be easily tailored to any other development board.
58 |
59 | - STM8/128-EVAL Set-up
60 | - Connect UART1 and SPI pins as follows:
61 | - UART1 TX (PA5) to SPI MOSI (PC6)
62 | - UART1 RX (PA4) to SPI MISO (PC7)
63 | - UART1 CLK (PA6) to SPI SCK (PC5)
64 |
65 |
66 | @par How to use it ?
67 |
68 | In order to make the program work, you must do the following :
69 |
70 | - Copy all source files from this example folder to the template folder under
71 | Project\Template
72 | - Open your preferred toolchain
73 | - Rebuild all files and load your image into target memory
74 | - Run the example
75 |
76 | @note
77 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
78 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
79 | density ranges between 32 to 128 Kbytes
80 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
81 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
82 | density ranges between 8 to 32 Kbytes
83 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
84 | where the Flash memory density ranges between 32 to 128 Kbytes.
85 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
86 | where the Flash memory density ranges between 16 to 32-Kbytes.
87 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
88 | where the Flash density is 8 Kbytes.
89 |
90 | * © COPYRIGHT STMicroelectronics
91 | */
92 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/SPI/SPI_SimplexLCD/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page SPI_SimplexLCD Communication with a monochrome LCD
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file SPI/SPI_SimplexLCD/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief Description of the SPI Simplex LCD Example.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 | @par Example description
27 |
28 | This example provides a short description of how to use the SPI firmware library
29 | in order to communicate with a monochrome LCD like the one present on the
30 | STM8/128-EVAL eval-board by the mean of the associated eval LCD driver.
31 | Running the example allows the display of "SPI-LCD example" on the first LCD
32 | line. While in the second line ST logo is scrolling to finally be displayed in
33 | the middle of the line.
34 |
35 |
36 | @par Directory contents
37 |
38 | - SPI\SPI_SimplexLCD\main.c Main file containing the "main" function
39 | - SPI\SPI_SimplexLCD\stm8s_conf.h Library Configuration file
40 | - SPI\SPI_SimplexLCD\stm8s_it.c Interrupt routines source (not used in this example)
41 | - SPI\SPI_SimplexLCD\stm8s_it.h Interrupt routines declaration
42 |
43 |
44 | @par Hardware and Software environment
45 |
46 | - This example runs on STM8S and STM8A High density, Medium density and Low
47 | density devices.
48 |
49 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
50 | board and can be easily tailored to any other development board.
51 |
52 | - STM8/128-EVAL Set-up
53 | - The mono LCD
54 |
55 |
56 | @par How to use it ?
57 |
58 | In order to make the program work, you must do the following :
59 |
60 | - Copy all source files from this example folder to the template folder under
61 | Project\Template
62 | - Open your preferred toolchain
63 | - Add the required file:
64 | - stm8s_eval_lcd.c (under Utilities\STM8S_EVAL\Common)
65 | - Rebuild all files and load your image into target memory
66 | - Run the example
67 |
68 | @note
69 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
70 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
71 | density ranges between 32 to 128 Kbytes
72 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
73 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
74 | density ranges between 8 to 32 Kbytes
75 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
76 | where the Flash memory density ranges between 32 to 128 Kbytes.
77 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
78 | where the Flash memory density ranges between 16 to 32-Kbytes.
79 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
80 | where the Flash density is 8 Kbytes.
81 |
82 | * © COPYRIGHT STMicroelectronics
83 | */
84 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/TIM1/TIM1_Input_Capture/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file TIM1_Input_Capture\main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains the main function for TIM1 Input Capture example.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm8s.h"
30 |
31 | /**
32 | * @addtogroup TIM1_Input_Capture
33 | * @{
34 | */
35 |
36 | /* Private typedef -----------------------------------------------------------*/
37 | /* Private define ------------------------------------------------------------*/
38 | /* Private macro -------------------------------------------------------------*/
39 | /* Private variables ---------------------------------------------------------*/
40 | uint32_t TIM1ClockFreq = 2000000;
41 | __IO uint32_t LSIClockFreq = 0;
42 | uint16_t ICValue1 =0, ICValue2 =0;
43 | /* Private function prototypes -----------------------------------------------*/
44 | static void TIM1_Config(void);
45 | /* Private functions ---------------------------------------------------------*/
46 | /* Public functions ----------------------------------------------------------*/
47 |
48 | /**
49 | * @brief Main program.
50 | * @param None
51 | * @retval None
52 | */
53 | void main(void)
54 | {
55 |
56 | /* Connect LSI to COO pin*/
57 | GPIO_Init(GPIOE, GPIO_PIN_0, GPIO_MODE_OUT_PP_LOW_FAST);
58 | CLK_CCOConfig(CLK_OUTPUT_LSI);
59 | CLK_CCOCmd(ENABLE);
60 |
61 | /* TIM1 configuration -----------------------------------------*/
62 | TIM1_Config();
63 |
64 | /* Compute LSI clock frequency */
65 | LSIClockFreq = (8 * TIM1ClockFreq) / (ICValue2 - ICValue1);
66 |
67 | /* Insert a break point here */
68 | while (1)
69 | {}
70 | }
71 |
72 | /**
73 | * @brief Configure TIM1 to to capture the internal clock source (LSI)
74 | * @param None
75 | * @retval None
76 | */
77 | static void TIM1_Config(void)
78 | {
79 | TIM1_ICInit( TIM1_CHANNEL_1, TIM1_ICPOLARITY_FALLING, TIM1_ICSELECTION_DIRECTTI,
80 | TIM1_ICPSC_DIV8, 0x0);
81 |
82 | /* Enable TIM1 */
83 | TIM1_Cmd(ENABLE);
84 |
85 | /* Clear CC1 Flag*/
86 | TIM1_ClearFlag(TIM1_FLAG_CC1);
87 |
88 | /* wait a capture on CC1 */
89 | while((TIM1->SR1 & TIM1_FLAG_CC1) != TIM1_FLAG_CC1);
90 | /* Get CCR1 value*/
91 | ICValue1 = TIM1_GetCapture1();
92 | TIM1_ClearFlag(TIM1_FLAG_CC1);
93 |
94 | /* wait a capture on cc1 */
95 | while((TIM1->SR1 & TIM1_FLAG_CC1) != TIM1_FLAG_CC1);
96 | /* Get CCR1 value*/
97 | ICValue2 = TIM1_GetCapture1();
98 | TIM1_ClearFlag(TIM1_FLAG_CC1);
99 | }
100 |
101 | #ifdef USE_FULL_ASSERT
102 |
103 | /**
104 | * @brief Reports the name of the source file and the source line number
105 | * where the assert_param error has occurred.
106 | * @param file: pointer to the source file name
107 | * @param line: assert_param error line source number
108 | * @retval None
109 | */
110 | void assert_failed(uint8_t* file, uint32_t line)
111 | {
112 | /* User can add his own implementation to report the file name and line number,
113 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
114 |
115 | /* Infinite loop */
116 | while (1)
117 | {
118 | }
119 | }
120 | #endif
121 |
122 | /**
123 | * @}
124 | */
125 |
126 |
127 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
128 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/TIM1/TIM1_Input_Capture/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page TIM1_Input_Capture LSI clock source Capture by TIM1
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file TIM1/TIM1_Input_Capture/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the TIM1 Input Capture Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example shows how to configure the TIM1 peripheral to capture the internal
30 | clock source (LSI).
31 |
32 | TIM1CLK is fixed to 2 MHz, the TIM1 Prescaler is equal to 0 so the TIM1 counter
33 | clock used is 2 MHz. (By default, fTIM1= fMaster/8 )
34 |
35 | The TIM1 Channel 1 is configured as Input capture.
36 | The LSI signal is redirected to the CCO output Pin.
37 | The TIM1 Channel 1 is connected to the CCO Pin.
38 |
39 | The captured value of LSI clock Frequency is stored in the LSIClockFreq variable.
40 |
41 |
42 | @par Directory contents
43 |
44 | - TIM1\TIM1_Input_Capture\main.c Main file containing the "main" function
45 | - TIM1\TIM1_Input_Capture\stm8s_conf.h Library Configuration file
46 | - TIM1\TIM1_Input_Capture\stm8s_it.c Interrupt routines source
47 | - TIM1\TIM1_Input_Capture\stm8s_it.h Interrupt routines declaration
48 |
49 |
50 | @par Hardware and Software environment
51 |
52 | - This example runs on STM8S and STM8A High density, Medium density and Low
53 | density devices.
54 |
55 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
56 | board and can be easily tailored to any other development board.
57 |
58 | - STM8/128-EVAL Set-up
59 | - Connect the configurable Clock Output pin CCO (PE.0) to the TIM1_CC1 pin (PC.1)
60 |
61 |
62 | @par How to use it ?
63 |
64 | In order to make the program work, you must do the following :
65 |
66 | - Copy all source files from this example folder to the template folder under
67 | Project\Template
68 | - Open your preferred toolchain
69 | - Rebuild all files and load your image into target memory
70 | - Run the example
71 | - Connect the TIM1_CC1 pin to COO pin
72 | - Read the value of LSIClockFreq variable
73 |
74 | @note
75 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
76 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
77 | density ranges between 32 to 128 Kbytes
78 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
79 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
80 | density ranges between 8 to 32 Kbytes
81 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
82 | where the Flash memory density ranges between 32 to 128 Kbytes.
83 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
84 | where the Flash memory density ranges between 16 to 32-Kbytes.
85 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
86 | where the Flash density is 8 Kbytes.
87 |
88 | * © COPYRIGHT STMicroelectronics
89 | */
90 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/TIM2/TIM2_OC_InactiveMode/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page TIM2_OC_InactiveMode Generate 3 different signals with 3 different delays with Inactive Mode
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file TIM2/TIM2_OC_InactiveMode/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the TIM2 Output compare Inactive mode Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example shows how to configure the TIM peripheral to generate 3 different
30 | signals with 3 different delays.
31 |
32 | The TIM2CLK frequency is set to 2 MHz, the Prescaler is set to 2048 and used in
33 | Output Compare Inactive Mode.
34 |
35 | TIM2 counter clock = TIM2CLK / (Prescaler) = 976 Hz
36 |
37 |
38 | The TIM2 CCR1 register value is equal to 976:
39 | TIM2_CH1 delay = CCR1_Val/TIM2 counter clock = 1000 ms
40 | so the TIM2 Channel 1 generates a signal with a delay equal to 1000 ms.
41 |
42 | The TIM2 CCR2 register value is equal to 488:
43 | TIM2_CH2 delay = CCR2_Val/TIM2 counter clock = 500 ms
44 | so the TIM2 Channel 2 generates a signal with a delay equal to 500 ms.
45 |
46 | The TIM2 CCR3 register value is equal to 244:
47 | TIM2_CH3 delay = CCR3_Val/TIM2 counter clock = 250 ms
48 | so the TIM2 Channel 3 generates a signal with a delay equal to 250 ms.
49 |
50 |
51 | @par Directory contents
52 |
53 | - TIM2\TIM2_OC_InactiveMode\main.c Main file containing the "main" function
54 | - TIM2\TIM2_OC_InactiveMode\stm8s_conf.h Library Configuration file
55 | - TIM2\TIM2_OC_InactiveMode\stm8s_it.c Interrupt routines source
56 | - TIM2\TIM2_OC_InactiveMode\stm8s_it.h Interrupt routines declaration
57 |
58 |
59 | @par Hardware and Software environment
60 |
61 | - This example runs on STM8S and STM8A High density, Medium density devices and
62 | STM8S103x Low density devices.
63 |
64 |
65 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
66 | board and can be easily tailored to any other development board.
67 |
68 | - STM8/128-EVAL Set-up
69 | - Connect the following pins to an oscilloscope:
70 | - Pin PG.5
71 | - Pin PG.6
72 | - Pin PG.7
73 |
74 | @par How to use it ?
75 |
76 | In order to make the program work, you must do the following :
77 |
78 | - Copy all source files from this example folder to the template folder under
79 | Project\Template
80 | - Open your preferred toolchain
81 | - Rebuild all files and load your image into target memory
82 | - Run the example
83 | - Connect PG.5 , PG.6 and PG.7 pins to an oscilloscope
84 |
85 | @note
86 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
87 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
88 | density ranges between 32 to 128 Kbytes
89 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
90 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
91 | density ranges between 8 to 32 Kbytes
92 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
93 | where the Flash memory density ranges between 32 to 128 Kbytes.
94 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
95 | where the Flash memory density ranges between 16 to 32-Kbytes.
96 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
97 | where the Flash density is 8 Kbytes.
98 |
99 | * © COPYRIGHT STMicroelectronics
100 | */
101 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/TIM2/TIM2_PWM_DutyCycleConfiguration/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file TIM2_PWM_DutyCycleConfiguration\main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief This file contains the main function for TIM2 PWM_DutyCycleConfiguration
8 | * example.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2014 STMicroelectronics
13 | *
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 | * You may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at:
17 | *
18 | * http://www.st.com/software_license_agreement_liberty_v2
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | *
26 | ******************************************************************************
27 | */
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm8s.h"
31 |
32 | /**
33 | * @addtogroup TIM2_PWM_DutyCycleConfiguration
34 | * @{
35 | */
36 |
37 | /* Private typedef -----------------------------------------------------------*/
38 | /* Private define ------------------------------------------------------------*/
39 | /* Private macro -------------------------------------------------------------*/
40 | /* Private variables ---------------------------------------------------------*/
41 | uint16_t CCR1_Val = 500;
42 | uint16_t CCR2_Val = 250;
43 | uint16_t CCR3_Val = 125;
44 |
45 | /* Private function prototypes -----------------------------------------------*/
46 | static void TIM2_Config(void);
47 | /* Private functions ---------------------------------------------------------*/
48 | /* Public functions ----------------------------------------------------------*/
49 |
50 | /**
51 | * @brief Main program.
52 | * @param None
53 | * @retval None
54 | */
55 | void main(void)
56 | {
57 | /* TIM2 configuration -----------------------------------------*/
58 | TIM2_Config();
59 |
60 | while (1)
61 | {}
62 | }
63 |
64 | /**
65 | * @brief Configure TIM2 peripheral in PWM mode
66 | * @param None
67 | * @retval None
68 | */
69 | static void TIM2_Config(void)
70 | {
71 | /* Time base configuration */
72 | TIM2_TimeBaseInit(TIM2_PRESCALER_1, 999);
73 |
74 | /* PWM1 Mode configuration: Channel1 */
75 | TIM2_OC1Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR1_Val, TIM2_OCPOLARITY_HIGH);
76 | TIM2_OC1PreloadConfig(ENABLE);
77 |
78 | /* PWM1 Mode configuration: Channel2 */
79 | TIM2_OC2Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR2_Val, TIM2_OCPOLARITY_HIGH);
80 | TIM2_OC2PreloadConfig(ENABLE);
81 |
82 | /* PWM1 Mode configuration: Channel3 */
83 | TIM2_OC3Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR3_Val, TIM2_OCPOLARITY_HIGH);
84 | TIM2_OC3PreloadConfig(ENABLE);
85 |
86 | TIM2_ARRPreloadConfig(ENABLE);
87 |
88 | /* TIM2 enable counter */
89 | TIM2_Cmd(ENABLE);
90 | }
91 |
92 | #ifdef USE_FULL_ASSERT
93 |
94 | /**
95 | * @brief Reports the name of the source file and the source line number
96 | * where the assert_param error has occurred.
97 | * @param file: pointer to the source file name
98 | * @param line: assert_param error line source number
99 | * @retval None
100 | */
101 | void assert_failed(uint8_t* file, uint32_t line)
102 | {
103 | /* User can add his own implementation to report the file name and line number,
104 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
105 |
106 | /* Infinite loop */
107 | while (1)
108 | {
109 | }
110 | }
111 | #endif
112 |
113 | /**
114 | * @}
115 | */
116 |
117 |
118 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
119 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/TIM4/TIM4_TimeBase/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page TIM4_TimeBase Use the TIM4 peripheral to generate 1 ms time base using
2 | * TIM4 update interrupt
3 |
4 | @verbatim
5 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
6 | * @file TIM4/TIM4_TimeBase/readme.txt
7 | * @author MCD Application Team
8 | * @version V2.2.0
9 | * @date 30-September-2014
10 | * @brief Description of the TIM4 Time Base Example.
11 | ******************************************************************************
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | @endverbatim
27 |
28 |
29 | @par Example description
30 |
31 | This example provides a short description of how to use the TIM4 peripheral
32 | to generate time base equal to 1 ms. In this example a "Delay" function is
33 | implemented based on the TIM4 time base.
34 | The four LEDs LD1..LD4 toggle with a timing defined by the Delay function.
35 |
36 | The TIM4CLK frequency is 16MHz, the Prescaler is 128 so the TIM4 counter
37 | clock is 125 KHz.
38 | The TIM4 is running at TIM4 frequency = TIM4 counter clock / (TIM4_PERIOD + 1
39 | = 125000 / 125 = 1 KHz.
40 | So the TIM4 generates an Update Interrupt each 1 / 1000 = 1 ms.
41 |
42 |
43 |
44 | @par Directory contents
45 |
46 | - TIM4\TIM4_TimeBase\main.c Main file containing the "main" function
47 | - TIM4\TIM4_TimeBase\stm8s_conf.h Library Configuration file
48 | - TIM4\TIM4_TimeBase\stm8s_it.c Interrupt routines source
49 | - TIM4\TIM4_TimeBase\stm8s_it.h Interrupt routines declaration
50 |
51 |
52 | @par Hardware and Software environment
53 |
54 | - This example runs on STM8S and STM8A High density, Medium density devices and
55 | STM8S103x Low density devices.
56 |
57 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
58 | board and can be easily tailored to any other development board.
59 |
60 | - STM8/128-EVAL Set-up
61 | - Four leds LD1..LD4
62 |
63 |
64 | @par How to use it ?
65 |
66 | In order to make the program work, you must do the following :
67 |
68 | - Copy all source files from this example folder to the template folder under
69 | Project\Template
70 | - Open your preferred toolchain
71 | - Rebuild all files and load your image into target memory
72 | - Run the example
73 |
74 | @note
75 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
76 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
77 | density ranges between 32 to 128 Kbytes
78 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
79 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
80 | density ranges between 8 to 32 Kbytes
81 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
82 | where the Flash memory density ranges between 32 to 128 Kbytes.
83 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
84 | where the Flash memory density ranges between 16 to 32-Kbytes.
85 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
86 | where the Flash density is 8 Kbytes.
87 |
88 | * © COPYRIGHT STMicroelectronics
89 | */
90 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/TIM5/TIM5_Synchronisation_With_TIM6/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page TIM5_Synchronisation_with_TIM6 Synchronisation of TIM5 using TIM6
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file TIM5/TIM5_Synchronisation_with_TIM6/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the TIM5 Synchronisation using TIM6 Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 |
28 | @par Example description
29 |
30 | This example provides a short description of how to use the TIM5 peripheral
31 | synchronised by TIM6. TIM5 is configured as a slave of TIM6.
32 |
33 | TIM5 is configured to be enabled if it detects an edge on its input trigger (TRGI).
34 | TIM6 is configurated to generate an edge through its (TRGO) at the update event.
35 | TIM5 TRGI is configurated to be connected (internal connection) to TIM6 TRGO.
36 |
37 | If line "TIM6_Cmd(ENABLE);" in main.c is commented, TIM6 is not enabled => no Edge is detected on TIM5 TRGI,
38 | ==> Result variable value will be equal to 0 (FAILED).
39 | If line "TIM6_Cmd(ENABLE);" in main.c is uncommented, TIM6 is enabled => TIM6 generate an Edge on its TRGO and
40 | an Edge is detected on TIM5 TRGI. ==> Result variable value will be equal to 1 (PASS).
41 |
42 |
43 | @par Directory contents
44 |
45 | - TIM5\TIM5_Synchronisation_With_TIM6\main.c Main file containing the "main" function
46 | - TIM5\TIM5_Synchronisation_With_TIM6\stm8s_conf.h Library Configuration file
47 | - TIM5\TIM5_Synchronisation_With_TIM6\stm8s_it.c Interrupt routines source
48 | - TIM5\TIM5_Synchronisation_With_TIM6\stm8s_it.h Interrupt routines declaration
49 |
50 |
51 | @par Hardware and Software environment
52 |
53 | - This example runs only on STM8S903 devices.
54 |
55 | - This example has been tested with a STMicroelectronics generic board
56 | (STM8S903 device) and can be easily tailored to any other development board.
57 |
58 |
59 | @par How to use it ?
60 |
61 | In order to make the program work, you must do the following :
62 |
63 | - Copy all source files from this example folder to the template folder under
64 | Project\Template
65 | - Open your preferred toolchain
66 | - Rebuild all files and load your image into target memory
67 | - Run the example
68 | - Example result can be displayed using "Result" variable.
69 |
70 | @note
71 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
72 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
73 | density ranges between 32 to 128 Kbytes
74 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
75 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
76 | density ranges between 8 to 32 Kbytes
77 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
78 | where the Flash memory density ranges between 32 to 128 Kbytes.
79 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
80 | where the Flash memory density ranges between 16 to 32-Kbytes.
81 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
82 | where the Flash density is 8 Kbytes.
83 |
84 | * © COPYRIGHT STMicroelectronics
85 | */
86 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/UART1/UART1_HyperTerminal_Interrupt/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page UART1_HyperTerminal_Interrupt Communication between UART1 and hyperterminal using interrupts
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file UART1/UART1_HyperTerminal_Interrupt/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the UART1 HyperTherminal interrupts Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example provides a description of how to use the UART1 interrupts to
30 | communicate with the HyperTerminal.
31 | The UART1 sends a predefined buffer to the HyperTerminal and keep waiting
32 | data to be entered by user and toggling infinitely LD1..LD4, each byte
33 | received is sent back to the HyperTerminal.
34 | The communication is managed by Transmit and Receive interrupts.
35 |
36 | UART1 is configured as follow:
37 | - BaudRate = 115200 baud
38 | - Word Length = 8 Bits (Word Length = 7 data bit + 1 parity bit
39 | - One Stop Bit
40 | - Odd parity
41 | - Receive and transmit enabled
42 | - UART1 Clock disabled
43 | @note When the parity is enabled, the computed parity is inserted at the MSB
44 | position of the transmitted data.
45 |
46 |
47 | @par Directory contents
48 |
49 | - UART1\UART1_HyperTerminal_Interrupt\main.c Main file containing the "main" function
50 | - UART1\UART1_HyperTerminal_Interrupt\stm8s_conf.h Library Configuration file
51 | - UART1\UART1_HyperTerminal_Interrupt\stm8s_it.c Interrupt routines source
52 | - UART1\UART1_HyperTerminal_Interrupt\stm8s_it.h Interrupt routines declaration
53 |
54 |
55 | @par Hardware and Software environment
56 |
57 | - This example runs on STM8S High density and Low density devices and on STM8A
58 | High density devices.
59 |
60 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
61 | board and can be easily tailored to any other development board.
62 |
63 | - STM8/128-EVAL Set-up
64 | - Connect a null-modem female/female RS232 cable between the DB9 connector
65 | CN13 and PC serial port.
66 | - HyperTerminal configuration:
67 | - Word Length = 7 Bits
68 | - One Stop Bit
69 | - Odd parity
70 | - BaudRate = 115200 baud
71 |
72 |
73 | @par How to use it ?
74 |
75 | In order to make the program work, you must do the following :
76 |
77 | - Copy all source files from this example folder to the template folder under
78 | Project\Template
79 | - Open your preferred toolchain
80 | - Rebuild all files and load your image into target memory
81 | - Run the example
82 |
83 | @note
84 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
85 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
86 | density ranges between 32 to 128 Kbytes
87 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
88 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
89 | density ranges between 8 to 32 Kbytes
90 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
91 | where the Flash memory density ranges between 32 to 128 Kbytes.
92 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
93 | where the Flash memory density ranges between 16 to 32-Kbytes.
94 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
95 | where the Flash density is 8 Kbytes.
96 |
97 | * © COPYRIGHT STMicroelectronics
98 | */
99 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/UART1/UART1_Interrupt/main.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file UART1_Interrupt\main.h
4 | * @author MCD Application Team
5 | * @version V2.0.1
6 | * @date 18-November-2011
7 | * @brief This file contains the external declaration of main.c file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __MAIN_H
30 | #define __MAIN_H
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | /* Private variables ---------------------------------------------------------*/
34 | /* Exported types ------------------------------------------------------------*/
35 | /* Private typedef -----------------------------------------------------------*/
36 | /* Private define ------------------------------------------------------------*/
37 | #define TxBufferSize1 (countof(TxBuffer1) - 1)
38 | #define TxBufferSize2 (countof(TxBuffer2) - 1)
39 | #define RxBufferSize1 TxBufferSize2
40 | #define RxBufferSize2 TxBufferSize1
41 |
42 | /* Private macro -------------------------------------------------------------*/
43 | #define countof(a) (sizeof(a) / sizeof(*(a)))
44 |
45 | /* Exported functions ------------------------------------------------------- */
46 | uint8_t GetVar_TxCounter1(void);
47 | uint8_t IncrementVar_TxCounter1(void);
48 | uint8_t GetVar_TxCounter2(void);
49 | uint8_t IncrementVar_TxCounter2(void);
50 | uint8_t GetVar_RxCounter1(void);
51 | uint8_t IncrementVar_RxCounter1(void);
52 | uint8_t GetVar_RxCounter2(void);
53 | uint8_t IncrementVar_RxCounter2(void);
54 | uint8_t GetVar_NbrOfDataToTransfer1(void);
55 | uint8_t GetVar_NbrOfDataToTransfer2(void);
56 | uint8_t GetVar_NbrOfDataToRead1(void);
57 | uint8_t GetVar_NbrOfDataToRead2(void);
58 |
59 |
60 | #endif /* __MAIN_H */
61 |
62 |
63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
64 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/UART1/UART1_Interrupt/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page UART1_Interrupt Communication between UART1 and UART3 using interrupts
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file UART1/UART1_Interrupt/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the communication between UART1 and UART3 using
10 | * interrupts Example.
11 | ******************************************************************************
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | @endverbatim
27 |
28 | @par Example description
29 |
30 | This example provides a basic communication between UART1 and UART3 using interrupts.
31 | UART3 sends TxBuffer2 to UART1 which sends TxBuffer1 to UART3. The data received
32 | by UART1 and UART3 are stored respectively in RxBuffer1 and RxBuffer2. The data
33 | transfer is managed in UART1_TX_IRQHandler,UART1_RX_IRQHandler,UART3_TX_IRQHandler
34 | and UART3_RX_IRQHandler in stm8s_it.c file.
35 |
36 |
37 | The UART1 and UART3 are configured as follows:
38 | - BaudRate = 9600 baud
39 | - Word Length = 8 Bits
40 | - One Stop Bit
41 | - No parity
42 | - Receive and transmit enabled
43 | - UART1 Clock disabled
44 |
45 |
46 | @par Directory contents
47 |
48 | - UART1\UART1_Interrupt\main.c Main file containing the "main" function
49 | - UART1\UART1_Interrupt\main.h Main functions prototype
50 | - UART1\UART1_Interrupt\stm8s_conf.h Library Configuration file
51 | - UART1\UART1_Interrupt\stm8s_it.c Interrupt routines source
52 | - UART1\UART1_Interrupt\stm8s_it.h Interrupt routines declaration
53 |
54 |
55 | @par Hardware and Software environment
56 |
57 | - This example runs on STM8S and STM8A High density devices only.
58 |
59 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
60 | board and can be easily tailored to any other development board.
61 |
62 | - STM8/128-EVAL Set-up
63 | - Connect UART1_Tx(PA.05) to UART3_Rx(PD.06) and UART1_Rx(PA.04) to UART3_Tx(PD.05)
64 | or connect a null-modem female/female RS232 cable between CN15 and CN13.
65 |
66 |
67 | @par How to use it ?
68 |
69 | In order to make the program work, you must do the following :
70 |
71 | - Copy all source files from this example folder to the template folder under
72 | Project\Template
73 | - Open your preferred toolchain
74 | - Rebuild all files and load your image into target memory
75 | - Run the example
76 | - Communication result in Receiver/ Transmitter modes can be checked respectively
77 | via TransferStatus2 and TransferStatus1 variables.
78 |
79 | @note
80 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
81 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
82 | density ranges between 32 to 128 Kbytes
83 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
84 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
85 | density ranges between 8 to 32 Kbytes
86 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
87 | where the Flash memory density ranges between 32 to 128 Kbytes.
88 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
89 | where the Flash memory density ranges between 16 to 32-Kbytes.
90 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
91 | where the Flash density is 8 Kbytes.
92 |
93 | * © COPYRIGHT STMicroelectronics
94 | */
95 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/UART1/UART1_MultiProcessor/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page UART1_MultiProcessor Use the UART1 in multi-processor mode
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file UART1/UART1_MultiProcessor/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the UART1 multi-processor Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example provides a description of how to use the UART1 in multi-processor mode.
30 | First, the UART1 and UART3 addresses are set to 0x1 and 0x2.
31 |
32 | The UART1 sends continuously the byte 0x33 to the UART3. When UART3 receives
33 | byte (0x33), LED1 to LED4 toggle.
34 |
35 | When a falling edge is applied on EXTI PORTB (Joystick up push-button on
36 | STM8-EVAL board is pressed), an interrupt is generated and in the
37 | EXTI_PORTB_IRQHandler routine, the UART3 is put into mute mode and stays in
38 | this mode(no LED toggling) until a rising edge is applied on EXTI PORTC
39 | (Key push-button on STM8-EVAL board is pressed).
40 | In this interrupt routine the UART1 sends the address mark data (0x102)
41 | to wake up the UART3. The LEDs restarts toggling.
42 |
43 | UART1 and UART3 are configured as follows:
44 | - BaudRate = 9600 baud
45 | - Word Length = 9 Bits
46 | - One Stop Bit
47 | - No parity
48 | - Receive and transmit enabled
49 | - UART1 Clock disabled
50 |
51 |
52 | @par Directory contents
53 |
54 | - UART1\UART1_MultiProcessor\main.c Main file containing the "main" function
55 | - UART1\UART1_MultiProcessor\stm8s_conf.h Library Configuration file
56 | - UART1\UART1_MultiProcessor\stm8s_it.c Interrupt routines source (not used in this example)
57 | - UART1\UART1_MultiProcessor\stm8s_it.h Interrupt routines declaration
58 |
59 |
60 | @par Hardware and Software environment
61 |
62 | - This example runs on STM8S and STM8A High density devices only.
63 |
64 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
65 | board and can be easily tailored to any other development board.
66 |
67 | - STM8/128-EVAL Set-up
68 | - Connect UART1_Tx(PA.05) to UART3_Rx(PD.06) and UART1_Rx(PA.04) to UART3_Tx(PD.05)
69 | or connect a null-modem female/female RS232 cable between CN15 and CN13.
70 | - Four leds LD1 to LD4, Key and Joystick UP push-button are used.
71 |
72 |
73 | @par How to use it ?
74 |
75 | In order to make the program work, you must do the following :
76 |
77 | - Copy all source files from this example folder to the template folder under
78 | Project\Template
79 | - Open your preferred toolchain
80 | - Rebuild all files and load your image into target memory
81 | - Run the example
82 |
83 | @note
84 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
85 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
86 | density ranges between 32 to 128 Kbytes
87 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
88 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
89 | density ranges between 8 to 32 Kbytes
90 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
91 | where the Flash memory density ranges between 32 to 128 Kbytes.
92 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
93 | where the Flash memory density ranges between 16 to 32-Kbytes.
94 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
95 | where the Flash density is 8 Kbytes.
96 |
97 | * © COPYRIGHT STMicroelectronics
98 | */
99 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/UART1/UART1_Printf/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page UART1_Printf Retarget the C library printf function to the UART1
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file UART1/UART1_Printf/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the UART1 retarget C library Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 | This example shows how to retarget the C library printf/getchar functions to the
29 | UART1.
30 | This implementation output the printf message on the Hyperterminal using UART1
31 | and keep waiting a character to be entered by the user.
32 |
33 | The UART1 is configured as follows:
34 | - BaudRate = 115200 baud
35 | - Word Length = 8 Bits
36 | - One Stop Bit
37 | - No parity
38 | - Receive and transmit enabled
39 | - UART1 Clock disabled
40 |
41 | @par Directory contents
42 |
43 | - UART1\UART1_Printf\main.c Main file containing the "main" function
44 | - UART1\UART1_Printf\stm8s_conf.h Library Configuration file
45 | - UART1\UART1_Printf\stm8s_it.c Interrupt routines source
46 | - UART1\UART1_Printf\stm8s_it.h Interrupt routines declaration
47 |
48 |
49 | @par Hardware and Software environment
50 |
51 | - This example runs on STM8S High density and Low density devices and on STM8A
52 | High density devices.
53 |
54 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
55 | board and can be easily tailored to any other development board.
56 |
57 | - STM8/128-EVAL Set-up
58 | - Connect a null-modem female/female RS232 cable between the DB9 connector
59 | CN13 and PC serial port.
60 |
61 | - Hyperterminal configuration:
62 | - Word Length = 8 Bits
63 | - One Stop Bit
64 | - No parity
65 | - BaudRate = 115200 baud
66 | - flow control: None
67 |
68 |
69 | @par How to use it ?
70 |
71 | In order to make the program work, you must do the following :
72 |
73 | - Copy all source files from this example folder to the template folder under
74 | Project\Template
75 | - Open your preferred toolchain
76 | - Rebuild all files and load your image into target memory
77 | - Run the example
78 |
79 | @note
80 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
81 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
82 | density ranges between 32 to 128 Kbytes
83 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
84 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
85 | density ranges between 8 to 32 Kbytes
86 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
87 | where the Flash memory density ranges between 32 to 128 Kbytes.
88 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
89 | where the Flash memory density ranges between 16 to 32-Kbytes.
90 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
91 | where the Flash density is 8 Kbytes.
92 |
93 | * © COPYRIGHT STMicroelectronics
94 | */
95 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/UART1/UART1_Synchronous/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page UART1_Synchronous UART1 Synchronous mode.
2 | @verbatim
3 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
4 | * @file UART1_Synchronous/readme.txt
5 | * @author MCD Application Team
6 | * @version V2.2.0
7 | * @date 30-September-2014
8 | * @brief Description of the UART1 Synchronous mode.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | @endverbatim
25 |
26 |
27 | @par Example description
28 |
29 | This example provides a short description of how to use UART1 in synchronous mode
30 | to ensure a master/slave full duplex communication with SPI.
31 |
32 | The UART1 sends data from TxBuffer1 buffer to SPI using TXE flag.
33 | Data received using RXNE flag by SPI is stored in RxBuffer2 then compared with
34 | the sent ones and the result of this comparison is stored in the "TransferStatus1"
35 | variable.
36 |
37 | In the same Time, the SPI sends data from TxBuffer2 buffer to UART1 using TXE flag.
38 | Data received using RXNE flag by UART1 is stored in RxBuffer1 then compared with
39 | the sent ones and the result of this comparison is stored in the "TransferStatus2"
40 | variable.
41 |
42 | @par Directory contents
43 |
44 | - UART1\UART1_Synchronous\main.c Main file containing the "main" function
45 | - UART1\UART1_Synchronous\stm8s_conf.h Library Configuration file
46 | - UART1\UART1_Synchronous\stm8s_it.c Interrupt routines source
47 | - UART1\UART1_Synchronous\stm8s_it.h Interrupt routines declaration
48 |
49 |
50 | @par Hardware and Software environment
51 |
52 | - This example runs on STM8S and STM8A High density,Low density devices.
53 | - For medium density devices, UART1 should be replaced by UART2
54 |
55 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
56 | board and can be easily tailored to any other development board.
57 |
58 | - STM8/128-EVAL Set-up
59 | - Connect UART1 and SPI pins as follows:
60 | - UART1 TX (PA5) to SPI MOSI (PC6)
61 | - UART1 RX (PA4) to SPI MISO (PC7)
62 | - UART1 CLK (PA6) to SPI SCK (PC5)
63 |
64 |
65 | @par How to use it ?
66 |
67 | In order to make the program work, you must do the following :
68 |
69 | - Copy all source files from this example folder to the template folder under
70 | Project\Template
71 | - Open your preferred toolchain
72 | - Rebuild all files and load your image into target memory
73 | - Run the example
74 |
75 | @note
76 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
77 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
78 | density ranges between 32 to 128 Kbytes
79 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
80 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
81 | density ranges between 8 to 32 Kbytes
82 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
83 | where the Flash memory density ranges between 32 to 128 Kbytes.
84 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
85 | where the Flash memory density ranges between 16 to 32-Kbytes.
86 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
87 | where the Flash density is 8 Kbytes.
88 |
89 | * © COPYRIGHT STMicroelectronics
90 | */
91 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Examples/WWDG/WWDG_Example/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page WWDG_Example WWDG refreshing, WWDG Reset
2 |
3 | @verbatim
4 | ******************** (C)COPYRIGHT 2014 STMicroelectronics *******************
5 | * @file WWDG/WWDG_Example/readme.txt
6 | * @author MCD Application Team
7 | * @version V2.2.0
8 | * @date 30-September-2014
9 | * @brief Description of the WWDG Rearm Reset Example.
10 | ******************************************************************************
11 | *
12 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
13 | * You may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at:
15 | *
16 | * http://www.st.com/software_license_agreement_liberty_v2
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | *
24 | ******************************************************************************
25 | @endverbatim
26 |
27 | @par Example description
28 |
29 | This example shows how to refresh the WWDG counter. The WWDG timeout is set to
30 | 251.9 ms.
31 |
32 | As AllowedRefresh variable is set to ENABLE the WWDG counter is refreshed
33 | preventing a WWDG reset and LED2 is toggling.
34 | When user press key button, an EXTI event is triggered and the corresponding
35 | ISR is served setting AllowedRefresh variable to DISABLE. So no WWDG counter
36 | refresh is performed and when WWDG counter reaches 63 an MCU reset will occur.
37 |
38 | When user press joystick down button, an EXTI event is triggered and the
39 | corresponding ISR is served setting NonAlowedRefresh variable to ENABLE.
40 | So WWDG counter refresh is performed in the non allowed window and as a result
41 | an MCU reset will occur.
42 |
43 | If a WWDG reset is generated, after system startup LED1 toggles otherwise it
44 | turns off.
45 |
46 |
47 |
48 | @par Directory contents
49 |
50 | - WWDG\WWDG_Example\main.c Main file containing the "main" function
51 | - WWDG\WWDG_Example\stm8s_conf.h Library Configuration file
52 | - WWDG\WWDG_Example\stm8s_it.c Interrupt routines source
53 | - WWDG\WWDG_Example\stm8s_it.h Interrupt routines declaration
54 |
55 |
56 | @par Hardware and Software environment
57 |
58 | - This example runs on STM8S and STM8A High density, Medium density Low density
59 | devices.
60 |
61 | - This example has been tested with STMicroelectronics STM8/128-EVAL evaluation
62 | board and can be easily tailored to any other development board.
63 |
64 | - STM8/128-EVAL Set-up
65 | - leds LD1, LD2, Key and joystick down push buttons are used.
66 |
67 |
68 | @par How to use it ?
69 |
70 | In order to make the program work, you must do the following :
71 |
72 | - Copy all source files from this example folder to the template folder under
73 | Project\Template
74 | - Open your preferred toolchain
75 | - Rebuild all files and load your image into target memory
76 | - Run the example
77 | - LED 2 is toggling, WWDG counter is refreshed in allowed window so no reset.
78 | - When you press key button, WWDG counter is never refreshed and when it
79 | reaches 63, LED1 toggles indicating a WWDG reset.
80 | - When you press joystick down button, WWDG counter is refreshed in the non
81 | allowed window so LED1 toggles indicating a WWDG reset.
82 |
83 | @note
84 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
85 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
86 | density ranges between 32 to 128 Kbytes
87 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
88 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
89 | density ranges between 8 to 32 Kbytes
90 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
91 | where the Flash memory density ranges between 32 to 128 Kbytes.
92 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
93 | where the Flash memory density ranges between 16 to 32-Kbytes.
94 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
95 | where the Flash density is 8 Kbytes.
96 |
97 | * © COPYRIGHT STMicroelectronics
98 | */
99 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/EWSTM8/Project.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $WS_DIR$\Project.ewp
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/EWSTM8/readme.txt:
--------------------------------------------------------------------------------
1 | /**
2 | @page ewstm8 EWSTM8 Project Template for STM8S/A product devices
3 |
4 | @verbatim
5 | ******************* (C) COPYRIGHT 2011 STMicroelectronics ********************
6 | * @file readme.txt
7 | * @author MCD Application Team
8 | * @version V2.1.0
9 | * @date 18-November-2011
10 | * @brief This sub-directory contains all the user-modifiable files needed
11 | * to create a new project linked with the STM8S/A Standard Peripheral
12 | * Library and working with IAR Embedded Workbench for STM8 (EWSTM8)
13 | * software toolchain.
14 | ******************************************************************************
15 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
16 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
17 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
18 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
19 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
20 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
21 | ******************************************************************************
22 | @endverbatim
23 |
24 | @par Directory contents
25 |
26 | - project .ewd/.eww/.ewp: A pre-configured project file with the provided library
27 | structure that produces an executable image with IAR
28 | Embedded Workbench.
29 |
30 |
31 | @par How to use it ?
32 |
33 | - Open the Project.eww workspace.
34 | - In the workspace toolbar select the project configuration:
35 | - stm8af622x: to configure the project for STM8AF622x Low-density devices.
36 | - stm8s103: to configure the project for STM8S103 Low-density devices.
37 | - stm8s903: to configure the project for STM8S903 Low-density devices.
38 | - stm8s105: to configure the project for STM8S Medium-density devices.
39 | - stm8s207: to configure the project for STM8S207 High-density devices.
40 | - stm8s208: to configure the project for STM8S208 High-density devices.
41 | - stm8af52ax: to configure the project for STM8AF52Ax High-density devices.
42 | - stm8af62ax: to configure the project for STM8AF62Ax High-density devices.
43 | - stm8af626x: to configure the project for STM8A Medium-density devices.
44 | @note The needed define symbols for these configurations are already declared in the
45 | preprocessor section.
46 |
47 | - Rebuild all files: Project->Rebuild all
48 | - Load project image: Project->Debug
49 | - Run program: Debug->Go(F5)
50 |
51 | @note
52 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
53 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
54 | density ranges between 32 to 128 Kbytes
55 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
56 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
57 | density ranges between 8 to 32 Kbytes
58 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
59 | where the Flash memory density ranges between 32 to 128 Kbytes.
60 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
61 | where the Flash memory density ranges between 16 to 32-Kbytes.
62 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
63 | where the Flash density is 8 Kbytes.
64 | - Low-Density STM8A devices are the STM8AF622x microcontrollers where the Flash
65 | density is 8 Kbytes.
66 |
67 | * © COPYRIGHT 2011 STMicroelectronics
68 | */
69 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/RIDE/STM8_OB.asm:
--------------------------------------------------------------------------------
1 | ;This file contains the values to program in the option bytes.
2 | ;You can change the values below according to the device datasheet.
3 | ;Be careful to respect the complement bytes,
4 | ; or the default values of the option bytes will be used.
5 |
6 | ;See the device datasheet for more information on the meaning of each bit.
7 |
8 | cseg at 04800h
9 |
10 | db 000h ;LOCKBYTE
11 |
12 | db 000h ;OPT1
13 | db 0FFh ;NOPT1
14 |
15 | db 000h ;OPT2
16 | db 0FFh ;NOPT2
17 |
18 | db 000h ;OPT3
19 | db 0FFh ;NOPT3
20 |
21 | db 000h ;OPT4
22 | db 0FFh ;NOPT4
23 |
24 | db 000h ;OPT5
25 | db 0FFh ;NOPT5
26 |
27 | db 000h ;OPT6
28 | db 0FFh ;NOPT6
29 |
30 | db 000h ;OPT7
31 | db 0FFh ;NOPT7
32 |
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/RIDE/project.rprj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/RIDE/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page project_Ride Template project for RIDE toolchain with Raisonance compiler
2 |
3 | @verbatim
4 | ******************* (C) COPYRIGHT 2011 STMicroelectronics ********************
5 | * @file readme.txt
6 | * @author MCD Application Team
7 | * @version V2.1.0
8 | * @date 18-November-2011
9 | * @brief This sub-directory contains all the user-modifiable files needed
10 | * to create a new project linked with the STM8S/A Standard Peripheral
11 | * Library and working with RIDE7 software toolchain.
12 | ******************************************************************************
13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 | ******************************************************************************
20 | @endverbatim
21 | @par Project description
22 |
23 | This folder contains a standard RIDE template workspace that includes 8
24 | projects related to the FW Lib supported products.
25 | Each project includes all the user-modifiable files that are necessary
26 | to create a new project.
27 | These project templates can be used by mean of minor updates in the library files
28 | to run the FWLib examples, or custom user applications.
29 |
30 |
31 | @par Directories contents
32 |
33 | - project\\template\\RIDE
34 | - project.rprj Workspace file
35 | - stm8s103.rapp Project file for STM8S103 Low-density devices.
36 | - stm8s903.rapp Project file for STM8S903 Low-density devices.
37 | - stm8s105.rapp Project file for STM8S Medium-density devices.
38 | - stm8s207.rapp Project file for STM8S207 High-density devices.
39 | - stm8s208.rapp Project file for STM8S208 High-density devices.
40 | - stm8af52ax.rapp Project file for STM8AF52Ax High-density devices.
41 | - stm8af62ax.rapp Project file for STM8AF62Ax High-density devices.
42 | - stm8af626x.rapp Project file for STM8A Medium-density devices.
43 | - STM8_OB.asm File required for option bytes configuration
44 |
45 |
46 |
47 | @par How to use it ?
48 |
49 | - Open the RIDE workspace (project.rprj)
50 | - Choose the desired project related to the used product from the list:
51 | in the "view Project Explorer" --> Right click on the desired project
52 | and select "Set as StartUp application"
53 | - Rebuild all files: : in the "view Project Explorer" Right click on
54 | the active application and select "Build"
55 | - Load project image: Debug->Load(Ctrl+L)
56 | - Run program: Debug->Start (Ctrl+D)
57 |
58 | @note
59 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
60 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
61 | density ranges between 32 to 128 Kbytes
62 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
63 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
64 | density ranges between 8 to 32 Kbytes
65 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
66 | where the Flash memory density ranges between 32 to 128 Kbytes.
67 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
68 | where the Flash memory density ranges between 16 to 32-Kbytes.
69 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
70 | where the Flash density is 8 Kbytes.
71 |
72 | * © COPYRIGHT 2011 STMicroelectronics
73 | */
74 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/Release_Notes.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/STM8S_StdPeriph_Template/Release_Notes.html
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/STVD/Cosmic/Project.stw:
--------------------------------------------------------------------------------
1 | ; STMicroelectronics Workspace file
2 |
3 | [Version]
4 | Keyword=ST7Workspace-V0.7
5 |
6 | [Project0]
7 | Filename=stm8s208.stp
8 | Dependencies=
9 |
10 | [Project1]
11 | Filename=stm8s207.stp
12 | Dependencies=
13 |
14 | [Project2]
15 | Filename=stm8s105.stp
16 | Dependencies=
17 |
18 | [Project3]
19 | Filename=stm8s103.stp
20 | Dependencies=
21 |
22 | [Project4]
23 | Filename=stm8s903.stp
24 | Dependencies=
25 |
26 | [Project5]
27 | Filename=stm8af52ax.stp
28 | Dependencies=
29 |
30 | [Project6]
31 | Filename=stm8af62ax.stp
32 | Dependencies=
33 |
34 | [Project7]
35 | Filename=stm8af626x.stp
36 | Dependencies=
37 |
38 | [Project8]
39 | Filename=stm8s007.stp
40 | Dependencies=
41 |
42 | [Project9]
43 | Filename=stm8s003.stp
44 | Dependencies=
45 |
46 | [Project10]
47 | Filename=stm8s005.stp
48 | Dependencies=
49 |
50 | [Project11]
51 | Filename=stm8af622x.stp
52 | Dependencies=
53 | [Options]
54 | ActiveProject=stm8s208
55 | ActiveConfig=Debug
56 | AddSortedElements=1
57 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/STVD/Cosmic/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page project Template project for ST Visual Develop (STVD) toolchain with Cosmic compiler
2 |
3 | @verbatim
4 | ******************* (C) COPYRIGHT 2011 STMicroelectronics ********************
5 | * @file readme.txt
6 | * @author MCD Application Team
7 | * @version V2.1.0
8 | * @date 18-November-2011
9 | * @brief This sub-directory contains all the user-modifiable files needed
10 | * to create a new project linked with the STM8S/A Standard Peripheral
11 | * Library and working with STVD and Cosmic software toolchain.
12 | ******************************************************************************
13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 | ******************************************************************************
20 | @endverbatim
21 |
22 | @par Project description
23 |
24 | This folder contains a standard STVD template workspace that includes 11
25 | projects related to the FW Lib supported products.
26 | Each project includes all the user-modifiable files that are necessary
27 | to create a new project.
28 | These project templates can be used by mean of minor updates in the library files
29 | to run the FWLib examples, or custom user applications.
30 |
31 |
32 | - project\\template\\STVD\\Cosmic
33 | - project.stw Workspace file
34 | - stm8s103.stp Project file for STM8S103 Low-density devices.
35 | - stm8s003.stp Project file for STM8S003 Low-density devices.
36 | - stm8s105.stp Project file for STM8S105 Medium-density devices.
37 | - stm8s005.stp Project file for STM8S005 Medium-density devices.
38 | - stm8s207.stp Project file for STM8S207 High-density devices.
39 | - stm8s007.stp Project file for STM8S007 High-density devices.
40 | - stm8s208.stp Project file for STM8S208 High-density devices.
41 | - stm8s903.stp Project file for STM8S903 Low-density devices.
42 | - stm8af52ax.stp Project file for STM8AF52Ax High-density devices.
43 | - stm8af62ax.stp Project file for STM8AF62Ax High-density devices.
44 | - stm8af626x.stp Project file for STM8A Medium-density devices.
45 |
46 |
47 | @par How to use it ?
48 |
49 | - Open the STVD workspace
50 | - Set active the project related to the used product: Project-> Set Active Project,
51 | and choose the desired project
52 | - Select your debug instrument: Debug instrument-> Target Settings, select the
53 | target you want to use for debug session (Swim Stice or Swim Rlink)
54 | - Rebuild all files: Build-> Rebuild all.
55 | - Load project image: Debug->Start Debugging
56 | - Run program: Debug->Run (Ctrl+F5)
57 |
58 | @b Tip: If it is your first time using STVD, you have to confirm the default
59 | toolset and path information that will be used when building your application,
60 | to do so:
61 | - Select Tools-> Options
62 | - In the Options window click on the Toolset tab
63 | - Select your toolset from the Toolset list box.
64 | If the path is incorrect you can type the correct path in the Root Path
65 | field, or use the browse button to locate it.
66 | - In the subpath fields, type the correct subpath if necessary
67 |
68 | @note
69 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
70 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
71 | density ranges between 32 to 128 Kbytes
72 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
73 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
74 | density ranges between 8 to 32 Kbytes
75 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
76 | where the Flash memory density ranges between 32 to 128 Kbytes.
77 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
78 | where the Flash memory density ranges between 16 to 32-Kbytes.
79 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
80 | where the Flash density is 8 Kbytes.
81 |
82 | * © COPYRIGHT 2011 STMicroelectronics
83 | */
84 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/STVD/Raisonance/Project.stw:
--------------------------------------------------------------------------------
1 | ; STMicroelectronics Workspace file
2 |
3 | [Version]
4 | Keyword=ST7Workspace-V0.7
5 |
6 | [Project0]
7 | Filename=stm8s208.stp
8 | Dependencies=
9 |
10 | [Project1]
11 | Filename=stm8s207.stp
12 | Dependencies=
13 |
14 | [Project2]
15 | Filename=stm8s105.stp
16 | Dependencies=
17 |
18 | [Project3]
19 | Filename=stm8s103.stp
20 | Dependencies=
21 |
22 | [Project4]
23 | Filename=stm8s903.stp
24 | Dependencies=
25 |
26 | [Project5]
27 | Filename=stm8af52ax.stp
28 | Dependencies=
29 |
30 | [Project6]
31 | Filename=stm8af62ax.stp
32 | Dependencies=
33 |
34 | [Project7]
35 | Filename=stm8af626x.stp
36 | Dependencies=
37 |
38 | [Project8]
39 | Filename=stm8s005.stp
40 | Dependencies=
41 |
42 | [Project9]
43 | Filename=stm8s003.stp
44 | Dependencies=
45 |
46 | [Project10]
47 | Filename=stm8s007.stp
48 | Dependencies=
49 |
50 | [Project11]
51 | Filename=stm8af622x.stp
52 | Dependencies=
53 | [Options]
54 | ActiveProject=stm8s208
55 | ActiveConfig=Debug
56 | AddSortedElements=0
57 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/main.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file Project/main.c
4 | * @author MCD Application Team
5 | * @version V2.2.0
6 | * @date 30-September-2014
7 | * @brief Main program body
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2014 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm8s.h"
31 |
32 | /* Private defines -----------------------------------------------------------*/
33 | /* Private function prototypes -----------------------------------------------*/
34 | /* Private functions ---------------------------------------------------------*/
35 |
36 | void main(void)
37 | {
38 | /* Infinite loop */
39 | while (1)
40 | {
41 | }
42 |
43 | }
44 |
45 | #ifdef USE_FULL_ASSERT
46 |
47 | /**
48 | * @brief Reports the name of the source file and the source line number
49 | * where the assert_param error has occurred.
50 | * @param file: pointer to the source file name
51 | * @param line: assert_param error line source number
52 | * @retval : None
53 | */
54 | void assert_failed(u8* file, u32 line)
55 | {
56 | /* User can add his own implementation to report the file name and line number,
57 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
58 |
59 | /* Infinite loop */
60 | while (1)
61 | {
62 | }
63 | }
64 | #endif
65 |
66 |
67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
68 |
--------------------------------------------------------------------------------
/Project/STM8S_StdPeriph_Template/readme.txt:
--------------------------------------------------------------------------------
1 | /**
2 | @page exampletemplate Project Example Template
3 |
4 | @verbatim
5 | ******************** (C) COPYRIGHT 2014 STMicroelectronics *******************
6 | * @file readme.txt
7 | * @author MCD Application Team
8 | * @version V2.2.0
9 | * @date 30-September-2014
10 | * @brief This sub-directory contains all the user-modifiable files
11 | * needed to create a new project linked with the STM8S/A
12 | * Standard Peripheral Library.
13 | ******************************************************************************
14 | *
15 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
16 | * You may not use this file except in compliance with the License.
17 | * You may obtain a copy of the License at:
18 | *
19 | * http://www.st.com/software_license_agreement_liberty_v2
20 | *
21 | * Unless required by applicable law or agreed to in writing, software
22 | * distributed under the License is distributed on an "AS IS" BASIS,
23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | * See the License for the specific language governing permissions and
25 | * limitations under the License.
26 | *
27 | ******************************************************************************
28 | @endverbatim
29 |
30 | @par Project Example Template Description
31 |
32 | This example is used as a template that can be used as reference to build any new
33 | firmware development for all STM8S and STM8A product devices using the STM8S/A
34 | Standard Peripherals Library.
35 |
36 |
37 | @par Directory contents
38 |
39 | This folder contains standard template projects for EWSTM8, STVD with Cosmic,
40 | STVD with raisonance and RIDE toolchains that compile the needed STM8S/A Standard
41 | Peripheral's drivers plus all the user-modifiable files that are necessary to
42 | create a new project.
43 |
44 | - Project/Template/stm8s_conf.h Library Configuration file
45 |
46 | - Project/Template/stm8s_it.c: Source file containing the interrupt handlers (the
47 | function bodies are empty in this template).
48 |
49 | - Project/Template/stm8s_it.h Header file including all interrupt handlers prototypes.
50 |
51 | - Project/Template/main.c Main program
52 |
53 | @note
54 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
55 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
56 | density ranges between 32 to 128 Kbytes
57 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
58 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
59 | density ranges between 8 to 32 Kbytes
60 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
61 | where the Flash memory density ranges between 32 to 128 Kbytes.
62 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
63 | where the Flash memory density ranges between 16 to 32-Kbytes.
64 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
65 | where the Flash density is 8 Kbytes.
66 |
67 | * © COPYRIGHT STMicroelectronics
68 | */
69 |
--------------------------------------------------------------------------------
/Project/modbus/.gitignore:
--------------------------------------------------------------------------------
1 | EWSTM8/STM8S003
2 | EWSTM8/settings
3 | EWSTM8/Backup of Project.ewd
4 | EWSTM8/Backup of Project.ewp
5 | EWSTM8/Project.dep
--------------------------------------------------------------------------------
/Project/modbus/EWSTM8/Project.eww:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $WS_DIR$\Project.ewp
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Project/modbus/EWSTM8/readme.txt:
--------------------------------------------------------------------------------
1 | /**
2 | @page ewstm8 EWSTM8 Project Template for STM8S/A product devices
3 |
4 | @verbatim
5 | ******************* (C) COPYRIGHT 2011 STMicroelectronics ********************
6 | * @file readme.txt
7 | * @author MCD Application Team
8 | * @version V2.1.0
9 | * @date 18-November-2011
10 | * @brief This sub-directory contains all the user-modifiable files needed
11 | * to create a new project linked with the STM8S/A Standard Peripheral
12 | * Library and working with IAR Embedded Workbench for STM8 (EWSTM8)
13 | * software toolchain.
14 | ******************************************************************************
15 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
16 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
17 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
18 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
19 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
20 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
21 | ******************************************************************************
22 | @endverbatim
23 |
24 | @par Directory contents
25 |
26 | - project .ewd/.eww/.ewp: A pre-configured project file with the provided library
27 | structure that produces an executable image with IAR
28 | Embedded Workbench.
29 |
30 |
31 | @par How to use it ?
32 |
33 | - Open the Project.eww workspace.
34 | - In the workspace toolbar select the project configuration:
35 | - stm8af622x: to configure the project for STM8AF622x Low-density devices.
36 | - stm8s103: to configure the project for STM8S103 Low-density devices.
37 | - stm8s903: to configure the project for STM8S903 Low-density devices.
38 | - stm8s105: to configure the project for STM8S Medium-density devices.
39 | - stm8s207: to configure the project for STM8S207 High-density devices.
40 | - stm8s208: to configure the project for STM8S208 High-density devices.
41 | - stm8af52ax: to configure the project for STM8AF52Ax High-density devices.
42 | - stm8af62ax: to configure the project for STM8AF62Ax High-density devices.
43 | - stm8af626x: to configure the project for STM8A Medium-density devices.
44 | @note The needed define symbols for these configurations are already declared in the
45 | preprocessor section.
46 |
47 | - Rebuild all files: Project->Rebuild all
48 | - Load project image: Project->Debug
49 | - Run program: Debug->Go(F5)
50 |
51 | @note
52 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
53 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
54 | density ranges between 32 to 128 Kbytes
55 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
56 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
57 | density ranges between 8 to 32 Kbytes
58 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
59 | where the Flash memory density ranges between 32 to 128 Kbytes.
60 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
61 | where the Flash memory density ranges between 16 to 32-Kbytes.
62 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
63 | where the Flash density is 8 Kbytes.
64 | - Low-Density STM8A devices are the STM8AF622x microcontrollers where the Flash
65 | density is 8 Kbytes.
66 |
67 | * © COPYRIGHT 2011 STMicroelectronics
68 | */
69 |
--------------------------------------------------------------------------------
/Project/modbus/RIDE/STM8_OB.asm:
--------------------------------------------------------------------------------
1 | ;This file contains the values to program in the option bytes.
2 | ;You can change the values below according to the device datasheet.
3 | ;Be careful to respect the complement bytes,
4 | ; or the default values of the option bytes will be used.
5 |
6 | ;See the device datasheet for more information on the meaning of each bit.
7 |
8 | cseg at 04800h
9 |
10 | db 000h ;LOCKBYTE
11 |
12 | db 000h ;OPT1
13 | db 0FFh ;NOPT1
14 |
15 | db 000h ;OPT2
16 | db 0FFh ;NOPT2
17 |
18 | db 000h ;OPT3
19 | db 0FFh ;NOPT3
20 |
21 | db 000h ;OPT4
22 | db 0FFh ;NOPT4
23 |
24 | db 000h ;OPT5
25 | db 0FFh ;NOPT5
26 |
27 | db 000h ;OPT6
28 | db 0FFh ;NOPT6
29 |
30 | db 000h ;OPT7
31 | db 0FFh ;NOPT7
32 |
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/Project/modbus/RIDE/project.rprj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Project/modbus/RIDE/readme.txt:
--------------------------------------------------------------------------------
1 | /** @page project_Ride Template project for RIDE toolchain with Raisonance compiler
2 |
3 | @verbatim
4 | ******************* (C) COPYRIGHT 2011 STMicroelectronics ********************
5 | * @file readme.txt
6 | * @author MCD Application Team
7 | * @version V2.1.0
8 | * @date 18-November-2011
9 | * @brief This sub-directory contains all the user-modifiable files needed
10 | * to create a new project linked with the STM8S/A Standard Peripheral
11 | * Library and working with RIDE7 software toolchain.
12 | ******************************************************************************
13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 | ******************************************************************************
20 | @endverbatim
21 | @par Project description
22 |
23 | This folder contains a standard RIDE template workspace that includes 8
24 | projects related to the FW Lib supported products.
25 | Each project includes all the user-modifiable files that are necessary
26 | to create a new project.
27 | These project templates can be used by mean of minor updates in the library files
28 | to run the FWLib examples, or custom user applications.
29 |
30 |
31 | @par Directories contents
32 |
33 | - project\\template\\RIDE
34 | - project.rprj Workspace file
35 | - stm8s103.rapp Project file for STM8S103 Low-density devices.
36 | - stm8s903.rapp Project file for STM8S903 Low-density devices.
37 | - stm8s105.rapp Project file for STM8S Medium-density devices.
38 | - stm8s207.rapp Project file for STM8S207 High-density devices.
39 | - stm8s208.rapp Project file for STM8S208 High-density devices.
40 | - stm8af52ax.rapp Project file for STM8AF52Ax High-density devices.
41 | - stm8af62ax.rapp Project file for STM8AF62Ax High-density devices.
42 | - stm8af626x.rapp Project file for STM8A Medium-density devices.
43 | - STM8_OB.asm File required for option bytes configuration
44 |
45 |
46 |
47 | @par How to use it ?
48 |
49 | - Open the RIDE workspace (project.rprj)
50 | - Choose the desired project related to the used product from the list:
51 | in the "view Project Explorer" --> Right click on the desired project
52 | and select "Set as StartUp application"
53 | - Rebuild all files: : in the "view Project Explorer" Right click on
54 | the active application and select "Build"
55 | - Load project image: Debug->Load(Ctrl+L)
56 | - Run program: Debug->Start (Ctrl+D)
57 |
58 | @note
59 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
60 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
61 | density ranges between 32 to 128 Kbytes
62 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
63 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
64 | density ranges between 8 to 32 Kbytes
65 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
66 | where the Flash memory density ranges between 32 to 128 Kbytes.
67 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
68 | where the Flash memory density ranges between 16 to 32-Kbytes.
69 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
70 | where the Flash density is 8 Kbytes.
71 |
72 | * © COPYRIGHT 2011 STMicroelectronics
73 | */
74 |
--------------------------------------------------------------------------------
/Project/modbus/Release_Notes.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/Release_Notes.html
--------------------------------------------------------------------------------
/Project/modbus/demo.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: BARE Demo Application
3 | * Copyright (C) 2006 Christian Walter
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | *
19 | * File: $Id: demo.c,v 1.1 2006/08/22 21:35:13 wolti Exp $
20 | */
21 |
22 | /* ----------------------- Modbus includes ----------------------------------*/
23 | #include "mb.h"
24 | #include "mbport.h"
25 |
26 | /* ----------------------- Defines ------------------------------------------*/
27 | #define REG_INPUT_START 1000
28 | #define REG_INPUT_NREGS 4
29 |
30 | /* ----------------------- Static variables ---------------------------------*/
31 | static USHORT usRegInputStart = REG_INPUT_START;
32 | static USHORT usRegInputBuf[REG_INPUT_NREGS];
33 |
34 | /* ----------------------- Start implementation -----------------------------*/
35 | int
36 | main( void )
37 | {
38 | eMBErrorCode eStatus;
39 |
40 | eStatus = eMBInit( MB_RTU, 0x0A, 0, 38400, MB_PAR_EVEN );
41 |
42 | /* Enable the Modbus Protocol Stack. */
43 | eStatus = eMBEnable( );
44 |
45 | for( ;; )
46 | {
47 | ( void )eMBPoll( );
48 |
49 | /* Here we simply count the number of poll cycles. */
50 | usRegInputBuf[0]++;
51 | }
52 | }
53 |
54 | eMBErrorCode
55 | eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )
56 | {
57 | eMBErrorCode eStatus = MB_ENOERR;
58 | int iRegIndex;
59 |
60 | if( ( usAddress >= REG_INPUT_START )
61 | && ( usAddress + usNRegs <= REG_INPUT_START + REG_INPUT_NREGS ) )
62 | {
63 | iRegIndex = ( int )( usAddress - usRegInputStart );
64 | while( usNRegs > 0 )
65 | {
66 | *pucRegBuffer++ =
67 | ( unsigned char )( usRegInputBuf[iRegIndex] >> 8 );
68 | *pucRegBuffer++ =
69 | ( unsigned char )( usRegInputBuf[iRegIndex] & 0xFF );
70 | iRegIndex++;
71 | usNRegs--;
72 | }
73 | }
74 | else
75 | {
76 | eStatus = MB_ENOREG;
77 | }
78 |
79 | return eStatus;
80 | }
81 |
82 | eMBErrorCode
83 | eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs,
84 | eMBRegisterMode eMode )
85 | {
86 | return MB_ENOREG;
87 | }
88 |
89 |
90 | eMBErrorCode
91 | eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils,
92 | eMBRegisterMode eMode )
93 | {
94 | return MB_ENOREG;
95 | }
96 |
97 | eMBErrorCode
98 | eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )
99 | {
100 | return MB_ENOREG;
101 | }
102 |
--------------------------------------------------------------------------------
/Project/modbus/main.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/main.c
--------------------------------------------------------------------------------
/Project/modbus/modbus/ascii/mbascii.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbascii.h,v 1.8 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_ASCII_H
32 | #define _MB_ASCII_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 |
38 | #if MB_ASCII_ENABLED > 0
39 | eMBErrorCode eMBASCIIInit( UCHAR slaveAddress, UCHAR ucPort,
40 | ULONG ulBaudRate, eMBParity eParity );
41 | void eMBASCIIStart( void );
42 | void eMBASCIIStop( void );
43 |
44 | eMBErrorCode eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame,
45 | USHORT * pusLength );
46 | eMBErrorCode eMBASCIISend( UCHAR slaveAddress, const UCHAR * pucFrame,
47 | USHORT usLength );
48 | BOOL xMBASCIIReceiveFSM( void );
49 | BOOL xMBASCIITransmitFSM( void );
50 | BOOL xMBASCIITimerT1SExpired( void );
51 | #endif
52 |
53 | #ifdef __cplusplus
54 | PR_END_EXTERN_C
55 | #endif
56 | #endif
57 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/functions/mbfuncdiag.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbfuncdiag.c,v 1.3 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/functions/mbfuncinput.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/modbus/functions/mbfuncinput.c
--------------------------------------------------------------------------------
/Project/modbus/modbus/functions/mbfuncother.c:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbfuncother.c,v 1.8 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | /* ----------------------- System includes ----------------------------------*/
32 | #include "stdlib.h"
33 | #include "string.h"
34 |
35 | /* ----------------------- Platform includes --------------------------------*/
36 | #include "port.h"
37 |
38 | /* ----------------------- Modbus includes ----------------------------------*/
39 | #include "mb.h"
40 | #include "mbframe.h"
41 | #include "mbproto.h"
42 | #include "mbconfig.h"
43 |
44 | #if MB_FUNC_OTHER_REP_SLAVEID_ENABLED > 0
45 |
46 | /* ----------------------- Static variables ---------------------------------*/
47 | static UCHAR ucMBSlaveID[MB_FUNC_OTHER_REP_SLAVEID_BUF];
48 | static USHORT usMBSlaveIDLen;
49 |
50 | /* ----------------------- Start implementation -----------------------------*/
51 |
52 | eMBErrorCode
53 | eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning,
54 | UCHAR const *pucAdditional, USHORT usAdditionalLen )
55 | {
56 | eMBErrorCode eStatus = MB_ENOERR;
57 |
58 | /* the first byte and second byte in the buffer is reserved for
59 | * the parameter ucSlaveID and the running flag. The rest of
60 | * the buffer is available for additional data. */
61 | if( usAdditionalLen + 2 < MB_FUNC_OTHER_REP_SLAVEID_BUF )
62 | {
63 | usMBSlaveIDLen = 0;
64 | ucMBSlaveID[usMBSlaveIDLen++] = ucSlaveID;
65 | ucMBSlaveID[usMBSlaveIDLen++] = ( UCHAR )( xIsRunning ? 0xFF : 0x00 );
66 | if( usAdditionalLen > 0 )
67 | {
68 | memcpy( &ucMBSlaveID[usMBSlaveIDLen], pucAdditional,
69 | ( size_t )usAdditionalLen );
70 | usMBSlaveIDLen += usAdditionalLen;
71 | }
72 | }
73 | else
74 | {
75 | eStatus = MB_ENORES;
76 | }
77 | return eStatus;
78 | }
79 |
80 | /* 0x17 - Report Slave ID */
81 | eMBException
82 | eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen )
83 | {
84 | memcpy( &pucFrame[MB_PDU_DATA_OFF], &ucMBSlaveID[0], ( size_t )usMBSlaveIDLen );
85 | *usLen = ( USHORT )( MB_PDU_DATA_OFF + usMBSlaveIDLen );
86 | return MB_EX_NONE;
87 | }
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/include/mbframe.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbframe.h,v 1.9 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_FRAME_H
32 | #define _MB_FRAME_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 |
38 | /*!
39 | * Constants which defines the format of a modbus frame. The example is
40 | * shown for a Modbus RTU/ASCII frame. Note that the Modbus PDU is not
41 | * dependent on the underlying transport.
42 | *
43 | *
44 | * <------------------------ MODBUS SERIAL LINE PDU (1) ------------------->
45 | * <----------- MODBUS PDU (1') ---------------->
46 | * +-----------+---------------+----------------------------+-------------+
47 | * | Address | Function Code | Data | CRC/LRC |
48 | * +-----------+---------------+----------------------------+-------------+
49 | * | | | |
50 | * (2) (3/2') (3') (4)
51 | *
52 | * (1) ... MB_SER_PDU_SIZE_MAX = 256
53 | * (2) ... MB_SER_PDU_ADDR_OFF = 0
54 | * (3) ... MB_SER_PDU_PDU_OFF = 1
55 | * (4) ... MB_SER_PDU_SIZE_CRC = 2
56 | *
57 | * (1') ... MB_PDU_SIZE_MAX = 253
58 | * (2') ... MB_PDU_FUNC_OFF = 0
59 | * (3') ... MB_PDU_DATA_OFF = 1
60 | *
61 | */
62 |
63 | /* ----------------------- Defines ------------------------------------------*/
64 | #define MB_PDU_SIZE_MAX 253 /*!< Maximum size of a PDU. */
65 | #define MB_PDU_SIZE_MIN 1 /*!< Function Code */
66 | #define MB_PDU_FUNC_OFF 0 /*!< Offset of function code in PDU. */
67 | #define MB_PDU_DATA_OFF 1 /*!< Offset for response data in PDU. */
68 |
69 | /* ----------------------- Prototypes 0-------------------------------------*/
70 | typedef void ( *pvMBFrameStart ) ( void );
71 |
72 | typedef void ( *pvMBFrameStop ) ( void );
73 |
74 | typedef eMBErrorCode( *peMBFrameReceive ) ( UCHAR * pucRcvAddress,
75 | UCHAR ** pucFrame,
76 | USHORT * pusLength );
77 |
78 | typedef eMBErrorCode( *peMBFrameSend ) ( UCHAR slaveAddress,
79 | const UCHAR * pucFrame,
80 | USHORT usLength );
81 |
82 | typedef void( *pvMBFrameClose ) ( void );
83 |
84 | #ifdef __cplusplus
85 | PR_END_EXTERN_C
86 | #endif
87 | #endif
88 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/include/mbfunc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbfunc.h,v 1.12 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_FUNC_H
32 | #define _MB_FUNC_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 | #if MB_FUNC_OTHER_REP_SLAVEID_BUF > 0
38 | eMBException eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen );
39 | #endif
40 |
41 | #if MB_FUNC_READ_INPUT_ENABLED > 0
42 | eMBException eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen );
43 | #endif
44 |
45 | #if MB_FUNC_READ_HOLDING_ENABLED > 0
46 | eMBException eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
47 | #endif
48 |
49 | #if MB_FUNC_WRITE_HOLDING_ENABLED > 0
50 | eMBException eMBFuncWriteHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
51 | #endif
52 |
53 | #if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0
54 | eMBException eMBFuncWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
55 | #endif
56 |
57 | #if MB_FUNC_READ_COILS_ENABLED > 0
58 | eMBException eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen );
59 | #endif
60 |
61 | #if MB_FUNC_WRITE_COIL_ENABLED > 0
62 | eMBException eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen );
63 | #endif
64 |
65 | #if MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED > 0
66 | eMBException eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen );
67 | #endif
68 |
69 | #if MB_FUNC_READ_DISCRETE_INPUTS_ENABLED > 0
70 | eMBException eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen );
71 | #endif
72 |
73 | #if MB_FUNC_READWRITE_HOLDING_ENABLED > 0
74 | eMBException eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
75 | #endif
76 |
77 | #ifdef __cplusplus
78 | PR_END_EXTERN_C
79 | #endif
80 | #endif
81 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/include/mbproto.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbproto.h,v 1.14 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_PROTO_H
32 | #define _MB_PROTO_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 | /* ----------------------- Defines ------------------------------------------*/
38 | #define MB_ADDRESS_BROADCAST ( 0 ) /*! Modbus broadcast address. */
39 | #define MB_ADDRESS_MIN ( 1 ) /*! Smallest possible slave address. */
40 | #define MB_ADDRESS_MAX ( 247 ) /*! Biggest possible slave address. */
41 | #define MB_FUNC_NONE ( 0 )
42 | #define MB_FUNC_READ_COILS ( 1 )
43 | #define MB_FUNC_READ_DISCRETE_INPUTS ( 2 )
44 | #define MB_FUNC_WRITE_SINGLE_COIL ( 5 )
45 | #define MB_FUNC_WRITE_MULTIPLE_COILS ( 15 )
46 | #define MB_FUNC_READ_HOLDING_REGISTER ( 3 )
47 | #define MB_FUNC_READ_INPUT_REGISTER ( 4 )
48 | #define MB_FUNC_WRITE_REGISTER ( 6 )
49 | #define MB_FUNC_WRITE_MULTIPLE_REGISTERS ( 16 )
50 | #define MB_FUNC_READWRITE_MULTIPLE_REGISTERS ( 23 )
51 | #define MB_FUNC_DIAG_READ_EXCEPTION ( 7 )
52 | #define MB_FUNC_DIAG_DIAGNOSTIC ( 8 )
53 | #define MB_FUNC_DIAG_GET_COM_EVENT_CNT ( 11 )
54 | #define MB_FUNC_DIAG_GET_COM_EVENT_LOG ( 12 )
55 | #define MB_FUNC_OTHER_REPORT_SLAVEID ( 17 )
56 | #define MB_FUNC_ERROR ( 128 )
57 | /* ----------------------- Type definitions ---------------------------------*/
58 | typedef enum
59 | {
60 | MB_EX_NONE = 0x00,
61 | MB_EX_ILLEGAL_FUNCTION = 0x01,
62 | MB_EX_ILLEGAL_DATA_ADDRESS = 0x02,
63 | MB_EX_ILLEGAL_DATA_VALUE = 0x03,
64 | MB_EX_SLAVE_DEVICE_FAILURE = 0x04,
65 | MB_EX_ACKNOWLEDGE = 0x05,
66 | MB_EX_SLAVE_BUSY = 0x06,
67 | MB_EX_MEMORY_PARITY_ERROR = 0x08,
68 | MB_EX_GATEWAY_PATH_FAILED = 0x0A,
69 | MB_EX_GATEWAY_TGT_FAILED = 0x0B
70 | } eMBException;
71 |
72 | typedef eMBException( *pxMBFunctionHandler ) ( UCHAR * pucFrame, USHORT * pusLength );
73 |
74 | typedef struct
75 | {
76 | UCHAR ucFunctionCode;
77 | pxMBFunctionHandler pxHandler;
78 | } xMBFunctionHandler;
79 |
80 | #ifdef __cplusplus
81 | PR_END_EXTERN_C
82 | #endif
83 | #endif
84 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/include/mbutils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbutils.h,v 1.5 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_UTILS_H
32 | #define _MB_UTILS_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 | /*! \defgroup modbus_utils Utilities
38 | *
39 | * This module contains some utility functions which can be used by
40 | * the application. It includes some special functions for working with
41 | * bitfields backed by a character array buffer.
42 | *
43 | */
44 | /*! \addtogroup modbus_utils
45 | * @{
46 | */
47 | /*! \brief Function to set bits in a byte buffer.
48 | *
49 | * This function allows the efficient use of an array to implement bitfields.
50 | * The array used for storing the bits must always be a multiple of two
51 | * bytes. Up to eight bits can be set or cleared in one operation.
52 | *
53 | * \param ucByteBuf A buffer where the bit values are stored. Must be a
54 | * multiple of 2 bytes. No length checking is performed and if
55 | * usBitOffset / 8 is greater than the size of the buffer memory contents
56 | * is overwritten.
57 | * \param usBitOffset The starting address of the bits to set. The first
58 | * bit has the offset 0.
59 | * \param ucNBits Number of bits to modify. The value must always be smaller
60 | * than 8.
61 | * \param ucValues Thew new values for the bits. The value for the first bit
62 | * starting at usBitOffset
is the LSB of the value
63 | * ucValues
64 | *
65 | * \code
66 | * ucBits[2] = {0, 0};
67 | *
68 | * // Set bit 4 to 1 (read: set 1 bit starting at bit offset 4 to value 1)
69 | * xMBUtilSetBits( ucBits, 4, 1, 1 );
70 | *
71 | * // Set bit 7 to 1 and bit 8 to 0.
72 | * xMBUtilSetBits( ucBits, 7, 2, 0x01 );
73 | *
74 | * // Set bits 8 - 11 to 0x05 and bits 12 - 15 to 0x0A;
75 | * xMBUtilSetBits( ucBits, 8, 8, 0x5A);
76 | * \endcode
77 | */
78 | void xMBUtilSetBits( UCHAR * ucByteBuf, USHORT usBitOffset,
79 | UCHAR ucNBits, UCHAR ucValues );
80 |
81 | /*! \brief Function to read bits in a byte buffer.
82 | *
83 | * This function is used to extract up bit values from an array. Up to eight
84 | * bit values can be extracted in one step.
85 | *
86 | * \param ucByteBuf A buffer where the bit values are stored.
87 | * \param usBitOffset The starting address of the bits to set. The first
88 | * bit has the offset 0.
89 | * \param ucNBits Number of bits to modify. The value must always be smaller
90 | * than 8.
91 | *
92 | * \code
93 | * UCHAR ucBits[2] = {0, 0};
94 | * UCHAR ucResult;
95 | *
96 | * // Extract the bits 3 - 10.
97 | * ucResult = xMBUtilGetBits( ucBits, 3, 8 );
98 | * \endcode
99 | */
100 | UCHAR xMBUtilGetBits( UCHAR * ucByteBuf, USHORT usBitOffset,
101 | UCHAR ucNBits );
102 |
103 | /*! @} */
104 |
105 | #ifdef __cplusplus
106 | PR_END_EXTERN_C
107 | #endif
108 | #endif
109 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/mb.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/modbus/mb.c
--------------------------------------------------------------------------------
/Project/modbus/modbus/rtu/mbcrc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbcrc.h,v 1.5 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_CRC_H
32 | #define _MB_CRC_H
33 |
34 | USHORT usMBCRC16( UCHAR * pucFrame, USHORT usLen );
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/rtu/mbrtu.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/modbus/rtu/mbrtu.c
--------------------------------------------------------------------------------
/Project/modbus/modbus/rtu/mbrtu.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbrtu.h,v 1.9 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_RTU_H
32 | #define _MB_RTU_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 | eMBErrorCode eMBRTUInit( UCHAR slaveAddress, UCHAR ucPort, ULONG ulBaudRate,
38 | eMBParity eParity );
39 | void eMBRTUStart( void );
40 | void eMBRTUStop( void );
41 | eMBErrorCode eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength );
42 | eMBErrorCode eMBRTUSend( UCHAR slaveAddress, const UCHAR * pucFrame, USHORT usLength );
43 | BOOL xMBRTUReceiveFSM( void );
44 | BOOL xMBRTUTransmitFSM( void );
45 | BOOL xMBRTUTimerT15Expired( void );
46 | BOOL xMBRTUTimerT35Expired( void );
47 |
48 | #ifdef __cplusplus
49 | PR_END_EXTERN_C
50 | #endif
51 | #endif
52 |
--------------------------------------------------------------------------------
/Project/modbus/modbus/tcp/mbtcp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
3 | * Copyright (c) 2006 Christian Walter
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | *
28 | * File: $Id: mbtcp.h,v 1.2 2006/12/07 22:10:34 wolti Exp $
29 | */
30 |
31 | #ifndef _MB_TCP_H
32 | #define _MB_TCP_H
33 |
34 | #ifdef __cplusplus
35 | PR_BEGIN_EXTERN_C
36 | #endif
37 |
38 | /* ----------------------- Defines ------------------------------------------*/
39 | #define MB_TCP_PSEUDO_ADDRESS 255
40 |
41 | /* ----------------------- Function prototypes ------------------------------*/
42 | eMBErrorCode eMBTCPDoInit( USHORT ucTCPPort );
43 | void eMBTCPStart( void );
44 | void eMBTCPStop( void );
45 | eMBErrorCode eMBTCPReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame,
46 | USHORT * pusLength );
47 | eMBErrorCode eMBTCPSend( UCHAR _unused, const UCHAR * pucFrame,
48 | USHORT usLength );
49 |
50 | #ifdef __cplusplus
51 | PR_END_EXTERN_C
52 | #endif
53 | #endif
54 |
--------------------------------------------------------------------------------
/Project/modbus/port/port.h:
--------------------------------------------------------------------------------
1 | /*
2 | * FreeModbus Libary: BARE Port
3 | * Copyright (C) 2006 Christian Walter
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | *
19 | * File: $Id: port.h,v 1.1 2006/08/22 21:35:13 wolti Exp $
20 | */
21 |
22 | #ifndef _PORT_H
23 | #define _PORT_H
24 |
25 | #include
26 | #include
27 |
28 | #include "stm8s.h"
29 |
30 | #define INLINE inline
31 | #define PR_BEGIN_EXTERN_C extern "C" {
32 | #define PR_END_EXTERN_C }
33 |
34 | #define ENTER_CRITICAL_SECTION( ) disableInterrupts()
35 | #define EXIT_CRITICAL_SECTION( ) enableInterrupts()
36 |
37 | typedef uint8_t BOOL;
38 |
39 | typedef unsigned char UCHAR;
40 | typedef char CHAR;
41 |
42 | typedef uint16_t USHORT;
43 | typedef int16_t SHORT;
44 |
45 | typedef uint32_t ULONG;
46 | typedef int32_t LONG;
47 |
48 | #ifndef TRUE
49 | #define TRUE 1
50 | #endif
51 |
52 | #ifndef FALSE
53 | #define FALSE 0
54 | #endif
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/Project/modbus/port/portevent.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/port/portevent.c
--------------------------------------------------------------------------------
/Project/modbus/port/porttimer.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Project/modbus/port/porttimer.c
--------------------------------------------------------------------------------
/Project/modbus/readme.txt:
--------------------------------------------------------------------------------
1 | /**
2 | @page exampletemplate Project Example Template
3 |
4 | @verbatim
5 | ******************** (C) COPYRIGHT 2014 STMicroelectronics *******************
6 | * @file readme.txt
7 | * @author MCD Application Team
8 | * @version V2.2.0
9 | * @date 30-September-2014
10 | * @brief This sub-directory contains all the user-modifiable files
11 | * needed to create a new project linked with the STM8S/A
12 | * Standard Peripheral Library.
13 | ******************************************************************************
14 | *
15 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
16 | * You may not use this file except in compliance with the License.
17 | * You may obtain a copy of the License at:
18 | *
19 | * http://www.st.com/software_license_agreement_liberty_v2
20 | *
21 | * Unless required by applicable law or agreed to in writing, software
22 | * distributed under the License is distributed on an "AS IS" BASIS,
23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | * See the License for the specific language governing permissions and
25 | * limitations under the License.
26 | *
27 | ******************************************************************************
28 | @endverbatim
29 |
30 | @par Project Example Template Description
31 |
32 | This example is used as a template that can be used as reference to build any new
33 | firmware development for all STM8S and STM8A product devices using the STM8S/A
34 | Standard Peripherals Library.
35 |
36 |
37 | @par Directory contents
38 |
39 | This folder contains standard template projects for EWSTM8, STVD with Cosmic,
40 | STVD with raisonance and RIDE toolchains that compile the needed STM8S/A Standard
41 | Peripheral's drivers plus all the user-modifiable files that are necessary to
42 | create a new project.
43 |
44 | - Project/Template/stm8s_conf.h Library Configuration file
45 |
46 | - Project/Template/stm8s_it.c: Source file containing the interrupt handlers (the
47 | function bodies are empty in this template).
48 |
49 | - Project/Template/stm8s_it.h Header file including all interrupt handlers prototypes.
50 |
51 | - Project/Template/main.c Main program
52 |
53 | @note
54 | - High-Density STM8A devices are the STM8AF52xx STM8AF6269/8x/Ax,
55 | STM8AF51xx, and STM8AF6169/7x/8x/9x/Ax microcontrollers where the Flash memory
56 | density ranges between 32 to 128 Kbytes
57 | - Medium-Density STM8A devices are the STM8AF622x/4x, STM8AF6266/68,
58 | STM8AF612x/4x, and STM8AF6166/68 microcontrollers where the Flash memory
59 | density ranges between 8 to 32 Kbytes
60 | - High-Density STM8S devices are the STM8S207xx, STM8S007 and STM8S208xx microcontrollers
61 | where the Flash memory density ranges between 32 to 128 Kbytes.
62 | - Medium-Density STM8S devices are the STM8S105x and STM8S005 microcontrollers
63 | where the Flash memory density ranges between 16 to 32-Kbytes.
64 | - Low-Density STM8S devices are the STM8S103xx, STM8S003 and STM8S903xx microcontrollers
65 | where the Flash density is 8 Kbytes.
66 |
67 | * © COPYRIGHT STMicroelectronics
68 | */
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "FreeModbus移植到stm8s芯片"
3 | author: "hnhkj@163.com"
4 | date: "2016年10月7日"
5 | output: html_document
6 | ---
7 |
8 |
9 | ## FreeModbus
10 |
11 | 是一款开源的modbus实现代码,在嵌入式领域有比较广泛的应用。但是,在FreeModbus众多的支持当中,缺少了
12 | 对STM8S003低端MCU的支持。为了降低产品成本,考虑移植FreeModbus到STM8S003当中。
13 | 对于移植的文档,在网络中有不少说明,但是很少有实际的代码。本人通过对FreeModbus的移植之后,觉得有必要
14 | 将给代码公开,方便人人使用,减少不必要的工作。
15 |
16 |
17 | ## FreeModbus使用注意:
18 |
19 | modbus系统默认开始地址为0x01,而大多数系统的开始地址为0x00.因而,modbus系统默认是不能读取mcu内部的0x00数据的。因而,在使用当中要注意这一点。
20 |
21 |
--------------------------------------------------------------------------------
/Release_Notes.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Release_Notes.html
--------------------------------------------------------------------------------
/Utilities/STM8S_EVAL/stm8s_eval.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm8s_eval.c
4 | * @author MCD Application Team
5 | * @version V1.0.1
6 | * @date 30-September-2014
7 | * @brief This file provides firmware functions to manage Leds, push-buttons
8 | * and COM ports available on STM8S Evaluation Boards from STMicroelectronics.
9 | ******************************************************************************
10 | *
11 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
12 | * You may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at:
14 | *
15 | * http://www.st.com/software_license_agreement_liberty_v2
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | *
23 | ******************************************************************************
24 | */
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm8s_eval.h"
28 |
29 | /** @addtogroup Utilities
30 | * @{
31 | */
32 |
33 | /** @defgroup STM8S_EVAL
34 | * @brief This file provides firmware functions to manage Leds, push-buttons
35 | * and COM ports available on STM8 Evaluation Boards from STMicroelectronics.
36 | * @{
37 | */
38 |
39 | /** @defgroup STM8S_EVAL_Abstraction_Layer
40 | * @{
41 | */
42 |
43 | #ifdef USE_STM8_128_EVAL
44 | #include "stm8-128_eval/stm8_128_eval.c"
45 | #else
46 | #error "Please select first the STM8 EVAL board to be used (in stm8s_eval.h)"
47 | #endif
48 |
49 | /* Private typedef -----------------------------------------------------------*/
50 | /* Private define ------------------------------------------------------------*/
51 | /* Private macro -------------------------------------------------------------*/
52 | /* Private variables ---------------------------------------------------------*/
53 | /* Private function prototypes -----------------------------------------------*/
54 | /* Private function ----------------------------------------------------------*/
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--------------------------------------------------------------------------------
/Utilities/STM8S_EVAL/stm8s_eval.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/Utilities/STM8S_EVAL/stm8s_eval.h
--------------------------------------------------------------------------------
/_htmresc/logo.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/_htmresc/logo.bmp
--------------------------------------------------------------------------------
/doc/Modbus_Application_Protocol_V1_1b.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/doc/Modbus_Application_Protocol_V1_1b.pdf
--------------------------------------------------------------------------------
/stm8s-a_stdperiph_lib_um.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hnhkj/stm8s_modbus/4f09a0952eb67e97ebc93275ab25e5183b4f646b/stm8s-a_stdperiph_lib_um.chm
--------------------------------------------------------------------------------