├── .gitignore ├── README.md ├── STM8_helloworld ├── .vscode │ ├── .cortex-debug.peripherals.state.json │ ├── .cortex-debug.registers.state.json │ ├── launch.json │ └── tasks.json ├── STM8S_StdPeriph_Driver │ ├── Release_Notes.html │ ├── inc │ │ ├── fireworks.h │ │ ├── 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 │ │ ├── fireworks.c │ │ ├── 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 ├── build │ ├── main.asm │ ├── main.cdb │ ├── main.elf │ ├── main.lk │ ├── main.lst │ ├── main.map │ ├── main.rel │ ├── main.rst │ ├── main.sym │ ├── stm8s_gpio.asm │ ├── stm8s_gpio.lst │ ├── stm8s_gpio.rel │ ├── stm8s_gpio.rst │ └── stm8s_gpio.sym ├── main.c ├── main.h ├── makefile ├── stm8s_conf.h ├── stm8s_it.c └── stm8s_it.h └── assets ├── DM00024550.pdf ├── STM8_full-pres.pdf ├── en.stsw-stm8069.zip └── img ├── STM8S003F3P6.jpg ├── debug.png ├── gdb.png ├── main.png ├── st-link_v2.png ├── stm8.png └── vscode_ide.png /.gitignore: -------------------------------------------------------------------------------- 1 | codealike.json 2 | .vscode -------------------------------------------------------------------------------- /STM8_helloworld/.vscode/.cortex-debug.peripherals.state.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /STM8_helloworld/.vscode/.cortex-debug.registers.state.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /STM8_helloworld/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "name": "(stm8-gdb) Launch", 10 | "type": "cppdbg", 11 | "request": "launch", 12 | //"preLaunchTask": "make", 13 | "program": "${workspaceRoot}/build/main.elf", 14 | "cwd": "${workspaceRoot}", 15 | "stopAtEntry": true, 16 | "MIMode": "gdb", 17 | "miDebuggerPath": "/usr/local/bin/stm8-gdb", 18 | "miDebuggerServerAddress":"localhost:3333", 19 | //"debugServerPath": "openocd", 20 | //"debugServerArgs": "-f interface/stlink.cfg -f target/stm8s003.cfg -c \"init\" -c \"reset halt\"", 21 | //"filterStderr": true, 22 | //"serverStarted": "Listening\\ on\\ port\\ 4444", 23 | 24 | 25 | "logging": { 26 | "moduleLoad": true, 27 | "trace": true, 28 | "engineLogging": true, 29 | "programOutput": true, 30 | "exceptions": true 31 | }, 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /STM8_helloworld/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "make", 8 | "type": "shell", 9 | "command": "make clean all", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/Release_Notes.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/Release_Notes.html -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/fireworks.h: -------------------------------------------------------------------------------- 1 | #ifndef __FIREWORK 2 | 3 | #define __FIREWORK 4 | 5 | #include "stm8s.h" 6 | #include 7 | #include 8 | #include 9 | 10 | char *strdcpy (char *string_, char delimiter_, char position_); 11 | unsigned char strtoint (char *string_); 12 | 13 | #endif /* __FIREWORKS */ 14 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_adc2.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_adc2.h 4 | * @author MCD Application Team 5 | * @version V2.2.0 6 | * @date 30-September-2014 7 | * @brief This file contains all the prototypes/macros for the ADC2 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_ADC2_H 31 | #define __STM8S_ADC2_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "stm8s.h" 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | 38 | /** @addtogroup ADC2_Exported_Types 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @brief ADC2 clock prescaler selection 44 | */ 45 | 46 | typedef enum { 47 | ADC2_PRESSEL_FCPU_D2 = (uint8_t)0x00, /**< Prescaler selection fADC2 = fcpu/2 */ 48 | ADC2_PRESSEL_FCPU_D3 = (uint8_t)0x10, /**< Prescaler selection fADC2 = fcpu/3 */ 49 | ADC2_PRESSEL_FCPU_D4 = (uint8_t)0x20, /**< Prescaler selection fADC2 = fcpu/4 */ 50 | ADC2_PRESSEL_FCPU_D6 = (uint8_t)0x30, /**< Prescaler selection fADC2 = fcpu/6 */ 51 | ADC2_PRESSEL_FCPU_D8 = (uint8_t)0x40, /**< Prescaler selection fADC2 = fcpu/8 */ 52 | ADC2_PRESSEL_FCPU_D10 = (uint8_t)0x50, /**< Prescaler selection fADC2 = fcpu/10 */ 53 | ADC2_PRESSEL_FCPU_D12 = (uint8_t)0x60, /**< Prescaler selection fADC2 = fcpu/12 */ 54 | ADC2_PRESSEL_FCPU_D18 = (uint8_t)0x70 /**< Prescaler selection fADC2 = fcpu/18 */ 55 | } ADC2_PresSel_TypeDef; 56 | 57 | /** 58 | * @brief ADC2 External conversion trigger event selection 59 | */ 60 | typedef enum { 61 | ADC2_EXTTRIG_TIM = (uint8_t)0x00, /**< Conversion from Internal TIM TRGO event */ 62 | ADC2_EXTTRIG_GPIO = (uint8_t)0x01 /**< Conversion from External interrupt on ADC_ETR pin*/ 63 | } ADC2_ExtTrig_TypeDef; 64 | 65 | /** 66 | * @brief ADC2 data alignment 67 | */ 68 | typedef enum { 69 | ADC2_ALIGN_LEFT = (uint8_t)0x00, /**< Data alignment left */ 70 | ADC2_ALIGN_RIGHT = (uint8_t)0x08 /**< Data alignment right */ 71 | } ADC2_Align_TypeDef; 72 | 73 | /** 74 | * @brief ADC2 schmitt Trigger 75 | */ 76 | typedef enum { 77 | ADC2_SCHMITTTRIG_CHANNEL0 = (uint8_t)0x00, /**< Schmitt trigger disable on AIN0 */ 78 | ADC2_SCHMITTTRIG_CHANNEL1 = (uint8_t)0x01, /**< Schmitt trigger disable on AIN1 */ 79 | ADC2_SCHMITTTRIG_CHANNEL2 = (uint8_t)0x02, /**< Schmitt trigger disable on AIN2 */ 80 | ADC2_SCHMITTTRIG_CHANNEL3 = (uint8_t)0x03, /**< Schmitt trigger disable on AIN3 */ 81 | ADC2_SCHMITTTRIG_CHANNEL4 = (uint8_t)0x04, /**< Schmitt trigger disable on AIN4 */ 82 | ADC2_SCHMITTTRIG_CHANNEL5 = (uint8_t)0x05, /**< Schmitt trigger disable on AIN5 */ 83 | ADC2_SCHMITTTRIG_CHANNEL6 = (uint8_t)0x06, /**< Schmitt trigger disable on AIN6 */ 84 | ADC2_SCHMITTTRIG_CHANNEL7 = (uint8_t)0x07, /**< Schmitt trigger disable on AIN7 */ 85 | ADC2_SCHMITTTRIG_CHANNEL8 = (uint8_t)0x08, /**< Schmitt trigger disable on AIN8 */ 86 | ADC2_SCHMITTTRIG_CHANNEL9 = (uint8_t)0x09, /**< Schmitt trigger disable on AIN9 */ 87 | ADC2_SCHMITTTRIG_CHANNEL10 = (uint8_t)0x0A, /**< Schmitt trigger disable on AIN10 */ 88 | ADC2_SCHMITTTRIG_CHANNEL11 = (uint8_t)0x0B, /**< Schmitt trigger disable on AIN11 */ 89 | ADC2_SCHMITTTRIG_CHANNEL12 = (uint8_t)0x0C, /**< Schmitt trigger disable on AIN12 */ 90 | ADC2_SCHMITTTRIG_CHANNEL13 = (uint8_t)0x0D, /**< Schmitt trigger disable on AIN13 */ 91 | ADC2_SCHMITTTRIG_CHANNEL14 = (uint8_t)0x0E, /**< Schmitt trigger disable on AIN14 */ 92 | ADC2_SCHMITTTRIG_CHANNEL15 = (uint8_t)0x0F, /**< Schmitt trigger disable on AIN15 */ 93 | ADC2_SCHMITTTRIG_ALL = (uint8_t)0x1F /**< Schmitt trigger disable on all channels */ 94 | 95 | } ADC2_SchmittTrigg_TypeDef; 96 | 97 | /** 98 | * @brief ADC2 conversion mode selection 99 | */ 100 | 101 | typedef enum { 102 | ADC2_CONVERSIONMODE_SINGLE = (uint8_t)0x00, /**< Single conversion mode */ 103 | ADC2_CONVERSIONMODE_CONTINUOUS = (uint8_t)0x01 /**< Continuous conversion mode */ 104 | } ADC2_ConvMode_TypeDef; 105 | 106 | /** 107 | * @brief ADC2 analog channel selection 108 | */ 109 | 110 | typedef enum { 111 | ADC2_CHANNEL_0 = (uint8_t)0x00, /**< Analog channel 0 */ 112 | ADC2_CHANNEL_1 = (uint8_t)0x01, /**< Analog channel 1 */ 113 | ADC2_CHANNEL_2 = (uint8_t)0x02, /**< Analog channel 2 */ 114 | ADC2_CHANNEL_3 = (uint8_t)0x03, /**< Analog channel 3 */ 115 | ADC2_CHANNEL_4 = (uint8_t)0x04, /**< Analog channel 4 */ 116 | ADC2_CHANNEL_5 = (uint8_t)0x05, /**< Analog channel 5 */ 117 | ADC2_CHANNEL_6 = (uint8_t)0x06, /**< Analog channel 6 */ 118 | ADC2_CHANNEL_7 = (uint8_t)0x07, /**< Analog channel 7 */ 119 | ADC2_CHANNEL_8 = (uint8_t)0x08, /**< Analog channel 8 */ 120 | ADC2_CHANNEL_9 = (uint8_t)0x09, /**< Analog channel 9 */ 121 | ADC2_CHANNEL_10 = (uint8_t)0x0A, /**< Analog channel 10 */ 122 | ADC2_CHANNEL_11 = (uint8_t)0x0B, /**< Analog channel 11 */ 123 | ADC2_CHANNEL_12 = (uint8_t)0x0C, /**< Analog channel 12 */ 124 | ADC2_CHANNEL_13 = (uint8_t)0x0D, /**< Analog channel 13 */ 125 | ADC2_CHANNEL_14 = (uint8_t)0x0E, /**< Analog channel 14 */ 126 | ADC2_CHANNEL_15 = (uint8_t)0x0F /**< Analog channel 15 */ 127 | } ADC2_Channel_TypeDef; 128 | 129 | /** 130 | * @} 131 | */ 132 | 133 | /* Exported constants --------------------------------------------------------*/ 134 | 135 | /* Exported macros ------------------------------------------------------------*/ 136 | 137 | /* Private macros ------------------------------------------------------------*/ 138 | 139 | /** @addtogroup ADC2_Private_Macros 140 | * @brief Macros used by the assert function to check the different functions parameters. 141 | * @{ 142 | */ 143 | 144 | /** 145 | * @brief Macro used by the assert function to check the different prescaler's values. 146 | */ 147 | #define IS_ADC2_PRESSEL_OK(PRESCALER) (((PRESCALER) == ADC2_PRESSEL_FCPU_D2) || \ 148 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D3) || \ 149 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D4) || \ 150 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D6) || \ 151 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D8) || \ 152 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D10) || \ 153 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D12) || \ 154 | ((PRESCALER) == ADC2_PRESSEL_FCPU_D18)) 155 | 156 | /** 157 | * @brief Macro used by the assert function to check the different external trigger values. 158 | */ 159 | #define IS_ADC2_EXTTRIG_OK(EXTRIG) (((EXTRIG) == ADC2_EXTTRIG_TIM) || \ 160 | ((EXTRIG) == ADC2_EXTTRIG_GPIO)) 161 | 162 | /** 163 | * @brief Macro used by the assert function to check the different alignment modes. 164 | */ 165 | #define IS_ADC2_ALIGN_OK(ALIGN) (((ALIGN) == ADC2_ALIGN_LEFT) || \ 166 | ((ALIGN) == ADC2_ALIGN_RIGHT)) 167 | 168 | 169 | /** 170 | * @brief Macro used by the assert function to check the different schmitt trigger values. 171 | */ 172 | #define IS_ADC2_SCHMITTTRIG_OK(SCHMITTTRIG) (((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL0) || \ 173 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL1) || \ 174 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL2) || \ 175 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL3) || \ 176 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL4) || \ 177 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL5) || \ 178 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL6) || \ 179 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL7) || \ 180 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL8) || \ 181 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL9) || \ 182 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL10) || \ 183 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL11) || \ 184 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL12) || \ 185 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL13) || \ 186 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL14) || \ 187 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_CHANNEL15) || \ 188 | ((SCHMITTTRIG) == ADC2_SCHMITTTRIG_ALL)) 189 | 190 | /** 191 | * @brief Macro used by the assert function to check the different conversion modes. 192 | */ 193 | #define IS_ADC2_CONVERSIONMODE_OK(MODE) (((MODE) == ADC2_CONVERSIONMODE_SINGLE) || \ 194 | ((MODE) == ADC2_CONVERSIONMODE_CONTINUOUS)) 195 | 196 | /** 197 | * @brief Macro used by the assert function to check the different channels values. 198 | */ 199 | #define IS_ADC2_CHANNEL_OK(CHANNEL) (((CHANNEL) == ADC2_CHANNEL_0) || \ 200 | ((CHANNEL) == ADC2_CHANNEL_1) || \ 201 | ((CHANNEL) == ADC2_CHANNEL_2) || \ 202 | ((CHANNEL) == ADC2_CHANNEL_3) || \ 203 | ((CHANNEL) == ADC2_CHANNEL_4) || \ 204 | ((CHANNEL) == ADC2_CHANNEL_5) || \ 205 | ((CHANNEL) == ADC2_CHANNEL_6) || \ 206 | ((CHANNEL) == ADC2_CHANNEL_7) || \ 207 | ((CHANNEL) == ADC2_CHANNEL_8) || \ 208 | ((CHANNEL) == ADC2_CHANNEL_9) || \ 209 | ((CHANNEL) == ADC2_CHANNEL_10) || \ 210 | ((CHANNEL) == ADC2_CHANNEL_11) || \ 211 | ((CHANNEL) == ADC2_CHANNEL_12) || \ 212 | ((CHANNEL) == ADC2_CHANNEL_13) || \ 213 | ((CHANNEL) == ADC2_CHANNEL_14) || \ 214 | ((CHANNEL) == ADC2_CHANNEL_15)) 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | /* Exported functions ------------------------------------------------------- */ 221 | 222 | /** @addtogroup ADC2_Exported_Functions 223 | * @{ 224 | */ 225 | void ADC2_DeInit(void); 226 | void ADC2_Init(ADC2_ConvMode_TypeDef ADC2_ConversionMode, 227 | ADC2_Channel_TypeDef ADC2_Channel, 228 | ADC2_PresSel_TypeDef ADC2_PrescalerSelection, 229 | ADC2_ExtTrig_TypeDef ADC2_ExtTrigger, 230 | FunctionalState ADC2_ExtTriggerState, 231 | ADC2_Align_TypeDef ADC2_Align, 232 | ADC2_SchmittTrigg_TypeDef ADC2_SchmittTriggerChannel, 233 | FunctionalState ADC2_SchmittTriggerState); 234 | void ADC2_Cmd(FunctionalState NewState); 235 | void ADC2_ITConfig(FunctionalState NewState); 236 | void ADC2_PrescalerConfig(ADC2_PresSel_TypeDef ADC2_Prescaler); 237 | void ADC2_SchmittTriggerConfig(ADC2_SchmittTrigg_TypeDef ADC2_SchmittTriggerChannel, 238 | FunctionalState NewState); 239 | void ADC2_ConversionConfig(ADC2_ConvMode_TypeDef ADC2_ConversionMode, 240 | ADC2_Channel_TypeDef ADC2_Channel, 241 | ADC2_Align_TypeDef ADC2_Align); 242 | void ADC2_ExternalTriggerConfig(ADC2_ExtTrig_TypeDef ADC2_ExtTrigger, FunctionalState NewState); 243 | void ADC2_StartConversion(void); 244 | uint16_t ADC2_GetConversionValue(void); 245 | FlagStatus ADC2_GetFlagStatus(void); 246 | void ADC2_ClearFlag(void); 247 | ITStatus ADC2_GetITStatus(void); 248 | void ADC2_ClearITPendingBit(void); 249 | /** 250 | * @} 251 | */ 252 | 253 | #endif /* __STM8S_ADC2_H */ 254 | 255 | 256 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 257 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_awu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_awu.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 AWU 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_AWU_H 30 | #define __STM8S_AWU_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | 37 | /** @addtogroup AWU_Exported_Types 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief AWU TimeBase selection 43 | */ 44 | 45 | typedef enum 46 | { 47 | AWU_TIMEBASE_NO_IT = (uint8_t)0, /*!< No AWU interrupt selected */ 48 | AWU_TIMEBASE_250US = (uint8_t)1, /*!< AWU Timebase equals 0.25 ms */ 49 | AWU_TIMEBASE_500US = (uint8_t)2, /*!< AWU Timebase equals 0.5 ms */ 50 | AWU_TIMEBASE_1MS = (uint8_t)3, /*!< AWU Timebase equals 1 ms */ 51 | AWU_TIMEBASE_2MS = (uint8_t)4, /*!< AWU Timebase equals 2 ms */ 52 | AWU_TIMEBASE_4MS = (uint8_t)5, /*!< AWU Timebase equals 4 ms */ 53 | AWU_TIMEBASE_8MS = (uint8_t)6, /*!< AWU Timebase equals 8 ms */ 54 | AWU_TIMEBASE_16MS = (uint8_t)7, /*!< AWU Timebase equals 16 ms */ 55 | AWU_TIMEBASE_32MS = (uint8_t)8, /*!< AWU Timebase equals 32 ms */ 56 | AWU_TIMEBASE_64MS = (uint8_t)9, /*!< AWU Timebase equals 64 ms */ 57 | AWU_TIMEBASE_128MS = (uint8_t)10, /*!< AWU Timebase equals 128 ms */ 58 | AWU_TIMEBASE_256MS = (uint8_t)11, /*!< AWU Timebase equals 256 ms */ 59 | AWU_TIMEBASE_512MS = (uint8_t)12, /*!< AWU Timebase equals 512 ms */ 60 | AWU_TIMEBASE_1S = (uint8_t)13, /*!< AWU Timebase equals 1 s */ 61 | AWU_TIMEBASE_2S = (uint8_t)14, /*!< AWU Timebase equals 2 s */ 62 | AWU_TIMEBASE_12S = (uint8_t)15, /*!< AWU Timebase equals 12 s */ 63 | AWU_TIMEBASE_30S = (uint8_t)16 /*!< AWU Timebase equals 30 s */ 64 | } AWU_Timebase_TypeDef; 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /* Exported constants --------------------------------------------------------*/ 71 | 72 | /** @addtogroup AWU_Exported_Constants 73 | * @{ 74 | */ 75 | 76 | #define LSI_FREQUENCY_MIN ((uint32_t)110000) /*!< LSI minimum value in Hertz */ 77 | #define LSI_FREQUENCY_MAX ((uint32_t)150000) /*!< LSI maximum value in Hertz */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /* Exported macros ------------------------------------------------------------*/ 84 | 85 | /* Private macros ------------------------------------------------------------*/ 86 | 87 | /** @addtogroup AWU_Private_Macros 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @brief Macro used by the assert function to check the different functions parameters. 93 | */ 94 | 95 | /** 96 | * @brief Macro used by the assert function to check the AWU timebases 97 | */ 98 | #define IS_AWU_TIMEBASE_OK(TB) \ 99 | (((TB) == AWU_TIMEBASE_NO_IT) || \ 100 | ((TB) == AWU_TIMEBASE_250US) || \ 101 | ((TB) == AWU_TIMEBASE_500US) || \ 102 | ((TB) == AWU_TIMEBASE_1MS) || \ 103 | ((TB) == AWU_TIMEBASE_2MS) || \ 104 | ((TB) == AWU_TIMEBASE_4MS) || \ 105 | ((TB) == AWU_TIMEBASE_8MS) || \ 106 | ((TB) == AWU_TIMEBASE_16MS) || \ 107 | ((TB) == AWU_TIMEBASE_32MS) || \ 108 | ((TB) == AWU_TIMEBASE_64MS) || \ 109 | ((TB) == AWU_TIMEBASE_128MS) || \ 110 | ((TB) == AWU_TIMEBASE_256MS) || \ 111 | ((TB) == AWU_TIMEBASE_512MS) || \ 112 | ((TB) == AWU_TIMEBASE_1S) || \ 113 | ((TB) == AWU_TIMEBASE_2S) || \ 114 | ((TB) == AWU_TIMEBASE_12S) || \ 115 | ((TB) == AWU_TIMEBASE_30S)) 116 | 117 | /** 118 | * @brief Macro used by the assert function to check the LSI frequency (in Hz) 119 | */ 120 | #define IS_LSI_FREQUENCY_OK(FREQ) \ 121 | (((FREQ) >= LSI_FREQUENCY_MIN) && \ 122 | ((FREQ) <= LSI_FREQUENCY_MAX)) 123 | 124 | /** 125 | * @} 126 | */ 127 | 128 | /* Exported functions ------------------------------------------------------- */ 129 | 130 | /** @addtogroup AWU_Exported_Functions 131 | * @{ 132 | */ 133 | void AWU_DeInit(void); 134 | void AWU_Init(AWU_Timebase_TypeDef AWU_TimeBase); 135 | void AWU_Cmd(FunctionalState NewState); 136 | void AWU_LSICalibrationConfig(uint32_t LSIFreqHz); 137 | void AWU_IdleModeEnable(void); 138 | FlagStatus AWU_GetFlagStatus(void); 139 | 140 | /** 141 | * @} 142 | */ 143 | 144 | #endif /* __STM8S_AWU_H */ 145 | 146 | 147 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 148 | -------------------------------------------------------------------------------- /STM8_helloworld/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 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_exti.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_exti.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 EXTI 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_EXTI_H 30 | #define __STM8S_EXTI_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | 37 | /** @addtogroup EXTI_Exported_Types 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief EXTI Sensitivity values for PORTA to PORTE 43 | */ 44 | typedef enum { 45 | EXTI_SENSITIVITY_FALL_LOW = (uint8_t)0x00, /*!< Interrupt on Falling edge and Low level */ 46 | EXTI_SENSITIVITY_RISE_ONLY = (uint8_t)0x01, /*!< Interrupt on Rising edge only */ 47 | EXTI_SENSITIVITY_FALL_ONLY = (uint8_t)0x02, /*!< Interrupt on Falling edge only */ 48 | EXTI_SENSITIVITY_RISE_FALL = (uint8_t)0x03 /*!< Interrupt on Rising and Falling edges */ 49 | } EXTI_Sensitivity_TypeDef; 50 | 51 | /** 52 | * @brief EXTI Sensitivity values for TLI 53 | */ 54 | typedef enum { 55 | EXTI_TLISENSITIVITY_FALL_ONLY = (uint8_t)0x00, /*!< Top Level Interrupt on Falling edge only */ 56 | EXTI_TLISENSITIVITY_RISE_ONLY = (uint8_t)0x04 /*!< Top Level Interrupt on Rising edge only */ 57 | } EXTI_TLISensitivity_TypeDef; 58 | 59 | /** 60 | * @brief EXTI PortNum possible values 61 | */ 62 | typedef enum { 63 | EXTI_PORT_GPIOA = (uint8_t)0x00, /*!< GPIO Port A */ 64 | EXTI_PORT_GPIOB = (uint8_t)0x01, /*!< GPIO Port B */ 65 | EXTI_PORT_GPIOC = (uint8_t)0x02, /*!< GPIO Port C */ 66 | EXTI_PORT_GPIOD = (uint8_t)0x03, /*!< GPIO Port D */ 67 | EXTI_PORT_GPIOE = (uint8_t)0x04 /*!< GPIO Port E */ 68 | } EXTI_Port_TypeDef; 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /* Private macros ------------------------------------------------------------*/ 75 | 76 | /** @addtogroup EXTI_Private_Macros 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @brief Macro used by the assert function in order to check the different sensitivity values for PORTA to PORTE. 82 | */ 83 | #define IS_EXTI_SENSITIVITY_OK(SensitivityValue) \ 84 | (((SensitivityValue) == EXTI_SENSITIVITY_FALL_LOW) || \ 85 | ((SensitivityValue) == EXTI_SENSITIVITY_RISE_ONLY) || \ 86 | ((SensitivityValue) == EXTI_SENSITIVITY_FALL_ONLY) || \ 87 | ((SensitivityValue) == EXTI_SENSITIVITY_RISE_FALL)) 88 | 89 | /** 90 | * @brief Macro used by the assert function in order to check the different sensitivity values for TLI. 91 | */ 92 | #define IS_EXTI_TLISENSITIVITY_OK(SensitivityValue) \ 93 | (((SensitivityValue) == EXTI_TLISENSITIVITY_FALL_ONLY) || \ 94 | ((SensitivityValue) == EXTI_TLISENSITIVITY_RISE_ONLY)) 95 | 96 | /** 97 | * @brief Macro used by the assert function in order to check the different Port values 98 | */ 99 | #define IS_EXTI_PORT_OK(PORT) \ 100 | (((PORT) == EXTI_PORT_GPIOA) ||\ 101 | ((PORT) == EXTI_PORT_GPIOB) ||\ 102 | ((PORT) == EXTI_PORT_GPIOC) ||\ 103 | ((PORT) == EXTI_PORT_GPIOD) ||\ 104 | ((PORT) == EXTI_PORT_GPIOE)) 105 | 106 | /** 107 | * @brief Macro used by the assert function in order to check the different values of the EXTI PinMask 108 | */ 109 | #define IS_EXTI_PINMASK_OK(PinMask) ((((PinMask) & (uint8_t)0x00) == (uint8_t)0x00) && ((PinMask) != (uint8_t)0x00)) 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /* Exported functions ------------------------------------------------------- */ 116 | 117 | /** @addtogroup EXTI_Exported_Functions 118 | * @{ 119 | */ 120 | 121 | void EXTI_DeInit(void); 122 | void EXTI_SetExtIntSensitivity(EXTI_Port_TypeDef Port, EXTI_Sensitivity_TypeDef SensitivityValue); 123 | void EXTI_SetTLISensitivity(EXTI_TLISensitivity_TypeDef SensitivityValue); 124 | EXTI_Sensitivity_TypeDef EXTI_GetExtIntSensitivity(EXTI_Port_TypeDef Port); 125 | EXTI_TLISensitivity_TypeDef EXTI_GetTLISensitivity(void); 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | #endif /* __STM8S_EXTI_H */ 132 | 133 | 134 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 135 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_gpio.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 GPIO 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_GPIO_H 30 | #define __STM8S_GPIO_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /* Exported variables ------------------------------------------------------- */ 36 | /* Exported types ------------------------------------------------------------*/ 37 | 38 | /** @addtogroup GPIO_Exported_Types 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @brief GPIO modes 44 | * 45 | * Bits definitions: 46 | * - Bit 7: 0 = INPUT mode 47 | * 1 = OUTPUT mode 48 | * 1 = PULL-UP (input) or PUSH-PULL (output) 49 | * - Bit 5: 0 = No external interrupt (input) or No slope control (output) 50 | * 1 = External interrupt (input) or Slow control enabled (output) 51 | * - Bit 4: 0 = Low level (output) 52 | * 1 = High level (output push-pull) or HI-Z (output open-drain) 53 | */ 54 | typedef enum 55 | { 56 | GPIO_MODE_IN_FL_NO_IT = (uint8_t)0x00, /*!< Input floating, no external interrupt */ 57 | GPIO_MODE_IN_PU_NO_IT = (uint8_t)0x40, /*!< Input pull-up, no external interrupt */ 58 | GPIO_MODE_IN_FL_IT = (uint8_t)0x20, /*!< Input floating, external interrupt */ 59 | GPIO_MODE_IN_PU_IT = (uint8_t)0x60, /*!< Input pull-up, external interrupt */ 60 | GPIO_MODE_OUT_OD_LOW_FAST = (uint8_t)0xA0, /*!< Output open-drain, low level, 10MHz */ 61 | GPIO_MODE_OUT_PP_LOW_FAST = (uint8_t)0xE0, /*!< Output push-pull, low level, 10MHz */ 62 | GPIO_MODE_OUT_OD_LOW_SLOW = (uint8_t)0x80, /*!< Output open-drain, low level, 2MHz */ 63 | GPIO_MODE_OUT_PP_LOW_SLOW = (uint8_t)0xC0, /*!< Output push-pull, low level, 2MHz */ 64 | GPIO_MODE_OUT_OD_HIZ_FAST = (uint8_t)0xB0, /*!< Output open-drain, high-impedance level,10MHz */ 65 | GPIO_MODE_OUT_PP_HIGH_FAST = (uint8_t)0xF0, /*!< Output push-pull, high level, 10MHz */ 66 | GPIO_MODE_OUT_OD_HIZ_SLOW = (uint8_t)0x90, /*!< Output open-drain, high-impedance level, 2MHz */ 67 | GPIO_MODE_OUT_PP_HIGH_SLOW = (uint8_t)0xD0 /*!< Output push-pull, high level, 2MHz */ 68 | }GPIO_Mode_TypeDef; 69 | 70 | /** 71 | * @brief Definition of the GPIO pins. Used by the @ref GPIO_Init function in 72 | * order to select the pins to be initialized. 73 | */ 74 | 75 | typedef enum 76 | { 77 | GPIO_PIN_0 = ((uint8_t)0x01), /*!< Pin 0 selected */ 78 | GPIO_PIN_1 = ((uint8_t)0x02), /*!< Pin 1 selected */ 79 | GPIO_PIN_2 = ((uint8_t)0x04), /*!< Pin 2 selected */ 80 | GPIO_PIN_3 = ((uint8_t)0x08), /*!< Pin 3 selected */ 81 | GPIO_PIN_4 = ((uint8_t)0x10), /*!< Pin 4 selected */ 82 | GPIO_PIN_5 = ((uint8_t)0x20), /*!< Pin 5 selected */ 83 | GPIO_PIN_6 = ((uint8_t)0x40), /*!< Pin 6 selected */ 84 | GPIO_PIN_7 = ((uint8_t)0x80), /*!< Pin 7 selected */ 85 | GPIO_PIN_LNIB = ((uint8_t)0x0F), /*!< Low nibble pins selected */ 86 | GPIO_PIN_HNIB = ((uint8_t)0xF0), /*!< High nibble pins selected */ 87 | GPIO_PIN_ALL = ((uint8_t)0xFF) /*!< All pins selected */ 88 | }GPIO_Pin_TypeDef; 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /* Exported constants --------------------------------------------------------*/ 95 | /* Exported macros -----------------------------------------------------------*/ 96 | /* Private macros ------------------------------------------------------------*/ 97 | 98 | /** @addtogroup GPIO_Private_Macros 99 | * @{ 100 | */ 101 | 102 | /** 103 | * @brief Macro used by the assert function to check the different functions parameters. 104 | */ 105 | 106 | /** 107 | * @brief Macro used by the assert function in order to check the different 108 | * values of GPIOMode_TypeDef. 109 | */ 110 | #define IS_GPIO_MODE_OK(MODE) \ 111 | (((MODE) == GPIO_MODE_IN_FL_NO_IT) || \ 112 | ((MODE) == GPIO_MODE_IN_PU_NO_IT) || \ 113 | ((MODE) == GPIO_MODE_IN_FL_IT) || \ 114 | ((MODE) == GPIO_MODE_IN_PU_IT) || \ 115 | ((MODE) == GPIO_MODE_OUT_OD_LOW_FAST) || \ 116 | ((MODE) == GPIO_MODE_OUT_PP_LOW_FAST) || \ 117 | ((MODE) == GPIO_MODE_OUT_OD_LOW_SLOW) || \ 118 | ((MODE) == GPIO_MODE_OUT_PP_LOW_SLOW) || \ 119 | ((MODE) == GPIO_MODE_OUT_OD_HIZ_FAST) || \ 120 | ((MODE) == GPIO_MODE_OUT_PP_HIGH_FAST) || \ 121 | ((MODE) == GPIO_MODE_OUT_OD_HIZ_SLOW) || \ 122 | ((MODE) == GPIO_MODE_OUT_PP_HIGH_SLOW)) 123 | 124 | /** 125 | * @brief Macro used by the assert function in order to check the different 126 | * values of GPIO_Pins. 127 | */ 128 | #define IS_GPIO_PIN_OK(PIN) ((PIN) != (uint8_t)0x00) 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /* Exported functions ------------------------------------------------------- */ 135 | /** @addtogroup GPIO_Exported_Functions 136 | * @{ 137 | */ 138 | 139 | void GPIO_DeInit(GPIO_TypeDef* GPIOx); 140 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode); 141 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint8_t PortVal); 142 | void GPIO_WriteHigh(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins); 143 | void GPIO_WriteLow(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins); 144 | void GPIO_WriteReverse(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins); 145 | uint8_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); 146 | uint8_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); 147 | BitStatus GPIO_ReadInputPin(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin); 148 | void GPIO_ExternalPullUpConfig(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, FunctionalState NewState); 149 | /** 150 | * @} 151 | */ 152 | 153 | #endif /* __STM8L_GPIO_H */ 154 | 155 | 156 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_itc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_itc.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 ITC 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_ITC_H 30 | #define __STM8S_ITC_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | 37 | /** @addtogroup ITC_Exported_Types 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief ITC Interrupt Lines selection 43 | */ 44 | typedef enum { 45 | ITC_IRQ_TLI = (uint8_t)0, /*!< Software interrupt */ 46 | ITC_IRQ_AWU = (uint8_t)1, /*!< Auto wake up from halt interrupt */ 47 | ITC_IRQ_CLK = (uint8_t)2, /*!< Clock controller interrupt */ 48 | ITC_IRQ_PORTA = (uint8_t)3, /*!< Port A external interrupts */ 49 | ITC_IRQ_PORTB = (uint8_t)4, /*!< Port B external interrupts */ 50 | ITC_IRQ_PORTC = (uint8_t)5, /*!< Port C external interrupts */ 51 | ITC_IRQ_PORTD = (uint8_t)6, /*!< Port D external interrupts */ 52 | ITC_IRQ_PORTE = (uint8_t)7, /*!< Port E external interrupts */ 53 | 54 | #if defined(STM8S208) || defined(STM8AF52Ax) 55 | ITC_IRQ_CAN_RX = (uint8_t)8, /*!< beCAN RX interrupt */ 56 | ITC_IRQ_CAN_TX = (uint8_t)9, /*!< beCAN TX/ER/SC interrupt */ 57 | #endif /*STM8S208 or STM8AF52Ax */ 58 | 59 | #if defined(STM8S903) || defined(STM8AF622x) 60 | ITC_IRQ_PORTF = (uint8_t)8, /*!< Port F external interrupts */ 61 | #endif /*STM8S903 or STM8AF622x */ 62 | 63 | ITC_IRQ_SPI = (uint8_t)10, /*!< SPI interrupt */ 64 | ITC_IRQ_TIM1_OVF = (uint8_t)11, /*!< TIM1 update/overflow/underflow/trigger/ 65 | break interrupt*/ 66 | ITC_IRQ_TIM1_CAPCOM = (uint8_t)12, /*!< TIM1 capture/compare interrupt */ 67 | 68 | #if defined(STM8S903) || defined(STM8AF622x) 69 | ITC_IRQ_TIM5_OVFTRI = (uint8_t)13, /*!< TIM5 update/overflow/underflow/trigger/ 70 | interrupt */ 71 | ITC_IRQ_TIM5_CAPCOM = (uint8_t)14, /*!< TIM5 capture/compare interrupt */ 72 | #else 73 | ITC_IRQ_TIM2_OVF = (uint8_t)13, /*!< TIM2 update /overflow interrupt */ 74 | ITC_IRQ_TIM2_CAPCOM = (uint8_t)14, /*!< TIM2 capture/compare interrupt */ 75 | #endif /*STM8S903 or STM8AF622x */ 76 | 77 | ITC_IRQ_TIM3_OVF = (uint8_t)15, /*!< TIM3 update /overflow interrupt*/ 78 | ITC_IRQ_TIM3_CAPCOM = (uint8_t)16, /*!< TIM3 update /overflow interrupt */ 79 | 80 | #if defined(STM8S208) ||defined(STM8S207) || defined (STM8S007) || defined(STM8S103) || \ 81 | defined(STM8S003) ||defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 82 | ITC_IRQ_UART1_TX = (uint8_t)17, /*!< UART1 TX interrupt */ 83 | ITC_IRQ_UART1_RX = (uint8_t)18, /*!< UART1 RX interrupt */ 84 | #endif /*STM8S208 or STM8S207 or STM8S007 or STM8S103 or STM8S003 or STM8S903 or STM8AF52Ax or STM8AF62Ax */ 85 | #if defined(STM8AF622x) 86 | ITC_IRQ_UART4_TX = (uint8_t)17, /*!< UART4 TX interrupt */ 87 | ITC_IRQ_UART4_RX = (uint8_t)18, /*!< UART4 RX interrupt */ 88 | #endif /*STM8AF622x */ 89 | 90 | ITC_IRQ_I2C = (uint8_t)19, /*!< I2C interrupt */ 91 | 92 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8AF626x) 93 | ITC_IRQ_UART2_TX = (uint8_t)20, /*!< USART2 TX interrupt */ 94 | ITC_IRQ_UART2_RX = (uint8_t)21, /*!< USART2 RX interrupt */ 95 | #endif /*STM8S105 or STM8AF626x */ 96 | 97 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8AF52Ax) || defined(STM8AF62Ax) 98 | ITC_IRQ_UART3_TX = (uint8_t)20, /*!< USART3 TX interrupt */ 99 | ITC_IRQ_UART3_RX = (uint8_t)21, /*!< USART3 RX interrupt */ 100 | ITC_IRQ_ADC2 = (uint8_t)22, /*!< ADC2 interrupt */ 101 | #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ 102 | 103 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) || defined(STM8S903) || defined(STM8AF626x) || defined(STM8AF622x) 104 | ITC_IRQ_ADC1 = (uint8_t)22, /*!< ADC2 interrupt */ 105 | #endif /*STM8S105 or STM8S005 or STM8S003 or STM8S103 or STM8S903 or STM8AF626x or STM8AF622x */ 106 | 107 | #if defined(STM8S903) || defined(STM8AF622x) 108 | ITC_IRQ_TIM6_OVFTRI = (uint8_t)23, /*!< TIM6 update/overflow/underflow/trigger/ 109 | interrupt */ 110 | #else 111 | ITC_IRQ_TIM4_OVF = (uint8_t)23, /*!< TIM4 update /overflow interrupt */ 112 | #endif /*STM8S903 or STM8AF622x */ 113 | 114 | ITC_IRQ_EEPROM_EEC = (uint8_t)24 /*!< Flash interrupt */ 115 | } ITC_Irq_TypeDef; 116 | 117 | /** 118 | * @brief ITC Priority Levels selection 119 | */ 120 | typedef enum { 121 | ITC_PRIORITYLEVEL_0 = (uint8_t)0x02, /*!< Software priority level 0 (cannot be written) */ 122 | ITC_PRIORITYLEVEL_1 = (uint8_t)0x01, /*!< Software priority level 1 */ 123 | ITC_PRIORITYLEVEL_2 = (uint8_t)0x00, /*!< Software priority level 2 */ 124 | ITC_PRIORITYLEVEL_3 = (uint8_t)0x03 /*!< Software priority level 3 */ 125 | } ITC_PriorityLevel_TypeDef; 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /* Exported constants --------------------------------------------------------*/ 132 | 133 | /** @addtogroup ITC_Exported_Constants 134 | * @{ 135 | */ 136 | #define CPU_SOFT_INT_DISABLED ((uint8_t)0x28) /*!< Mask for I1 and I0 bits in CPU_CC register */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /* Private macros ------------------------------------------------------------*/ 143 | 144 | /** 145 | * @brief Macros used by the assert function in order to check the different functions parameters. 146 | * @addtogroup ITC_Private_Macros 147 | * @{ 148 | */ 149 | 150 | /* Used by assert function */ 151 | #define IS_ITC_IRQ_OK(IRQ) ((IRQ) <= (uint8_t)24) 152 | 153 | /* Used by assert function */ 154 | #define IS_ITC_PRIORITY_OK(PriorityValue) \ 155 | (((PriorityValue) == ITC_PRIORITYLEVEL_0) || \ 156 | ((PriorityValue) == ITC_PRIORITYLEVEL_1) || \ 157 | ((PriorityValue) == ITC_PRIORITYLEVEL_2) || \ 158 | ((PriorityValue) == ITC_PRIORITYLEVEL_3)) 159 | 160 | /* Used by assert function */ 161 | #define IS_ITC_INTERRUPTS_DISABLED (ITC_GetSoftIntStatus() == CPU_SOFT_INT_DISABLED) 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /* Exported functions ------------------------------------------------------- */ 168 | 169 | /** @addtogroup ITC_Exported_Functions 170 | * @{ 171 | */ 172 | 173 | uint8_t ITC_GetCPUCC(void); 174 | void ITC_DeInit(void); 175 | uint8_t ITC_GetSoftIntStatus(void); 176 | void ITC_SetSoftwarePriority(ITC_Irq_TypeDef IrqNum, ITC_PriorityLevel_TypeDef PriorityValue); 177 | ITC_PriorityLevel_TypeDef ITC_GetSoftwarePriority(ITC_Irq_TypeDef IrqNum); 178 | 179 | /** 180 | * @} 181 | */ 182 | 183 | #endif /* __STM8S_ITC_H */ 184 | 185 | 186 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 187 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_iwdg.h 4 | * @author MCD Application Team 5 | * @version V2.2.0 6 | * @date 30-September-2014 7 | * @brief This file contains all functions prototypes and macros 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __STM8S_IWDG_H 30 | #define __STM8S_IWDG_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /** @addtogroup STM8S_StdPeriph_Driver 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup IWDG_Private_Define 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @brief Define used to prevent watchdog reset 45 | */ 46 | #define IWDG_KEY_REFRESH ((uint8_t)0xAA) /*!< This value written in the Key register prevent the watchdog reset */ 47 | 48 | /** 49 | * @brief Define used to start the watchdog counter down 50 | */ 51 | #define IWDG_KEY_ENABLE ((uint8_t)0xCC) /*!< This value written in the Key register start the watchdog counting down*/ 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /** @addtogroup IWDG_Private_Macros 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @brief Macro used by the assert function in order to check the different 63 | * values of the prescaler. 64 | */ 65 | #define IS_IWDG_PRESCALER_OK(VALUE) (((VALUE) == IWDG_Prescaler_4 ) || \ 66 | ((VALUE) == IWDG_Prescaler_8 ) || \ 67 | ((VALUE) == IWDG_Prescaler_16 ) || \ 68 | ((VALUE) == IWDG_Prescaler_32 ) || \ 69 | ((VALUE) == IWDG_Prescaler_64 ) || \ 70 | ((VALUE) == IWDG_Prescaler_128 ) || \ 71 | ((VALUE) == IWDG_Prescaler_256)) 72 | 73 | /** 74 | * @brief Macro used by the assert function in order to check the different 75 | * values of the counter register. 76 | */ 77 | #define IS_IWDG_WRITEACCESS_MODE_OK(MODE) (((MODE) == IWDG_WriteAccess_Enable) || ((MODE) == IWDG_WriteAccess_Disable)) 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup IWDG_Exported_Types 84 | * @{ 85 | */ 86 | 87 | /** IWDG write access enumeration */ 88 | typedef enum 89 | { 90 | IWDG_WriteAccess_Enable = (uint8_t)0x55, /*!< Code 0x55 in Key register, allow write access to Prescaler and Reload registers */ 91 | IWDG_WriteAccess_Disable = (uint8_t)0x00 /*!< Code 0x00 in Key register, not allow write access to Prescaler and Reload registers */ 92 | } IWDG_WriteAccess_TypeDef; 93 | 94 | /** IWDG prescaler enumaration */ 95 | typedef enum 96 | { 97 | IWDG_Prescaler_4 = (uint8_t)0x00, /*!< Used to set prescaler register to 4 */ 98 | IWDG_Prescaler_8 = (uint8_t)0x01, /*!< Used to set prescaler register to 8 */ 99 | IWDG_Prescaler_16 = (uint8_t)0x02, /*!< Used to set prescaler register to 16 */ 100 | IWDG_Prescaler_32 = (uint8_t)0x03, /*!< Used to set prescaler register to 32 */ 101 | IWDG_Prescaler_64 = (uint8_t)0x04, /*!< Used to set prescaler register to 64 */ 102 | IWDG_Prescaler_128 = (uint8_t)0x05, /*!< Used to set prescaler register to 128 */ 103 | IWDG_Prescaler_256 = (uint8_t)0x06 /*!< Used to set prescaler register to 256 */ 104 | } IWDG_Prescaler_TypeDef; 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @addtogroup IWDG_Exported_Functions 111 | * @{ 112 | */ 113 | 114 | void IWDG_WriteAccessCmd(IWDG_WriteAccess_TypeDef IWDG_WriteAccess); 115 | void IWDG_SetPrescaler(IWDG_Prescaler_TypeDef IWDG_Prescaler); 116 | void IWDG_SetReload(uint8_t IWDG_Reload); 117 | void IWDG_ReloadCounter(void); 118 | void IWDG_Enable(void); 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | #endif /* __STM8S_IWDG_H */ 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | 131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 132 | -------------------------------------------------------------------------------- /STM8_helloworld/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 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_spi.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_spi.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 SPI 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_SPI_H 30 | #define __STM8S_SPI_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /** @addtogroup STM8S_StdPeriph_Driver 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup SPI_Exported_Types 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @brief SPI data direction mode 45 | * Warning: element values correspond to BDM, BDOE, RXONLY bits position 46 | */ 47 | typedef enum { 48 | SPI_DATADIRECTION_2LINES_FULLDUPLEX = (uint8_t)0x00, /*!< 2-line uni-directional data mode enable */ 49 | SPI_DATADIRECTION_2LINES_RXONLY = (uint8_t)0x04, /*!< Receiver only in 2 line uni-directional data mode */ 50 | SPI_DATADIRECTION_1LINE_RX = (uint8_t)0x80, /*!< Receiver only in 1 line bi-directional data mode */ 51 | SPI_DATADIRECTION_1LINE_TX = (uint8_t)0xC0 /*!< Transmit only in 1 line bi-directional data mode */ 52 | } SPI_DataDirection_TypeDef; 53 | 54 | /** 55 | * @brief SPI Slave Select management 56 | * Warning: element values correspond to LSBFIRST bit position 57 | */ 58 | typedef enum 59 | { 60 | SPI_NSS_SOFT = (uint8_t)0x02, /*!< Software slave management disabled */ 61 | SPI_NSS_HARD = (uint8_t)0x00 /*!< Software slave management enabled */ 62 | } SPI_NSS_TypeDef; 63 | 64 | 65 | /** 66 | * @brief SPI direction transmit/receive 67 | */ 68 | 69 | typedef enum { 70 | SPI_DIRECTION_RX = (uint8_t)0x00, /*!< Selects Rx receive direction in bi-directional mode */ 71 | SPI_DIRECTION_TX = (uint8_t)0x01 /*!< Selects Tx transmission direction in bi-directional mode */ 72 | } SPI_Direction_TypeDef; 73 | 74 | /** 75 | * @brief SPI master/slave mode 76 | * Warning: element values correspond to MSTR bit position 77 | */ 78 | typedef enum { 79 | SPI_MODE_MASTER = (uint8_t)0x04, /*!< SPI Master configuration */ 80 | SPI_MODE_SLAVE = (uint8_t)0x00 /*!< SPI Slave configuration */ 81 | } SPI_Mode_TypeDef; 82 | 83 | /** 84 | * @brief SPI BaudRate Prescaler 85 | * Warning: element values correspond to BR bits position 86 | */ 87 | typedef enum { 88 | SPI_BAUDRATEPRESCALER_2 = (uint8_t)0x00, /*!< SPI frequency = frequency(CPU)/2 */ 89 | SPI_BAUDRATEPRESCALER_4 = (uint8_t)0x08, /*!< SPI frequency = frequency(CPU)/4 */ 90 | SPI_BAUDRATEPRESCALER_8 = (uint8_t)0x10, /*!< SPI frequency = frequency(CPU)/8 */ 91 | SPI_BAUDRATEPRESCALER_16 = (uint8_t)0x18, /*!< SPI frequency = frequency(CPU)/16 */ 92 | SPI_BAUDRATEPRESCALER_32 = (uint8_t)0x20, /*!< SPI frequency = frequency(CPU)/32 */ 93 | SPI_BAUDRATEPRESCALER_64 = (uint8_t)0x28, /*!< SPI frequency = frequency(CPU)/64 */ 94 | SPI_BAUDRATEPRESCALER_128 = (uint8_t)0x30, /*!< SPI frequency = frequency(CPU)/128 */ 95 | SPI_BAUDRATEPRESCALER_256 = (uint8_t)0x38 /*!< SPI frequency = frequency(CPU)/256 */ 96 | } SPI_BaudRatePrescaler_TypeDef; 97 | 98 | /** 99 | * @brief SPI Clock Polarity 100 | * Warning: element values correspond to CPOL bit position 101 | */ 102 | typedef enum { 103 | SPI_CLOCKPOLARITY_LOW = (uint8_t)0x00, /*!< Clock to 0 when idle */ 104 | SPI_CLOCKPOLARITY_HIGH = (uint8_t)0x02 /*!< Clock to 1 when idle */ 105 | } SPI_ClockPolarity_TypeDef; 106 | 107 | /** 108 | * @brief SPI Clock Phase 109 | * Warning: element values correspond to CPHA bit position 110 | */ 111 | typedef enum { 112 | SPI_CLOCKPHASE_1EDGE = (uint8_t)0x00, /*!< The first clock transition is the first data capture edge */ 113 | SPI_CLOCKPHASE_2EDGE = (uint8_t)0x01 /*!< The second clock transition is the first data capture edge */ 114 | } SPI_ClockPhase_TypeDef; 115 | 116 | /** 117 | * @brief SPI Frame Format: MSB or LSB transmitted first 118 | * Warning: element values correspond to LSBFIRST bit position 119 | */ 120 | typedef enum { 121 | SPI_FIRSTBIT_MSB = (uint8_t)0x00, /*!< MSB bit will be transmitted first */ 122 | SPI_FIRSTBIT_LSB = (uint8_t)0x80 /*!< LSB bit will be transmitted first */ 123 | } SPI_FirstBit_TypeDef; 124 | 125 | /** 126 | * @brief SPI CRC Transmit/Receive 127 | */ 128 | typedef enum { 129 | SPI_CRC_RX = (uint8_t)0x00, /*!< Select Tx CRC register */ 130 | SPI_CRC_TX = (uint8_t)0x01 /*!< Select Rx CRC register */ 131 | } SPI_CRC_TypeDef; 132 | 133 | /** 134 | * @brief SPI flags definition - Warning : FLAG value = mapping position register 135 | */ 136 | typedef enum { 137 | SPI_FLAG_BSY = (uint8_t)0x80, /*!< Busy flag */ 138 | SPI_FLAG_OVR = (uint8_t)0x40, /*!< Overrun flag */ 139 | SPI_FLAG_MODF = (uint8_t)0x20, /*!< Mode fault */ 140 | SPI_FLAG_CRCERR = (uint8_t)0x10, /*!< CRC error flag */ 141 | SPI_FLAG_WKUP = (uint8_t)0x08, /*!< Wake-up flag */ 142 | SPI_FLAG_TXE = (uint8_t)0x02, /*!< Transmit buffer empty */ 143 | SPI_FLAG_RXNE = (uint8_t)0x01 /*!< Receive buffer empty */ 144 | } SPI_Flag_TypeDef; 145 | 146 | /** 147 | * @brief SPI_IT possible values 148 | * Elements values convention: 0xYX 149 | * X: Position of the corresponding Interrupt 150 | * Y: ITPENDINGBIT position 151 | */ 152 | typedef enum 153 | { 154 | SPI_IT_WKUP = (uint8_t)0x34, /*!< Wake-up interrupt*/ 155 | SPI_IT_OVR = (uint8_t)0x65, /*!< Overrun interrupt*/ 156 | SPI_IT_MODF = (uint8_t)0x55, /*!< Mode fault interrupt*/ 157 | SPI_IT_CRCERR = (uint8_t)0x45, /*!< CRC error interrupt*/ 158 | SPI_IT_TXE = (uint8_t)0x17, /*!< Transmit buffer empty interrupt*/ 159 | SPI_IT_RXNE = (uint8_t)0x06, /*!< Receive buffer not empty interrupt*/ 160 | SPI_IT_ERR = (uint8_t)0x05 /*!< Error interrupt*/ 161 | } SPI_IT_TypeDef; 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /* Private define ------------------------------------------------------------*/ 168 | 169 | /** @addtogroup SPI_Private_Macros 170 | * @brief Macros used by the assert_param function to check the different functions parameters. 171 | * @{ 172 | */ 173 | 174 | /** 175 | * @brief Macro used by the assert_param function in order to check the data direction mode values 176 | */ 177 | #define IS_SPI_DATA_DIRECTION_OK(MODE) (((MODE) == SPI_DATADIRECTION_2LINES_FULLDUPLEX) || \ 178 | ((MODE) == SPI_DATADIRECTION_2LINES_RXONLY) || \ 179 | ((MODE) == SPI_DATADIRECTION_1LINE_RX) || \ 180 | ((MODE) == SPI_DATADIRECTION_1LINE_TX)) 181 | 182 | /** 183 | * @brief Macro used by the assert_param function in order to check the mode 184 | * half duplex data direction values 185 | */ 186 | #define IS_SPI_DIRECTION_OK(DIRECTION) (((DIRECTION) == SPI_DIRECTION_RX) || \ 187 | ((DIRECTION) == SPI_DIRECTION_TX)) 188 | 189 | /** 190 | * @brief Macro used by the assert_param function in order to check the NSS 191 | * management values 192 | */ 193 | #define IS_SPI_SLAVEMANAGEMENT_OK(NSS) (((NSS) == SPI_NSS_SOFT) || \ 194 | ((NSS) == SPI_NSS_HARD)) 195 | 196 | 197 | /** 198 | * @brief Macro used by the assert_param function in order to check the different 199 | * sensitivity values for the CRC polynomial 200 | */ 201 | #define IS_SPI_CRC_POLYNOMIAL_OK(POLYNOMIAL) ((POLYNOMIAL) > (uint8_t)0x00) 202 | 203 | /** 204 | * @brief Macro used by the assert_param function in order to check the SPI Mode values 205 | */ 206 | #define IS_SPI_MODE_OK(MODE) (((MODE) == SPI_MODE_MASTER) || \ 207 | ((MODE) == SPI_MODE_SLAVE)) 208 | 209 | /** 210 | * @brief Macro used by the assert_param function in order to check the baudrate values 211 | */ 212 | #define IS_SPI_BAUDRATE_PRESCALER_OK(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \ 213 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \ 214 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \ 215 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \ 216 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \ 217 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \ 218 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \ 219 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_256)) 220 | 221 | /** 222 | * @brief Macro used by the assert_param function in order to check the polarity values 223 | */ 224 | #define IS_SPI_POLARITY_OK(CLKPOL) (((CLKPOL) == SPI_CLOCKPOLARITY_LOW) || \ 225 | ((CLKPOL) == SPI_CLOCKPOLARITY_HIGH)) 226 | 227 | /** 228 | * @brief Macro used by the assert_param function in order to check the phase values 229 | */ 230 | #define IS_SPI_PHASE_OK(CLKPHA) (((CLKPHA) == SPI_CLOCKPHASE_1EDGE) || \ 231 | ((CLKPHA) == SPI_CLOCKPHASE_2EDGE)) 232 | 233 | /** 234 | * @brief Macro used by the assert_param function in order to check the first 235 | * bit to be transmited values 236 | */ 237 | #define IS_SPI_FIRSTBIT_OK(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \ 238 | ((BIT) == SPI_FIRSTBIT_LSB)) 239 | 240 | /** 241 | * @brief Macro used by the assert_param function in order to check the CRC 242 | * Transmit/Receive 243 | */ 244 | #define IS_SPI_CRC_OK(CRC) (((CRC) == SPI_CRC_TX) || \ 245 | ((CRC) == SPI_CRC_RX)) 246 | 247 | /** 248 | * @brief Macro used by the assert_param function in order to check the 249 | * different flags values 250 | */ 251 | #define IS_SPI_FLAGS_OK(FLAG) (((FLAG) == SPI_FLAG_OVR) || \ 252 | ((FLAG) == SPI_FLAG_MODF) || \ 253 | ((FLAG) == SPI_FLAG_CRCERR) || \ 254 | ((FLAG) == SPI_FLAG_WKUP) || \ 255 | ((FLAG) == SPI_FLAG_TXE) || \ 256 | ((FLAG) == SPI_FLAG_RXNE) || \ 257 | ((FLAG) == SPI_FLAG_BSY)) 258 | 259 | /** 260 | * @brief Macro used by the assert_param function in order to check the 261 | * different sensitivity values for the flag that can be cleared 262 | * by writing 0 263 | */ 264 | #define IS_SPI_CLEAR_FLAGS_OK(FLAG) (((FLAG) == SPI_FLAG_CRCERR) || \ 265 | ((FLAG) == SPI_FLAG_WKUP)) 266 | 267 | /** 268 | * @brief Macro used by the assert_param function in order to check the 269 | * different sensitivity values for the Interrupts 270 | */ 271 | #define IS_SPI_CONFIG_IT_OK(Interrupt) (((Interrupt) == SPI_IT_TXE) || \ 272 | ((Interrupt) == SPI_IT_RXNE) || \ 273 | ((Interrupt) == SPI_IT_ERR) || \ 274 | ((Interrupt) == SPI_IT_WKUP)) 275 | 276 | /** 277 | * @brief Macro used by the assert_param function in order to check the 278 | * different sensitivity values for the pending bit 279 | */ 280 | #define IS_SPI_GET_IT_OK(ITPendingBit) (((ITPendingBit) == SPI_IT_OVR) || \ 281 | ((ITPendingBit) == SPI_IT_MODF) || \ 282 | ((ITPendingBit) == SPI_IT_CRCERR) || \ 283 | ((ITPendingBit) == SPI_IT_WKUP) || \ 284 | ((ITPendingBit) == SPI_IT_TXE) || \ 285 | ((ITPendingBit) == SPI_IT_RXNE)) 286 | 287 | /** 288 | * @brief Macro used by the assert_param function in order to check the 289 | * different sensitivity values for the pending bit that can be cleared 290 | * by writing 0 291 | */ 292 | #define IS_SPI_CLEAR_IT_OK(ITPendingBit) (((ITPendingBit) == SPI_IT_CRCERR) || \ 293 | ((ITPendingBit) == SPI_IT_WKUP)) 294 | 295 | /** 296 | * @} 297 | */ 298 | 299 | /** @addtogroup SPI_Exported_Functions 300 | * @{ 301 | */ 302 | void SPI_DeInit(void); 303 | void SPI_Init(SPI_FirstBit_TypeDef FirstBit, 304 | SPI_BaudRatePrescaler_TypeDef BaudRatePrescaler, 305 | SPI_Mode_TypeDef Mode, SPI_ClockPolarity_TypeDef ClockPolarity, 306 | SPI_ClockPhase_TypeDef ClockPhase, 307 | SPI_DataDirection_TypeDef Data_Direction, 308 | SPI_NSS_TypeDef Slave_Management, uint8_t CRCPolynomial); 309 | void SPI_Cmd(FunctionalState NewState); 310 | void SPI_ITConfig(SPI_IT_TypeDef SPI_IT, FunctionalState NewState); 311 | void SPI_SendData(uint8_t Data); 312 | uint8_t SPI_ReceiveData(void); 313 | void SPI_NSSInternalSoftwareCmd(FunctionalState NewState); 314 | void SPI_TransmitCRC(void); 315 | void SPI_CalculateCRCCmd(FunctionalState NewState); 316 | uint8_t SPI_GetCRC(SPI_CRC_TypeDef SPI_CRC); 317 | void SPI_ResetCRC(void); 318 | uint8_t SPI_GetCRCPolynomial(void); 319 | void SPI_BiDirectionalLineConfig(SPI_Direction_TypeDef SPI_Direction); 320 | FlagStatus SPI_GetFlagStatus(SPI_Flag_TypeDef SPI_FLAG); 321 | void SPI_ClearFlag(SPI_Flag_TypeDef SPI_FLAG); 322 | ITStatus SPI_GetITStatus(SPI_IT_TypeDef SPI_IT); 323 | void SPI_ClearITPendingBit(SPI_IT_TypeDef SPI_IT); 324 | 325 | /** 326 | * @} 327 | */ 328 | 329 | #endif /* __STM8S_SPI_H */ 330 | 331 | /** 332 | * @} 333 | */ 334 | 335 | 336 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 337 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_tim3.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_tim3.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 TIM3 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_TIM3_H 30 | #define __STM8S_TIM3_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /** @addtogroup STM8S_StdPeriph_Driver 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | 41 | /** @addtogroup TIM3_Exported_Types 42 | * @{ 43 | */ 44 | 45 | /** TIM3 Forced Action */ 46 | typedef enum 47 | { 48 | TIM3_FORCEDACTION_ACTIVE = ((uint8_t)0x50), 49 | TIM3_FORCEDACTION_INACTIVE = ((uint8_t)0x40) 50 | } TIM3_ForcedAction_TypeDef; 51 | 52 | #define IS_TIM3_FORCED_ACTION_OK(ACTION) (((ACTION) == TIM3_FORCEDACTION_ACTIVE) || \ 53 | ((ACTION) == TIM3_FORCEDACTION_INACTIVE)) 54 | 55 | /** TIM3 Prescaler */ 56 | typedef enum 57 | { 58 | TIM3_PRESCALER_1 = ((uint8_t)0x00), 59 | TIM3_PRESCALER_2 = ((uint8_t)0x01), 60 | TIM3_PRESCALER_4 = ((uint8_t)0x02), 61 | TIM3_PRESCALER_8 = ((uint8_t)0x03), 62 | TIM3_PRESCALER_16 = ((uint8_t)0x04), 63 | TIM3_PRESCALER_32 = ((uint8_t)0x05), 64 | TIM3_PRESCALER_64 = ((uint8_t)0x06), 65 | TIM3_PRESCALER_128 = ((uint8_t)0x07), 66 | TIM3_PRESCALER_256 = ((uint8_t)0x08), 67 | TIM3_PRESCALER_512 = ((uint8_t)0x09), 68 | TIM3_PRESCALER_1024 = ((uint8_t)0x0A), 69 | TIM3_PRESCALER_2048 = ((uint8_t)0x0B), 70 | TIM3_PRESCALER_4096 = ((uint8_t)0x0C), 71 | TIM3_PRESCALER_8192 = ((uint8_t)0x0D), 72 | TIM3_PRESCALER_16384 = ((uint8_t)0x0E), 73 | TIM3_PRESCALER_32768 = ((uint8_t)0x0F) 74 | } TIM3_Prescaler_TypeDef; 75 | 76 | #define IS_TIM3_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM3_PRESCALER_1 ) || \ 77 | ((PRESCALER) == TIM3_PRESCALER_2 ) || \ 78 | ((PRESCALER) == TIM3_PRESCALER_4 ) || \ 79 | ((PRESCALER) == TIM3_PRESCALER_8 ) || \ 80 | ((PRESCALER) == TIM3_PRESCALER_16 ) || \ 81 | ((PRESCALER) == TIM3_PRESCALER_32 ) || \ 82 | ((PRESCALER) == TIM3_PRESCALER_64 ) || \ 83 | ((PRESCALER) == TIM3_PRESCALER_128 ) || \ 84 | ((PRESCALER) == TIM3_PRESCALER_256 ) || \ 85 | ((PRESCALER) == TIM3_PRESCALER_512 ) || \ 86 | ((PRESCALER) == TIM3_PRESCALER_1024 ) || \ 87 | ((PRESCALER) == TIM3_PRESCALER_2048 ) || \ 88 | ((PRESCALER) == TIM3_PRESCALER_4096 ) || \ 89 | ((PRESCALER) == TIM3_PRESCALER_8192 ) || \ 90 | ((PRESCALER) == TIM3_PRESCALER_16384 ) || \ 91 | ((PRESCALER) == TIM3_PRESCALER_32768 )) 92 | 93 | /** TIM3 Output Compare and PWM modes */ 94 | typedef enum 95 | { 96 | TIM3_OCMODE_TIMING = ((uint8_t)0x00), 97 | TIM3_OCMODE_ACTIVE = ((uint8_t)0x10), 98 | TIM3_OCMODE_INACTIVE = ((uint8_t)0x20), 99 | TIM3_OCMODE_TOGGLE = ((uint8_t)0x30), 100 | TIM3_OCMODE_PWM1 = ((uint8_t)0x60), 101 | TIM3_OCMODE_PWM2 = ((uint8_t)0x70) 102 | } TIM3_OCMode_TypeDef; 103 | 104 | #define IS_TIM3_OC_MODE_OK(MODE) (((MODE) == TIM3_OCMODE_TIMING) || \ 105 | ((MODE) == TIM3_OCMODE_ACTIVE) || \ 106 | ((MODE) == TIM3_OCMODE_INACTIVE) || \ 107 | ((MODE) == TIM3_OCMODE_TOGGLE)|| \ 108 | ((MODE) == TIM3_OCMODE_PWM1) || \ 109 | ((MODE) == TIM3_OCMODE_PWM2)) 110 | 111 | #define IS_TIM3_OCM_OK(MODE)(((MODE) == TIM3_OCMODE_TIMING) || \ 112 | ((MODE) == TIM3_OCMODE_ACTIVE) || \ 113 | ((MODE) == TIM3_OCMODE_INACTIVE) || \ 114 | ((MODE) == TIM3_OCMODE_TOGGLE)|| \ 115 | ((MODE) == TIM3_OCMODE_PWM1) || \ 116 | ((MODE) == TIM3_OCMODE_PWM2) || \ 117 | ((MODE) == (uint8_t)TIM3_FORCEDACTION_ACTIVE) || \ 118 | ((MODE) == (uint8_t)TIM3_FORCEDACTION_INACTIVE)) 119 | 120 | /** TIM3 One Pulse Mode */ 121 | typedef enum 122 | { 123 | TIM3_OPMODE_SINGLE = ((uint8_t)0x01), 124 | TIM3_OPMODE_REPETITIVE = ((uint8_t)0x00) 125 | } TIM3_OPMode_TypeDef; 126 | 127 | #define IS_TIM3_OPM_MODE_OK(MODE) (((MODE) == TIM3_OPMODE_SINGLE) || \ 128 | ((MODE) == TIM3_OPMODE_REPETITIVE)) 129 | 130 | /** TIM3 Channel */ 131 | 132 | typedef enum 133 | { 134 | TIM3_CHANNEL_1 = ((uint8_t)0x00), 135 | TIM3_CHANNEL_2 = ((uint8_t)0x01) 136 | } TIM3_Channel_TypeDef; 137 | 138 | #define IS_TIM3_CHANNEL_OK(CHANNEL) (((CHANNEL) == TIM3_CHANNEL_1) || \ 139 | ((CHANNEL) == TIM3_CHANNEL_2)) 140 | 141 | #define IS_TIM3_PWMI_CHANNEL_OK(CHANNEL) (((CHANNEL) == TIM3_CHANNEL_1) || \ 142 | ((CHANNEL) == TIM3_CHANNEL_2)) 143 | 144 | /** TIM3 Output Compare Polarity */ 145 | typedef enum 146 | { 147 | TIM3_OCPOLARITY_HIGH = ((uint8_t)0x00), 148 | TIM3_OCPOLARITY_LOW = ((uint8_t)0x22) 149 | } TIM3_OCPolarity_TypeDef; 150 | 151 | #define IS_TIM3_OC_POLARITY_OK(POLARITY) (((POLARITY) == TIM3_OCPOLARITY_HIGH) || \ 152 | ((POLARITY) == TIM3_OCPOLARITY_LOW)) 153 | 154 | /** TIM3 Output Compare states */ 155 | typedef enum 156 | { 157 | TIM3_OUTPUTSTATE_DISABLE = ((uint8_t)0x00), 158 | TIM3_OUTPUTSTATE_ENABLE = ((uint8_t)0x11) 159 | } TIM3_OutputState_TypeDef; 160 | 161 | #define IS_TIM3_OUTPUT_STATE_OK(STATE) (((STATE) == TIM3_OUTPUTSTATE_DISABLE) || \ 162 | ((STATE) == TIM3_OUTPUTSTATE_ENABLE)) 163 | 164 | /** TIM3 Input Capture Polarity */ 165 | typedef enum 166 | { 167 | TIM3_ICPOLARITY_RISING = ((uint8_t)0x00), 168 | TIM3_ICPOLARITY_FALLING = ((uint8_t)0x44) 169 | } TIM3_ICPolarity_TypeDef; 170 | 171 | #define IS_TIM3_IC_POLARITY_OK(POLARITY) (((POLARITY) == TIM3_ICPOLARITY_RISING) || \ 172 | ((POLARITY) == TIM3_ICPOLARITY_FALLING)) 173 | 174 | /** TIM3 Input Capture Selection */ 175 | typedef enum 176 | { 177 | TIM3_ICSELECTION_DIRECTTI = ((uint8_t)0x01), 178 | TIM3_ICSELECTION_INDIRECTTI = ((uint8_t)0x02), 179 | TIM3_ICSELECTION_TRGI = ((uint8_t)0x03) 180 | } TIM3_ICSelection_TypeDef; 181 | 182 | #define IS_TIM3_IC_SELECTION_OK(SELECTION) (((SELECTION) == TIM3_ICSELECTION_DIRECTTI) || \ 183 | ((SELECTION) == TIM3_ICSELECTION_INDIRECTTI) || \ 184 | ((SELECTION) == TIM3_ICSELECTION_TRGI)) 185 | 186 | /** TIM3 Input Capture Prescaler */ 187 | typedef enum 188 | { 189 | TIM3_ICPSC_DIV1 = ((uint8_t)0x00), 190 | TIM3_ICPSC_DIV2 = ((uint8_t)0x04), 191 | TIM3_ICPSC_DIV4 = ((uint8_t)0x08), 192 | TIM3_ICPSC_DIV8 = ((uint8_t)0x0C) 193 | } TIM3_ICPSC_TypeDef; 194 | 195 | #define IS_TIM3_IC_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM3_ICPSC_DIV1) || \ 196 | ((PRESCALER) == TIM3_ICPSC_DIV2) || \ 197 | ((PRESCALER) == TIM3_ICPSC_DIV4) || \ 198 | ((PRESCALER) == TIM3_ICPSC_DIV8)) 199 | 200 | /** TIM3 Input Capture Filer Value */ 201 | #define IS_TIM3_IC_FILTER_OK(ICFILTER) ((ICFILTER) <= 0x0F) 202 | 203 | /** TIM3 interrupt sources */ 204 | typedef enum 205 | { 206 | TIM3_IT_UPDATE = ((uint8_t)0x01), 207 | TIM3_IT_CC1 = ((uint8_t)0x02), 208 | TIM3_IT_CC2 = ((uint8_t)0x04) 209 | } TIM3_IT_TypeDef; 210 | 211 | #define IS_TIM3_IT_OK(IT) (((IT) != 0x00) && ((IT) <= 0x07)) 212 | 213 | #define IS_TIM3_GET_IT_OK(IT) (((IT) == TIM3_IT_UPDATE) || \ 214 | ((IT) == TIM3_IT_CC1) || \ 215 | ((IT) == TIM3_IT_CC2)) 216 | 217 | /** TIM3 Prescaler Reload Mode */ 218 | typedef enum 219 | { 220 | TIM3_PSCRELOADMODE_UPDATE = ((uint8_t)0x00), 221 | TIM3_PSCRELOADMODE_IMMEDIATE = ((uint8_t)0x01) 222 | } TIM3_PSCReloadMode_TypeDef; 223 | 224 | #define IS_TIM3_PRESCALER_RELOAD_OK(RELOAD) (((RELOAD) == TIM3_PSCRELOADMODE_UPDATE) || \ 225 | ((RELOAD) == TIM3_PSCRELOADMODE_IMMEDIATE)) 226 | 227 | /** TIM3 Event Source */ 228 | typedef enum 229 | { 230 | TIM3_EVENTSOURCE_UPDATE = ((uint8_t)0x01), 231 | TIM3_EVENTSOURCE_CC1 = ((uint8_t)0x02), 232 | TIM3_EVENTSOURCE_CC2 = ((uint8_t)0x04) 233 | } TIM3_EventSource_TypeDef; 234 | 235 | #define IS_TIM3_EVENT_SOURCE_OK(SOURCE) (((SOURCE) != 0x00)) 236 | 237 | /** TIM3 Update Source */ 238 | typedef enum 239 | { 240 | TIM3_UPDATESOURCE_GLOBAL = ((uint8_t)0x00), 241 | TIM3_UPDATESOURCE_REGULAR = ((uint8_t)0x01) 242 | } TIM3_UpdateSource_TypeDef; 243 | 244 | #define IS_TIM3_UPDATE_SOURCE_OK(SOURCE) (((SOURCE) == TIM3_UPDATESOURCE_GLOBAL) || \ 245 | ((SOURCE) == TIM3_UPDATESOURCE_REGULAR)) 246 | 247 | /** TIM3 Flags */ 248 | typedef enum 249 | { 250 | TIM3_FLAG_UPDATE = ((uint16_t)0x0001), 251 | TIM3_FLAG_CC1 = ((uint16_t)0x0002), 252 | TIM3_FLAG_CC2 = ((uint16_t)0x0004), 253 | TIM3_FLAG_CC1OF = ((uint16_t)0x0200), 254 | TIM3_FLAG_CC2OF = ((uint16_t)0x0400) 255 | } TIM3_FLAG_TypeDef; 256 | 257 | #define IS_TIM3_GET_FLAG_OK(FLAG) (((FLAG) == TIM3_FLAG_UPDATE) || \ 258 | ((FLAG) == TIM3_FLAG_CC1) || \ 259 | ((FLAG) == TIM3_FLAG_CC2) || \ 260 | ((FLAG) == TIM3_FLAG_CC1OF) || \ 261 | ((FLAG) == TIM3_FLAG_CC2OF) ) 262 | 263 | #define IS_TIM3_CLEAR_FLAG_OK(FLAG) ((((uint16_t)(FLAG) & 0xF9F8) == 0x0000) && ((uint16_t)(FLAG)!= 0x0000)) 264 | 265 | /** 266 | * @} 267 | */ 268 | 269 | /* Exported macro ------------------------------------------------------------*/ 270 | 271 | /* Exported functions --------------------------------------------------------*/ 272 | 273 | /** @addtogroup TIM3_Exported_Functions 274 | * @{ 275 | */ 276 | 277 | void TIM3_DeInit(void); 278 | void TIM3_TimeBaseInit(TIM3_Prescaler_TypeDef TIM3_Prescaler, uint16_t TIM3_Period); 279 | void TIM3_OC1Init(TIM3_OCMode_TypeDef TIM3_OCMode, TIM3_OutputState_TypeDef TIM3_OutputState, uint16_t TIM3_Pulse, TIM3_OCPolarity_TypeDef TIM3_OCPolarity); 280 | void TIM3_OC2Init(TIM3_OCMode_TypeDef TIM3_OCMode, TIM3_OutputState_TypeDef TIM3_OutputState, uint16_t TIM3_Pulse, TIM3_OCPolarity_TypeDef TIM3_OCPolarity); 281 | void TIM3_ICInit(TIM3_Channel_TypeDef TIM3_Channel, TIM3_ICPolarity_TypeDef TIM3_ICPolarity, TIM3_ICSelection_TypeDef TIM3_ICSelection, TIM3_ICPSC_TypeDef TIM3_ICPrescaler, uint8_t TIM3_ICFilter); 282 | void TIM3_PWMIConfig(TIM3_Channel_TypeDef TIM3_Channel, TIM3_ICPolarity_TypeDef TIM3_ICPolarity, TIM3_ICSelection_TypeDef TIM3_ICSelection, TIM3_ICPSC_TypeDef TIM3_ICPrescaler, uint8_t TIM3_ICFilter); 283 | void TIM3_Cmd(FunctionalState NewState); 284 | void TIM3_ITConfig(TIM3_IT_TypeDef TIM3_IT, FunctionalState NewState); 285 | void TIM3_InternalClockConfig(void); 286 | void TIM3_UpdateDisableConfig(FunctionalState NewState); 287 | void TIM3_UpdateRequestConfig(TIM3_UpdateSource_TypeDef TIM3_UpdateSource); 288 | void TIM3_SelectOnePulseMode(TIM3_OPMode_TypeDef TIM3_OPMode); 289 | void TIM3_PrescalerConfig(TIM3_Prescaler_TypeDef Prescaler, TIM3_PSCReloadMode_TypeDef TIM3_PSCReloadMode); 290 | void TIM3_ForcedOC1Config(TIM3_ForcedAction_TypeDef TIM3_ForcedAction); 291 | void TIM3_ForcedOC2Config(TIM3_ForcedAction_TypeDef TIM3_ForcedAction); 292 | void TIM3_ARRPreloadConfig(FunctionalState NewState); 293 | void TIM3_CCPreloadControl(FunctionalState NewState); 294 | void TIM3_OC1PreloadConfig(FunctionalState NewState); 295 | void TIM3_OC2PreloadConfig(FunctionalState NewState); 296 | void TIM3_GenerateEvent(TIM3_EventSource_TypeDef TIM3_EventSource); 297 | void TIM3_OC1PolarityConfig(TIM3_OCPolarity_TypeDef TIM3_OCPolarity); 298 | void TIM3_OC2PolarityConfig(TIM3_OCPolarity_TypeDef TIM3_OCPolarity); 299 | void TIM3_CCxCmd(TIM3_Channel_TypeDef TIM3_Channel, FunctionalState NewState); 300 | void TIM3_SelectOCxM(TIM3_Channel_TypeDef TIM3_Channel, TIM3_OCMode_TypeDef TIM3_OCMode); 301 | void TIM3_SetCounter(uint16_t Counter); 302 | void TIM3_SetAutoreload(uint16_t Autoreload); 303 | void TIM3_SetCompare1(uint16_t Compare1); 304 | void TIM3_SetCompare2(uint16_t Compare2); 305 | void TIM3_SetIC1Prescaler(TIM3_ICPSC_TypeDef TIM3_IC1Prescaler); 306 | void TIM3_SetIC2Prescaler(TIM3_ICPSC_TypeDef TIM3_IC2Prescaler); 307 | uint16_t TIM3_GetCapture1(void); 308 | uint16_t TIM3_GetCapture2(void); 309 | uint16_t TIM3_GetCounter(void); 310 | TIM3_Prescaler_TypeDef TIM3_GetPrescaler(void); 311 | FlagStatus TIM3_GetFlagStatus(TIM3_FLAG_TypeDef TIM3_FLAG); 312 | void TIM3_ClearFlag(TIM3_FLAG_TypeDef TIM3_FLAG); 313 | ITStatus TIM3_GetITStatus(TIM3_IT_TypeDef TIM3_IT); 314 | void TIM3_ClearITPendingBit(TIM3_IT_TypeDef TIM3_IT); 315 | 316 | /** 317 | * @} 318 | */ 319 | 320 | #endif /* __STM8S_TIM3_H */ 321 | 322 | /** 323 | * @} 324 | */ 325 | 326 | 327 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 328 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_tim4.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_tim4.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 TIM4 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_TIM4_H 30 | #define __STM8S_TIM4_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /** @addtogroup STM8S_StdPeriph_Driver 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | 41 | /** @addtogroup TIM4_Exported_Types 42 | * @{ 43 | */ 44 | 45 | 46 | 47 | /** TIM4 Prescaler */ 48 | typedef enum 49 | { 50 | TIM4_PRESCALER_1 = ((uint8_t)0x00), 51 | TIM4_PRESCALER_2 = ((uint8_t)0x01), 52 | TIM4_PRESCALER_4 = ((uint8_t)0x02), 53 | TIM4_PRESCALER_8 = ((uint8_t)0x03), 54 | TIM4_PRESCALER_16 = ((uint8_t)0x04), 55 | TIM4_PRESCALER_32 = ((uint8_t)0x05), 56 | TIM4_PRESCALER_64 = ((uint8_t)0x06), 57 | TIM4_PRESCALER_128 = ((uint8_t)0x07) 58 | } TIM4_Prescaler_TypeDef; 59 | 60 | #define IS_TIM4_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM4_PRESCALER_1 ) || \ 61 | ((PRESCALER) == TIM4_PRESCALER_2 ) || \ 62 | ((PRESCALER) == TIM4_PRESCALER_4 ) || \ 63 | ((PRESCALER) == TIM4_PRESCALER_8 ) || \ 64 | ((PRESCALER) == TIM4_PRESCALER_16 ) || \ 65 | ((PRESCALER) == TIM4_PRESCALER_32 ) || \ 66 | ((PRESCALER) == TIM4_PRESCALER_64 ) || \ 67 | ((PRESCALER) == TIM4_PRESCALER_128 ) ) 68 | 69 | /** TIM4 One Pulse Mode */ 70 | typedef enum 71 | { 72 | TIM4_OPMODE_SINGLE = ((uint8_t)0x01), 73 | TIM4_OPMODE_REPETITIVE = ((uint8_t)0x00) 74 | } TIM4_OPMode_TypeDef; 75 | 76 | #define IS_TIM4_OPM_MODE_OK(MODE) (((MODE) == TIM4_OPMODE_SINGLE) || \ 77 | ((MODE) == TIM4_OPMODE_REPETITIVE)) 78 | 79 | /** TIM4 Prescaler Reload Mode */ 80 | typedef enum 81 | { 82 | TIM4_PSCRELOADMODE_UPDATE = ((uint8_t)0x00), 83 | TIM4_PSCRELOADMODE_IMMEDIATE = ((uint8_t)0x01) 84 | } TIM4_PSCReloadMode_TypeDef; 85 | 86 | #define IS_TIM4_PRESCALER_RELOAD_OK(RELOAD) (((RELOAD) == TIM4_PSCRELOADMODE_UPDATE) || \ 87 | ((RELOAD) == TIM4_PSCRELOADMODE_IMMEDIATE)) 88 | 89 | /** TIM4 Update Source */ 90 | typedef enum 91 | { 92 | TIM4_UPDATESOURCE_GLOBAL = ((uint8_t)0x00), 93 | TIM4_UPDATESOURCE_REGULAR = ((uint8_t)0x01) 94 | } TIM4_UpdateSource_TypeDef; 95 | 96 | #define IS_TIM4_UPDATE_SOURCE_OK(SOURCE) (((SOURCE) == TIM4_UPDATESOURCE_GLOBAL) || \ 97 | ((SOURCE) == TIM4_UPDATESOURCE_REGULAR)) 98 | 99 | /** TIM4 Event Source */ 100 | typedef enum 101 | { 102 | TIM4_EVENTSOURCE_UPDATE = ((uint8_t)0x01) 103 | }TIM4_EventSource_TypeDef; 104 | 105 | #define IS_TIM4_EVENT_SOURCE_OK(SOURCE) (((SOURCE) == 0x01)) 106 | 107 | /** TIM4 Flags */ 108 | typedef enum 109 | { 110 | TIM4_FLAG_UPDATE = ((uint8_t)0x01) 111 | }TIM4_FLAG_TypeDef; 112 | 113 | #define IS_TIM4_GET_FLAG_OK(FLAG) ((FLAG) == TIM4_FLAG_UPDATE) 114 | 115 | 116 | 117 | /** TIM4 interrupt sources */ 118 | typedef enum 119 | { 120 | TIM4_IT_UPDATE = ((uint8_t)0x01) 121 | }TIM4_IT_TypeDef; 122 | 123 | #define IS_TIM4_IT_OK(IT) ((IT) == TIM4_IT_UPDATE) 124 | 125 | 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /* Exported macro ------------------------------------------------------------*/ 132 | 133 | /* Exported functions --------------------------------------------------------*/ 134 | 135 | /** @addtogroup TIM4_Exported_Functions 136 | * @{ 137 | */ 138 | void TIM4_DeInit(void); 139 | void TIM4_TimeBaseInit(TIM4_Prescaler_TypeDef TIM4_Prescaler, uint8_t TIM4_Period); 140 | void TIM4_Cmd(FunctionalState NewState); 141 | void TIM4_ITConfig(TIM4_IT_TypeDef TIM4_IT, FunctionalState NewState); 142 | void TIM4_UpdateDisableConfig(FunctionalState NewState); 143 | void TIM4_UpdateRequestConfig(TIM4_UpdateSource_TypeDef TIM4_UpdateSource); 144 | void TIM4_SelectOnePulseMode(TIM4_OPMode_TypeDef TIM4_OPMode); 145 | void TIM4_PrescalerConfig(TIM4_Prescaler_TypeDef Prescaler, TIM4_PSCReloadMode_TypeDef TIM4_PSCReloadMode); 146 | void TIM4_ARRPreloadConfig(FunctionalState NewState); 147 | void TIM4_GenerateEvent(TIM4_EventSource_TypeDef TIM4_EventSource); 148 | void TIM4_SetCounter(uint8_t Counter); 149 | void TIM4_SetAutoreload(uint8_t Autoreload); 150 | uint8_t TIM4_GetCounter(void); 151 | TIM4_Prescaler_TypeDef TIM4_GetPrescaler(void); 152 | FlagStatus TIM4_GetFlagStatus(TIM4_FLAG_TypeDef TIM4_FLAG); 153 | void TIM4_ClearFlag(TIM4_FLAG_TypeDef TIM4_FLAG); 154 | ITStatus TIM4_GetITStatus(TIM4_IT_TypeDef TIM4_IT); 155 | void TIM4_ClearITPendingBit(TIM4_IT_TypeDef TIM4_IT); 156 | 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | #endif /* __STM8S_TIM4_H */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | 169 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 170 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/inc/stm8s_tim6.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_tim6.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 TIM6 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_TIM6_H 30 | #define __STM8S_TIM6_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /** @addtogroup STM8S_StdPeriph_Driver 36 | * @{ 37 | */ 38 | 39 | /* Exported variables ------------------------------------------------------- */ 40 | /* Exported types ------------------------------------------------------------*/ 41 | 42 | /** @addtogroup TIM6_Exported_Types 43 | * @{ 44 | */ 45 | 46 | 47 | /** 48 | * @brief TIM6 Prescaler 49 | */ 50 | typedef enum 51 | { 52 | TIM6_PRESCALER_1 = ((uint8_t)0x00), /*!< Time base Prescaler = 1 (No effect)*/ 53 | TIM6_PRESCALER_2 = ((uint8_t)0x01), /*!< Time base Prescaler = 2 */ 54 | TIM6_PRESCALER_4 = ((uint8_t)0x02), /*!< Time base Prescaler = 4 */ 55 | TIM6_PRESCALER_8 = ((uint8_t)0x03), /*!< Time base Prescaler = 8 */ 56 | TIM6_PRESCALER_16 = ((uint8_t)0x04), /*!< Time base Prescaler = 16 */ 57 | TIM6_PRESCALER_32 = ((uint8_t)0x05), /*!< Time base Prescaler = 32 */ 58 | TIM6_PRESCALER_64 = ((uint8_t)0x06), /*!< Time base Prescaler = 64 */ 59 | TIM6_PRESCALER_128 = ((uint8_t)0x07) /*!< Time base Prescaler = 128 */ 60 | }TIM6_Prescaler_TypeDef; 61 | 62 | /** 63 | * @brief TIM6 One Pulse Mode 64 | */ 65 | typedef enum 66 | { 67 | TIM6_OPMODE_SINGLE = ((uint8_t)0x01), /*!< Single one Pulse mode (OPM Active) */ 68 | TIM6_OPMODE_REPETITIVE = ((uint8_t)0x00) /*!< Repetitive Pulse mode (OPM inactive) */ 69 | }TIM6_OPMode_TypeDef; 70 | 71 | /** 72 | * @brief TIM6 Prescaler Reload Mode 73 | */ 74 | typedef enum 75 | { 76 | TIM6_PSCRELOADMODE_UPDATE =((uint8_t)0x00), /*!< Prescaler value is reloaded at every update*/ 77 | TIM6_PSCRELOADMODE_IMMEDIATE =((uint8_t)0x01) /*!< Prescaler value is reloaded immediately*/ 78 | }TIM6_PSCReloadMode_TypeDef; 79 | 80 | /** 81 | * @brief TIM6 Update Source 82 | */ 83 | typedef enum 84 | { 85 | TIM6_UPDATESOURCE_GLOBAL =((uint8_t)0x00), /*!< Global Update request source */ 86 | TIM6_UPDATESOURCE_REGULAR =((uint8_t)0x01) /*!< Regular Update request source */ 87 | }TIM6_UpdateSource_TypeDef; 88 | 89 | /** 90 | * @brief TIM6 Event Source 91 | */ 92 | typedef enum 93 | { 94 | TIM6_EVENTSOURCE_UPDATE = ((uint8_t)0x01), /*!< Update Event*/ 95 | TIM6_EVENTSOURCE_TRIGGER = ((uint8_t)0x40) /*!< Trigger Event*/ 96 | }TIM6_EventSource_TypeDef; 97 | 98 | /** 99 | * @brief TIM6 Trigger Output Source 100 | */ 101 | typedef enum 102 | { 103 | TIM6_TRGOSOURCE_RESET = ((uint8_t)0x00), /*!< Trigger Output source = Reset*/ 104 | TIM6_TRGOSOURCE_ENABLE = ((uint8_t)0x10), /*!< Trigger Output source = TIM5 is enabled*/ 105 | TIM6_TRGOSOURCE_UPDATE = ((uint8_t)0x20) /*!< Trigger Output source = Update event*/ 106 | }TIM6_TRGOSource_TypeDef; 107 | 108 | /** 109 | * @brief TIM6 Slave Mode 110 | */ 111 | typedef enum 112 | { 113 | TIM6_SLAVEMODE_DISABLE = ((uint8_t)0x00), /*!< Disable slave mode to clock the prescaler directly with the internal clock */ 114 | TIM6_SLAVEMODE_RESET = ((uint8_t)0x04), /*!< Slave Mode Selection = Reset*/ 115 | TIM6_SLAVEMODE_GATED = ((uint8_t)0x05), /*!< Slave Mode Selection = Gated*/ 116 | TIM6_SLAVEMODE_TRIGGER = ((uint8_t)0x06), /*!< Slave Mode Selection = Trigger*/ 117 | TIM6_SLAVEMODE_EXTERNAL1 = ((uint8_t)0x07) /*!< Slave Mode Selection = External 1*/ 118 | }TIM6_SlaveMode_TypeDef; 119 | 120 | /** 121 | * @brief TIM6 Flags 122 | */ 123 | typedef enum 124 | { 125 | TIM6_FLAG_UPDATE = ((uint8_t)0x01), /*!< Update Flag */ 126 | TIM6_FLAG_TRIGGER = ((uint8_t)0x40) /*!< Trigger Flag */ 127 | }TIM6_FLAG_TypeDef; 128 | 129 | /** 130 | * @brief TIM6 interrupt sources 131 | */ 132 | typedef enum 133 | { 134 | TIM6_IT_UPDATE = ((uint8_t)0x01), /*!< Update Interrupt*/ 135 | TIM6_IT_TRIGGER = ((uint8_t)0x40) /*!< Trigger Interrupt*/ 136 | }TIM6_IT_TypeDef; 137 | 138 | /** 139 | * @brief TIM6 Internal Trigger Selection 140 | */ 141 | typedef enum 142 | { 143 | TIM6_TS_TIM1 = ((uint8_t)0x20),/*!< TRIG Input source = TIM1 TRIG Output */ 144 | TIM6_TS_TIM5 = ((uint8_t)0x30) /*!< TRIG Input source = TIM5 TRIG Output */ 145 | }TIM6_TS_TypeDef; 146 | 147 | /** 148 | * @} 149 | */ 150 | 151 | /* Exported constants --------------------------------------------------------*/ 152 | /* Exported macros -----------------------------------------------------------*/ 153 | /* Private macros ------------------------------------------------------------*/ 154 | 155 | /** @addtogroup TIM6_Private_Macros 156 | * @{ 157 | */ 158 | 159 | /** 160 | * @brief Macro used by the assert function to check the different functions parameters. 161 | */ 162 | 163 | /** 164 | * @brief Macro TIM6 Prescaler 165 | */ 166 | #define IS_TIM6_PRESCALER_OK(PRESCALER) \ 167 | (((PRESCALER) == TIM6_PRESCALER_1) || \ 168 | ((PRESCALER) == TIM6_PRESCALER_2) || \ 169 | ((PRESCALER) == TIM6_PRESCALER_4) || \ 170 | ((PRESCALER) == TIM6_PRESCALER_8) || \ 171 | ((PRESCALER) == TIM6_PRESCALER_16) || \ 172 | ((PRESCALER) == TIM6_PRESCALER_32) || \ 173 | ((PRESCALER) == TIM6_PRESCALER_64) || \ 174 | ((PRESCALER) == TIM6_PRESCALER_128)) 175 | /** 176 | * @brief Macro TIM6 One Pulse Mode 177 | */ 178 | #define IS_TIM6_OPM_MODE_OK(MODE) \ 179 | (((MODE) == TIM6_OPMODE_SINGLE) || \ 180 | ((MODE) == TIM6_OPMODE_REPETITIVE)) 181 | 182 | /** 183 | * @brief Macro TIM6 Prescaler reload 184 | */ 185 | #define IS_TIM6_PRESCALER_RELOAD_OK(RELOAD) \ 186 | (((RELOAD) == TIM6_PSCRELOADMODE_UPDATE) || \ 187 | ((RELOAD) == TIM6_PSCRELOADMODE_IMMEDIATE)) 188 | /** 189 | * @brief Macro TIM6 Update source 190 | */ 191 | #define IS_TIM6_UPDATE_SOURCE_OK(SOURCE) \ 192 | (((SOURCE) == TIM6_UPDATESOURCE_GLOBAL) || \ 193 | ((SOURCE) == TIM6_UPDATESOURCE_REGULAR)) 194 | /** 195 | * @brief Macro TIM6 Event source 196 | */ 197 | #define IS_TIM6_EVENT_SOURCE_OK(SOURCE) \ 198 | ((((SOURCE) & (uint8_t)0xBE) == 0x00) && \ 199 | ((SOURCE) != 0x00)) 200 | 201 | /** 202 | * @brief Macro TIM6 TRGO source 203 | */ 204 | #define IS_TIM6_TRGO_SOURCE_OK(SOURCE) \ 205 | (((SOURCE) == TIM6_TRGOSOURCE_RESET) || \ 206 | ((SOURCE) == TIM6_TRGOSOURCE_ENABLE)|| \ 207 | ((SOURCE) == TIM6_TRGOSOURCE_UPDATE)) 208 | /** 209 | * @brief Macro TIM6 Slave mode 210 | */ 211 | #define IS_TIM6_SLAVE_MODE_OK(MODE) \ 212 | (((MODE) == TIM6_SLAVEMODE_DISABLE) || \ 213 | ((MODE) == TIM6_SLAVEMODE_RESET) || \ 214 | ((MODE) == TIM6_SLAVEMODE_GATED) || \ 215 | ((MODE) == TIM6_SLAVEMODE_TRIGGER) || \ 216 | ((MODE) == TIM6_SLAVEMODE_EXTERNAL1)) 217 | /** 218 | * @brief Macro TIM6 Flags 219 | */ 220 | #define IS_TIM6_GET_FLAG_OK(FLAG) \ 221 | (((FLAG) == TIM6_FLAG_UPDATE) || \ 222 | ((FLAG) == TIM6_FLAG_TRIGGER)) 223 | 224 | #define IS_TIM6_CLEAR_FLAG_OK(FLAG) \ 225 | ((((FLAG) & (uint8_t)0xBE) == 0x00) && ((FLAG) != 0x00)) 226 | /** 227 | * @brief Macro TIM6 interrupts 228 | */ 229 | #define IS_TIM6_IT_OK(IT) \ 230 | (((IT) != 0x00) && \ 231 | (((IT) & (uint8_t)(~(uint8_t)(0x41)))== 0x00)) 232 | 233 | #define IS_TIM6_GET_IT_OK(IT) \ 234 | (((IT) == TIM6_IT_UPDATE) || \ 235 | ((IT) == TIM6_IT_TRIGGER)) 236 | /** 237 | * @brief Macro TIM6 Trigger selection 238 | */ 239 | #define IS_TIM6_TRIGGER_SELECTION_OK(SELECTION) \ 240 | (((SELECTION) == TIM6_TS_TIM5) || \ 241 | ((SELECTION) == TIM6_TS_TIM1)) 242 | /** 243 | * @} 244 | */ 245 | 246 | /* Exported functions --------------------------------------------------------*/ 247 | 248 | /** @addtogroup TIM6_Exported_Functions 249 | * @{ 250 | */ 251 | 252 | void TIM6_DeInit(void); 253 | void TIM6_TimeBaseInit(TIM6_Prescaler_TypeDef TIM6_Prescaler, uint8_t TIM6_Period); 254 | void TIM6_Cmd(FunctionalState NewState); 255 | void TIM6_UpdateDisableConfig(FunctionalState NewState); 256 | void TIM6_UpdateRequestConfig(TIM6_UpdateSource_TypeDef TIM6_UpdateSource); 257 | void TIM6_SelectOnePulseMode(TIM6_OPMode_TypeDef TIM6_OPMode); 258 | void TIM6_PrescalerConfig(TIM6_Prescaler_TypeDef Prescaler, TIM6_PSCReloadMode_TypeDef TIM6_PSCReloadMode); 259 | void TIM6_ARRPreloadConfig(FunctionalState NewState); 260 | void TIM6_SetCounter(uint8_t Counter); 261 | void TIM6_SetAutoreload(uint8_t Autoreload); 262 | uint8_t TIM6_GetCounter(void); 263 | TIM6_Prescaler_TypeDef TIM6_GetPrescaler(void); 264 | void TIM6_ITConfig(TIM6_IT_TypeDef TIM6_IT, FunctionalState NewState); 265 | void TIM6_ClearFlag(TIM6_FLAG_TypeDef TIM6_FLAG); 266 | ITStatus TIM6_GetITStatus(TIM6_IT_TypeDef TIM6_IT); 267 | void TIM6_GenerateEvent(TIM6_EventSource_TypeDef TIM6_EventSource); 268 | FlagStatus TIM6_GetFlagStatus(TIM6_FLAG_TypeDef TIM6_FLAG); 269 | void TIM6_ClearITPendingBit(TIM6_IT_TypeDef TIM6_IT); 270 | void TIM6_SelectOutputTrigger(TIM6_TRGOSource_TypeDef TIM6_TRGOSource); 271 | void TIM6_SelectMasterSlaveMode(FunctionalState NewState); 272 | void TIM6_SelectInputTrigger(TIM6_TS_TypeDef TIM6_InputTriggerSource); 273 | void TIM6_InternalClockConfig(void); 274 | void TIM6_SelectSlaveMode(TIM6_SlaveMode_TypeDef TIM6_SlaveMode); 275 | 276 | /** 277 | * @} 278 | */ 279 | 280 | #endif /* __STM8S_TIM6_H */ 281 | 282 | /** 283 | * @} 284 | */ 285 | 286 | 287 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 288 | -------------------------------------------------------------------------------- /STM8_helloworld/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 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/fireworks.c: -------------------------------------------------------------------------------- 1 | #include "fireworks.h" 2 | 3 | // string copy by delimiter 4 | char *strdcpy(char *string_, char delimiter_, char position_) 5 | { 6 | unsigned char j=0, length= strlen(string_); 7 | char *str_result= malloc((length+1) * sizeof(char)); 8 | for (unsigned char i = 0; i < length; ++i){ 9 | if ((string_[i] == delimiter_ && position_ == 0) || (string_[i] == '\r') || (string_[i] == '\n') || (string_[i] == '\0')) 10 | { 11 | break; 12 | } 13 | else if (string_[i] != delimiter_ && position_ == 0) 14 | { 15 | str_result[j] = string_[i]; 16 | j++; 17 | } 18 | else if (string_[i] == delimiter_ && position_ != 0) 19 | { 20 | position_--; 21 | } 22 | } 23 | str_result[j] = '\0'; 24 | return str_result; 25 | } 26 | 27 | unsigned char strtoint (char *string_) 28 | { 29 | char length = strlen(string_); 30 | unsigned long i=1, x=0; 31 | while (length) 32 | { 33 | length--; 34 | x += ( (string_[length]-48) * i ); 35 | i *= 10; 36 | } 37 | return x; 38 | } 39 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_awu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_awu.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 AWU 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_awu.h" 30 | 31 | /** @addtogroup STM8S_StdPeriph_Driver 32 | * @{ 33 | */ 34 | /* Private typedef -----------------------------------------------------------*/ 35 | /* Private define ------------------------------------------------------------*/ 36 | /* Private macro -------------------------------------------------------------*/ 37 | /* Private variables ---------------------------------------------------------*/ 38 | /* Private function prototypes -----------------------------------------------*/ 39 | /* Private functions ---------------------------------------------------------*/ 40 | 41 | /* See also AWU_Timebase_TypeDef structure in stm8s_awu.h file : 42 | N 2 5 1 2 4 8 1 3 6 1 2 5 1 2 1 3 43 | O 5 0 m m m m 6 2 4 2 5 1 s s 2 0 44 | I 0 0 s s s s m m m 8 6 2 s s 45 | T u u s s s m m m 46 | s s s s s 47 | */ 48 | /** Contains the different values to write in the APR register (used by AWU_Init function) */ 49 | CONST uint8_t APR_Array[17] = 50 | { 51 | 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 61, 23, 23, 62 52 | }; 53 | 54 | /** Contains the different values to write in the TBR register (used by AWU_Init function) */ 55 | CONST uint8_t TBR_Array[17] = 56 | { 57 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 14, 15, 15 58 | }; 59 | 60 | /* Public functions ----------------------------------------------------------*/ 61 | 62 | /** 63 | * @addtogroup AWU_Public_Functions 64 | * @{ 65 | */ 66 | 67 | /** 68 | * @brief Deinitializes the AWU peripheral registers to their default reset 69 | * values. 70 | * @param None 71 | * @retval None 72 | */ 73 | void AWU_DeInit(void) 74 | { 75 | AWU->CSR = AWU_CSR_RESET_VALUE; 76 | AWU->APR = AWU_APR_RESET_VALUE; 77 | AWU->TBR = AWU_TBR_RESET_VALUE; 78 | } 79 | 80 | /** 81 | * @brief Initializes the AWU peripheral according to the specified parameters. 82 | * @param AWU_TimeBase : Time base selection (interval between AWU interrupts). 83 | * can be one of the values of @ref AWU_Timebase_TypeDef. 84 | * @retval None 85 | * @par Required preconditions: 86 | * The LS RC calibration must be performed before calling this function. 87 | */ 88 | void AWU_Init(AWU_Timebase_TypeDef AWU_TimeBase) 89 | { 90 | /* Check parameter */ 91 | assert_param(IS_AWU_TIMEBASE_OK(AWU_TimeBase)); 92 | 93 | /* Enable the AWU peripheral */ 94 | AWU->CSR |= AWU_CSR_AWUEN; 95 | 96 | /* Set the TimeBase */ 97 | AWU->TBR &= (uint8_t)(~AWU_TBR_AWUTB); 98 | AWU->TBR |= TBR_Array[(uint8_t)AWU_TimeBase]; 99 | 100 | /* Set the APR divider */ 101 | AWU->APR &= (uint8_t)(~AWU_APR_APR); 102 | AWU->APR |= APR_Array[(uint8_t)AWU_TimeBase]; 103 | } 104 | 105 | /** 106 | * @brief Enable or disable the AWU peripheral. 107 | * @param NewState Indicates the new state of the AWU peripheral. 108 | * @retval None 109 | * @par Required preconditions: 110 | * Initialisation of AWU and LS RC calibration must be done before. 111 | */ 112 | void AWU_Cmd(FunctionalState NewState) 113 | { 114 | if (NewState != DISABLE) 115 | { 116 | /* Enable the AWU peripheral */ 117 | AWU->CSR |= AWU_CSR_AWUEN; 118 | } 119 | else 120 | { 121 | /* Disable the AWU peripheral */ 122 | AWU->CSR &= (uint8_t)(~AWU_CSR_AWUEN); 123 | } 124 | } 125 | 126 | /** 127 | * @brief Update APR register with the measured LSI frequency. 128 | * @par Note on the APR calculation: 129 | * A is the integer part of lsifreqkhz/4 and x the decimal part. 130 | * x <= A/(1+2A) is equivalent to A >= x(1+2A) and also to 4A >= 4x(1+2A) [F1] 131 | * but we know that A + x = lsifreqkhz/4 ==> 4x = lsifreqkhz-4A 132 | * so [F1] can be written : 133 | * 4A >= (lsifreqkhz-4A)(1+2A) 134 | * @param LSIFreqHz Low Speed RC frequency measured by timer (in Hz). 135 | * @retval None 136 | * @par Required preconditions: 137 | * - AWU must be disabled to avoid unwanted interrupts. 138 | */ 139 | void AWU_LSICalibrationConfig(uint32_t LSIFreqHz) 140 | { 141 | uint16_t lsifreqkhz = 0x0; 142 | uint16_t A = 0x0; 143 | 144 | /* Check parameter */ 145 | assert_param(IS_LSI_FREQUENCY_OK(LSIFreqHz)); 146 | 147 | lsifreqkhz = (uint16_t)(LSIFreqHz / 1000); /* Converts value in kHz */ 148 | 149 | /* Calculation of AWU calibration value */ 150 | 151 | A = (uint16_t)(lsifreqkhz >> 2U); /* Division by 4, keep integer part only */ 152 | 153 | if ((4U * A) >= ((lsifreqkhz - (4U * A)) * (1U + (2U * A)))) 154 | { 155 | AWU->APR = (uint8_t)(A - 2U); 156 | } 157 | else 158 | { 159 | AWU->APR = (uint8_t)(A - 1U); 160 | } 161 | } 162 | 163 | /** 164 | * @brief Configures AWU in Idle mode to reduce power consumption. 165 | * @param None 166 | * @retval None 167 | */ 168 | void AWU_IdleModeEnable(void) 169 | { 170 | /* Disable AWU peripheral */ 171 | AWU->CSR &= (uint8_t)(~AWU_CSR_AWUEN); 172 | 173 | /* No AWU timebase */ 174 | AWU->TBR = (uint8_t)(~AWU_TBR_AWUTB); 175 | } 176 | 177 | /** 178 | * @brief Returns status of the AWU peripheral flag. 179 | * @param None 180 | * @retval FlagStatus : Status of the AWU flag. 181 | * This parameter can be any of the @ref FlagStatus enumeration. 182 | */ 183 | FlagStatus AWU_GetFlagStatus(void) 184 | { 185 | return((FlagStatus)(((uint8_t)(AWU->CSR & AWU_CSR_AWUF) == (uint8_t)0x00) ? RESET : SET)); 186 | } 187 | 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /** 194 | * @} 195 | */ 196 | 197 | 198 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 199 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_beep.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_beep.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 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 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm8s_beep.h" 30 | 31 | /** @addtogroup STM8S_StdPeriph_Driver 32 | * @{ 33 | */ 34 | /* Private typedef -----------------------------------------------------------*/ 35 | /* Private define ------------------------------------------------------------*/ 36 | /* Private macro -------------------------------------------------------------*/ 37 | /* Private variables ---------------------------------------------------------*/ 38 | /* Private function prototypes -----------------------------------------------*/ 39 | /* Private functions ---------------------------------------------------------*/ 40 | 41 | /* Public functions ----------------------------------------------------------*/ 42 | 43 | /** 44 | * @addtogroup BEEP_Public_Functions 45 | * @{ 46 | */ 47 | 48 | /** 49 | * @brief Deinitializes the BEEP peripheral registers to their default reset 50 | * values. 51 | * @param None 52 | * @retval None 53 | */ 54 | void BEEP_DeInit(void) 55 | { 56 | BEEP->CSR = BEEP_CSR_RESET_VALUE; 57 | } 58 | 59 | /** 60 | * @brief Initializes the BEEP function according to the specified parameters. 61 | * @param BEEP_Frequency Frequency selection. 62 | * can be one of the values of @ref BEEP_Frequency_TypeDef. 63 | * @retval None 64 | * @par Required preconditions: 65 | * The LS RC calibration must be performed before calling this function. 66 | */ 67 | void BEEP_Init(BEEP_Frequency_TypeDef BEEP_Frequency) 68 | { 69 | /* Check parameter */ 70 | assert_param(IS_BEEP_FREQUENCY_OK(BEEP_Frequency)); 71 | 72 | /* Set a default calibration value if no calibration is done */ 73 | if ((BEEP->CSR & BEEP_CSR_BEEPDIV) == BEEP_CSR_BEEPDIV) 74 | { 75 | BEEP->CSR &= (uint8_t)(~BEEP_CSR_BEEPDIV); /* Clear bits */ 76 | BEEP->CSR |= BEEP_CALIBRATION_DEFAULT; 77 | } 78 | 79 | /* Select the output frequency */ 80 | BEEP->CSR &= (uint8_t)(~BEEP_CSR_BEEPSEL); 81 | BEEP->CSR |= (uint8_t)(BEEP_Frequency); 82 | } 83 | 84 | /** 85 | * @brief Enable or disable the BEEP function. 86 | * @param NewState Indicates the new state of the BEEP function. 87 | * @retval None 88 | * @par Required preconditions: 89 | * Initialisation of BEEP and LS RC calibration must be done before. 90 | */ 91 | void BEEP_Cmd(FunctionalState NewState) 92 | { 93 | if (NewState != DISABLE) 94 | { 95 | /* Enable the BEEP peripheral */ 96 | BEEP->CSR |= BEEP_CSR_BEEPEN; 97 | } 98 | else 99 | { 100 | /* Disable the BEEP peripheral */ 101 | BEEP->CSR &= (uint8_t)(~BEEP_CSR_BEEPEN); 102 | } 103 | } 104 | 105 | /** 106 | * @brief Update CSR register with the measured LSI frequency. 107 | * @par Note on the APR calculation: 108 | * A is the integer part of LSIFreqkHz/4 and x the decimal part. 109 | * x <= A/(1+2A) is equivalent to A >= x(1+2A) and also to 4A >= 4x(1+2A) [F1] 110 | * but we know that A + x = LSIFreqkHz/4 ==> 4x = LSIFreqkHz-4A 111 | * so [F1] can be written : 112 | * 4A >= (LSIFreqkHz-4A)(1+2A) 113 | * @param LSIFreqHz Low Speed RC frequency measured by timer (in Hz). 114 | * @retval None 115 | * @par Required preconditions: 116 | * - BEEP must be disabled to avoid unwanted interrupts. 117 | */ 118 | void BEEP_LSICalibrationConfig(uint32_t LSIFreqHz) 119 | { 120 | uint16_t lsifreqkhz; 121 | uint16_t A; 122 | 123 | /* Check parameter */ 124 | assert_param(IS_LSI_FREQUENCY_OK(LSIFreqHz)); 125 | 126 | lsifreqkhz = (uint16_t)(LSIFreqHz / 1000); /* Converts value in kHz */ 127 | 128 | /* Calculation of BEEPER calibration value */ 129 | 130 | BEEP->CSR &= (uint8_t)(~BEEP_CSR_BEEPDIV); /* Clear bits */ 131 | 132 | A = (uint16_t)(lsifreqkhz >> 3U); /* Division by 8, keep integer part only */ 133 | 134 | if ((8U * A) >= ((lsifreqkhz - (8U * A)) * (1U + (2U * A)))) 135 | { 136 | BEEP->CSR |= (uint8_t)(A - 2U); 137 | } 138 | else 139 | { 140 | BEEP->CSR |= (uint8_t)(A - 1U); 141 | } 142 | } 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | 153 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 154 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_can.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_can.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_clk.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_clk.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_exti.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_exti.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 EXTI 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_exti.h" 30 | 31 | /** @addtogroup STM8S_StdPeriph_Driver 32 | * @{ 33 | */ 34 | /* Private typedef -----------------------------------------------------------*/ 35 | /* Private define ------------------------------------------------------------*/ 36 | /* Private macro -------------------------------------------------------------*/ 37 | /* Private variables ---------------------------------------------------------*/ 38 | /* Private function prototypes -----------------------------------------------*/ 39 | /* Private functions ---------------------------------------------------------*/ 40 | 41 | /* Public functions ----------------------------------------------------------*/ 42 | 43 | /** 44 | * @addtogroup EXTI_Public_Functions 45 | * @{ 46 | */ 47 | 48 | /** 49 | * @brief Deinitializes the external interrupt control registers to their default reset value. 50 | * @param None 51 | * @retval None 52 | */ 53 | void EXTI_DeInit(void) 54 | { 55 | EXTI->CR1 = EXTI_CR1_RESET_VALUE; 56 | EXTI->CR2 = EXTI_CR2_RESET_VALUE; 57 | } 58 | 59 | /** 60 | * @brief Set the external interrupt sensitivity of the selected port. 61 | * @warning 62 | * - The modification of external interrupt sensitivity is only possible when the interrupts are disabled. 63 | * - The normal behavior is to disable the interrupts before calling this function, and re-enable them after. 64 | * @param Port The port number to access. 65 | * @param SensitivityValue The external interrupt sensitivity value to set. 66 | * @retval None 67 | * @par Required preconditions: 68 | * Global interrupts must be disabled before calling this function. 69 | */ 70 | void EXTI_SetExtIntSensitivity(EXTI_Port_TypeDef Port, EXTI_Sensitivity_TypeDef SensitivityValue) 71 | { 72 | /* Check function parameters */ 73 | assert_param(IS_EXTI_PORT_OK(Port)); 74 | assert_param(IS_EXTI_SENSITIVITY_OK(SensitivityValue)); 75 | 76 | /* Set external interrupt sensitivity */ 77 | switch (Port) 78 | { 79 | case EXTI_PORT_GPIOA: 80 | EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PAIS); 81 | EXTI->CR1 |= (uint8_t)(SensitivityValue); 82 | break; 83 | case EXTI_PORT_GPIOB: 84 | EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PBIS); 85 | EXTI->CR1 |= (uint8_t)((uint8_t)(SensitivityValue) << 2); 86 | break; 87 | case EXTI_PORT_GPIOC: 88 | EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PCIS); 89 | EXTI->CR1 |= (uint8_t)((uint8_t)(SensitivityValue) << 4); 90 | break; 91 | case EXTI_PORT_GPIOD: 92 | EXTI->CR1 &= (uint8_t)(~EXTI_CR1_PDIS); 93 | EXTI->CR1 |= (uint8_t)((uint8_t)(SensitivityValue) << 6); 94 | break; 95 | case EXTI_PORT_GPIOE: 96 | EXTI->CR2 &= (uint8_t)(~EXTI_CR2_PEIS); 97 | EXTI->CR2 |= (uint8_t)(SensitivityValue); 98 | break; 99 | default: 100 | break; 101 | } 102 | } 103 | 104 | /** 105 | * @brief Set the TLI interrupt sensitivity. 106 | * @param SensitivityValue The TLI interrupt sensitivity value. 107 | * @retval None 108 | * @par Required preconditions: 109 | * Global interrupts must be disabled before calling this function. 110 | */ 111 | void EXTI_SetTLISensitivity(EXTI_TLISensitivity_TypeDef SensitivityValue) 112 | { 113 | /* Check function parameters */ 114 | assert_param(IS_EXTI_TLISENSITIVITY_OK(SensitivityValue)); 115 | 116 | /* Set TLI interrupt sensitivity */ 117 | EXTI->CR2 &= (uint8_t)(~EXTI_CR2_TLIS); 118 | EXTI->CR2 |= (uint8_t)(SensitivityValue); 119 | } 120 | 121 | /** 122 | * @brief Get the external interrupt sensitivity of the selected port. 123 | * @param Port The port number to access. 124 | * @retval EXTI_Sensitivity_TypeDef The external interrupt sensitivity of the selected port. 125 | */ 126 | EXTI_Sensitivity_TypeDef EXTI_GetExtIntSensitivity(EXTI_Port_TypeDef Port) 127 | { 128 | uint8_t value = 0; 129 | 130 | /* Check function parameters */ 131 | assert_param(IS_EXTI_PORT_OK(Port)); 132 | 133 | switch (Port) 134 | { 135 | case EXTI_PORT_GPIOA: 136 | value = (uint8_t)(EXTI->CR1 & EXTI_CR1_PAIS); 137 | break; 138 | case EXTI_PORT_GPIOB: 139 | value = (uint8_t)((uint8_t)(EXTI->CR1 & EXTI_CR1_PBIS) >> 2); 140 | break; 141 | case EXTI_PORT_GPIOC: 142 | value = (uint8_t)((uint8_t)(EXTI->CR1 & EXTI_CR1_PCIS) >> 4); 143 | break; 144 | case EXTI_PORT_GPIOD: 145 | value = (uint8_t)((uint8_t)(EXTI->CR1 & EXTI_CR1_PDIS) >> 6); 146 | break; 147 | case EXTI_PORT_GPIOE: 148 | value = (uint8_t)(EXTI->CR2 & EXTI_CR2_PEIS); 149 | break; 150 | default: 151 | break; 152 | } 153 | 154 | return((EXTI_Sensitivity_TypeDef)value); 155 | } 156 | 157 | /** 158 | * @brief Get the TLI interrupt sensitivity. 159 | * @param None 160 | * @retval EXTI_TLISensitivity_TypeDef The TLI interrupt sensitivity read. 161 | */ 162 | EXTI_TLISensitivity_TypeDef EXTI_GetTLISensitivity(void) 163 | { 164 | uint8_t value = 0; 165 | 166 | /* Get TLI interrupt sensitivity */ 167 | value = (uint8_t)(EXTI->CR2 & EXTI_CR2_TLIS); 168 | 169 | return((EXTI_TLISensitivity_TypeDef)value); 170 | } 171 | 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | 181 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 182 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_gpio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_gpio.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 GPIO 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_gpio.h" 30 | 31 | /** @addtogroup STM8S_StdPeriph_Driver 32 | * @{ 33 | */ 34 | /* Private typedef -----------------------------------------------------------*/ 35 | /* Private define ------------------------------------------------------------*/ 36 | /* Private macro -------------------------------------------------------------*/ 37 | /* Private variables ---------------------------------------------------------*/ 38 | /* Private function prototypes -----------------------------------------------*/ 39 | /* Private functions ---------------------------------------------------------*/ 40 | 41 | /* Public functions ----------------------------------------------------------*/ 42 | 43 | /** 44 | * @addtogroup GPIO_Public_Functions 45 | * @{ 46 | */ 47 | 48 | /** 49 | * @brief Deinitializes the GPIOx peripheral registers to their default reset values. 50 | * @param GPIOx: Select the GPIO peripheral number (x = A to I). 51 | * @retval None 52 | */ 53 | void GPIO_DeInit(GPIO_TypeDef* GPIOx) 54 | { 55 | GPIOx->ODR = GPIO_ODR_RESET_VALUE; /* Reset Output Data Register */ 56 | GPIOx->DDR = GPIO_DDR_RESET_VALUE; /* Reset Data Direction Register */ 57 | GPIOx->CR1 = GPIO_CR1_RESET_VALUE; /* Reset Control Register 1 */ 58 | GPIOx->CR2 = GPIO_CR2_RESET_VALUE; /* Reset Control Register 2 */ 59 | } 60 | 61 | /** 62 | * @brief Initializes the GPIOx according to the specified parameters. 63 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 64 | * @param GPIO_Pin : This parameter contains the pin number, it can be any value 65 | * of the @ref GPIO_Pin_TypeDef enumeration. 66 | * @param GPIO_Mode : This parameter can be a value of the 67 | * @Ref GPIO_Mode_TypeDef enumeration. 68 | * @retval None 69 | */ 70 | 71 | void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode) 72 | { 73 | /*----------------------*/ 74 | /* Check the parameters */ 75 | /*----------------------*/ 76 | 77 | assert_param(IS_GPIO_MODE_OK(GPIO_Mode)); 78 | assert_param(IS_GPIO_PIN_OK(GPIO_Pin)); 79 | 80 | /* Reset corresponding bit to GPIO_Pin in CR2 register */ 81 | GPIOx->CR2 &= (uint8_t)(~(GPIO_Pin)); 82 | 83 | /*-----------------------------*/ 84 | /* Input/Output mode selection */ 85 | /*-----------------------------*/ 86 | 87 | if ((((uint8_t)(GPIO_Mode)) & (uint8_t)0x80) != (uint8_t)0x00) /* Output mode */ 88 | { 89 | if ((((uint8_t)(GPIO_Mode)) & (uint8_t)0x10) != (uint8_t)0x00) /* High level */ 90 | { 91 | GPIOx->ODR |= (uint8_t)GPIO_Pin; 92 | } 93 | else /* Low level */ 94 | { 95 | GPIOx->ODR &= (uint8_t)(~(GPIO_Pin)); 96 | } 97 | /* Set Output mode */ 98 | GPIOx->DDR |= (uint8_t)GPIO_Pin; 99 | } 100 | else /* Input mode */ 101 | { 102 | /* Set Input mode */ 103 | GPIOx->DDR &= (uint8_t)(~(GPIO_Pin)); 104 | } 105 | 106 | /*------------------------------------------------------------------------*/ 107 | /* Pull-Up/Float (Input) or Push-Pull/Open-Drain (Output) modes selection */ 108 | /*------------------------------------------------------------------------*/ 109 | 110 | if ((((uint8_t)(GPIO_Mode)) & (uint8_t)0x40) != (uint8_t)0x00) /* Pull-Up or Push-Pull */ 111 | { 112 | GPIOx->CR1 |= (uint8_t)GPIO_Pin; 113 | } 114 | else /* Float or Open-Drain */ 115 | { 116 | GPIOx->CR1 &= (uint8_t)(~(GPIO_Pin)); 117 | } 118 | 119 | /*-----------------------------------------------------*/ 120 | /* Interrupt (Input) or Slope (Output) modes selection */ 121 | /*-----------------------------------------------------*/ 122 | 123 | if ((((uint8_t)(GPIO_Mode)) & (uint8_t)0x20) != (uint8_t)0x00) /* Interrupt or Slow slope */ 124 | { 125 | GPIOx->CR2 |= (uint8_t)GPIO_Pin; 126 | } 127 | else /* No external interrupt or No slope control */ 128 | { 129 | GPIOx->CR2 &= (uint8_t)(~(GPIO_Pin)); 130 | } 131 | } 132 | 133 | /** 134 | * @brief Writes data to the specified GPIO data port. 135 | * @note The port must be configured in output mode. 136 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 137 | * @param GPIO_PortVal : Specifies the value to be written to the port output 138 | * data register. 139 | * @retval None 140 | */ 141 | void GPIO_Write(GPIO_TypeDef* GPIOx, uint8_t PortVal) 142 | { 143 | GPIOx->ODR = PortVal; 144 | } 145 | 146 | /** 147 | * @brief Writes high level to the specified GPIO pins. 148 | * @note The port must be configured in output mode. 149 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 150 | * @param PortPins : Specifies the pins to be turned high to the port output. 151 | * data register. 152 | * @retval None 153 | */ 154 | void GPIO_WriteHigh(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins) 155 | { 156 | GPIOx->ODR |= (uint8_t)PortPins; 157 | } 158 | 159 | /** 160 | * @brief Writes low level to the specified GPIO pins. 161 | * @note The port must be configured in output mode. 162 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 163 | * @param PortPins : Specifies the pins to be turned low to the port output. 164 | * data register. 165 | * @retval None 166 | */ 167 | void GPIO_WriteLow(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins) 168 | { 169 | GPIOx->ODR &= (uint8_t)(~PortPins); 170 | } 171 | 172 | /** 173 | * @brief Writes reverse level to the specified GPIO pins. 174 | * @note The port must be configured in output mode. 175 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 176 | * @param PortPins : Specifies the pins to be reversed to the port output. 177 | * data register. 178 | * @retval None 179 | */ 180 | void GPIO_WriteReverse(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins) 181 | { 182 | GPIOx->ODR ^= (uint8_t)PortPins; 183 | } 184 | 185 | /** 186 | * @brief Reads the specified GPIO output data port. 187 | * @note The port must be configured in input mode. 188 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 189 | * @retval GPIO output data port value. 190 | */ 191 | uint8_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx) 192 | { 193 | return ((uint8_t)GPIOx->ODR); 194 | } 195 | 196 | /** 197 | * @brief Reads the specified GPIO input data port. 198 | * @note The port must be configured in input mode. 199 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 200 | * @retval GPIO input data port value. 201 | */ 202 | uint8_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx) 203 | { 204 | return ((uint8_t)GPIOx->IDR); 205 | } 206 | 207 | /** 208 | * @brief Reads the specified GPIO input data pin. 209 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 210 | * @param GPIO_Pin : Specifies the pin number. 211 | * @retval BitStatus : GPIO input pin status. 212 | */ 213 | BitStatus GPIO_ReadInputPin(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin) 214 | { 215 | return ((BitStatus)(GPIOx->IDR & (uint8_t)GPIO_Pin)); 216 | } 217 | 218 | /** 219 | * @brief Configures the external pull-up on GPIOx pins. 220 | * @param GPIOx : Select the GPIO peripheral number (x = A to I). 221 | * @param GPIO_Pin : Specifies the pin number 222 | * @param NewState : The new state of the pull up pin. 223 | * @retval None 224 | */ 225 | void GPIO_ExternalPullUpConfig(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, FunctionalState NewState) 226 | { 227 | /* Check the parameters */ 228 | assert_param(IS_GPIO_PIN_OK(GPIO_Pin)); 229 | assert_param(IS_FUNCTIONALSTATE_OK(NewState)); 230 | 231 | if (NewState != DISABLE) /* External Pull-Up Set*/ 232 | { 233 | GPIOx->CR1 |= (uint8_t)GPIO_Pin; 234 | } else /* External Pull-Up Reset*/ 235 | { 236 | GPIOx->CR1 &= (uint8_t)(~(GPIO_Pin)); 237 | } 238 | } 239 | 240 | /** 241 | * @} 242 | */ 243 | 244 | /** 245 | * @} 246 | */ 247 | 248 | 249 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 250 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_itc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_itc.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 ITC 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_itc.h" 30 | 31 | /** @addtogroup STM8S_StdPeriph_Driver 32 | * @{ 33 | */ 34 | /* Private typedef -----------------------------------------------------------*/ 35 | /* Private define ------------------------------------------------------------*/ 36 | /* Private macro -------------------------------------------------------------*/ 37 | /* Private variables ---------------------------------------------------------*/ 38 | /* Private function prototypes -----------------------------------------------*/ 39 | /* Private functions ---------------------------------------------------------*/ 40 | 41 | /** @addtogroup ITC_Private_Functions 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @brief Utility function used to read CC register. 47 | * @param None 48 | * @retval CPU CC register value 49 | */ 50 | uint8_t ITC_GetCPUCC(void) 51 | { 52 | #ifdef _COSMIC_ 53 | _asm("push cc"); 54 | _asm("pop a"); 55 | return; /* Ignore compiler warning, the returned value is in A register */ 56 | #elif defined _RAISONANCE_ /* _RAISONANCE_ */ 57 | return _getCC_(); 58 | #elif defined(_SDCC_) /* SDCC patch: do same as IAR */ 59 | __asm__("push cc"); 60 | __asm__("pop a"); 61 | #else /* _IAR_ */ 62 | asm("push cc"); 63 | asm("pop a"); /* Ignore compiler warning, the returned value is in A register */ 64 | #endif /* _COSMIC_*/ 65 | } 66 | 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /* Public functions ----------------------------------------------------------*/ 73 | 74 | /** @addtogroup ITC_Public_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief Deinitializes the ITC registers to their default reset value. 80 | * @param None 81 | * @retval None 82 | */ 83 | void ITC_DeInit(void) 84 | { 85 | ITC->ISPR1 = ITC_SPRX_RESET_VALUE; 86 | ITC->ISPR2 = ITC_SPRX_RESET_VALUE; 87 | ITC->ISPR3 = ITC_SPRX_RESET_VALUE; 88 | ITC->ISPR4 = ITC_SPRX_RESET_VALUE; 89 | ITC->ISPR5 = ITC_SPRX_RESET_VALUE; 90 | ITC->ISPR6 = ITC_SPRX_RESET_VALUE; 91 | ITC->ISPR7 = ITC_SPRX_RESET_VALUE; 92 | ITC->ISPR8 = ITC_SPRX_RESET_VALUE; 93 | } 94 | 95 | /** 96 | * @brief Gets the interrupt software priority bits (I1, I0) value from CPU CC register. 97 | * @param None 98 | * @retval The interrupt software priority bits value. 99 | */ 100 | uint8_t ITC_GetSoftIntStatus(void) 101 | { 102 | return (uint8_t)(ITC_GetCPUCC() & CPU_CC_I1I0); 103 | } 104 | 105 | /** 106 | * @brief Gets the software priority of the specified interrupt source. 107 | * @param IrqNum : Specifies the peripheral interrupt source. 108 | * @retval ITC_PriorityLevel_TypeDef : Specifies the software priority of the interrupt source. 109 | */ 110 | ITC_PriorityLevel_TypeDef ITC_GetSoftwarePriority(ITC_Irq_TypeDef IrqNum) 111 | { 112 | uint8_t Value = 0; 113 | uint8_t Mask = 0; 114 | 115 | /* Check function parameters */ 116 | assert_param(IS_ITC_IRQ_OK((uint8_t)IrqNum)); 117 | 118 | /* Define the mask corresponding to the bits position in the SPR register */ 119 | Mask = (uint8_t)(0x03U << (((uint8_t)IrqNum % 4U) * 2U)); 120 | 121 | switch (IrqNum) 122 | { 123 | case ITC_IRQ_TLI: /* TLI software priority can be read but has no meaning */ 124 | case ITC_IRQ_AWU: 125 | case ITC_IRQ_CLK: 126 | case ITC_IRQ_PORTA: 127 | Value = (uint8_t)(ITC->ISPR1 & Mask); /* Read software priority */ 128 | break; 129 | 130 | case ITC_IRQ_PORTB: 131 | case ITC_IRQ_PORTC: 132 | case ITC_IRQ_PORTD: 133 | case ITC_IRQ_PORTE: 134 | Value = (uint8_t)(ITC->ISPR2 & Mask); /* Read software priority */ 135 | break; 136 | 137 | #if defined(STM8S208) || defined(STM8AF52Ax) 138 | case ITC_IRQ_CAN_RX: 139 | case ITC_IRQ_CAN_TX: 140 | #endif /*STM8S208 or STM8AF52Ax */ 141 | #if defined(STM8S903) || defined(STM8AF622x) 142 | case ITC_IRQ_PORTF: 143 | #endif /*STM8S903 or STM8AF622x */ 144 | case ITC_IRQ_SPI: 145 | case ITC_IRQ_TIM1_OVF: 146 | Value = (uint8_t)(ITC->ISPR3 & Mask); /* Read software priority */ 147 | break; 148 | 149 | case ITC_IRQ_TIM1_CAPCOM: 150 | #if defined (STM8S903) || defined (STM8AF622x) 151 | case ITC_IRQ_TIM5_OVFTRI: 152 | case ITC_IRQ_TIM5_CAPCOM: 153 | #else 154 | case ITC_IRQ_TIM2_OVF: 155 | case ITC_IRQ_TIM2_CAPCOM: 156 | #endif /* STM8S903 or STM8AF622x*/ 157 | case ITC_IRQ_TIM3_OVF: 158 | Value = (uint8_t)(ITC->ISPR4 & Mask); /* Read software priority */ 159 | break; 160 | 161 | case ITC_IRQ_TIM3_CAPCOM: 162 | #if defined(STM8S208) ||defined(STM8S207) || defined (STM8S007) || defined(STM8S103) || \ 163 | defined(STM8S003) ||defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 164 | case ITC_IRQ_UART1_TX: 165 | case ITC_IRQ_UART1_RX: 166 | #endif /*STM8S208 or STM8S207 or STM8S007 or STM8S103 or STM8S003 or STM8S903 or STM8AF52Ax or STM8AF62Ax */ 167 | #if defined(STM8AF622x) 168 | case ITC_IRQ_UART4_TX: 169 | case ITC_IRQ_UART4_RX: 170 | #endif /*STM8AF622x */ 171 | case ITC_IRQ_I2C: 172 | Value = (uint8_t)(ITC->ISPR5 & Mask); /* Read software priority */ 173 | break; 174 | 175 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8AF626x) 176 | case ITC_IRQ_UART2_TX: 177 | case ITC_IRQ_UART2_RX: 178 | #endif /*STM8S105 or STM8AF626x*/ 179 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8AF52Ax) || \ 180 | defined(STM8AF62Ax) 181 | case ITC_IRQ_UART3_TX: 182 | case ITC_IRQ_UART3_RX: 183 | case ITC_IRQ_ADC2: 184 | #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ 185 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) || \ 186 | defined(STM8S903) || defined(STM8AF626x) || defined(STM8AF622x) 187 | case ITC_IRQ_ADC1: 188 | #endif /*STM8S105, STM8S005, STM8S103 or STM8S003 or STM8S903 or STM8AF626x or STM8AF622x */ 189 | #if defined (STM8S903) || defined (STM8AF622x) 190 | case ITC_IRQ_TIM6_OVFTRI: 191 | #else 192 | case ITC_IRQ_TIM4_OVF: 193 | #endif /*STM8S903 or STM8AF622x */ 194 | Value = (uint8_t)(ITC->ISPR6 & Mask); /* Read software priority */ 195 | break; 196 | 197 | case ITC_IRQ_EEPROM_EEC: 198 | Value = (uint8_t)(ITC->ISPR7 & Mask); /* Read software priority */ 199 | break; 200 | 201 | default: 202 | break; 203 | } 204 | 205 | Value >>= (uint8_t)(((uint8_t)IrqNum % 4u) * 2u); 206 | 207 | return((ITC_PriorityLevel_TypeDef)Value); 208 | } 209 | 210 | /** 211 | * @brief Sets the software priority of the specified interrupt source. 212 | * @note - The modification of the software priority is only possible when 213 | * the interrupts are disabled. 214 | * - The normal behavior is to disable the interrupt before calling 215 | * this function, and re-enable it after. 216 | * - The priority level 0 cannot be set (see product specification 217 | * for more details). 218 | * @param IrqNum : Specifies the peripheral interrupt source. 219 | * @param PriorityValue : Specifies the software priority value to set, 220 | * can be a value of @ref ITC_PriorityLevel_TypeDef . 221 | * @retval None 222 | */ 223 | void ITC_SetSoftwarePriority(ITC_Irq_TypeDef IrqNum, ITC_PriorityLevel_TypeDef PriorityValue) 224 | { 225 | uint8_t Mask = 0; 226 | uint8_t NewPriority = 0; 227 | 228 | /* Check function parameters */ 229 | assert_param(IS_ITC_IRQ_OK((uint8_t)IrqNum)); 230 | assert_param(IS_ITC_PRIORITY_OK(PriorityValue)); 231 | 232 | /* Check if interrupts are disabled */ 233 | assert_param(IS_ITC_INTERRUPTS_DISABLED); 234 | 235 | /* Define the mask corresponding to the bits position in the SPR register */ 236 | /* The mask is reversed in order to clear the 2 bits after more easily */ 237 | Mask = (uint8_t)(~(uint8_t)(0x03U << (((uint8_t)IrqNum % 4U) * 2U))); 238 | 239 | /* Define the new priority to write */ 240 | NewPriority = (uint8_t)((uint8_t)(PriorityValue) << (((uint8_t)IrqNum % 4U) * 2U)); 241 | 242 | switch (IrqNum) 243 | { 244 | case ITC_IRQ_TLI: /* TLI software priority can be written but has no meaning */ 245 | case ITC_IRQ_AWU: 246 | case ITC_IRQ_CLK: 247 | case ITC_IRQ_PORTA: 248 | ITC->ISPR1 &= Mask; 249 | ITC->ISPR1 |= NewPriority; 250 | break; 251 | 252 | case ITC_IRQ_PORTB: 253 | case ITC_IRQ_PORTC: 254 | case ITC_IRQ_PORTD: 255 | case ITC_IRQ_PORTE: 256 | ITC->ISPR2 &= Mask; 257 | ITC->ISPR2 |= NewPriority; 258 | break; 259 | 260 | #if defined(STM8S208) || defined(STM8AF52Ax) 261 | case ITC_IRQ_CAN_RX: 262 | case ITC_IRQ_CAN_TX: 263 | #endif /*STM8S208 or STM8AF52Ax */ 264 | #if defined(STM8S903) || defined(STM8AF622x) 265 | case ITC_IRQ_PORTF: 266 | #endif /*STM8S903 or STM8AF622x */ 267 | case ITC_IRQ_SPI: 268 | case ITC_IRQ_TIM1_OVF: 269 | ITC->ISPR3 &= Mask; 270 | ITC->ISPR3 |= NewPriority; 271 | break; 272 | 273 | case ITC_IRQ_TIM1_CAPCOM: 274 | #if defined(STM8S903) || defined(STM8AF622x) 275 | case ITC_IRQ_TIM5_OVFTRI: 276 | case ITC_IRQ_TIM5_CAPCOM: 277 | #else 278 | case ITC_IRQ_TIM2_OVF: 279 | case ITC_IRQ_TIM2_CAPCOM: 280 | #endif /*STM8S903 or STM8AF622x */ 281 | case ITC_IRQ_TIM3_OVF: 282 | ITC->ISPR4 &= Mask; 283 | ITC->ISPR4 |= NewPriority; 284 | break; 285 | 286 | case ITC_IRQ_TIM3_CAPCOM: 287 | #if defined(STM8S208) ||defined(STM8S207) || defined (STM8S007) || defined(STM8S103) || \ 288 | defined(STM8S003) ||defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 289 | case ITC_IRQ_UART1_TX: 290 | case ITC_IRQ_UART1_RX: 291 | #endif /*STM8S208 or STM8S207 or STM8S007 or STM8S103 or STM8S003 or STM8S903 or STM8AF52Ax or STM8AF62Ax */ 292 | #if defined(STM8AF622x) 293 | case ITC_IRQ_UART4_TX: 294 | case ITC_IRQ_UART4_RX: 295 | #endif /*STM8AF622x */ 296 | case ITC_IRQ_I2C: 297 | ITC->ISPR5 &= Mask; 298 | ITC->ISPR5 |= NewPriority; 299 | break; 300 | 301 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8AF626x) 302 | case ITC_IRQ_UART2_TX: 303 | case ITC_IRQ_UART2_RX: 304 | #endif /*STM8S105 or STM8AF626x */ 305 | 306 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8AF52Ax) || \ 307 | defined(STM8AF62Ax) 308 | case ITC_IRQ_UART3_TX: 309 | case ITC_IRQ_UART3_RX: 310 | case ITC_IRQ_ADC2: 311 | #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ 312 | 313 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) || \ 314 | defined(STM8S903) || defined(STM8AF626x) || defined (STM8AF622x) 315 | case ITC_IRQ_ADC1: 316 | #endif /*STM8S105, STM8S005, STM8S103 or STM8S003 or STM8S903 or STM8AF626x or STM8AF622x */ 317 | 318 | #if defined (STM8S903) || defined (STM8AF622x) 319 | case ITC_IRQ_TIM6_OVFTRI: 320 | #else 321 | case ITC_IRQ_TIM4_OVF: 322 | #endif /* STM8S903 or STM8AF622x */ 323 | ITC->ISPR6 &= Mask; 324 | ITC->ISPR6 |= NewPriority; 325 | break; 326 | 327 | case ITC_IRQ_EEPROM_EEC: 328 | ITC->ISPR7 &= Mask; 329 | ITC->ISPR7 |= NewPriority; 330 | break; 331 | 332 | default: 333 | break; 334 | } 335 | } 336 | 337 | /** 338 | * @} 339 | */ 340 | 341 | /** 342 | * @} 343 | */ 344 | 345 | 346 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 347 | -------------------------------------------------------------------------------- /STM8_helloworld/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 | -------------------------------------------------------------------------------- /STM8_helloworld/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 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim1.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim2.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim3.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim4.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim5.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim6.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_tim6.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_uart1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_uart1.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_uart2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_uart2.c -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_uart4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/src/stm8s_uart4.c -------------------------------------------------------------------------------- /STM8_helloworld/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 | -------------------------------------------------------------------------------- /STM8_helloworld/STM8S_StdPeriph_Driver/stm8s-a_stdperiph_drivers_um.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/STM8S_StdPeriph_Driver/stm8s-a_stdperiph_drivers_um.chm -------------------------------------------------------------------------------- /STM8_helloworld/build/main.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------- 2 | ; File Created by SDCC : free open source ANSI-C Compiler 3 | ; Version 3.7.0 #10231 (Linux) 4 | ;-------------------------------------------------------- 5 | .module main 6 | .optsdcc -mstm8 7 | 8 | ;-------------------------------------------------------- 9 | ; Public variables in this module 10 | ;-------------------------------------------------------- 11 | .globl _main 12 | .globl _GPIO_WriteReverse 13 | .globl _GPIO_Init 14 | .globl _Delay 15 | ;-------------------------------------------------------- 16 | ; ram data 17 | ;-------------------------------------------------------- 18 | .area DATA 19 | ;-------------------------------------------------------- 20 | ; ram data 21 | ;-------------------------------------------------------- 22 | .area INITIALIZED 23 | ;-------------------------------------------------------- 24 | ; Stack segment in internal ram 25 | ;-------------------------------------------------------- 26 | .area SSEG 27 | __start__stack: 28 | .ds 1 29 | 30 | ;-------------------------------------------------------- 31 | ; absolute external ram data 32 | ;-------------------------------------------------------- 33 | .area DABS (ABS) 34 | ;-------------------------------------------------------- 35 | ; interrupt vector 36 | ;-------------------------------------------------------- 37 | .area HOME 38 | __interrupt_vect: 39 | int s_GSINIT ; reset 40 | ;-------------------------------------------------------- 41 | ; global & static initialisations 42 | ;-------------------------------------------------------- 43 | .area HOME 44 | .area GSINIT 45 | .area GSFINAL 46 | .area GSINIT 47 | __sdcc_gs_init_startup: 48 | __sdcc_init_data: 49 | ; stm8_genXINIT() start 50 | ldw x, #l_DATA 51 | jreq 00002$ 52 | 00001$: 53 | clr (s_DATA - 1, x) 54 | decw x 55 | jrne 00001$ 56 | 00002$: 57 | ldw x, #l_INITIALIZER 58 | jreq 00004$ 59 | 00003$: 60 | ld a, (s_INITIALIZER - 1, x) 61 | ld (s_INITIALIZED - 1, x), a 62 | decw x 63 | jrne 00003$ 64 | 00004$: 65 | ; stm8_genXINIT() end 66 | .area GSFINAL 67 | jp __sdcc_program_startup 68 | ;-------------------------------------------------------- 69 | ; Home 70 | ;-------------------------------------------------------- 71 | .area HOME 72 | .area HOME 73 | __sdcc_program_startup: 74 | jp _main 75 | ; return from main will return to caller 76 | ;-------------------------------------------------------- 77 | ; code 78 | ;-------------------------------------------------------- 79 | .area CODE 80 | Smain$main$0 ==. 81 | ; ./main.c: 8: int main(void) 82 | ; genLabel 83 | ; ----------------------------------------- 84 | ; function main 85 | ; ----------------------------------------- 86 | ; Register assignment is optimal. 87 | ; Stack space usage: 0 bytes. 88 | _main: 89 | Smain$main$1 ==. 90 | Smain$main$2 ==. 91 | ; ./main.c: 14: GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST); 92 | ; genIPush 93 | push #0xe0 94 | Smain$main$3 ==. 95 | ; genIPush 96 | push #0x0e 97 | Smain$main$4 ==. 98 | ; genIPush 99 | push #0x00 100 | Smain$main$5 ==. 101 | push #0x50 102 | Smain$main$6 ==. 103 | ; genCall 104 | call _GPIO_Init 105 | addw sp, #4 106 | Smain$main$7 ==. 107 | Smain$main$8 ==. 108 | ; ./main.c: 16: while (1) 109 | ; genLabel 110 | 00102$: 111 | Smain$main$9 ==. 112 | Smain$main$10 ==. 113 | ; ./main.c: 20: GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS); 114 | ; genIPush 115 | push #0x0e 116 | Smain$main$11 ==. 117 | ; genIPush 118 | push #0x00 119 | Smain$main$12 ==. 120 | push #0x50 121 | Smain$main$13 ==. 122 | ; genCall 123 | call _GPIO_WriteReverse 124 | addw sp, #3 125 | Smain$main$14 ==. 126 | Smain$main$15 ==. 127 | ; ./main.c: 21: Delay(0xFFFF); 128 | ; genIPush 129 | push #0xff 130 | Smain$main$16 ==. 131 | push #0xff 132 | Smain$main$17 ==. 133 | ; genCall 134 | call _Delay 135 | addw sp, #2 136 | Smain$main$18 ==. 137 | Smain$main$19 ==. 138 | ; genGoto 139 | jp 00102$ 140 | ; genLabel 141 | 00104$: 142 | Smain$main$20 ==. 143 | ; ./main.c: 24: } 144 | ; genEndFunction 145 | Smain$main$21 ==. 146 | XG$main$0$0 ==. 147 | ret 148 | Smain$main$22 ==. 149 | Smain$Delay$23 ==. 150 | ; ./main.c: 26: void Delay(uint16_t nCount) 151 | ; genLabel 152 | ; ----------------------------------------- 153 | ; function Delay 154 | ; ----------------------------------------- 155 | ; Register assignment is optimal. 156 | ; Stack space usage: 0 bytes. 157 | _Delay: 158 | Smain$Delay$24 ==. 159 | Smain$Delay$25 ==. 160 | ; ./main.c: 29: while (nCount != 0) 161 | ; genAssign 162 | ldw x, (0x03, sp) 163 | ; genLabel 164 | 00101$: 165 | ; genIfx 166 | tnzw x 167 | jrne 00115$ 168 | jp 00104$ 169 | 00115$: 170 | Smain$Delay$26 ==. 171 | Smain$Delay$27 ==. 172 | ; ./main.c: 31: nCount--; 173 | ; genMinus 174 | decw x 175 | Smain$Delay$28 ==. 176 | ; genGoto 177 | jp 00101$ 178 | ; genLabel 179 | 00104$: 180 | Smain$Delay$29 ==. 181 | ; ./main.c: 33: } 182 | ; genEndFunction 183 | Smain$Delay$30 ==. 184 | XG$Delay$0$0 ==. 185 | ret 186 | Smain$Delay$31 ==. 187 | .area CODE 188 | .area INITIALIZER 189 | .area CABS (ABS) 190 | 191 | .area .debug_line (NOLOAD) 192 | .dw 0,Ldebug_line_end-Ldebug_line_start 193 | Ldebug_line_start: 194 | .dw 2 195 | .dw 0,Ldebug_line_stmt-6-Ldebug_line_start 196 | .db 1 197 | .db 1 198 | .db -5 199 | .db 15 200 | .db 10 201 | .db 0 202 | .db 1 203 | .db 1 204 | .db 1 205 | .db 1 206 | .db 0 207 | .db 0 208 | .db 0 209 | .db 1 210 | .ascii "/usr/bin/../share/sdcc/include/stm8" 211 | .db 0 212 | .ascii "/usr/share/sdcc/include/stm8" 213 | .db 0 214 | .ascii "/usr/bin/../share/sdcc/include" 215 | .db 0 216 | .ascii "/usr/share/sdcc/include" 217 | .db 0 218 | .db 0 219 | .ascii "./main.c" 220 | .db 0 221 | .uleb128 0 222 | .uleb128 0 223 | .uleb128 0 224 | .db 0 225 | Ldebug_line_stmt: 226 | .db 0 227 | .uleb128 5 228 | .db 2 229 | .dw 0,(Smain$main$0) 230 | .db 3 231 | .sleb128 7 232 | .db 1 233 | .db 9 234 | .dw Smain$main$2-Smain$main$0 235 | .db 3 236 | .sleb128 6 237 | .db 1 238 | .db 9 239 | .dw Smain$main$8-Smain$main$2 240 | .db 3 241 | .sleb128 2 242 | .db 1 243 | .db 9 244 | .dw Smain$main$10-Smain$main$8 245 | .db 3 246 | .sleb128 4 247 | .db 1 248 | .db 9 249 | .dw Smain$main$15-Smain$main$10 250 | .db 3 251 | .sleb128 1 252 | .db 1 253 | .db 9 254 | .dw Smain$main$20-Smain$main$15 255 | .db 3 256 | .sleb128 3 257 | .db 1 258 | .db 9 259 | .dw 1+Smain$main$21-Smain$main$20 260 | .db 0 261 | .uleb128 1 262 | .db 1 263 | .db 0 264 | .uleb128 5 265 | .db 2 266 | .dw 0,(Smain$Delay$23) 267 | .db 3 268 | .sleb128 25 269 | .db 1 270 | .db 9 271 | .dw Smain$Delay$25-Smain$Delay$23 272 | .db 3 273 | .sleb128 3 274 | .db 1 275 | .db 9 276 | .dw Smain$Delay$27-Smain$Delay$25 277 | .db 3 278 | .sleb128 2 279 | .db 1 280 | .db 9 281 | .dw Smain$Delay$29-Smain$Delay$27 282 | .db 3 283 | .sleb128 2 284 | .db 1 285 | .db 9 286 | .dw 1+Smain$Delay$30-Smain$Delay$29 287 | .db 0 288 | .uleb128 1 289 | .db 1 290 | Ldebug_line_end: 291 | 292 | .area .debug_loc (NOLOAD) 293 | Ldebug_loc_start: 294 | .dw 0,(Smain$Delay$24) 295 | .dw 0,(Smain$Delay$31) 296 | .dw 2 297 | .db 120 298 | .sleb128 1 299 | .dw 0,0 300 | .dw 0,0 301 | .dw 0,(Smain$main$18) 302 | .dw 0,(Smain$main$22) 303 | .dw 2 304 | .db 120 305 | .sleb128 1 306 | .dw 0,(Smain$main$17) 307 | .dw 0,(Smain$main$18) 308 | .dw 2 309 | .db 120 310 | .sleb128 3 311 | .dw 0,(Smain$main$16) 312 | .dw 0,(Smain$main$17) 313 | .dw 2 314 | .db 120 315 | .sleb128 2 316 | .dw 0,(Smain$main$14) 317 | .dw 0,(Smain$main$16) 318 | .dw 2 319 | .db 120 320 | .sleb128 1 321 | .dw 0,(Smain$main$13) 322 | .dw 0,(Smain$main$14) 323 | .dw 2 324 | .db 120 325 | .sleb128 4 326 | .dw 0,(Smain$main$12) 327 | .dw 0,(Smain$main$13) 328 | .dw 2 329 | .db 120 330 | .sleb128 3 331 | .dw 0,(Smain$main$11) 332 | .dw 0,(Smain$main$12) 333 | .dw 2 334 | .db 120 335 | .sleb128 2 336 | .dw 0,(Smain$main$7) 337 | .dw 0,(Smain$main$11) 338 | .dw 2 339 | .db 120 340 | .sleb128 1 341 | .dw 0,(Smain$main$6) 342 | .dw 0,(Smain$main$7) 343 | .dw 2 344 | .db 120 345 | .sleb128 5 346 | .dw 0,(Smain$main$5) 347 | .dw 0,(Smain$main$6) 348 | .dw 2 349 | .db 120 350 | .sleb128 4 351 | .dw 0,(Smain$main$4) 352 | .dw 0,(Smain$main$5) 353 | .dw 2 354 | .db 120 355 | .sleb128 3 356 | .dw 0,(Smain$main$3) 357 | .dw 0,(Smain$main$4) 358 | .dw 2 359 | .db 120 360 | .sleb128 2 361 | .dw 0,(Smain$main$1) 362 | .dw 0,(Smain$main$3) 363 | .dw 2 364 | .db 120 365 | .sleb128 1 366 | .dw 0,0 367 | .dw 0,0 368 | 369 | .area .debug_abbrev (NOLOAD) 370 | Ldebug_abbrev: 371 | .uleb128 7 372 | .uleb128 5 373 | .db 0 374 | .uleb128 2 375 | .uleb128 10 376 | .uleb128 3 377 | .uleb128 8 378 | .uleb128 73 379 | .uleb128 19 380 | .uleb128 0 381 | .uleb128 0 382 | .uleb128 6 383 | .uleb128 46 384 | .db 1 385 | .uleb128 1 386 | .uleb128 19 387 | .uleb128 3 388 | .uleb128 8 389 | .uleb128 17 390 | .uleb128 1 391 | .uleb128 18 392 | .uleb128 1 393 | .uleb128 63 394 | .uleb128 12 395 | .uleb128 64 396 | .uleb128 6 397 | .uleb128 0 398 | .uleb128 0 399 | .uleb128 5 400 | .uleb128 52 401 | .db 0 402 | .uleb128 2 403 | .uleb128 10 404 | .uleb128 3 405 | .uleb128 8 406 | .uleb128 73 407 | .uleb128 19 408 | .uleb128 0 409 | .uleb128 0 410 | .uleb128 3 411 | .uleb128 46 412 | .db 1 413 | .uleb128 1 414 | .uleb128 19 415 | .uleb128 3 416 | .uleb128 8 417 | .uleb128 17 418 | .uleb128 1 419 | .uleb128 18 420 | .uleb128 1 421 | .uleb128 63 422 | .uleb128 12 423 | .uleb128 64 424 | .uleb128 6 425 | .uleb128 73 426 | .uleb128 19 427 | .uleb128 0 428 | .uleb128 0 429 | .uleb128 1 430 | .uleb128 17 431 | .db 1 432 | .uleb128 3 433 | .uleb128 8 434 | .uleb128 16 435 | .uleb128 6 436 | .uleb128 19 437 | .uleb128 11 438 | .uleb128 37 439 | .uleb128 8 440 | .uleb128 0 441 | .uleb128 0 442 | .uleb128 4 443 | .uleb128 11 444 | .db 0 445 | .uleb128 17 446 | .uleb128 1 447 | .uleb128 18 448 | .uleb128 1 449 | .uleb128 0 450 | .uleb128 0 451 | .uleb128 2 452 | .uleb128 36 453 | .db 0 454 | .uleb128 3 455 | .uleb128 8 456 | .uleb128 11 457 | .uleb128 11 458 | .uleb128 62 459 | .uleb128 11 460 | .uleb128 0 461 | .uleb128 0 462 | .uleb128 0 463 | 464 | .area .debug_info (NOLOAD) 465 | .dw 0,Ldebug_info_end-Ldebug_info_start 466 | Ldebug_info_start: 467 | .dw 2 468 | .dw 0,(Ldebug_abbrev) 469 | .db 4 470 | .uleb128 1 471 | .ascii "./main.c" 472 | .db 0 473 | .dw 0,(Ldebug_line_start+-4) 474 | .db 1 475 | .ascii "SDCC version 3.7.0 #10231" 476 | .db 0 477 | .uleb128 2 478 | .ascii "int" 479 | .db 0 480 | .db 2 481 | .db 5 482 | .uleb128 3 483 | .dw 0,121 484 | .ascii "main" 485 | .db 0 486 | .dw 0,(_main) 487 | .dw 0,(XG$main$0$0+1) 488 | .db 1 489 | .dw 0,(Ldebug_loc_start+20) 490 | .dw 0,52 491 | .uleb128 4 492 | .dw 0,(Smain$main$9) 493 | .dw 0,(Smain$main$19) 494 | .uleb128 5 495 | .db 2 496 | .db 145 497 | .sleb128 0 498 | .ascii "i_var" 499 | .db 0 500 | .dw 0,121 501 | .uleb128 5 502 | .db 2 503 | .db 145 504 | .sleb128 0 505 | .ascii "io" 506 | .db 0 507 | .dw 0,121 508 | .uleb128 0 509 | .uleb128 2 510 | .ascii "unsigned char" 511 | .db 0 512 | .db 1 513 | .db 8 514 | .uleb128 6 515 | .dw 0,187 516 | .ascii "Delay" 517 | .db 0 518 | .dw 0,(_Delay) 519 | .dw 0,(XG$Delay$0$0+1) 520 | .db 1 521 | .dw 0,(Ldebug_loc_start) 522 | .uleb128 7 523 | .db 2 524 | .db 145 525 | .sleb128 2 526 | .ascii "nCount" 527 | .db 0 528 | .dw 0,187 529 | .uleb128 4 530 | .dw 0,(Smain$Delay$26) 531 | .dw 0,(Smain$Delay$28) 532 | .uleb128 0 533 | .uleb128 2 534 | .ascii "unsigned int" 535 | .db 0 536 | .db 2 537 | .db 7 538 | .uleb128 0 539 | .uleb128 0 540 | .uleb128 0 541 | Ldebug_info_end: 542 | 543 | .area .debug_pubnames (NOLOAD) 544 | .dw 0,Ldebug_pubnames_end-Ldebug_pubnames_start 545 | Ldebug_pubnames_start: 546 | .dw 2 547 | .dw 0,(Ldebug_info_start-4) 548 | .dw 0,4+Ldebug_info_end-Ldebug_info_start 549 | .dw 0,59 550 | .ascii "main" 551 | .db 0 552 | .dw 0,138 553 | .ascii "Delay" 554 | .db 0 555 | .dw 0,0 556 | Ldebug_pubnames_end: 557 | 558 | .area .debug_frame (NOLOAD) 559 | .dw 0 560 | .dw Ldebug_CIE0_end-Ldebug_CIE0_start 561 | Ldebug_CIE0_start: 562 | .dw 0xffff 563 | .dw 0xffff 564 | .db 1 565 | .db 0 566 | .uleb128 1 567 | .sleb128 -1 568 | .db 9 569 | .db 12 570 | .uleb128 8 571 | .uleb128 2 572 | .db 137 573 | .uleb128 1 574 | Ldebug_CIE0_end: 575 | .dw 0,19 576 | .dw 0,(Ldebug_CIE0_start-4) 577 | .dw 0,(Smain$Delay$24) ;initial loc 578 | .dw 0,Smain$Delay$31-Smain$Delay$24 579 | .db 1 580 | .dw 0,(Smain$Delay$24) 581 | .db 14 582 | .uleb128 2 583 | 584 | .area .debug_frame (NOLOAD) 585 | .dw 0 586 | .dw Ldebug_CIE1_end-Ldebug_CIE1_start 587 | Ldebug_CIE1_start: 588 | .dw 0xffff 589 | .dw 0xffff 590 | .db 1 591 | .db 0 592 | .uleb128 1 593 | .sleb128 -1 594 | .db 9 595 | .db 12 596 | .uleb128 8 597 | .uleb128 2 598 | .db 137 599 | .uleb128 1 600 | Ldebug_CIE1_end: 601 | .dw 0,103 602 | .dw 0,(Ldebug_CIE1_start-4) 603 | .dw 0,(Smain$main$1) ;initial loc 604 | .dw 0,Smain$main$22-Smain$main$1 605 | .db 1 606 | .dw 0,(Smain$main$1) 607 | .db 14 608 | .uleb128 2 609 | .db 1 610 | .dw 0,(Smain$main$3) 611 | .db 14 612 | .uleb128 3 613 | .db 1 614 | .dw 0,(Smain$main$4) 615 | .db 14 616 | .uleb128 4 617 | .db 1 618 | .dw 0,(Smain$main$5) 619 | .db 14 620 | .uleb128 5 621 | .db 1 622 | .dw 0,(Smain$main$6) 623 | .db 14 624 | .uleb128 6 625 | .db 1 626 | .dw 0,(Smain$main$7) 627 | .db 14 628 | .uleb128 2 629 | .db 1 630 | .dw 0,(Smain$main$11) 631 | .db 14 632 | .uleb128 3 633 | .db 1 634 | .dw 0,(Smain$main$12) 635 | .db 14 636 | .uleb128 4 637 | .db 1 638 | .dw 0,(Smain$main$13) 639 | .db 14 640 | .uleb128 5 641 | .db 1 642 | .dw 0,(Smain$main$14) 643 | .db 14 644 | .uleb128 2 645 | .db 1 646 | .dw 0,(Smain$main$16) 647 | .db 14 648 | .uleb128 3 649 | .db 1 650 | .dw 0,(Smain$main$17) 651 | .db 14 652 | .uleb128 4 653 | .db 1 654 | .dw 0,(Smain$main$18) 655 | .db 14 656 | .uleb128 2 657 | -------------------------------------------------------------------------------- /STM8_helloworld/build/main.cdb: -------------------------------------------------------------------------------- 1 | L:XG$main$0$0:8048 2 | L:XG$Delay$0$0:8055 3 | L:XG$GPIO_DeInit$0$0:8068 4 | L:XG$GPIO_Init$0$0:80EF 5 | L:XG$GPIO_Write$0$0:80F5 6 | L:XG$GPIO_WriteHigh$0$0:80FC 7 | L:XG$GPIO_WriteLow$0$0:810A 8 | L:XG$GPIO_WriteReverse$0$0:8111 9 | L:XG$GPIO_ReadOutputData$0$0:8115 10 | L:XG$GPIO_ReadInputData$0$0:811A 11 | L:XG$GPIO_ReadInputPin$0$0:8121 12 | L:XG$GPIO_ExternalPullUpConfig$0$0:8141 13 | -------------------------------------------------------------------------------- /STM8_helloworld/build/main.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/STM8_helloworld/build/main.elf -------------------------------------------------------------------------------- /STM8_helloworld/build/main.lk: -------------------------------------------------------------------------------- 1 | -muwx 2 | -E ./build/main.elf 3 | -Y 4 | -y 5 | -b HOME = 0x8000 6 | -b DATA = 0x0001 7 | -b SSEG = 0xffffffff 8 | -k /usr/bin/../share/sdcc/lib/stm8 9 | -k /usr/share/sdcc/lib/stm8 10 | -l stm8 11 | ./build/main.rel 12 | ./build/stm8s_gpio.rel 13 | 14 | -e 15 | -------------------------------------------------------------------------------- /STM8_helloworld/build/main.rel: -------------------------------------------------------------------------------- 1 | ;!FILE ./build/main.asm 2 | XH3 3 | H 11 areas 53 global symbols 4 | M main 5 | O -mstm8 6 | S _GPIO_Init Ref000000 7 | S s_INITIALIZED Ref000000 8 | S l_INITIALIZER Ref000000 9 | S _GPIO_WriteReverse Ref000000 10 | S s_INITIALIZER Ref000000 11 | S .__.ABS. Def000000 12 | S s_GSINIT Ref000000 13 | S l_DATA Ref000000 14 | S s_DATA Ref000000 15 | A _CODE size 0 flags 0 addr 0 16 | A DATA size 0 flags 0 addr 0 17 | A INITIALIZED size 0 flags 0 addr 0 18 | A SSEG size 1 flags 0 addr 0 19 | A DABS size 0 flags 8 addr 0 20 | A HOME size 7 flags 0 addr 0 21 | S A$main$74 Def000004 22 | S A$main$39 Def000000 23 | A GSINIT size 1A flags 0 addr 0 24 | S A$main$50 Def000000 25 | S A$main$60 Def000011 26 | S A$main$51 Def000003 27 | S A$main$61 Def000014 28 | S A$main$62 Def000017 29 | S A$main$53 Def000005 30 | S A$main$63 Def000018 31 | S A$main$54 Def000009 32 | S A$main$55 Def00000A 33 | S A$main$57 Def00000C 34 | S A$main$58 Def00000F 35 | A GSFINAL size 3 flags 0 addr 0 36 | S A$main$67 Def000000 37 | A CODE size 32 flags 0 addr 0 38 | S A$main$101 Def000006 39 | S A$main$120 Def000011 40 | S A$main$131 Def00001A 41 | S A$main$104 Def000008 42 | S A$main$123 Def000013 43 | S A$main$105 Def00000B 44 | S _main Def000000 45 | S A$main$124 Def000016 46 | S A$main$115 Def00000D 47 | S A$main$134 Def00001C 48 | S Smain$main$10 Def00000D 49 | S A$main$162 Def000025 50 | S A$main$135 Def00001F 51 | S Smain$main$20 Def000024 52 | S Smain$main$11 Def00000F 53 | S A$main$118 Def00000F 54 | S Smain$main$21 Def000024 55 | S Smain$main$12 Def000011 56 | S Smain$main$22 Def000025 57 | S Smain$main$13 Def000013 58 | S A$main$174 Def00002D 59 | S A$main$147 Def000024 60 | S A$main$129 Def000018 61 | S Smain$main$14 Def000018 62 | S A$main$166 Def000027 63 | S A$main$139 Def000021 64 | S Smain$main$15 Def000018 65 | S A$main$185 Def000031 66 | S A$main$167 Def000028 67 | S Smain$main$16 Def00001A 68 | S A$main$177 Def00002E 69 | S A$main$168 Def00002A 70 | S Smain$main$17 Def00001C 71 | S Smain$main$18 Def000021 72 | S _Delay Def000025 73 | S Smain$main$19 Def000021 74 | S XG$main$0$0 Def000024 75 | S Smain$Delay$30 Def000031 76 | S Smain$Delay$31 Def000032 77 | S Smain$Delay$23 Def000025 78 | S Smain$Delay$24 Def000025 79 | S Smain$main$0 Def000000 80 | S Smain$Delay$25 Def000025 81 | S Smain$main$1 Def000000 82 | S Smain$Delay$26 Def00002D 83 | S Smain$main$2 Def000000 84 | S Smain$Delay$27 Def00002D 85 | S Smain$main$3 Def000002 86 | S Smain$Delay$28 Def00002E 87 | S Smain$main$4 Def000004 88 | S A$main$93 Def000000 89 | S XG$Delay$0$0 Def000031 90 | S Smain$Delay$29 Def000031 91 | S Smain$main$5 Def000006 92 | S Smain$main$6 Def000008 93 | S Smain$main$7 Def00000D 94 | S A$main$96 Def000002 95 | S Smain$main$8 Def00000D 96 | S Smain$main$9 Def00000D 97 | S A$main$99 Def000004 98 | A INITIALIZER size 0 flags 0 addr 0 99 | A CABS size 0 flags 8 addr 0 100 | A .debug_line size EE flags 100 addr 0 101 | A .debug_loc size B8 flags 100 addr 0 102 | A .debug_abbrev size 5C flags 100 addr 0 103 | A .debug_info size CE flags 100 addr 0 104 | A .debug_pubnames size 25 flags 100 addr 0 105 | A .debug_frame size A6 flags 100 addr 0 106 | T 00 00 00 107 | R 00 00 00 03 108 | T 00 00 00 109 | R 00 00 00 03 110 | T 00 00 00 111 | R 00 00 00 05 112 | T 00 00 00 82 00 00 00 113 | R 00 00 00 05 92 04 00 06 114 | T 00 00 00 115 | R 00 00 00 06 116 | T 00 00 00 117 | R 00 00 00 06 118 | T 00 00 00 AE 00 00 27 07 119 | R 00 00 00 06 02 04 00 07 120 | T 00 00 05 121 | R 00 00 00 06 122 | T 00 00 05 72 4F FF FF 5A 26 F9 123 | R 00 00 00 06 12 05 00 08 124 | T 00 00 0C 125 | R 00 00 00 06 126 | T 00 00 0C AE 00 00 27 09 127 | R 00 00 00 06 02 04 00 02 128 | T 00 00 11 129 | R 00 00 00 06 130 | T 00 00 11 D6 FF FF D7 FF FF 5A 26 F7 131 | R 00 00 00 06 12 04 00 04 12 07 00 01 132 | T 00 00 1A 133 | R 00 00 00 06 134 | T 00 00 00 CC 00 04 135 | R 00 00 00 07 00 04 00 05 136 | T 00 00 04 137 | R 00 00 00 05 138 | T 00 00 04 CC 00 00 139 | R 00 00 00 05 00 04 00 08 140 | T 00 00 00 141 | R 00 00 00 08 142 | T 00 00 00 4B E0 4B 0E 4B 00 4B 50 CD 00 00 5B 04 143 | R 00 00 00 08 02 0C 00 00 144 | T 00 00 0D 145 | R 00 00 00 08 146 | T 00 00 0D 4B 0E 4B 00 4B 50 CD 00 00 5B 03 4B FF 147 | R 00 00 00 08 02 0A 00 03 148 | T 00 00 1A 4B FF CD 00 25 5B 02 CC 00 0D 149 | R 00 00 00 08 00 06 00 08 00 0B 00 08 150 | T 00 00 24 151 | R 00 00 00 08 152 | T 00 00 24 81 153 | R 00 00 00 08 154 | T 00 00 25 155 | R 00 00 00 08 156 | T 00 00 25 1E 03 157 | R 00 00 00 08 158 | T 00 00 27 159 | R 00 00 00 08 160 | T 00 00 27 5D 26 03 CC 00 31 161 | R 00 00 00 08 00 07 00 08 162 | T 00 00 2D 163 | R 00 00 00 08 164 | T 00 00 2D 5A CC 00 27 165 | R 00 00 00 08 00 05 00 08 166 | T 00 00 31 167 | R 00 00 00 08 168 | T 00 00 31 81 169 | R 00 00 00 08 170 | T 00 00 00 00 00 00 EA 171 | R 00 00 00 0B 172 | T 00 00 04 173 | R 00 00 00 0B 174 | T 00 00 04 00 02 00 00 00 94 01 01 FB 0F 0A 00 01 175 | R 00 00 00 0B 176 | T 00 00 11 01 01 01 00 00 00 01 2F 75 73 72 2F 62 177 | R 00 00 00 0B 178 | T 00 00 1E 69 6E 2F 2E 2E 2F 73 68 61 72 65 2F 73 179 | R 00 00 00 0B 180 | T 00 00 2B 64 63 63 2F 69 6E 63 6C 75 64 65 2F 73 181 | R 00 00 00 0B 182 | T 00 00 38 74 6D 38 00 2F 75 73 72 2F 73 68 61 72 183 | R 00 00 00 0B 184 | T 00 00 45 65 2F 73 64 63 63 2F 69 6E 63 6C 75 64 185 | R 00 00 00 0B 186 | T 00 00 52 65 2F 73 74 6D 38 00 2F 75 73 72 2F 62 187 | R 00 00 00 0B 188 | T 00 00 5F 69 6E 2F 2E 2E 2F 73 68 61 72 65 2F 73 189 | R 00 00 00 0B 190 | T 00 00 6C 64 63 63 2F 69 6E 63 6C 75 64 65 00 2F 191 | R 00 00 00 0B 192 | T 00 00 79 75 73 72 2F 73 68 61 72 65 2F 73 64 63 193 | R 00 00 00 0B 194 | T 00 00 86 63 2F 69 6E 63 6C 75 64 65 00 00 2E 2F 195 | R 00 00 00 0B 196 | T 00 00 93 6D 61 69 6E 2E 63 00 00 00 00 00 197 | R 00 00 00 0B 198 | T 00 00 9E 199 | R 00 00 00 0B 200 | T 00 00 9E 00 05 02 00 00 00 00 03 07 01 09 00 00 201 | R 00 00 00 0B 00 08 00 08 202 | T 00 00 AB 03 06 01 09 00 0D 03 02 01 09 00 00 03 203 | R 00 00 00 0B 204 | T 00 00 B8 04 01 09 00 0B 03 01 01 09 00 0C 03 03 205 | R 00 00 00 0B 206 | T 00 00 C5 01 09 00 01 00 01 01 00 05 02 00 00 207 | R 00 00 00 0B 208 | T 00 00 D1 00 25 03 19 01 09 00 00 03 03 01 09 209 | R 00 00 00 0B 00 03 00 08 210 | T 00 00 DD 00 08 03 02 01 09 00 04 03 02 01 09 211 | R 00 00 00 0B 212 | T 00 00 E9 00 01 00 01 01 213 | R 00 00 00 0B 214 | T 00 00 EE 215 | R 00 00 00 0B 216 | T 00 00 00 217 | R 00 00 00 0C 218 | T 00 00 00 00 00 00 25 00 00 00 32 00 02 78 01 219 | R 00 00 00 0C 00 05 00 08 00 09 00 08 220 | T 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 21 221 | R 00 00 00 0C 00 0D 00 08 222 | T 00 00 18 00 00 00 25 00 02 78 01 00 00 00 1C 223 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 224 | T 00 00 24 00 00 00 21 00 02 78 03 00 00 00 1A 225 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 226 | T 00 00 30 00 00 00 1C 00 02 78 02 00 00 00 18 227 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 228 | T 00 00 3C 00 00 00 1A 00 02 78 01 00 00 00 13 229 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 230 | T 00 00 48 00 00 00 18 00 02 78 04 00 00 00 11 231 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 232 | T 00 00 54 00 00 00 13 00 02 78 03 00 00 00 0F 233 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 234 | T 00 00 60 00 00 00 11 00 02 78 02 00 00 00 0D 235 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 236 | T 00 00 6C 00 00 00 0F 00 02 78 01 00 00 00 08 237 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 238 | T 00 00 78 00 00 00 0D 00 02 78 05 00 00 00 06 239 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 240 | T 00 00 84 00 00 00 08 00 02 78 04 00 00 00 04 241 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 242 | T 00 00 90 00 00 00 06 00 02 78 03 00 00 00 02 243 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 244 | T 00 00 9C 00 00 00 04 00 02 78 02 00 00 00 00 245 | R 00 00 00 0C 00 05 00 08 00 0D 00 08 246 | T 00 00 A8 00 00 00 02 00 02 78 01 00 00 00 00 247 | R 00 00 00 0C 00 05 00 08 248 | T 00 00 B4 00 00 00 00 249 | R 00 00 00 0C 250 | T 00 00 00 251 | R 00 00 00 0D 252 | T 00 00 00 07 05 00 02 0A 03 08 49 13 00 00 06 2E 253 | R 00 00 00 0D 254 | T 00 00 0D 01 01 13 03 08 11 01 12 01 3F 0C 40 06 255 | R 00 00 00 0D 256 | T 00 00 1A 00 00 05 34 00 02 0A 03 08 49 13 00 00 257 | R 00 00 00 0D 258 | T 00 00 27 03 2E 01 01 13 03 08 11 01 12 01 3F 0C 259 | R 00 00 00 0D 260 | T 00 00 34 40 06 49 13 00 00 01 11 01 03 08 10 06 261 | R 00 00 00 0D 262 | T 00 00 41 13 0B 25 08 00 00 04 0B 00 11 01 12 01 263 | R 00 00 00 0D 264 | T 00 00 4E 00 00 02 24 00 03 08 0B 0B 3E 0B 00 00 265 | R 00 00 00 0D 266 | T 00 00 5B 00 267 | R 00 00 00 0D 268 | T 00 00 00 00 00 00 CA 269 | R 00 00 00 0E 270 | T 00 00 04 271 | R 00 00 00 0E 272 | T 00 00 04 00 02 00 00 00 00 04 01 2E 2F 6D 61 69 273 | R 00 00 00 0E 00 07 00 0D 274 | T 00 00 11 6E 2E 63 00 00 00 00 00 01 53 44 43 43 275 | R 00 00 00 0E 00 09 00 0B 276 | T 00 00 1E 20 76 65 72 73 69 6F 6E 20 33 2E 37 2E 277 | R 00 00 00 0E 278 | T 00 00 2B 30 20 23 31 30 32 33 31 00 02 69 6E 74 279 | R 00 00 00 0E 280 | T 00 00 38 00 02 05 03 00 00 00 79 6D 61 69 6E 00 281 | R 00 00 00 0E 282 | T 00 00 45 00 00 00 00 00 00 00 25 01 00 00 00 14 283 | R 00 00 00 0E 00 05 00 08 00 09 00 08 00 0E 00 0C 284 | T 00 00 52 00 00 00 34 04 00 00 00 0D 00 00 00 21 285 | R 00 00 00 0E 00 0A 00 08 00 0E 00 08 286 | T 00 00 5F 05 02 91 00 69 5F 76 61 72 00 00 00 287 | R 00 00 00 0E 288 | T 00 00 6B 00 79 05 02 91 00 69 6F 00 00 00 00 79 289 | R 00 00 00 0E 290 | T 00 00 78 00 02 75 6E 73 69 67 6E 65 64 20 63 68 291 | R 00 00 00 0E 292 | T 00 00 85 61 72 00 01 08 06 00 00 00 BB 44 65 6C 293 | R 00 00 00 0E 294 | T 00 00 92 61 79 00 00 00 00 25 00 00 00 32 01 295 | R 00 00 00 0E 00 08 00 08 00 0C 00 08 296 | T 00 00 9E 00 00 00 00 07 02 91 02 6E 43 6F 75 6E 297 | R 00 00 00 0E 00 05 00 0C 298 | T 00 00 AB 74 00 00 00 00 BB 04 00 00 00 2D 00 00 299 | R 00 00 00 0E 00 0C 00 08 300 | T 00 00 B8 00 2E 00 02 75 6E 73 69 67 6E 65 64 20 301 | R 00 00 00 0E 00 03 00 08 302 | T 00 00 C5 69 6E 74 00 02 07 00 00 00 303 | R 00 00 00 0E 304 | T 00 00 CE 305 | R 00 00 00 0E 306 | T 00 00 00 00 00 00 21 307 | R 00 00 00 0F 308 | T 00 00 04 309 | R 00 00 00 0F 310 | T 00 00 04 00 02 00 00 00 00 00 00 00 CE 00 00 311 | R 00 00 00 0F 00 07 00 0E 312 | T 00 00 10 00 3B 6D 61 69 6E 00 00 00 00 8A 44 65 313 | R 00 00 00 0F 314 | T 00 00 1D 6C 61 79 00 00 00 00 00 315 | R 00 00 00 0F 316 | T 00 00 25 317 | R 00 00 00 0F 318 | T 00 00 00 00 00 00 0E 319 | R 00 00 00 10 320 | T 00 00 04 321 | R 00 00 00 10 322 | T 00 00 04 FF FF FF FF 01 00 01 7F 09 0C 08 02 89 323 | R 00 00 00 10 324 | T 00 00 11 01 325 | R 00 00 00 10 326 | T 00 00 12 327 | R 00 00 00 10 328 | T 00 00 12 00 00 00 13 00 00 00 00 00 00 00 25 329 | R 00 00 00 10 00 09 00 10 00 0D 00 08 330 | T 00 00 1E 00 00 00 0D 01 00 00 00 25 0E 02 331 | R 00 00 00 10 00 0A 00 08 332 | T 00 00 29 00 00 00 0E 333 | R 00 00 00 10 334 | T 00 00 2D 335 | R 00 00 00 10 336 | T 00 00 2D FF FF FF FF 01 00 01 7F 09 0C 08 02 89 337 | R 00 00 00 10 338 | T 00 00 3A 01 339 | R 00 00 00 10 340 | T 00 00 3B 341 | R 00 00 00 10 342 | T 00 00 3B 00 00 00 67 00 00 00 29 00 00 00 00 343 | R 00 00 00 10 00 09 00 10 00 0D 00 08 344 | T 00 00 47 00 00 00 25 01 00 00 00 00 0E 02 01 345 | R 00 00 00 10 00 0A 00 08 346 | T 00 00 53 00 00 00 02 0E 03 01 00 00 00 04 0E 04 347 | R 00 00 00 10 00 05 00 08 00 0C 00 08 348 | T 00 00 60 01 00 00 00 06 0E 05 01 00 00 00 08 0E 349 | R 00 00 00 10 00 06 00 08 00 0D 00 08 350 | T 00 00 6D 06 01 00 00 00 0D 0E 02 01 00 00 00 0F 351 | R 00 00 00 10 00 07 00 08 00 0E 00 08 352 | T 00 00 7A 0E 03 01 00 00 00 11 0E 04 01 00 00 353 | R 00 00 00 10 00 08 00 08 354 | T 00 00 86 00 13 0E 05 01 00 00 00 18 0E 02 01 355 | R 00 00 00 10 00 03 00 08 00 0A 00 08 356 | T 00 00 92 00 00 00 1A 0E 03 01 00 00 00 1C 0E 04 357 | R 00 00 00 10 00 05 00 08 00 0C 00 08 358 | T 00 00 9F 01 00 00 00 21 0E 02 359 | R 00 00 00 10 00 06 00 08 360 | -------------------------------------------------------------------------------- /STM8_helloworld/build/main.sym: -------------------------------------------------------------------------------- 1 | ASxxxx Assembler V02.00 + NoICE + SDCC mods (STMicroelectronics STM8), page 1. 2 | Hexadecimal [24-Bits] 3 | 4 | Symbol Table 5 | 6 | .__.$$$. = 002710 L 7 | .__.ABS. = 000000 G 8 | .__.CPU. = 000000 L 9 | .__.H$L. = 000001 L 10 | 8 A$main$101 000006 GR 11 | 8 A$main$104 000008 GR 12 | 8 A$main$105 00000B GR 13 | 8 A$main$115 00000D GR 14 | 8 A$main$118 00000F GR 15 | 8 A$main$120 000011 GR 16 | 8 A$main$123 000013 GR 17 | 8 A$main$124 000016 GR 18 | 8 A$main$129 000018 GR 19 | 8 A$main$131 00001A GR 20 | 8 A$main$134 00001C GR 21 | 8 A$main$135 00001F GR 22 | 8 A$main$139 000021 GR 23 | 8 A$main$147 000024 GR 24 | 8 A$main$162 000025 GR 25 | 8 A$main$166 000027 GR 26 | 8 A$main$167 000028 GR 27 | 8 A$main$168 00002A GR 28 | 8 A$main$174 00002D GR 29 | 8 A$main$177 00002E GR 30 | 8 A$main$185 000031 GR 31 | 5 A$main$39 000000 GR 32 | 6 A$main$50 000000 GR 33 | 6 A$main$51 000003 GR 34 | 6 A$main$53 000005 GR 35 | 6 A$main$54 000009 GR 36 | 6 A$main$55 00000A GR 37 | 6 A$main$57 00000C GR 38 | 6 A$main$58 00000F GR 39 | 6 A$main$60 000011 GR 40 | 6 A$main$61 000014 GR 41 | 6 A$main$62 000017 GR 42 | 6 A$main$63 000018 GR 43 | 7 A$main$67 000000 GR 44 | 5 A$main$74 000004 GR 45 | 8 A$main$93 000000 GR 46 | 8 A$main$96 000002 GR 47 | 8 A$main$99 000004 GR 48 | 10 Ldebug_CIE0_end 000012 R 49 | 10 Ldebug_CIE0_start 000004 R 50 | 10 Ldebug_CIE1_end 00003B R 51 | 10 Ldebug_CIE1_start 00002D R 52 | D Ldebug_abbrev 000000 R 53 | E Ldebug_info_end 0000CE R 54 | E Ldebug_info_start 000004 R 55 | B Ldebug_line_end 0000EE R 56 | B Ldebug_line_start 000004 R 57 | B Ldebug_line_stmt 00009E R 58 | C Ldebug_loc_start 000000 R 59 | F Ldebug_pubnames_end 000025 R 60 | F Ldebug_pubnames_start 000004 R 61 | ASxxxx Assembler V02.00 + NoICE + SDCC mods (STMicroelectronics STM8), page 2. 62 | Hexadecimal [24-Bits] 63 | 64 | Symbol Table 65 | 66 | 8 Smain$Delay$23 = 000025 GR 67 | 8 Smain$Delay$24 = 000025 GR 68 | 8 Smain$Delay$25 = 000025 GR 69 | 8 Smain$Delay$26 = 00002D GR 70 | 8 Smain$Delay$27 = 00002D GR 71 | 8 Smain$Delay$28 = 00002E GR 72 | 8 Smain$Delay$29 = 000031 GR 73 | 8 Smain$Delay$30 = 000031 GR 74 | 8 Smain$Delay$31 = 000032 GR 75 | 8 Smain$main$0 = 000000 GR 76 | 8 Smain$main$1 = 000000 GR 77 | 8 Smain$main$10 = 00000D GR 78 | 8 Smain$main$11 = 00000F GR 79 | 8 Smain$main$12 = 000011 GR 80 | 8 Smain$main$13 = 000013 GR 81 | 8 Smain$main$14 = 000018 GR 82 | 8 Smain$main$15 = 000018 GR 83 | 8 Smain$main$16 = 00001A GR 84 | 8 Smain$main$17 = 00001C GR 85 | 8 Smain$main$18 = 000021 GR 86 | 8 Smain$main$19 = 000021 GR 87 | 8 Smain$main$2 = 000000 GR 88 | 8 Smain$main$20 = 000024 GR 89 | 8 Smain$main$21 = 000024 GR 90 | 8 Smain$main$22 = 000025 GR 91 | 8 Smain$main$3 = 000002 GR 92 | 8 Smain$main$4 = 000004 GR 93 | 8 Smain$main$5 = 000006 GR 94 | 8 Smain$main$6 = 000008 GR 95 | 8 Smain$main$7 = 00000D GR 96 | 8 Smain$main$8 = 00000D GR 97 | 8 Smain$main$9 = 00000D GR 98 | 8 XG$Delay$0$0 = 000031 GR 99 | 8 XG$main$0$0 = 000024 GR 100 | 8 _Delay 000025 GR 101 | _GPIO_Init ****** GX 102 | _GPIO_WriteReverse ****** GX 103 | 5 __interrupt_vect 000000 R 104 | 6 __sdcc_gs_init_startup 000000 R 105 | 6 __sdcc_init_data 000000 R 106 | 5 __sdcc_program_startup 000004 R 107 | 3 __start__stack 000000 R 108 | 8 _main 000000 GR 109 | l_DATA ****** GX 110 | l_INITIALIZER ****** GX 111 | s_DATA ****** GX 112 | s_GSINIT ****** GX 113 | s_INITIALIZED ****** GX 114 | s_INITIALIZER ****** GX 115 | 116 | 117 | ASxxxx Assembler V02.00 + NoICE + SDCC mods (STMicroelectronics STM8), page 3. 118 | Hexadecimal [24-Bits] 119 | 120 | Area Table 121 | 122 | 0 _CODE size 0 flags 0 123 | 1 DATA size 0 flags 0 124 | 2 INITIALIZED size 0 flags 0 125 | 3 SSEG size 1 flags 0 126 | 4 DABS size 0 flags 8 127 | 5 HOME size 7 flags 0 128 | 6 GSINIT size 1A flags 0 129 | 7 GSFINAL size 3 flags 0 130 | 8 CODE size 32 flags 0 131 | 9 INITIALIZER size 0 flags 0 132 | A CABS size 0 flags 8 133 | B .debug_line size EE flags 100 134 | C .debug_loc size B8 flags 100 135 | D .debug_abbrev size 5C flags 100 136 | E .debug_info size CE flags 100 137 | F .debug_pubnames size 25 flags 100 138 | 10 .debug_frame size A6 flags 100 139 | 140 | -------------------------------------------------------------------------------- /STM8_helloworld/main.c: -------------------------------------------------------------------------------- 1 | #include "stm8s.h" 2 | 3 | #define LED_GPIO_PORT (GPIOA) 4 | #define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1) 5 | 6 | void Delay (uint16_t nCount); 7 | 8 | int main(void) 9 | { 10 | uint8_t i_var = 1; 11 | uint8_t io = 255; 12 | io++; 13 | /* Initialize I/Os in Output Mode */ 14 | GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST); 15 | 16 | while (1) 17 | { 18 | /* Toggles LEDs */ 19 | i_var++; 20 | GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS); 21 | Delay(0xFFFF); 22 | } 23 | 24 | } 25 | 26 | void Delay(uint16_t nCount) 27 | { 28 | /* Decrement nCount value */ 29 | while (nCount != 0) 30 | { 31 | nCount--; 32 | } 33 | } 34 | 35 | #ifdef USE_FULL_ASSERT 36 | 37 | /** 38 | * @brief Reports the name of the source file and the source line number 39 | * where the assert_param error has occurred. 40 | * @param file: pointer to the source file name 41 | * @param line: assert_param error line source number 42 | * @retval None 43 | */ 44 | void assert_failed(uint8_t* file, uint32_t line) 45 | { 46 | /* User can add his own implementation to report the file name and line number, 47 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 48 | 49 | /* Infinite loop */ 50 | while (1) 51 | { 52 | } 53 | } 54 | #endif -------------------------------------------------------------------------------- /STM8_helloworld/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 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H__ 24 | #define __MAIN_H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Private variables ---------------------------------------------------------*/ 28 | /* Exported types ------------------------------------------------------------*/ 29 | /* Private typedef -----------------------------------------------------------*/ 30 | /* Private define ------------------------------------------------------------*/ 31 | /* Private macro -------------------------------------------------------------*/ 32 | /* Exported functions ------------------------------------------------------- */ 33 | 34 | 35 | 36 | #endif /* __MAIN_H__ */ 37 | 38 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ -------------------------------------------------------------------------------- /STM8_helloworld/makefile: -------------------------------------------------------------------------------- 1 | # STM8 device (for supported devices see stm8s.h) 2 | DEVICE =STM8S003 3 | MCU =stm8s003?3 4 | 5 | SDCC =sdcc 6 | 7 | # Add process specific arguments here 8 | CFLAGS =-lstm8 9 | CFLAGS +=-mstm8 10 | CFLAGS +=--opt-code-size 11 | CFLAGS +=--std-sdcc99 12 | CFLAGS +=--nogcse 13 | #CFLAGS +=--vc --debug 14 | 15 | CFLAGS +=--out-fmt-elf 16 | 17 | CFLAGS = -mstm8 --out-fmt-elf --all-callee-saves --debug --verbose --stack-auto --fverbose-asm --float-reent --no-peep 18 | #CFLAGS +=--all-callee-saves 19 | #CFLAGS +=--debug 20 | #CFLAGS +=--verbose 21 | #CFLAGS +=--stack-auto 22 | #CFLAGS +=--fverbose-asm 23 | #CFLAGS +=--float-reent 24 | #CFLAGS +=--no-peep 25 | 26 | SOURCE =main 27 | SOURCE_DIR =. 28 | OUTPUT_DIR =$(SOURCE_DIR)/build 29 | StdPeriph =$(SOURCE_DIR)/STM8S_StdPeriph_Driver 30 | 31 | # Add include paths here 32 | INCLUDEPATH =-I$(SOURCE_DIR)/ 33 | INCLUDEPATH +=-I$(StdPeriph)/inc 34 | 35 | def: compile flash 36 | 37 | all: clean compile_obj compile 38 | 39 | compile: 40 | $(SDCC) $(CFLAGS) $(INCLUDEPATH) -D $(DEVICE) -o $(OUTPUT_DIR)/ $(SOURCE_DIR)/$(SOURCE).c \ 41 | $(OUTPUT_DIR)/stm8s_gpio.rel 42 | # $(OUTPUT_DIR)/stm8s_clk.rel \ 43 | # $(OUTPUT_DIR)/stm8s_tim2.rel \ 44 | # --out-fmt-elf --all-callee-saves --debug --verbose --stack-auto --fverbose-asm --float-reent --no-peep 45 | 46 | compile_obj: 47 | mkdir -p $(OUTPUT_DIR) 48 | $(SDCC) $(CFLAGS) $(INCLUDEPATH) -D $(DEVICE) -o $(OUTPUT_DIR)/ -c $(StdPeriph)/src/stm8s_gpio.c 49 | # $(SDCC) $(CFLAGS) $(INCLUDEPATH) -D $(DEVICE) -o $(OUTPUT_DIR)/ -c $(StdPeriph)/src/stm8s_clk.c 50 | # $(SDCC) $(CFLAGS) $(INCLUDEPATH) -D $(DEVICE) -o $(OUTPUT_DIR)/ -c $(StdPeriph)/src/stm8s_tim2.c 51 | 52 | clean: 53 | rm -Rrf $(OUTPUT_DIR) 54 | 55 | flash: 56 | stm8flash -c stlinkv2 -p $(MCU) -w $(OUTPUT_DIR)/$(SOURCE).elf 57 | 58 | openocd: 59 | openocd -f interface/stlink.cfg -f target/stm8s003.cfg -c "init" -c "reset halt" -------------------------------------------------------------------------------- /STM8_helloworld/stm8s_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_conf.h 4 | * @author MCD Application Team 5 | * @version V2.2.0 6 | * @date 30-September-2014 7 | * @brief This file is used to configure the Library. 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_CONF_H 30 | #define __STM8S_CONF_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /* Uncomment the line below to enable peripheral header file inclusion */ 36 | #if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) ||\ 37 | defined(STM8S903) || defined (STM8AF626x) || defined (STM8AF622x) 38 | #include "stm8s_adc1.h" 39 | #endif /* (STM8S105) ||(STM8S103) || (STM8S903) || (STM8AF626x) || (STM8AF622x) */ 40 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ 41 | defined (STM8AF62Ax) 42 | #include "stm8s_adc2.h" 43 | #endif /* (STM8S208) || (STM8S207) || (STM8AF62Ax) || (STM8AF52Ax) */ 44 | #include "stm8s_awu.h" 45 | #include "stm8s_beep.h" 46 | #if defined (STM8S208) || defined (STM8AF52Ax) 47 | #include "stm8s_can.h" 48 | #endif /* (STM8S208) || (STM8AF52Ax) */ 49 | #include "stm8s_clk.h" 50 | #include "stm8s_exti.h" 51 | #include "stm8s_flash.h" 52 | #include "stm8s_gpio.h" 53 | #include "stm8s_i2c.h" 54 | #include "stm8s_itc.h" 55 | #include "stm8s_iwdg.h" 56 | #include "stm8s_rst.h" 57 | #include "stm8s_spi.h" 58 | #include "stm8s_tim1.h" 59 | #if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ 60 | #include "stm8s_tim2.h" 61 | #endif /* (STM8S903) || (STM8AF622x) */ 62 | #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) ||\ 63 | defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) 64 | #include "stm8s_tim3.h" 65 | #endif /* (STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S105) */ 66 | #if !defined(STM8S903) && !defined(STM8AF622x) /* SDCC patch: see https://github.com/tenbaht/sduino/tree/master/STM8S_StdPeriph_Driver */ 67 | #include "stm8s_tim4.h" 68 | #endif /* (STM8S903) || (STM8AF622x) */ 69 | #if defined(STM8S903) || defined(STM8AF622x) 70 | #include "stm8s_tim5.h" 71 | #include "stm8s_tim6.h" 72 | #endif /* (STM8S903) || (STM8AF622x) */ 73 | #if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) ||defined(STM8S103) ||\ 74 | defined(STM8S003) || defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 75 | #include "stm8s_uart1.h" 76 | #endif /* (STM8S208) || (STM8S207) || (STM8S103) || (STM8S903) || (STM8AF52Ax) || (STM8AF62Ax) */ 77 | #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) 78 | #include "stm8s_uart2.h" 79 | #endif /* (STM8S105) || (STM8AF626x) */ 80 | #if defined(STM8S208) ||defined(STM8S207) || defined(STM8S007) || defined (STM8AF52Ax) ||\ 81 | defined (STM8AF62Ax) 82 | #include "stm8s_uart3.h" 83 | #endif /* STM8S208 || STM8S207 || STM8AF52Ax || STM8AF62Ax */ 84 | #if defined(STM8AF622x) 85 | #include "stm8s_uart4.h" 86 | #endif /* (STM8AF622x) */ 87 | #include "stm8s_wwdg.h" 88 | 89 | /* Exported types ------------------------------------------------------------*/ 90 | /* Exported constants --------------------------------------------------------*/ 91 | /* Uncomment the line below to expanse the "assert_param" macro in the 92 | Standard Peripheral Library drivers code */ 93 | //#define USE_FULL_ASSERT (0) 94 | 95 | /* Exported macro ------------------------------------------------------------*/ 96 | #ifdef USE_FULL_ASSERT 97 | 98 | /** 99 | * @brief The assert_param macro is used for function's parameters check. 100 | * @param expr: If expr is false, it calls assert_failed function 101 | * which reports the name of the source file and the source 102 | * line number of the call that failed. 103 | * If expr is true, it returns no value. 104 | * @retval : None 105 | */ 106 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 107 | /* Exported functions ------------------------------------------------------- */ 108 | void assert_failed(uint8_t* file, uint32_t line); 109 | #else 110 | #define assert_param(expr) ((void)0) 111 | #endif /* USE_FULL_ASSERT */ 112 | 113 | #endif /* __STM8S_CONF_H */ 114 | 115 | 116 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 117 | -------------------------------------------------------------------------------- /STM8_helloworld/stm8s_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm8s_it.h 4 | * @author MCD Application Team 5 | * @version V2.2.0 6 | * @date 30-September-2014 7 | * @brief This file contains the headers of the interrupt handlers 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_IT_H 30 | #define __STM8S_IT_H 31 | 32 | /* Includes ------------------------------------------------------------------*/ 33 | #include "stm8s.h" 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* Exported constants --------------------------------------------------------*/ 37 | /* Exported macro ------------------------------------------------------------*/ 38 | /* Exported functions ------------------------------------------------------- */ 39 | #ifdef _COSMIC_ 40 | void _stext(void); /* RESET startup routine */ 41 | INTERRUPT void NonHandledInterrupt(void); 42 | #endif /* _COSMIC_ */ 43 | 44 | // SDCC patch: requires separate handling for SDCC (see below) 45 | #if !defined(_RAISONANCE_) && !defined(_SDCC_) 46 | INTERRUPT void TRAP_IRQHandler(void); /* TRAP */ 47 | INTERRUPT void TLI_IRQHandler(void); /* TLI */ 48 | INTERRUPT void AWU_IRQHandler(void); /* AWU */ 49 | INTERRUPT void CLK_IRQHandler(void); /* CLOCK */ 50 | INTERRUPT void EXTI_PORTA_IRQHandler(void); /* EXTI PORTA */ 51 | INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */ 52 | INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */ 53 | INTERRUPT void EXTI_PORTD_IRQHandler(void); /* EXTI PORTD */ 54 | INTERRUPT void EXTI_PORTE_IRQHandler(void); /* EXTI PORTE */ 55 | 56 | #if defined(STM8S903) || defined(STM8AF622x) 57 | INTERRUPT void EXTI_PORTF_IRQHandler(void); /* EXTI PORTF */ 58 | #endif /* (STM8S903) || (STM8AF622x) */ 59 | 60 | #if defined (STM8S208) || defined (STM8AF52Ax) 61 | INTERRUPT void CAN_RX_IRQHandler(void); /* CAN RX */ 62 | INTERRUPT void CAN_TX_IRQHandler(void); /* CAN TX/ER/SC */ 63 | #endif /* (STM8S208) || (STM8AF52Ax) */ 64 | 65 | INTERRUPT void SPI_IRQHandler(void); /* SPI */ 66 | INTERRUPT void TIM1_CAP_COM_IRQHandler(void); /* TIM1 CAP/COM */ 67 | INTERRUPT void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void); /* TIM1 UPD/OVF/TRG/BRK */ 68 | 69 | #if defined(STM8S903) || defined(STM8AF622x) 70 | INTERRUPT void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void); /* TIM5 UPD/OVF/BRK/TRG */ 71 | INTERRUPT void TIM5_CAP_COM_IRQHandler(void); /* TIM5 CAP/COM */ 72 | #else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ 73 | INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 UPD/OVF/BRK */ 74 | INTERRUPT void TIM2_CAP_COM_IRQHandler(void); /* TIM2 CAP/COM */ 75 | #endif /* (STM8S903) || (STM8AF622x) */ 76 | 77 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ 78 | defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) 79 | INTERRUPT void TIM3_UPD_OVF_BRK_IRQHandler(void); /* TIM3 UPD/OVF/BRK */ 80 | INTERRUPT void TIM3_CAP_COM_IRQHandler(void); /* TIM3 CAP/COM */ 81 | #endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ 82 | 83 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ 84 | defined(STM8S003) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903) 85 | INTERRUPT void UART1_TX_IRQHandler(void); /* UART1 TX */ 86 | INTERRUPT void UART1_RX_IRQHandler(void); /* UART1 RX */ 87 | #endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) */ 88 | 89 | #if defined (STM8AF622x) 90 | INTERRUPT void UART4_TX_IRQHandler(void); /* UART4 TX */ 91 | INTERRUPT void UART4_RX_IRQHandler(void); /* UART4 RX */ 92 | #endif /* (STM8AF622x) */ 93 | 94 | INTERRUPT void I2C_IRQHandler(void); /* I2C */ 95 | 96 | #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) 97 | INTERRUPT void UART2_RX_IRQHandler(void); /* UART2 RX */ 98 | INTERRUPT void UART2_TX_IRQHandler(void); /* UART2 TX */ 99 | #endif /* (STM8S105) || (STM8AF626x) */ 100 | 101 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 102 | INTERRUPT void UART3_RX_IRQHandler(void); /* UART3 RX */ 103 | INTERRUPT void UART3_TX_IRQHandler(void); /* UART3 TX */ 104 | #endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ 105 | 106 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 107 | INTERRUPT void ADC2_IRQHandler(void); /* ADC2 */ 108 | #else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ 109 | INTERRUPT void ADC1_IRQHandler(void); /* ADC1 */ 110 | #endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ 111 | 112 | #if defined(STM8S903) || defined(STM8AF622x) 113 | INTERRUPT void TIM6_UPD_OVF_TRG_IRQHandler(void); /* TIM6 UPD/OVF/TRG */ 114 | #else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */ 115 | INTERRUPT void TIM4_UPD_OVF_IRQHandler(void); /* TIM4 UPD/OVF */ 116 | #endif /* (STM8S903) || (STM8AF622x) */ 117 | INTERRUPT void EEPROM_EEC_IRQHandler(void); /* EEPROM ECC CORRECTION */ 118 | 119 | 120 | // SDCC patch: __interrupt keyword required after function name --> requires new block 121 | #elif defined (_SDCC_) 122 | 123 | void TRAP_IRQHandler(void) __trap; /* TRAP */ 124 | void TLI_IRQHandler(void) INTERRUPT(0); /* TLI */ 125 | void AWU_IRQHandler(void) INTERRUPT(1); /* AWU */ 126 | void CLK_IRQHandler(void) INTERRUPT(2); /* CLOCK */ 127 | void EXTI_PORTA_IRQHandler(void) INTERRUPT(3); /* EXTI PORTA */ 128 | void EXTI_PORTB_IRQHandler(void) INTERRUPT(4); /* EXTI PORTB */ 129 | void EXTI_PORTC_IRQHandler(void) INTERRUPT(5); /* EXTI PORTC */ 130 | void EXTI_PORTD_IRQHandler(void) INTERRUPT(6); /* EXTI PORTD */ 131 | void EXTI_PORTE_IRQHandler(void) INTERRUPT(7); /* EXTI PORTE */ 132 | 133 | #if defined(STM8S903) || defined(STM8AF622x) 134 | void EXTI_PORTF_IRQHandler(void) INTERRUPT(8); /* EXTI PORTF */ 135 | #endif /* (STM8S903) || (STM8AF622x) */ 136 | 137 | #if defined (STM8S208) || defined (STM8AF52Ax) 138 | void CAN_RX_IRQHandler(void) INTERRUPT(8); /* CAN RX */ 139 | void CAN_TX_IRQHandler(void) INTERRUPT(9); /* CAN TX/ER/SC */ 140 | #endif /* (STM8S208) || (STM8AF52Ax) */ 141 | 142 | void SPI_IRQHandler(void) INTERRUPT(10); /* SPI */ 143 | void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void) INTERRUPT(11); /* TIM1 UPD/OVF/TRG/BRK */ 144 | void TIM1_CAP_COM_IRQHandler(void) INTERRUPT(12); /* TIM1 CAP/COM */ 145 | 146 | #if defined(STM8S903) || defined(STM8AF622x) 147 | void TIM5_UPD_OVF_BRK_TRG_IRQHandler(void) INTERRUPT(13); /* TIM5 UPD/OVF/BRK/TRG */ 148 | void TIM5_CAP_COM_IRQHandler(void) INTERRUPT(14); /* TIM5 CAP/COM */ 149 | #else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ 150 | void TIM2_UPD_OVF_BRK_IRQHandler(void) INTERRUPT(13); /* TIM2 UPD/OVF/BRK */ 151 | void TIM2_CAP_COM_IRQHandler(void) INTERRUPT(14); /* TIM2 CAP/COM */ 152 | #endif /* (STM8S903) || (STM8AF622x) */ 153 | 154 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ 155 | defined(STM8S005) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8AF626x) 156 | void TIM3_UPD_OVF_BRK_IRQHandler(void) INTERRUPT(15); /* TIM3 UPD/OVF/BRK */ 157 | void TIM3_CAP_COM_IRQHandler(void) INTERRUPT(16); /* TIM3 CAP/COM */ 158 | #endif /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8AF52Ax) || (STM8AF62Ax) || (STM8A626x) */ 159 | 160 | #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ 161 | defined(STM8S003) || defined (STM8AF52Ax) || defined (STM8AF62Ax) || defined (STM8S903) 162 | void UART1_TX_IRQHandler(void) INTERRUPT(17); /* UART1 TX */ 163 | void UART1_RX_IRQHandler(void) INTERRUPT(18); /* UART1 RX */ 164 | #endif /* (STM8S208) || (STM8S207) || (STM8S903) || (STM8S103) || (STM8AF52Ax) || (STM8AF62Ax) */ 165 | 166 | #if defined (STM8AF622x) 167 | void UART4_TX_IRQHandler(void) INTERRUPT(17); /* UART4 TX */ 168 | void UART4_RX_IRQHandler(void) INTERRUPT(18); /* UART4 RX */ 169 | #endif /* (STM8AF622x) */ 170 | 171 | void I2C_IRQHandler(void) INTERRUPT(19); /* I2C */ 172 | 173 | #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) 174 | void UART2_TX_IRQHandler(void) INTERRUPT(20); /* UART2 TX */ 175 | void UART2_RX_IRQHandler(void) INTERRUPT(21); /* UART2 RX */ 176 | #endif /* (STM8S105) || (STM8AF626x) */ 177 | 178 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 179 | void UART3_RX_IRQHandler(void) INTERRUPT(20); /* UART3 RX */ 180 | void UART3_TX_IRQHandler(void) INTERRUPT(21); /* UART3 TX */ 181 | #endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ 182 | 183 | #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 184 | void ADC2_IRQHandler(void) INTERRUPT(22); /* ADC2 */ 185 | #else /* (STM8S105) || (STM8S103) || (STM8S903) || (STM8AF622x) */ 186 | void ADC1_IRQHandler(void) INTERRUPT(22); /* ADC1 */ 187 | #endif /* (STM8S207) || (STM8S208) || (STM8AF62Ax) || (STM8AF52Ax) */ 188 | 189 | #if defined(STM8S903) || defined(STM8AF622x) 190 | void TIM6_UPD_OVF_TRG_IRQHandler(void) INTERRUPT(23); /* TIM6 UPD/OVF/TRG */ 191 | #else /* (STM8S208) || (STM8S207) || (STM8S105) || (STM8S103) || (STM8AF62Ax) || (STM8AF52Ax) || (STM8AF626x) */ 192 | void TIM4_UPD_OVF_IRQHandler(void) INTERRUPT(23); /* TIM4 UPD/OVF */ 193 | #endif /* (STM8S903) || (STM8AF622x) */ 194 | void EEPROM_EEC_IRQHandler(void) INTERRUPT(24); /* EEPROM ECC CORRECTION */ 195 | 196 | #endif /* !(_RAISONANCE_) && !(_SDCC_) */ 197 | 198 | #endif /* __STM8S_IT_H */ 199 | 200 | 201 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 202 | -------------------------------------------------------------------------------- /assets/DM00024550.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/DM00024550.pdf -------------------------------------------------------------------------------- /assets/STM8_full-pres.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/STM8_full-pres.pdf -------------------------------------------------------------------------------- /assets/en.stsw-stm8069.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/en.stsw-stm8069.zip -------------------------------------------------------------------------------- /assets/img/STM8S003F3P6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/STM8S003F3P6.jpg -------------------------------------------------------------------------------- /assets/img/debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/debug.png -------------------------------------------------------------------------------- /assets/img/gdb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/gdb.png -------------------------------------------------------------------------------- /assets/img/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/main.png -------------------------------------------------------------------------------- /assets/img/st-link_v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/st-link_v2.png -------------------------------------------------------------------------------- /assets/img/stm8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/stm8.png -------------------------------------------------------------------------------- /assets/img/vscode_ide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hbend1li/stm8_started/b96df02e2342e43a3b1e08564a97dafcebcf377a/assets/img/vscode_ide.png --------------------------------------------------------------------------------