├── .gitignore ├── Debug ├── ota.elf ├── src │ ├── delay.o │ ├── main.o │ ├── FPEC_program.o │ ├── GPIO_program.o │ ├── NVIC_program.o │ ├── OTA_program.o │ ├── RCC_program.o │ ├── STK_program.o │ ├── USART_program.o │ ├── main.d │ ├── delay.d │ ├── RCC_program.d │ ├── STK_program.d │ ├── NVIC_program.d │ ├── FPEC_program.d │ ├── GPIO_program.d │ ├── USART_program.d │ ├── OTA_program.d │ └── subdir.mk ├── system │ └── src │ │ ├── newlib │ │ ├── _sbrk.d │ │ ├── _startup.d │ │ ├── _syscalls.d │ │ ├── _cxx.o │ │ ├── _exit.o │ │ ├── _sbrk.o │ │ ├── assert.o │ │ ├── _startup.o │ │ ├── _syscalls.o │ │ ├── _cxx.d │ │ ├── _exit.d │ │ ├── assert.d │ │ └── subdir.mk │ │ ├── diag │ │ ├── Trace.o │ │ ├── trace_impl.o │ │ ├── Trace.d │ │ ├── subdir.mk │ │ └── trace_impl.d │ │ ├── cmsis │ │ ├── system_stm32f10x.o │ │ ├── vectors_stm32f10x.o │ │ ├── vectors_stm32f10x.d │ │ ├── subdir.mk │ │ └── system_stm32f10x.d │ │ ├── cortexm │ │ ├── _reset_hardware.o │ │ ├── exception_handlers.o │ │ ├── _initialize_hardware.o │ │ ├── subdir.mk │ │ ├── _reset_hardware.d │ │ ├── _initialize_hardware.d │ │ └── exception_handlers.d │ │ └── stm32f1-stdperiph │ │ ├── misc.o │ │ ├── stm32f10x_rcc.o │ │ ├── stm32f10x_gpio.o │ │ ├── subdir.mk │ │ ├── misc.d │ │ ├── stm32f10x_rcc.d │ │ └── stm32f10x_gpio.d ├── objects.mk ├── sources.mk └── makefile ├── ldscripts ├── libs.ld └── mem.ld ├── system ├── src │ ├── stm32f1-stdperiph │ │ ├── README_STDPERIPH.txt │ │ ├── stm32f10x_crc.c │ │ ├── stm32f10x_iwdg.c │ │ ├── stm32f10x_dbgmcu.c │ │ └── stm32f10x_wwdg.c │ ├── cmsis │ │ └── README_DEVICE.txt │ ├── newlib │ │ ├── README.txt │ │ ├── _cxx.cpp │ │ ├── _exit.c │ │ ├── assert.c │ │ └── _sbrk.c │ ├── cortexm │ │ ├── _reset_hardware.c │ │ └── _initialize_hardware.c │ └── diag │ │ └── Trace.c └── include │ ├── stm32f1-stdperiph │ ├── README_STDPERIPH.txt │ ├── stm32f10x_crc.h │ ├── stm32f10x_wwdg.h │ ├── stm32f10x_dbgmcu.h │ ├── stm32f10x_iwdg.h │ ├── stm32f10x_rtc.h │ └── stm32f10x_pwr.h │ ├── cmsis │ ├── README_DEVICE.txt │ ├── cmsis_device.h │ ├── system_stm32f10x.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── core_cmSimd.h │ └── arm_const_structs.h │ ├── cortexm │ └── ExceptionHandlers.h │ ├── diag │ └── Trace.h │ └── arm │ └── semihosting.h ├── .settings ├── ilg.gnuarmeclipse.managedbuild.cross.prefs └── language.settings.xml ├── .vscode └── settings.json ├── include ├── FPEC_config.h ├── OTA_interface.h ├── GPIO_config.h ├── NVIC_config.h ├── USART_config.h ├── BIT_MATH.h ├── OTA_private.h ├── STK_config.h ├── FPEC_interface.h ├── NVIC_private.h ├── OTA_config.h ├── STK_interface.h ├── USART_interface.h ├── STD_TYPES.h ├── STK_private.h ├── FPEC_private.h ├── USART_private.h ├── GPIO_interface.h ├── GPIO_private.h ├── RCC_private.h ├── RCC_config.h ├── NVIC_interface.h ├── stm32f10x_conf.h └── RCC_interface.h ├── src ├── main.c ├── NVIC_program.c ├── USART_program.c ├── STK_program.c ├── FPEC_program.c ├── GPIO_program.c ├── RCC_program.c └── OTA_program.c └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .xml -------------------------------------------------------------------------------- /Debug/ota.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/ota.elf -------------------------------------------------------------------------------- /Debug/src/delay.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/delay.o -------------------------------------------------------------------------------- /Debug/src/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/main.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/_sbrk.d: -------------------------------------------------------------------------------- 1 | system/src/newlib/_sbrk.o: ../system/src/newlib/_sbrk.c 2 | -------------------------------------------------------------------------------- /Debug/system/src/newlib/_startup.d: -------------------------------------------------------------------------------- 1 | system/src/newlib/_startup.o: ../system/src/newlib/_startup.c 2 | -------------------------------------------------------------------------------- /Debug/system/src/newlib/_syscalls.d: -------------------------------------------------------------------------------- 1 | system/src/newlib/_syscalls.o: ../system/src/newlib/_syscalls.c 2 | -------------------------------------------------------------------------------- /Debug/src/FPEC_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/FPEC_program.o -------------------------------------------------------------------------------- /Debug/src/GPIO_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/GPIO_program.o -------------------------------------------------------------------------------- /Debug/src/NVIC_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/NVIC_program.o -------------------------------------------------------------------------------- /Debug/src/OTA_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/OTA_program.o -------------------------------------------------------------------------------- /Debug/src/RCC_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/RCC_program.o -------------------------------------------------------------------------------- /Debug/src/STK_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/STK_program.o -------------------------------------------------------------------------------- /Debug/src/USART_program.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/src/USART_program.o -------------------------------------------------------------------------------- /Debug/src/main.d: -------------------------------------------------------------------------------- 1 | src/main.o: ../src/main.c ../include/OTA_interface.h 2 | 3 | ../include/OTA_interface.h: 4 | -------------------------------------------------------------------------------- /Debug/system/src/diag/Trace.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/diag/Trace.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/_cxx.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/newlib/_cxx.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/_exit.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/newlib/_exit.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/_sbrk.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/newlib/_sbrk.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/assert.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/newlib/assert.o -------------------------------------------------------------------------------- /Debug/system/src/diag/trace_impl.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/diag/trace_impl.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/_startup.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/newlib/_startup.o -------------------------------------------------------------------------------- /Debug/system/src/newlib/_syscalls.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/newlib/_syscalls.o -------------------------------------------------------------------------------- /ldscripts/libs.ld: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Placeholder to list other libraries required by the application. 4 | 5 | GROUP( 6 | ) 7 | 8 | */ 9 | -------------------------------------------------------------------------------- /Debug/system/src/cmsis/system_stm32f10x.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/cmsis/system_stm32f10x.o -------------------------------------------------------------------------------- /Debug/system/src/cmsis/vectors_stm32f10x.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/cmsis/vectors_stm32f10x.o -------------------------------------------------------------------------------- /Debug/system/src/cortexm/_reset_hardware.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/cortexm/_reset_hardware.o -------------------------------------------------------------------------------- /Debug/system/src/stm32f1-stdperiph/misc.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/stm32f1-stdperiph/misc.o -------------------------------------------------------------------------------- /Debug/system/src/cortexm/exception_handlers.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/cortexm/exception_handlers.o -------------------------------------------------------------------------------- /Debug/system/src/cortexm/_initialize_hardware.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/cortexm/_initialize_hardware.o -------------------------------------------------------------------------------- /Debug/system/src/stm32f1-stdperiph/stm32f10x_rcc.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/stm32f1-stdperiph/stm32f10x_rcc.o -------------------------------------------------------------------------------- /Debug/system/src/stm32f1-stdperiph/stm32f10x_gpio.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ota-programmer/ota-stm/HEAD/Debug/system/src/stm32f1-stdperiph/stm32f10x_gpio.o -------------------------------------------------------------------------------- /Debug/system/src/diag/Trace.d: -------------------------------------------------------------------------------- 1 | system/src/diag/Trace.o: ../system/src/diag/Trace.c \ 2 | ../system/include/diag/Trace.h 3 | 4 | ../system/include/diag/Trace.h: 5 | -------------------------------------------------------------------------------- /Debug/system/src/newlib/_cxx.d: -------------------------------------------------------------------------------- 1 | system/src/newlib/_cxx.o: ../system/src/newlib/_cxx.cpp \ 2 | ../system/include/diag/Trace.h 3 | 4 | ../system/include/diag/Trace.h: 5 | -------------------------------------------------------------------------------- /Debug/system/src/newlib/_exit.d: -------------------------------------------------------------------------------- 1 | system/src/newlib/_exit.o: ../system/src/newlib/_exit.c \ 2 | ../system/include/diag/Trace.h 3 | 4 | ../system/include/diag/Trace.h: 5 | -------------------------------------------------------------------------------- /Debug/system/src/newlib/assert.d: -------------------------------------------------------------------------------- 1 | system/src/newlib/assert.o: ../system/src/newlib/assert.c \ 2 | ../system/include/diag/Trace.h 3 | 4 | ../system/include/diag/Trace.h: 5 | -------------------------------------------------------------------------------- /system/src/stm32f1-stdperiph/README_STDPERIPH.txt: -------------------------------------------------------------------------------- 1 | These files are from stsw-stm32054.zip, the folder: 2 | 3 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src 4 | 5 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/README_STDPERIPH.txt: -------------------------------------------------------------------------------- 1 | These files are from stsw-stm32054.zip, the folder: 2 | 3 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc 4 | 5 | -------------------------------------------------------------------------------- /Debug/src/delay.d: -------------------------------------------------------------------------------- 1 | src/delay.o: ../src/delay.c ../include/STD_TYPES.h ../include/delay.h \ 2 | ../include/RCC_interface.h 3 | 4 | ../include/STD_TYPES.h: 5 | 6 | ../include/delay.h: 7 | 8 | ../include/RCC_interface.h: 9 | -------------------------------------------------------------------------------- /Debug/system/src/cmsis/vectors_stm32f10x.d: -------------------------------------------------------------------------------- 1 | system/src/cmsis/vectors_stm32f10x.o: \ 2 | ../system/src/cmsis/vectors_stm32f10x.c \ 3 | ../system/include/cortexm/ExceptionHandlers.h 4 | 5 | ../system/include/cortexm/ExceptionHandlers.h: 6 | -------------------------------------------------------------------------------- /system/src/cmsis/README_DEVICE.txt: -------------------------------------------------------------------------------- 1 | The system_stm32f10x.c file is from stsw-stm32054.zip, the folder: 2 | 3 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x 4 | 5 | The vectors_stm32f10x.c was created to conform to the startup_stm32f10x_xx*.s. -------------------------------------------------------------------------------- /Debug/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := 8 | 9 | -------------------------------------------------------------------------------- /system/include/cmsis/README_DEVICE.txt: -------------------------------------------------------------------------------- 1 | The stm32f10x.h and system_stm32f10x.h files are from stsw-stm32054.zip, 2 | the folder: 3 | 4 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x 5 | 6 | The cmsis_device.h is added for convenience. 7 | 8 | -------------------------------------------------------------------------------- /.settings/ilg.gnuarmeclipse.managedbuild.cross.prefs: -------------------------------------------------------------------------------- 1 | buildTools.path=E\:\\Embedded\\IMT_ARM_Course\\02-Tools\\03-IMT SDK\\IMT_SDK_Win_64\\WinARM\\Build Tools\\2.10-20180103-1919\\bin 2 | eclipse.preferences.version=1 3 | toolchain.path.1287942917=E\:\\Embedded\\IMT_ARM_Course\\02-Tools\\03-IMT SDK\\IMT_SDK_Win_64\\WinARM\\ArmGCC\\bin 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "gpio_interface.h": "c", 4 | "usart_interface.h": "c", 5 | "stk_interface.h": "c", 6 | "ota_interface.h": "c", 7 | "fpec_private.h": "c", 8 | "rcc_interface.h": "c", 9 | "std_types.h": "c", 10 | "nvic_interface.h": "c" 11 | } 12 | } -------------------------------------------------------------------------------- /Debug/src/RCC_program.d: -------------------------------------------------------------------------------- 1 | src/RCC_program.o: ../src/RCC_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/RCC_interface.h \ 3 | ../include/RCC_private.h ../include/RCC_config.h 4 | 5 | ../include/STD_TYPES.h: 6 | 7 | ../include/BIT_MATH.h: 8 | 9 | ../include/RCC_interface.h: 10 | 11 | ../include/RCC_private.h: 12 | 13 | ../include/RCC_config.h: 14 | -------------------------------------------------------------------------------- /Debug/src/STK_program.d: -------------------------------------------------------------------------------- 1 | src/STK_program.o: ../src/STK_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/STK_interface.h \ 3 | ../include/STK_private.h ../include/STK_config.h 4 | 5 | ../include/STD_TYPES.h: 6 | 7 | ../include/BIT_MATH.h: 8 | 9 | ../include/STK_interface.h: 10 | 11 | ../include/STK_private.h: 12 | 13 | ../include/STK_config.h: 14 | -------------------------------------------------------------------------------- /Debug/src/NVIC_program.d: -------------------------------------------------------------------------------- 1 | src/NVIC_program.o: ../src/NVIC_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/NVIC_interface.h \ 3 | ../include/NVIC_private.h ../include/NVIC_config.h 4 | 5 | ../include/STD_TYPES.h: 6 | 7 | ../include/BIT_MATH.h: 8 | 9 | ../include/NVIC_interface.h: 10 | 11 | ../include/NVIC_private.h: 12 | 13 | ../include/NVIC_config.h: 14 | -------------------------------------------------------------------------------- /include/FPEC_config.h: -------------------------------------------------------------------------------- 1 | /******************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Date : Jun 1, 2021 */ 4 | /* Version : V01 */ 5 | /******************************************************/ 6 | 7 | 8 | #ifndef FPEC_CONFIG_H 9 | #define FPEC_CONFIG_H 10 | 11 | 12 | #endif -------------------------------------------------------------------------------- /Debug/src/FPEC_program.d: -------------------------------------------------------------------------------- 1 | src/FPEC_program.o: ../src/FPEC_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/FPEC_interface.h \ 3 | ../include/FPEC_private.h ../include/FPEC_config.h \ 4 | ../include/RCC_interface.h 5 | 6 | ../include/STD_TYPES.h: 7 | 8 | ../include/BIT_MATH.h: 9 | 10 | ../include/FPEC_interface.h: 11 | 12 | ../include/FPEC_private.h: 13 | 14 | ../include/FPEC_config.h: 15 | 16 | ../include/RCC_interface.h: 17 | -------------------------------------------------------------------------------- /Debug/src/GPIO_program.d: -------------------------------------------------------------------------------- 1 | src/GPIO_program.o: ../src/GPIO_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/GPIO_interface.h \ 3 | ../include/GPIO_private.h ../include/GPIO_config.h \ 4 | ../include/RCC_interface.h 5 | 6 | ../include/STD_TYPES.h: 7 | 8 | ../include/BIT_MATH.h: 9 | 10 | ../include/GPIO_interface.h: 11 | 12 | ../include/GPIO_private.h: 13 | 14 | ../include/GPIO_config.h: 15 | 16 | ../include/RCC_interface.h: 17 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /******************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Date : Jun 1, 2021 */ 4 | /* Version : V01 */ 5 | /******************************************************/ 6 | 7 | #include "OTA_interface.h" 8 | 9 | void main (void) { 10 | 11 | OTA_vidInit(); 12 | OTA_vidRun(); 13 | 14 | while (1); 15 | } 16 | -------------------------------------------------------------------------------- /Debug/src/USART_program.d: -------------------------------------------------------------------------------- 1 | src/USART_program.o: ../src/USART_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/USART_interface.h \ 3 | ../include/USART_private.h ../include/USART_config.h \ 4 | ../include/RCC_interface.h 5 | 6 | ../include/STD_TYPES.h: 7 | 8 | ../include/BIT_MATH.h: 9 | 10 | ../include/USART_interface.h: 11 | 12 | ../include/USART_private.h: 13 | 14 | ../include/USART_config.h: 15 | 16 | ../include/RCC_interface.h: 17 | -------------------------------------------------------------------------------- /include/OTA_interface.h: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************/ 3 | /* Author : Ahmed Hassan */ 4 | /* Date : Jun 1, 2021 */ 5 | /* Version : V01 */ 6 | /******************************************************/ 7 | 8 | #ifndef OTA_INTERFACE_H 9 | #define OTA_INTERFACE_H 10 | 11 | void OTA_vidInit (void); 12 | void OTA_vidRun(void); 13 | 14 | #endif -------------------------------------------------------------------------------- /include/GPIO_config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 19, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #ifndef GPIO_CONFIG_H 8 | #define GPIO_CONFIG_H 9 | 10 | #endif -------------------------------------------------------------------------------- /include/NVIC_config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 28, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #ifndef NVIC_CONFIG_H 8 | #define NVIC_CONFIG_H 9 | 10 | 11 | #endif -------------------------------------------------------------------------------- /system/src/newlib/README.txt: -------------------------------------------------------------------------------- 1 | 2 | The following files extend or replace some of the the newlib functionality: 3 | 4 | _startup.c: a customised startup sequence, written in C 5 | 6 | _exit.c: a customised exit() implementation 7 | 8 | _syscalls.c: local versions of the libnosys/librdimon code 9 | 10 | _sbrk.c: a custom _sbrk() to match the actual linker scripts 11 | 12 | assert.c: implementation for the asserion macros 13 | 14 | _cxx.cpp: local versions of some C++ support, to avoid references to 15 | large functions. 16 | 17 | -------------------------------------------------------------------------------- /include/USART_config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Mar 02, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #ifndef USART_CONFIG_H 8 | #define USART_CONFIG_H 9 | 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/BIT_MATH.h: -------------------------------------------------------------------------------- 1 | /******************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Date : Jan 5, 2021 */ 4 | /* Version : V01 */ 5 | /******************************************************/ 6 | #ifndef BIT_MATH_H 7 | #define BIT_MATH_H 8 | #define SET_BIT(VAR,BIT) VAR |= (1 << (BIT)) 9 | #define CLR_BIT(VAR,BIT) VAR &= ~(1 << (BIT)) 10 | #define GET_BIT(VAR,BIT) ((VAR >> BIT) & 1 ) 11 | #define TOG_BIT(VAR,BIT) VAR ^= (1 << (BIT)) 12 | #endif -------------------------------------------------------------------------------- /include/OTA_private.h: -------------------------------------------------------------------------------- 1 | /******************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Date : Jun 1, 2021 */ 4 | /* Version : V01 */ 5 | /******************************************************/ 6 | 7 | #ifndef OTA_PRIVATE_H 8 | #define OTA_PRIVATE_H 9 | 10 | static void OTA_vidParseRecord(); 11 | static void OTA_vidSetHighAddress(void); 12 | static u8 getHex(u8 Copy_u8Asci); 13 | static void OTA_vidCharReceived(u8 rec); 14 | static void OTA_vidRunAppCode(void); 15 | 16 | 17 | #endif -------------------------------------------------------------------------------- /include/STK_config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 30, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef STK_CONFIG_H 7 | #define STK_CONFIG_H 8 | 9 | 10 | /* Options: 11 | MSTK_SRC_AHB 12 | MSTK_SRC_AHB_8 13 | */ 14 | #define STK_CLK_SRC STK_SRC_AHB_8 15 | 16 | 17 | #endif -------------------------------------------------------------------------------- /include/FPEC_interface.h: -------------------------------------------------------------------------------- 1 | /******************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Date : Jun 1, 2021 */ 4 | /* Version : V01 */ 5 | /******************************************************/ 6 | 7 | #ifndef FPEC_INTERFACE_H 8 | #define FPEC_INTERFACE_H 9 | 10 | void FPEC_voidEraseArea(u8 copy_u8StartPage, u8 copy_u8EndPage); 11 | void FPEC_voidFlashPageErase(u8 Copy_u8PageNumber); 12 | void FPEC_voidFlashWrite(u32 Copy_u32Address, u16* Copy_u16Data, u8 Copy_u8Length); 13 | void FPEC_vidEnableClock(void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/NVIC_private.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 28, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #ifndef NVIC_PRIVATE_H 8 | #define NVIC_PRIVATE_H 9 | 10 | #define NVIC_ISER0 *((volatile u32*)(0xE000E100)) 11 | #define NVIC_ISER1 *((volatile u32*)(0xE000E104)) 12 | 13 | #endif -------------------------------------------------------------------------------- /include/OTA_config.h: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************/ 3 | /* Author : Ahmed Hassan */ 4 | /* Date : Jun 1, 2021 */ 5 | /* Version : V01 */ 6 | /******************************************************/ 7 | 8 | #ifndef OTA_CONFIG_H 9 | #define OTA_CONFIG_H 10 | 11 | #define OTA_RECIEVE_TIMEOUT_S 5 12 | 13 | /* To change these values you muct change it too in NodeMCU code*/ 14 | #define OTA_DATA_START_CHAR 'X' 15 | #define OTA_LINE_BREAK_CHAR 'Y' 16 | #define OTA_DATA_END_CHAR 'Z' 17 | #define OTA_READ_CONFIRM_CHAR 'R' 18 | #endif -------------------------------------------------------------------------------- /include/STK_interface.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 30, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef STK_INTERFACE_H 7 | #define STK_INTERFACE_H 8 | 9 | 10 | void STK_vidInit (void); 11 | void STK_vidStopInterval (void); 12 | void STK_vidSetIntervalSingle ( u32 copy_u32Ticks, void (*copy_ptr)(void) ); 13 | 14 | #endif -------------------------------------------------------------------------------- /include/USART_interface.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Mar 02, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #ifndef USART_INTERFACE_H 8 | #define USART_INTERFACE_H 9 | 10 | void USART1_vidInit (void); 11 | void USART1_vidTransmit(u8 data); 12 | void USART1_vidEnableClock(void); 13 | void USART1_vidEnableRecieveInterrupt(void (*copy_ptr)(u8 x)); 14 | void USART1_vidDisableRecieveInterrupt(); 15 | #endif 16 | -------------------------------------------------------------------------------- /Debug/src/OTA_program.d: -------------------------------------------------------------------------------- 1 | src/OTA_program.o: ../src/OTA_program.c ../include/STD_TYPES.h \ 2 | ../include/BIT_MATH.h ../include/OTA_interface.h \ 3 | ../include/OTA_private.h ../include/OTA_config.h \ 4 | ../include/RCC_interface.h ../include/GPIO_interface.h \ 5 | ../include/NVIC_interface.h ../include/STK_interface.h \ 6 | ../include/USART_interface.h ../include/FPEC_interface.h 7 | 8 | ../include/STD_TYPES.h: 9 | 10 | ../include/BIT_MATH.h: 11 | 12 | ../include/OTA_interface.h: 13 | 14 | ../include/OTA_private.h: 15 | 16 | ../include/OTA_config.h: 17 | 18 | ../include/RCC_interface.h: 19 | 20 | ../include/GPIO_interface.h: 21 | 22 | ../include/NVIC_interface.h: 23 | 24 | ../include/STK_interface.h: 25 | 26 | ../include/USART_interface.h: 27 | 28 | ../include/FPEC_interface.h: 29 | -------------------------------------------------------------------------------- /Debug/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | ELF_SRCS := 6 | C_UPPER_SRCS := 7 | CXX_SRCS := 8 | C++_SRCS := 9 | OBJ_SRCS := 10 | CC_SRCS := 11 | ASM_SRCS := 12 | C_SRCS := 13 | CPP_SRCS := 14 | S_UPPER_SRCS := 15 | O_SRCS := 16 | CC_DEPS := 17 | C++_DEPS := 18 | OBJS := 19 | C_UPPER_DEPS := 20 | CXX_DEPS := 21 | SECONDARY_FLASH := 22 | SECONDARY_SIZE := 23 | ASM_DEPS := 24 | S_UPPER_DEPS := 25 | C_DEPS := 26 | CPP_DEPS := 27 | 28 | # Every subdirectory with source files must be described here 29 | SUBDIRS := \ 30 | src \ 31 | system/src/cmsis \ 32 | system/src/cortexm \ 33 | system/src/diag \ 34 | system/src/newlib \ 35 | system/src/stm32f1-stdperiph \ 36 | 37 | -------------------------------------------------------------------------------- /include/STD_TYPES.h: -------------------------------------------------------------------------------- 1 | /******************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Date : Jan 5, 2021 */ 4 | /* Version : V01 */ 5 | /******************************************************/ 6 | #ifndef STD_TYPES_H 7 | #define STD_TYPES_H 8 | typedef signed char s8; 9 | typedef unsigned char u8; 10 | typedef unsigned char boolean; 11 | typedef signed short int s16; 12 | typedef unsigned short int u16; 13 | typedef signed long int s32; 14 | typedef unsigned long int u32; 15 | typedef unsigned long long int u64; 16 | typedef float f32; 17 | typedef double f64; 18 | typedef long double f96; 19 | 20 | #define TRUE 1 21 | #define FALSE 0 22 | #define STD_HIGH 1 23 | #define STD_LOW 0 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/STK_private.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 30, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef STK_PRIVATE_H 7 | #define STK_PRIVATE_H 8 | 9 | 10 | #define STK_CTRL *((volatile u32*)0xE000E010) 11 | #define STK_LOAD *((volatile u32*)0xE000E014) 12 | #define STK_VAL *((volatile u32*)0xE000E018) 13 | #define STK_CALIB *((volatile u32*)0xE000E01C) 14 | 15 | 16 | #define STK_SRC_AHB 0 17 | #define STK_SRC_AHB_8 1 18 | 19 | #define STK_SINGLE_INTERVAL 0 20 | #define STK_PERIOD_INTERVAL 1 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/NVIC_program.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 28, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #include "STD_TYPES.h" 8 | #include "BIT_MATH.h" 9 | 10 | #include "NVIC_interface.h" 11 | #include "NVIC_private.h" 12 | #include "NVIC_config.h" 13 | 14 | 15 | void NVIC_vidEnableInterrupt (u8 copy_u8PeripheralIndex) { 16 | 17 | if (copy_u8PeripheralIndex<=31) { 18 | NVIC_ISER0 = (1<BRR = 0x341; /* Setting up baud rate 9600 */ 21 | SET_BIT((USART1->CR1), 2); /* RX enable */ 22 | SET_BIT((USART1->CR1), 3); /* TX enable */ 23 | SET_BIT((USART1->CR1), 13); /* USART enable */ 24 | USART1->SR = 0; /* Clear status register */ 25 | } 26 | 27 | void USART1_vidEnableRecieveInterrupt(void (*copy_ptr)(u8 x)) 28 | { 29 | USART1_recieveCallback = copy_ptr; 30 | SET_BIT((USART1->CR1), 5); /* Enable Interrupt */ 31 | } 32 | void USART1_vidDisableRecieveInterrupt (void) { 33 | CLR_BIT((USART1->CR1), 5); /* Disable Interrupt */ 34 | } 35 | void USART1_vidTransmit(u8 data) 36 | { 37 | USART1->DR = data; 38 | while ((GET_BIT(USART1->SR, 6)) == 0) 39 | ; /* Wait till transmission is complete */ 40 | } 41 | 42 | void USART1_vidEnableClock(void) 43 | { 44 | RCC_vidEnableClock(RCC_APB2, USART1EN); 45 | } 46 | 47 | void USART1_IRQHandler(void) 48 | { 49 | 50 | if ((GET_BIT(USART1->SR, 5))) 51 | { 52 | /* Callback notification */ 53 | USART1_recieveCallback(USART1->DR); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /include/GPIO_interface.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 19, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef GPIO_INTERFACE_H 7 | #define GPIO_INTERFACE_H 8 | 9 | #define GPIOA 0 10 | #define GPIOB 1 11 | #define GPIOC 2 12 | 13 | #define PIN0 0 14 | #define PIN1 1 15 | #define PIN2 2 16 | #define PIN3 3 17 | #define PIN4 4 18 | #define PIN5 5 19 | #define PIN6 6 20 | #define PIN7 7 21 | #define PIN8 8 22 | #define PIN9 9 23 | #define PIN10 10 24 | #define PIN11 11 25 | #define PIN12 12 26 | #define PIN13 13 27 | #define PIN14 14 28 | #define PIN15 15 29 | 30 | #define INPUT_ANLOG 0b0000 31 | #define INPUT_FLOATING 0b0100 32 | #define INPUT_PULLUP_PULLDOWN 0b1000 33 | 34 | //For Speed 10MHZ 35 | #define OUTPUT_SPEED_10MHZ_PP 0b0001 36 | #define OUTPUT_SPEED_10MHZ_OD 0b0101 37 | #define OUTPUT_SPEED_10MHZ_AFPP 0b1001 38 | #define OUTPUT_SPEED_10MHZ_AFOD 0b1101 39 | 40 | //For Speed 2MHZ 41 | #define OUTPUT_SPEED_2MHZ_PP 0b0010 42 | #define OUTPUT_SPEED_2MHZ_OD 0b0110 43 | #define OUTPUT_SPEED_2MHZ_AFPP 0b1010 44 | #define OUTPUT_SPEED_2MHZ_AFOD 0b1110 45 | 46 | //For Speed 50MHZ 47 | #define OUTPUT_SPEED_50MHZ_PP 0b0011 48 | #define OUTPUT_SPEED_50MHZ_OD 0b0111 49 | #define OUTPUT_SPEED_50MHZ_AFPP 0b1011 50 | #define OUTPUT_SPEED_50MHZ_AFOD 0b1111 51 | 52 | 53 | void GPIO_vidSetPinDirection ( u8 Copy_u8Port, u8 Copy_u8Pin, u8 u8Copy_u8Mode ); 54 | void GPIO_vidEnablePortClock ( u8 Copy_u8Port ); 55 | 56 | #endif -------------------------------------------------------------------------------- /src/STK_program.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 30, 2021 */ 5 | /*********************************************************************************/ 6 | #include "STD_TYPES.h" 7 | #include "BIT_MATH.h" 8 | 9 | #include "STK_interface.h" 10 | #include "STK_private.h" 11 | #include "STK_config.h" 12 | 13 | 14 | static void(*STK_callBack)(void); 15 | 16 | static u8 STK_u8ModeOfInterval; 17 | 18 | void STK_vidInit (void) { 19 | 20 | #if STK_CLK_SRC == STK_SRC_AHB 21 | /* Disable STK - Disable STK Interrupt - Set clock source AHB */ 22 | STK_CTRL = 0x00000004; 23 | 24 | #else 25 | /* Disable STK - Disable STK Interrupt - Set clock source AHB/8 */ 26 | STK_CTRL = 0; 27 | 28 | #endif 29 | } 30 | 31 | void STK_vidSetIntervalSingle ( u32 copy_u32Ticks, void (*copy_ptr)(void) ) { 32 | /* Load ticks to load register */ 33 | STK_LOAD = copy_u32Ticks; 34 | 35 | /* Start Timer */ 36 | SET_BIT(STK_CTRL, 0); 37 | 38 | /* Save CallBack */ 39 | STK_callBack = copy_ptr; 40 | 41 | /* Set Mode to Single */ 42 | STK_u8ModeOfInterval = STK_SINGLE_INTERVAL; 43 | 44 | /* Enable STK Interrupt */ 45 | SET_BIT(STK_CTRL, 1); 46 | } 47 | 48 | void STK_vidStopInterval (void) { 49 | /* Disable STK Interrupt */ 50 | CLR_BIT(STK_CTRL, 1); 51 | 52 | /* Stop Timer */ 53 | CLR_BIT(STK_CTRL, 0); 54 | STK_LOAD = 0; 55 | STK_VAL = 0; 56 | } 57 | 58 | 59 | 60 | void SysTick_Handler (void) { 61 | 62 | if (STK_u8ModeOfInterval == STK_SINGLE_INTERVAL) { 63 | STK_vidStopInterval(); 64 | } 65 | 66 | /* Callback notification */ 67 | STK_callBack(); 68 | 69 | /* Clear interrupt flag */ 70 | (void) GET_BIT(STK_CTRL,16); 71 | } 72 | -------------------------------------------------------------------------------- /src/FPEC_program.c: -------------------------------------------------------------------------------- 1 | #include "STD_TYPES.h" 2 | #include "BIT_MATH.h" 3 | 4 | #include "FPEC_interface.h" 5 | #include "FPEC_private.h" 6 | #include "FPEC_config.h" 7 | 8 | #include "RCC_interface.h" 9 | 10 | 11 | void FPEC_vidEnableClock(void) { 12 | RCC_vidEnableClock(RCC_AHB, FLITFEN); 13 | } 14 | 15 | void FPEC_voidEraseArea(u8 copy_u8StartPage, u8 copy_u8EndPage) 16 | { 17 | u8 i; 18 | 19 | for (i=copy_u8StartPage;iSR,0) == 1); 29 | 30 | /* Check if FPEC is locked or not */ 31 | if ( GET_BIT(FPEC->CR,7) == 1) 32 | { 33 | FPEC -> KEYR = 0x45670123; 34 | FPEC -> KEYR = 0xCDEF89AB; 35 | } 36 | 37 | /* Page Erase Operation */ 38 | SET_BIT(FPEC->CR,1); 39 | 40 | /* Write Page address */ 41 | FPEC->AR = (u32)(Copy_u8PageNumber * 1024) + 0x08000000 ; 42 | 43 | /* Start operation */ 44 | SET_BIT(FPEC->CR,6); 45 | 46 | /* Wait Busy Flag */ 47 | while (GET_BIT(FPEC->SR,0) == 1); 48 | 49 | /* EOP */ 50 | SET_BIT(FPEC->SR,5); 51 | CLR_BIT(FPEC->CR,1); 52 | } 53 | 54 | void FPEC_voidFlashWrite(u32 Copy_u32Address, u16* Copy_u16Data, u8 Copy_u8Length) 55 | { 56 | u8 i; 57 | volatile u16 Temp; 58 | 59 | while (GET_BIT(FPEC->SR,0) == 1); 60 | 61 | /* Check if FPEC is locked or not */ 62 | if ( /* FPEC_CR->BitAccess.LOCK == 1 */ GET_BIT(FPEC->CR,7) == 1 ) 63 | { 64 | FPEC -> KEYR = 0x45670123; 65 | FPEC -> KEYR = 0xCDEF89AB; 66 | } 67 | 68 | 69 | for (i = 0; i< Copy_u8Length; i++) 70 | { 71 | /* Write Flash Programming */ 72 | SET_BIT(FPEC->CR,0); 73 | 74 | /* Half word operation */ 75 | 76 | Temp = Copy_u16Data[i]; 77 | *((volatile u16*)Copy_u32Address) = Temp; 78 | Copy_u32Address += 2 ; 79 | 80 | /* Wait Busy Flag */ 81 | while (GET_BIT(FPEC->SR,0) == 1); 82 | 83 | /* EOP */ 84 | SET_BIT(FPEC->SR,5); 85 | CLR_BIT(FPEC->CR,0); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /include/GPIO_private.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 19, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef GPIO_PRIVATE_H 7 | #define GPIO_PRIVATE_H 8 | 9 | 10 | /* PORTA Registers */ 11 | #define GPIOA_CRL *((volatile u32*)(0x40010800)) 12 | #define GPIOA_CRH *((volatile u32*)(0x40010804)) 13 | #define GPIOA_IDR *((volatile u32*)(0x40010808)) 14 | #define GPIOA_ODR *((volatile u32*)(0x4001080c)) 15 | #define GPIOA_BSRR *((volatile u32*)(0x40010810)) 16 | #define GPIOA_BRR *((volatile u32*)(0x40010814)) 17 | #define GPIOA_LCKR *((volatile u32*)(0x40010818)) 18 | 19 | /* PORTB Registers */ 20 | #define GPIOB_CRL *((volatile u32*)(0x40010C00)) 21 | #define GPIOB_CRH *((volatile u32*)(0x40010C04)) 22 | #define GPIOB_IDR *((volatile u32*)(0x40010C08)) 23 | #define GPIOB_ODR *((volatile u32*)(0x40010C0c)) 24 | #define GPIOB_BSRR *((volatile u32*)(0x40010C10)) 25 | #define GPIOB_BRR *((volatile u32*)(0x40010C14)) 26 | #define GPIOB_LCKR *((volatile u32*)(0x40010C18)) 27 | 28 | /* PORTC Registers */ 29 | #define GPIOC_CRL *((volatile u32*)(0x40011000)) 30 | #define GPIOC_CRH *((volatile u32*)(0x40011004)) 31 | #define GPIOC_IDR *((volatile u32*)(0x40011008)) 32 | #define GPIOC_ODR *((volatile u32*)(0x4001100c)) 33 | #define GPIOC_BSRR *((volatile u32*)(0x40011010)) 34 | #define GPIOC_BRR *((volatile u32*)(0x40011014)) 35 | #define GPIOC_LCKR *((volatile u32*)(0x40011018)) 36 | 37 | 38 | #endif -------------------------------------------------------------------------------- /system/src/cortexm/_reset_hardware.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | #include "cmsis_device.h" 31 | 32 | // ---------------------------------------------------------------------------- 33 | 34 | extern void 35 | __attribute__((noreturn)) 36 | NVIC_SystemReset(void); 37 | 38 | // ---------------------------------------------------------------------------- 39 | 40 | // Forward declarations 41 | 42 | void 43 | __reset_hardware(void); 44 | 45 | // ---------------------------------------------------------------------------- 46 | 47 | // This is the default hardware reset routine; it can be 48 | // redefined in the application for more complex applications. 49 | // 50 | // Called from _exit(). 51 | 52 | void 53 | __attribute__((weak,noreturn)) 54 | __reset_hardware() 55 | { 56 | NVIC_SystemReset(); 57 | } 58 | 59 | // ---------------------------------------------------------------------------- 60 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /include/RCC_private.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V02 */ 4 | /* Date : Feb 19, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef RCC_PRIVATE_H 7 | #define RCC_PRIVATE_H 8 | 9 | 10 | /* Register Definitions */ 11 | #define RCC_CR *((volatile u32*)0x40021000) 12 | #define RCC_CFGR *((volatile u32*)0x40021004) 13 | #define RCC_CIR *((volatile u32*)0x40021008) 14 | #define RCC_APB2RSTR *((volatile u32*)0x4002100C) 15 | #define RCC_APB1RSTR *((volatile u32*)0x40021010) 16 | #define RCC_AHBENR *((volatile u32*)0x40021014) 17 | #define RCC_APB2ENR *((volatile u32*)0x40021018) 18 | #define RCC_APB1ENR *((volatile u32*)0x4002101C) 19 | #define RCC_BDCR *((uvolatileu32*)0x40021020) 20 | #define RCC_CSR *((volatile u32*)0x40021024) 21 | 22 | /* Bits */ 23 | #define HSIRDY 1 24 | #define HSERDY 17 25 | #define PLLRDY 25 26 | #define PLLXTPRE 17 27 | #define PLLSRC 16 28 | 29 | /* Clock Types */ 30 | #define RCC_HSE_CRYSTAL 0 31 | #define RCC_HSE_RC 1 32 | #define RCC_HSI 2 33 | #define RCC_PLL 3 34 | 35 | /* PLL Options */ 36 | #define RCC_PLL_IN_HSI_DIV_2 0 37 | #define RCC_PLL_IN_HSE_DIV_2 1 38 | #define RCC_PLL_IN_HSE 2 39 | 40 | 41 | #define RCC_SYSCLK_DIVIDED_1 0b0001 42 | #define RCC_SYSCLK_DIVIDED_2 0b1000 43 | #define RCC_SYSCLK_DIVIDED_4 0b1001 44 | #define RCC_SYSCLK_DIVIDED_8 0b1010 45 | #define RCC_SYSCLK_DIVIDED_16 0b1011 46 | #define RCC_SYSCLK_DIVIDED_64 0b1100 47 | #define RCC_SYSCLK_DIVIDED_128 0b1101 48 | #define RCC_SYSCLK_DIVIDED_256 0b1110 49 | #define RCC_SYSCLK_DIVIDED_512 0b1111 50 | 51 | #define RCC_HCLK_DIVIDED_1 0b001 52 | #define RCC_HCLK_DIVIDED_2 0b100 53 | #define RCC_HCLK_DIVIDED_4 0b101 54 | #define RCC_HCLK_DIVIDED_8 0b110 55 | #define RCC_HCLK_DIVIDED_16 0b111 56 | 57 | 58 | 59 | 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/RCC_config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V02 */ 4 | /* Date : Feb 19, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef RCC_CONFIG_H 7 | #define RCC_CONFIG_H 8 | 9 | #define RCC_HSI_FREQ 8000000 10 | #define RCC_HSE_FREQ 8000000 11 | 12 | #define RCC_CLOCK_TYPE RCC_HSI 13 | #define RCC_AHB_PRESCALER RCC_SYSCLK_DIVIDED_1 14 | #define RCC_APB1_PRESCALER RCC_HCLK_DIVIDED_1 15 | #define RCC_APB2_PRESCALER RCC_HCLK_DIVIDED_1 16 | 17 | #if RCC_CLOCK_TYPE == RCC_PLL 18 | #define RCC_PLL_INPUT RCC_PLL_IN_HSE_DIV_2 19 | #define RCC_PLL_MUL_VAL 4 20 | #endif 21 | 22 | /* 23 | --> Options for (RCC_CLOCK_TYPE): 24 | RCC_HSE_CRYSTAL 25 | RCC_HSE_RC 26 | RCC_HSI 27 | RCC_PLL 28 | ----------------------------------------------------------------------- 29 | --> Options for (RCC_AHB_PRESCALER): 30 | RCC_SYSCLK_DIVIDED_1 31 | RCC_SYSCLK_DIVIDED_2 32 | RCC_SYSCLK_DIVIDED_4 33 | RCC_SYSCLK_DIVIDED_8 34 | RCC_SYSCLK_DIVIDED_16 35 | RCC_SYSCLK_DIVIDED_64 36 | RCC_SYSCLK_DIVIDED_128 37 | RCC_SYSCLK_DIVIDED_256 38 | RCC_SYSCLK_DIVIDED_512 39 | ----------------------------------------------------------------------- 40 | --> Options for (RCC_APB1_PRESCALER) , (RCC_APB2_PRESCALER): 41 | RCC_HCLK_DIVIDED_1 42 | RCC_HCLK_DIVIDED_2 43 | RCC_HCLK_DIVIDED_4 44 | RCC_HCLK_DIVIDED_8 45 | RCC_HCLK_DIVIDED_16 46 | ----------------------------------------------------------------------- 47 | --> Options for (RCC_PLL_INPUT): 48 | RCC_PLL_IN_HSI_DIV_2 49 | RCC_PLL_IN_HSE_DIV_2 50 | RCC_PLL_IN_HSE 51 | ----------------------------------------------------------------------- 52 | --> Options for (RCC_PLL_MUL_VAL): 53 | 2, 3, 4, ...... , 16 54 | ----------------------------------------------------------------------- 55 | --> Note: 56 | (RCC_PLL_INPUT), (RCC_PLL_MUL_VAL) are used 57 | only if you have PLL as input clock source. 58 | */ 59 | 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /system/include/cmsis/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header 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 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f10x_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F10X_H 34 | #define __SYSTEM_STM32F10X_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F10x_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F10x_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /include/NVIC_interface.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V01 */ 4 | /* Date : Jan 28, 2021 */ 5 | /*********************************************************************************/ 6 | 7 | #ifndef NVIC_INTERFACE_H 8 | #define NVIC_INTERFACE_H 9 | 10 | void NVIC_vidEnableInterrupt ( u8 copy_u8PeripheralIndex ); 11 | 12 | enum { 13 | NVIC_WWDG , 14 | NVIC_PVD , 15 | NVIC_TAMPER , 16 | NVIC_RTC , 17 | NVIC_FLASH , 18 | NVIC_RCC , 19 | NVIC_EXTI0 , 20 | NVIC_EXTI1 , 21 | NVIC_EXTI2 , 22 | NVIC_EXTI3 , 23 | NVIC_EXTI4 , 24 | NVIC_DMA1_Channel1 , 25 | NVIC_DMA1_Channel2 , 26 | NVIC_DMA1_Channel3 , 27 | NVIC_DMA1_Channel4 , 28 | NVIC_DMA1_Channel5 , 29 | NVIC_DMA1_Channel6 , 30 | NVIC_DMA1_Channel7 , 31 | NVIC_ADC1_2 , 32 | NVIC_USB_HP_CAN_TX , 33 | NVIC_USB_LP_CAN_RX0 , 34 | NVIC_CAN_RX1 , 35 | NVIC_CAN_SCE , 36 | NVIC_EXTI9_5 , 37 | NVIC_TIM1_BRK , 38 | NVIC_TIM1_UP , 39 | NVIC_TIM1_TRG_COM , 40 | NVIC_TIM1_CC , 41 | NVIC_TIM2 , 42 | NVIC_TIM3 , 43 | NVIC_TIM4 , 44 | NVIC_I2C1_EV , 45 | NVIC_I2C1_ER , 46 | NVIC_I2C2_EV , 47 | NVIC_I2C2_ER , 48 | NVIC_SPI1 , 49 | NVIC_SPI2 , 50 | NVIC_USART1 , 51 | NVIC_USART2 , 52 | NVIC_USART3 , 53 | NVIC_EXTI15_10 , 54 | NVIC_RTCAlarm , 55 | NVIC_USBWakeup , 56 | NVIC_TIM8_BRK , 57 | NVIC_TIM8_UP , 58 | NVIC_TIM8_TRG_COM , 59 | NVIC_TIM8_CC , 60 | NVIC_ADC3 , 61 | NVIC_FSMC , 62 | NVIC_SDIO , 63 | NVIC_TIM5 , 64 | NVIC_SPI3 , 65 | NVIC_UART4 , 66 | NVIC_UART5 , 67 | NVIC_TIM6 , 68 | NVIC_TIM7 , 69 | NVIC_DMA2_Channel1 , 70 | NVIC_DMA2_Channel2 , 71 | NVIC_DMA2_Channel3 , 72 | NVIC_DMA2_Channel4 , 73 | NVIC_DMA2_Channel4_5 74 | }; 75 | 76 | #endif -------------------------------------------------------------------------------- /system/src/newlib/_cxx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | // These functions are redefined locally, to avoid references to some 31 | // heavy implementations in the standard C++ library. 32 | 33 | // ---------------------------------------------------------------------------- 34 | 35 | #include 36 | #include 37 | #include "diag/Trace.h" 38 | 39 | // ---------------------------------------------------------------------------- 40 | 41 | namespace __gnu_cxx 42 | { 43 | void 44 | __attribute__((noreturn)) 45 | __verbose_terminate_handler(); 46 | 47 | void 48 | __verbose_terminate_handler() 49 | { 50 | trace_puts(__func__); 51 | abort(); 52 | } 53 | } 54 | 55 | // ---------------------------------------------------------------------------- 56 | 57 | extern "C" 58 | { 59 | void 60 | __attribute__((noreturn)) 61 | __cxa_pure_virtual(); 62 | 63 | void 64 | __cxa_pure_virtual() 65 | { 66 | trace_puts(__func__); 67 | abort(); 68 | } 69 | } 70 | 71 | // ---------------------------------------------------------------------------- 72 | 73 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_CRC_H 25 | #define __STM32F10x_CRC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CRC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup CRC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Exported_Macros 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | void CRC_ResetDR(void); 71 | uint32_t CRC_CalcCRC(uint32_t Data); 72 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 73 | uint32_t CRC_GetCRC(void); 74 | void CRC_SetIDRegister(uint8_t IDValue); 75 | uint8_t CRC_GetIDRegister(void); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __STM32F10x_CRC_H */ 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /Debug/system/src/newlib/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../system/src/newlib/_exit.c \ 8 | ../system/src/newlib/_sbrk.c \ 9 | ../system/src/newlib/_startup.c \ 10 | ../system/src/newlib/_syscalls.c \ 11 | ../system/src/newlib/assert.c 12 | 13 | CPP_SRCS += \ 14 | ../system/src/newlib/_cxx.cpp 15 | 16 | OBJS += \ 17 | ./system/src/newlib/_cxx.o \ 18 | ./system/src/newlib/_exit.o \ 19 | ./system/src/newlib/_sbrk.o \ 20 | ./system/src/newlib/_startup.o \ 21 | ./system/src/newlib/_syscalls.o \ 22 | ./system/src/newlib/assert.o 23 | 24 | C_DEPS += \ 25 | ./system/src/newlib/_exit.d \ 26 | ./system/src/newlib/_sbrk.d \ 27 | ./system/src/newlib/_startup.d \ 28 | ./system/src/newlib/_syscalls.d \ 29 | ./system/src/newlib/assert.d 30 | 31 | CPP_DEPS += \ 32 | ./system/src/newlib/_cxx.d 33 | 34 | 35 | # Each subdirectory must supply rules for building sources it contributes 36 | system/src/newlib/%.o: ../system/src/newlib/%.cpp 37 | @echo 'Building file: $<' 38 | @echo 'Invoking: Cross ARM GNU C++ Compiler' 39 | arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -DDEBUG -DUSE_FULL_ASSERT -DTRACE -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<" 40 | @echo 'Finished building: $<' 41 | @echo ' ' 42 | 43 | system/src/newlib/%.o: ../system/src/newlib/%.c 44 | @echo 'Building file: $<' 45 | @echo 'Invoking: Cross ARM GNU C Compiler' 46 | arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -DDEBUG -DUSE_FULL_ASSERT -DTRACE -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<" 47 | @echo 'Finished building: $<' 48 | @echo ' ' 49 | 50 | 51 | -------------------------------------------------------------------------------- /system/src/newlib/_exit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | #include 31 | #include "diag/Trace.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | 35 | #if !defined(DEBUG) 36 | extern void 37 | __attribute__((noreturn)) 38 | __reset_hardware(void); 39 | #endif 40 | 41 | // ---------------------------------------------------------------------------- 42 | 43 | // Forward declaration 44 | 45 | void 46 | _exit(int code); 47 | 48 | // ---------------------------------------------------------------------------- 49 | 50 | // On Release, call the hardware reset procedure. 51 | // On Debug we just enter an infinite loop, to be used as landmark when halting 52 | // the debugger. 53 | // 54 | // It can be redefined in the application, if more functionality 55 | // is required. 56 | 57 | void 58 | __attribute__((weak)) 59 | _exit(int code __attribute__((unused))) 60 | { 61 | #if !defined(DEBUG) 62 | __reset_hardware(); 63 | #endif 64 | 65 | // TODO: write on trace 66 | while (1) 67 | ; 68 | } 69 | 70 | // ---------------------------------------------------------------------------- 71 | 72 | void 73 | __attribute__((weak,noreturn)) 74 | abort(void) 75 | { 76 | trace_puts("abort(), exiting..."); 77 | 78 | _exit(1); 79 | } 80 | 81 | // ---------------------------------------------------------------------------- 82 | -------------------------------------------------------------------------------- /Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include system/src/stm32f1-stdperiph/subdir.mk 12 | -include system/src/newlib/subdir.mk 13 | -include system/src/diag/subdir.mk 14 | -include system/src/cortexm/subdir.mk 15 | -include system/src/cmsis/subdir.mk 16 | -include src/subdir.mk 17 | -include subdir.mk 18 | -include objects.mk 19 | 20 | ifneq ($(MAKECMDGOALS),clean) 21 | ifneq ($(strip $(CC_DEPS)),) 22 | -include $(CC_DEPS) 23 | endif 24 | ifneq ($(strip $(C++_DEPS)),) 25 | -include $(C++_DEPS) 26 | endif 27 | ifneq ($(strip $(C_UPPER_DEPS)),) 28 | -include $(C_UPPER_DEPS) 29 | endif 30 | ifneq ($(strip $(CXX_DEPS)),) 31 | -include $(CXX_DEPS) 32 | endif 33 | ifneq ($(strip $(ASM_DEPS)),) 34 | -include $(ASM_DEPS) 35 | endif 36 | ifneq ($(strip $(S_UPPER_DEPS)),) 37 | -include $(S_UPPER_DEPS) 38 | endif 39 | ifneq ($(strip $(C_DEPS)),) 40 | -include $(C_DEPS) 41 | endif 42 | ifneq ($(strip $(CPP_DEPS)),) 43 | -include $(CPP_DEPS) 44 | endif 45 | endif 46 | 47 | -include ../makefile.defs 48 | 49 | # Add inputs and outputs from these tool invocations to the build variables 50 | SECONDARY_FLASH += \ 51 | ota.hex \ 52 | 53 | SECONDARY_SIZE += \ 54 | ota.siz \ 55 | 56 | 57 | # All Target 58 | all: ota.elf secondary-outputs 59 | 60 | # Tool invocations 61 | ota.elf: $(OBJS) $(USER_OBJS) 62 | @echo 'Building target: $@' 63 | @echo 'Invoking: Cross ARM GNU C++ Linker' 64 | arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"ota.map" --specs=nano.specs -o "ota.elf" $(OBJS) $(USER_OBJS) $(LIBS) 65 | @echo 'Finished building target: $@' 66 | @echo ' ' 67 | 68 | ota.hex: ota.elf 69 | @echo 'Invoking: Cross ARM GNU Create Flash Image' 70 | arm-none-eabi-objcopy -O ihex "ota.elf" "ota.hex" 71 | @echo 'Finished building: $@' 72 | @echo ' ' 73 | 74 | ota.siz: ota.elf 75 | @echo 'Invoking: Cross ARM GNU Print Size' 76 | arm-none-eabi-size --format=berkeley "ota.elf" 77 | @echo 'Finished building: $@' 78 | @echo ' ' 79 | 80 | # Other Targets 81 | clean: 82 | -$(RM) $(CC_DEPS)$(C++_DEPS)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS) ota.elf 83 | -@echo ' ' 84 | 85 | secondary-outputs: $(SECONDARY_FLASH) $(SECONDARY_SIZE) 86 | 87 | .PHONY: all clean dependents 88 | .SECONDARY: 89 | 90 | -include ../makefile.targets 91 | -------------------------------------------------------------------------------- /src/GPIO_program.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V02 */ 4 | /* Date : Jan 19, 2021 */ 5 | /*********************************************************************************/ 6 | #include "STD_TYPES.h" 7 | #include "BIT_MATH.h" 8 | 9 | #include "GPIO_interface.h" 10 | #include "GPIO_private.h" 11 | #include "GPIO_config.h" 12 | 13 | #include "RCC_interface.h" 14 | 15 | void GPIO_vidSetPinDirection (u8 Copy_u8Port, u8 Copy_u8Pin, u8 u8Copy_u8Mode) { 16 | 17 | switch (Copy_u8Port) 18 | { 19 | case GPIOA: 20 | 21 | /* PINS 0...7 (CRL) */ 22 | if (Copy_u8Pin<=7) 23 | { 24 | GPIOA_CRL &= ~ (0xF << (Copy_u8Pin * 4)); 25 | GPIOA_CRL |= (u8Copy_u8Mode << (Copy_u8Pin*4)); 26 | } 27 | 28 | /* PINS 8...15 (CRH) */ 29 | else if (Copy_u8Pin<=15) 30 | { 31 | Copy_u8Pin -= 8; 32 | GPIOA_CRH &= ~ (0xF << (Copy_u8Pin * 4)); 33 | GPIOA_CRH |= (u8Copy_u8Mode << (Copy_u8Pin*4)); 34 | } 35 | 36 | break; 37 | 38 | case GPIOB: 39 | 40 | /* PINS 0...7 (CRL) */ 41 | if (Copy_u8Pin<=7) 42 | { 43 | GPIOB_CRL &= ~ (0xF << (Copy_u8Pin * 4)); 44 | GPIOB_CRL |= (u8Copy_u8Mode << (Copy_u8Pin*4)); 45 | } 46 | 47 | /* PINS 8...15 (CRH) */ 48 | else if (Copy_u8Pin<=15) 49 | { 50 | Copy_u8Pin -= 8; 51 | GPIOB_CRH &= ~ (0xF << (Copy_u8Pin * 4)); 52 | GPIOB_CRH |= (u8Copy_u8Mode << (Copy_u8Pin*4)); 53 | } 54 | 55 | break; 56 | 57 | case GPIOC: 58 | 59 | /* PINS 0...7 (CRL) */ 60 | if (Copy_u8Pin<=7) 61 | { 62 | GPIOC_CRL &= ~ (0xF << (Copy_u8Pin * 4)); 63 | GPIOC_CRL |= (u8Copy_u8Mode << (Copy_u8Pin*4)); 64 | } 65 | 66 | /* PINS 8...15 (CRH) */ 67 | else if (Copy_u8Pin<=15) 68 | { 69 | Copy_u8Pin -= 8; 70 | GPIOC_CRH &= ~ (0xF << (Copy_u8Pin * 4)); 71 | GPIOC_CRH |= (u8Copy_u8Mode << (Copy_u8Pin*4)); 72 | } 73 | 74 | break; 75 | 76 | default: 77 | break; 78 | } 79 | 80 | } 81 | 82 | void GPIO_vidEnablePortClock (u8 Copy_u8Port) { 83 | switch (Copy_u8Port) 84 | { 85 | case GPIOA: 86 | RCC_vidEnableClock(RCC_APB2 , IOPAEN); 87 | break; 88 | case GPIOB: 89 | RCC_vidEnableClock(RCC_APB2 , IOPBEN); 90 | break; 91 | case GPIOC: 92 | RCC_vidEnableClock(RCC_APB2 , IOPCEN); 93 | break; 94 | default: 95 | break; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/RCC_program.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V02 */ 4 | /* Date : Feb 19, 2021 */ 5 | /*********************************************************************************/ 6 | #include "STD_TYPES.h" 7 | #include "BIT_MATH.h" 8 | 9 | #include "RCC_interface.h" 10 | #include "RCC_private.h" 11 | #include "RCC_config.h" 12 | 13 | void RCC_vidInitSysClock(void) 14 | { 15 | #if RCC_CLOCK_TYPE == RCC_HSE_CRYSTAL 16 | RCC_CR = 0x00010000; /* Enable HSE with no bypass : HSEON = 1, HSEBYP = 0 */ 17 | RCC_CFGR = 0x00000001; /* HSE selected as system clock : SW = 01 */ 18 | /*Wait until HSE ready*/ 19 | while (!GET_BIT(RCC_CR, HSERDY)); 20 | 21 | 22 | #elif RCC_CLOCK_TYPE == RCC_HSE_RC 23 | RCC_CR = 0x00050000; /* Enable HSE with bypass : HSEON = 1, HSEBYP = 1 */ 24 | RCC_CFGR = 0x00000001; /* HSE selected as system clock : SW = 01 */ 25 | /*Wait until HSE ready*/ 26 | while (!GET_BIT(RCC_CR, HSERDY)); 27 | 28 | #elif RCC_CLOCK_TYPE == RCC_HSI 29 | RCC_CR = 0x00000081; /* Enable HSI + Trimming = 0 : HSION = 1, HSITRIM = 10000 */ 30 | RCC_CFGR = 0x00000000; /* HSI selected as system clock : SW = 00 */ 31 | /*Wait until HSI ready*/ 32 | while (!GET_BIT(RCC_CR, HSIRDY)); 33 | 34 | #elif RCC_CLOCK_TYPE == RCC_PLL 35 | RCC_CR = 0x00000000; 36 | RCC_CFGR = 0x00000002; /* PLL selected as system clock : SW = 11 */ 37 | RCC_CFGR |= (RCC_PLL_MUL_VAL-2)<<18; /* PLL multiplication factor */ 38 | #if RCC_PLL_INPUT == RCC_PLL_IN_HSI_DIV_2 39 | CLR_BIT(RCC_CFGR, PLLSRC); 40 | #elif RCC_PLL_INPUT == RCC_PLL_IN_HSE_DIV_2 41 | SET_BIT(RCC_CFGR, PLLSRC); 42 | SET_BIT(RCC_CFGR, PLLXTPRE); 43 | #elif RCC_PLL_INPUT == RCC_PLL_IN_HSE 44 | SET_BIT(RCC_CFGR, PLLSRC); 45 | CLR_BIT(RCC_CFGR, PLLXTPRE); 46 | #else 47 | #error("WRONG PLL INPUT") 48 | #endif 49 | RCC_CR = 0x01000000; /* Enable PLL : PLLON = 1*/ 50 | 51 | 52 | #else 53 | #error("WRONG CLOCK TYPE") 54 | #endif 55 | 56 | /* Configure AHB presaler */ 57 | RCC_CFGR |= (RCC_AHB_PRESCALER << 4); 58 | 59 | /* Configure APB1 presaler */ 60 | RCC_CFGR |= (RCC_APB1_PRESCALER << 8); 61 | 62 | /* Configure APB2 presaler */ 63 | RCC_CFGR |= (RCC_APB2_PRESCALER << 11); 64 | 65 | } 66 | 67 | void RCC_vidEnableClock (u8 copy_u8BusId, u8 copy_u8PeriheralId) 68 | { 69 | if (copy_u8PeriheralId <= 31) 70 | { 71 | switch (copy_u8BusId) 72 | { 73 | case RCC_AHB : SET_BIT(RCC_AHBENR ,copy_u8PeriheralId); break; 74 | case RCC_APB1 : SET_BIT(RCC_APB1ENR ,copy_u8PeriheralId); break; 75 | case RCC_APB2 : SET_BIT(RCC_APB2ENR ,copy_u8PeriheralId); break; 76 | } 77 | } 78 | 79 | else 80 | { 81 | /* Return Error */ 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /system/src/newlib/assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "diag/Trace.h" 33 | 34 | // ---------------------------------------------------------------------------- 35 | 36 | void 37 | __attribute__((noreturn)) 38 | __assert_func (const char *file, int line, const char *func, 39 | const char *failedexpr) 40 | { 41 | trace_printf ("assertion \"%s\" failed: file \"%s\", line %d%s%s\n", 42 | failedexpr, file, line, func ? ", function: " : "", 43 | func ? func : ""); 44 | abort (); 45 | /* NOTREACHED */ 46 | } 47 | 48 | // ---------------------------------------------------------------------------- 49 | 50 | // This is STM32 specific, but can be used on other platforms too. 51 | // If you need it, add the following to your application header: 52 | 53 | //#ifdef USE_FULL_ASSERT 54 | //#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 55 | //void assert_failed(uint8_t* file, uint32_t line); 56 | //#else 57 | //#define assert_param(expr) ((void)0) 58 | //#endif // USE_FULL_ASSERT 59 | 60 | #if defined(USE_FULL_ASSERT) 61 | 62 | void 63 | assert_failed (uint8_t* file, uint32_t line); 64 | 65 | // Called from the assert_param() macro, usually defined in the stm32f*_conf.h 66 | void 67 | __attribute__((noreturn, weak)) 68 | assert_failed (uint8_t* file, uint32_t line) 69 | { 70 | trace_printf ("assert_param() failed: file \"%s\", line %d\n", file, line); 71 | abort (); 72 | /* NOTREACHED */ 73 | } 74 | 75 | #endif // defined(USE_FULL_ASSERT) 76 | 77 | // ---------------------------------------------------------------------------- 78 | -------------------------------------------------------------------------------- /system/src/diag/Trace.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | #if defined(TRACE) 31 | 32 | #include 33 | #include 34 | #include "diag/Trace.h" 35 | #include "string.h" 36 | 37 | #ifndef OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE 38 | #define OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE (128) 39 | #endif 40 | 41 | // ---------------------------------------------------------------------------- 42 | 43 | int 44 | trace_printf(const char* format, ...) 45 | { 46 | int ret; 47 | va_list ap; 48 | 49 | va_start (ap, format); 50 | 51 | // TODO: rewrite it to no longer use newlib, it is way too heavy 52 | 53 | static char buf[OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE]; 54 | 55 | // Print to the local buffer 56 | ret = vsnprintf (buf, sizeof(buf), format, ap); 57 | if (ret > 0) 58 | { 59 | // Transfer the buffer to the device 60 | ret = trace_write (buf, (size_t)ret); 61 | } 62 | 63 | va_end (ap); 64 | return ret; 65 | } 66 | 67 | int 68 | trace_puts(const char *s) 69 | { 70 | trace_write(s, strlen(s)); 71 | return trace_write("\n", 1); 72 | } 73 | 74 | int 75 | trace_putchar(int c) 76 | { 77 | trace_write((const char*)&c, 1); 78 | return c; 79 | } 80 | 81 | void 82 | trace_dump_args(int argc, char* argv[]) 83 | { 84 | trace_printf("main(argc=%d, argv=[", argc); 85 | for (int i = 0; i < argc; ++i) 86 | { 87 | if (i != 0) 88 | { 89 | trace_printf(", "); 90 | } 91 | trace_printf("\"%s\"", argv[i]); 92 | } 93 | trace_printf("]);\n"); 94 | } 95 | 96 | // ---------------------------------------------------------------------------- 97 | 98 | #endif // TRACE 99 | -------------------------------------------------------------------------------- /system/src/newlib/_sbrk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | #include 31 | #include 32 | 33 | // ---------------------------------------------------------------------------- 34 | 35 | caddr_t 36 | _sbrk(int incr); 37 | 38 | // ---------------------------------------------------------------------------- 39 | 40 | // The definitions used here should be kept in sync with the 41 | // stack definitions in the linker script. 42 | 43 | caddr_t 44 | _sbrk(int incr) 45 | { 46 | extern char _Heap_Begin; // Defined by the linker. 47 | extern char _Heap_Limit; // Defined by the linker. 48 | 49 | static char* current_heap_end; 50 | char* current_block_address; 51 | 52 | if (current_heap_end == 0) 53 | { 54 | current_heap_end = &_Heap_Begin; 55 | } 56 | 57 | current_block_address = current_heap_end; 58 | 59 | // Need to align heap to word boundary, else will get 60 | // hard faults on Cortex-M0. So we assume that heap starts on 61 | // word boundary, hence make sure we always add a multiple of 62 | // 4 to it. 63 | incr = (incr + 3) & (~3); // align value to 4 64 | if (current_heap_end + incr > &_Heap_Limit) 65 | { 66 | // Some of the libstdc++-v3 tests rely upon detecting 67 | // out of memory errors, so do not abort here. 68 | #if 0 69 | extern void abort (void); 70 | 71 | _write (1, "_sbrk: Heap and stack collision\n", 32); 72 | 73 | abort (); 74 | #else 75 | // Heap has overflowed 76 | errno = ENOMEM; 77 | return (caddr_t) - 1; 78 | #endif 79 | } 80 | 81 | current_heap_end += incr; 82 | 83 | return (caddr_t) current_block_address; 84 | } 85 | 86 | // ---------------------------------------------------------------------------- 87 | 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Over-The-Air Programmer (OTA Programmer) 2 | Over-the-air programming (OTA programming) refers to various methods of distributing new software, configuration settings, and even updating encryption keys to devices like mobile phones, set-top boxes, electric cars. 3 | This project is implemented to program BlueBill Board (STM32 Micro-controller) over the air using a website connected to a cloud database (Firebase) and NodeMCU board to get the code from internet for sending it to STM to write it to the Flash Memory using the Bootloader flashed on the first 8 kB of Flash Memory. 4 | ## ‣ Circuit Diagram 5 | ![Circuit Diagram](https://ota-programmer.github.io/diagram.jpg) 6 | 7 | 8 | ## ‣ The project is divided into three mini-projects 9 | 10 | ### 1. Website 11 | The website is responsible for letting the user upload a ```.hex``` file to a cloud database (Firebase) to be ready to be received by NodeMCU. 12 | The website only allows ```.hex``` to be uploaded, it also have some ```.hex``` file examples to let the user test the project. 13 | Examples are 14 | - ```.hex``` file to only erase the application area in Flash memory. 15 | - ```.hex``` file to blink the leds connected to pin A0,A1,A2 every 0.5 second. 16 | - ```.hex``` file to left-shift two leeds connected to pin A0,A1,A2 every 0.5 second. 17 | - ```.hex``` file to right-shift two leeds connected to pin A0,A1,A2 every 0.5 second. 18 | 19 | The website also allows the user to vheck if NodeMCU is connected to Internet. 20 | ### 2. NodeMCU 21 | Once a new ```.hex``` file is uploaded to Firebase, NodeMCU reads its content to try sending it line by line to STM through UART. 22 | NodeMCU code has a ```config.h``` file to let the user choose the following 23 | - UART Baudrate. 24 | - Wi-Fi SSID and Password. 25 | - The timeout interval of trying to connect to Wi-Fi. 26 | 27 | ### 3. STM 28 | On reset, STM Bootloader waits for 5 seconds if there is any code received from NodeMCU. If any, it will first erase the application area and then flash the code received. Once it finished, it will run the application code. 29 | If no code received from NodeMCU for 5 seconds, it will jump to latest flashed application code. 30 | 31 | ## ‣ Future Improvements 32 | - Let the user upload multiple application files, and choose which application to run. 33 | - Impove how STM receives the code, instead of waiting 5 seconds on every reset. 34 | 35 | 36 | ## ‣ Programming Languages 37 | ``` sh 38 | C, C++, HTML, CSS, JavaScript. 39 | ``` 40 | ## ‣ Hardware Required 41 | - NodeMCU V1.0 Board 42 | - BlueBill Board 43 | 44 | 45 | ## ‣ Links 46 | - The source code of all project can be found on this [GitHub Organization](https://github.com/ota-programmer). 47 | - The website for uploading the ```.hex``` file can be found on this [link](https://ota-programmer.github.io). 48 | 49 | ## ‣ Video: 50 | A video illustrating the project can be found on this youtube video. 51 | 52 | [![Video](https://securityweekly.com/wp-content/uploads/2021/03/youtube-logo2-1.jpeg)](https://www.youtube.com/watch?v=N_zM7etQvOw) 53 | 54 | ## ‣ Developer 55 | This project is developed by [Ahmed Hassan](https://ahmed-hassann.github.io/). 56 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_WWDG_H 25 | #define __STM32F10x_WWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup WWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup WWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Exported_Macros 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup WWDG_Exported_Functions 85 | * @{ 86 | */ 87 | 88 | void WWDG_DeInit(void); 89 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 90 | void WWDG_SetWindowValue(uint8_t WindowValue); 91 | void WWDG_EnableIT(void); 92 | void WWDG_SetCounter(uint8_t Counter); 93 | void WWDG_Enable(uint8_t Counter); 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F10x_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /Debug/system/src/cmsis/system_stm32f10x.d: -------------------------------------------------------------------------------- 1 | system/src/cmsis/system_stm32f10x.o: \ 2 | ../system/src/cmsis/system_stm32f10x.c \ 3 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 4 | ../system/include/cmsis/core_cmInstr.h \ 5 | ../system/include/cmsis/cmsis_gcc.h \ 6 | ../system/include/cmsis/core_cmFunc.h \ 7 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 8 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 9 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 10 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 30 | ../system/include/stm32f1-stdperiph/misc.h 31 | 32 | ../system/include/cmsis/stm32f10x.h: 33 | 34 | ../system/include/cmsis/core_cm3.h: 35 | 36 | ../system/include/cmsis/core_cmInstr.h: 37 | 38 | ../system/include/cmsis/cmsis_gcc.h: 39 | 40 | ../system/include/cmsis/core_cmFunc.h: 41 | 42 | ../system/include/cmsis/system_stm32f10x.h: 43 | 44 | ../include/stm32f10x_conf.h: 45 | 46 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 47 | 48 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 51 | 52 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 89 | 90 | ../system/include/stm32f1-stdperiph/misc.h: 91 | -------------------------------------------------------------------------------- /Debug/system/src/stm32f1-stdperiph/misc.d: -------------------------------------------------------------------------------- 1 | system/src/stm32f1-stdperiph/misc.o: \ 2 | ../system/src/stm32f1-stdperiph/misc.c \ 3 | ../system/include/stm32f1-stdperiph/misc.h \ 4 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 5 | ../system/include/cmsis/core_cmInstr.h \ 6 | ../system/include/cmsis/cmsis_gcc.h \ 7 | ../system/include/cmsis/core_cmFunc.h \ 8 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 9 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 10 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 30 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h 31 | 32 | ../system/include/stm32f1-stdperiph/misc.h: 33 | 34 | ../system/include/cmsis/stm32f10x.h: 35 | 36 | ../system/include/cmsis/core_cm3.h: 37 | 38 | ../system/include/cmsis/core_cmInstr.h: 39 | 40 | ../system/include/cmsis/cmsis_gcc.h: 41 | 42 | ../system/include/cmsis/core_cmFunc.h: 43 | 44 | ../system/include/cmsis/system_stm32f10x.h: 45 | 46 | ../include/stm32f10x_conf.h: 47 | 48 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 51 | 52 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 89 | 90 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 91 | -------------------------------------------------------------------------------- /include/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Library configuration 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 __STM32F10x_CONF_H 24 | #define __STM32F10x_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ 28 | #include "stm32f10x_adc.h" 29 | #include "stm32f10x_bkp.h" 30 | #include "stm32f10x_can.h" 31 | #include "stm32f10x_cec.h" 32 | #include "stm32f10x_crc.h" 33 | #include "stm32f10x_dac.h" 34 | #include "stm32f10x_dbgmcu.h" 35 | #include "stm32f10x_dma.h" 36 | #include "stm32f10x_exti.h" 37 | #include "stm32f10x_flash.h" 38 | #include "stm32f10x_fsmc.h" 39 | #include "stm32f10x_gpio.h" 40 | #include "stm32f10x_i2c.h" 41 | #include "stm32f10x_iwdg.h" 42 | #include "stm32f10x_pwr.h" 43 | #include "stm32f10x_rcc.h" 44 | #include "stm32f10x_rtc.h" 45 | #include "stm32f10x_sdio.h" 46 | #include "stm32f10x_spi.h" 47 | #include "stm32f10x_tim.h" 48 | #include "stm32f10x_usart.h" 49 | #include "stm32f10x_wwdg.h" 50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | /* Exported constants --------------------------------------------------------*/ 54 | /* Uncomment the line below to expanse the "assert_param" macro in the 55 | Standard Peripheral Library drivers code */ 56 | /* #define USE_FULL_ASSERT 1 */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #ifdef USE_FULL_ASSERT 60 | 61 | /** 62 | * @brief The assert_param macro is used for function's parameters check. 63 | * @param expr: If expr is false, it calls assert_failed function which reports 64 | * the name of the source file and the source line number of the call 65 | * that failed. If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | //#define VECT_TAB_SRAM 76 | 77 | #endif /* __STM32F10x_CONF_H */ 78 | 79 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /Debug/system/src/stm32f1-stdperiph/stm32f10x_rcc.d: -------------------------------------------------------------------------------- 1 | system/src/stm32f1-stdperiph/stm32f10x_rcc.o: \ 2 | ../system/src/stm32f1-stdperiph/stm32f10x_rcc.c \ 3 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 4 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 5 | ../system/include/cmsis/core_cmInstr.h \ 6 | ../system/include/cmsis/cmsis_gcc.h \ 7 | ../system/include/cmsis/core_cmFunc.h \ 8 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 9 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 10 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 30 | ../system/include/stm32f1-stdperiph/misc.h 31 | 32 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 33 | 34 | ../system/include/cmsis/stm32f10x.h: 35 | 36 | ../system/include/cmsis/core_cm3.h: 37 | 38 | ../system/include/cmsis/core_cmInstr.h: 39 | 40 | ../system/include/cmsis/cmsis_gcc.h: 41 | 42 | ../system/include/cmsis/core_cmFunc.h: 43 | 44 | ../system/include/cmsis/system_stm32f10x.h: 45 | 46 | ../include/stm32f10x_conf.h: 47 | 48 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 51 | 52 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 89 | 90 | ../system/include/stm32f1-stdperiph/misc.h: 91 | -------------------------------------------------------------------------------- /Debug/system/src/stm32f1-stdperiph/stm32f10x_gpio.d: -------------------------------------------------------------------------------- 1 | system/src/stm32f1-stdperiph/stm32f10x_gpio.o: \ 2 | ../system/src/stm32f1-stdperiph/stm32f10x_gpio.c \ 3 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 4 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 5 | ../system/include/cmsis/core_cmInstr.h \ 6 | ../system/include/cmsis/cmsis_gcc.h \ 7 | ../system/include/cmsis/core_cmFunc.h \ 8 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 9 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 10 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 30 | ../system/include/stm32f1-stdperiph/misc.h 31 | 32 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 33 | 34 | ../system/include/cmsis/stm32f10x.h: 35 | 36 | ../system/include/cmsis/core_cm3.h: 37 | 38 | ../system/include/cmsis/core_cmInstr.h: 39 | 40 | ../system/include/cmsis/cmsis_gcc.h: 41 | 42 | ../system/include/cmsis/core_cmFunc.h: 43 | 44 | ../system/include/cmsis/system_stm32f10x.h: 45 | 46 | ../include/stm32f10x_conf.h: 47 | 48 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 51 | 52 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 89 | 90 | ../system/include/stm32f1-stdperiph/misc.h: 91 | -------------------------------------------------------------------------------- /Debug/system/src/cortexm/_reset_hardware.d: -------------------------------------------------------------------------------- 1 | system/src/cortexm/_reset_hardware.o: \ 2 | ../system/src/cortexm/_reset_hardware.c \ 3 | ../system/include/cmsis/cmsis_device.h \ 4 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 5 | ../system/include/cmsis/core_cmInstr.h \ 6 | ../system/include/cmsis/cmsis_gcc.h \ 7 | ../system/include/cmsis/core_cmFunc.h \ 8 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 9 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 10 | ../system/include/cmsis/stm32f10x.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 30 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 31 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 32 | ../system/include/stm32f1-stdperiph/misc.h 33 | 34 | ../system/include/cmsis/cmsis_device.h: 35 | 36 | ../system/include/cmsis/stm32f10x.h: 37 | 38 | ../system/include/cmsis/core_cm3.h: 39 | 40 | ../system/include/cmsis/core_cmInstr.h: 41 | 42 | ../system/include/cmsis/cmsis_gcc.h: 43 | 44 | ../system/include/cmsis/core_cmFunc.h: 45 | 46 | ../system/include/cmsis/system_stm32f10x.h: 47 | 48 | ../include/stm32f10x_conf.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 51 | 52 | ../system/include/cmsis/stm32f10x.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 89 | 90 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 91 | 92 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 93 | 94 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 95 | 96 | ../system/include/stm32f1-stdperiph/misc.h: 97 | -------------------------------------------------------------------------------- /Debug/system/src/cortexm/_initialize_hardware.d: -------------------------------------------------------------------------------- 1 | system/src/cortexm/_initialize_hardware.o: \ 2 | ../system/src/cortexm/_initialize_hardware.c \ 3 | ../system/include/cmsis/cmsis_device.h \ 4 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 5 | ../system/include/cmsis/core_cmInstr.h \ 6 | ../system/include/cmsis/cmsis_gcc.h \ 7 | ../system/include/cmsis/core_cmFunc.h \ 8 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 9 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 10 | ../system/include/cmsis/stm32f10x.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 30 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 31 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 32 | ../system/include/stm32f1-stdperiph/misc.h 33 | 34 | ../system/include/cmsis/cmsis_device.h: 35 | 36 | ../system/include/cmsis/stm32f10x.h: 37 | 38 | ../system/include/cmsis/core_cm3.h: 39 | 40 | ../system/include/cmsis/core_cmInstr.h: 41 | 42 | ../system/include/cmsis/cmsis_gcc.h: 43 | 44 | ../system/include/cmsis/core_cmFunc.h: 45 | 46 | ../system/include/cmsis/system_stm32f10x.h: 47 | 48 | ../include/stm32f10x_conf.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 51 | 52 | ../system/include/cmsis/stm32f10x.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 89 | 90 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 91 | 92 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 93 | 94 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 95 | 96 | ../system/include/stm32f1-stdperiph/misc.h: 97 | -------------------------------------------------------------------------------- /system/include/cmsis/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /system/include/cortexm/ExceptionHandlers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | #ifndef CORTEXM_EXCEPTION_HANDLERS_H_ 29 | #define CORTEXM_EXCEPTION_HANDLERS_H_ 30 | 31 | #include 32 | 33 | #if defined(DEBUG) 34 | #define __DEBUG_BKPT() asm volatile ("bkpt 0") 35 | #endif 36 | 37 | // ---------------------------------------------------------------------------- 38 | 39 | #if defined(__cplusplus) 40 | extern "C" 41 | { 42 | #endif 43 | 44 | // External references to cortexm_handlers.c 45 | 46 | extern void 47 | Reset_Handler (void); 48 | extern void 49 | NMI_Handler (void); 50 | extern void 51 | HardFault_Handler (void); 52 | 53 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 54 | extern void 55 | MemManage_Handler (void); 56 | extern void 57 | BusFault_Handler (void); 58 | extern void 59 | UsageFault_Handler (void); 60 | extern void 61 | DebugMon_Handler (void); 62 | #endif 63 | 64 | extern void 65 | SVC_Handler (void); 66 | 67 | extern void 68 | PendSV_Handler (void); 69 | extern void 70 | SysTick_Handler (void); 71 | 72 | // Exception Stack Frame of the Cortex-M3 or Cortex-M4 processor. 73 | typedef struct 74 | { 75 | uint32_t r0; 76 | uint32_t r1; 77 | uint32_t r2; 78 | uint32_t r3; 79 | uint32_t r12; 80 | uint32_t lr; 81 | uint32_t pc; 82 | uint32_t psr; 83 | #if defined(__ARM_ARCH_7EM__) 84 | uint32_t s[16]; 85 | #endif 86 | } ExceptionStackFrame; 87 | 88 | #if defined(TRACE) 89 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 90 | void 91 | dumpExceptionStack (ExceptionStackFrame* frame, uint32_t cfsr, uint32_t mmfar, 92 | uint32_t bfar, uint32_t lr); 93 | #endif // defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 94 | #if defined(__ARM_ARCH_6M__) 95 | void 96 | dumpExceptionStack (ExceptionStackFrame* frame, uint32_t lr); 97 | #endif // defined(__ARM_ARCH_6M__) 98 | #endif // defined(TRACE) 99 | 100 | void 101 | HardFault_Handler_C (ExceptionStackFrame* frame, uint32_t lr); 102 | 103 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 104 | void 105 | UsageFault_Handler_C (ExceptionStackFrame* frame, uint32_t lr); 106 | void 107 | BusFault_Handler_C (ExceptionStackFrame* frame, uint32_t lr); 108 | #endif // defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 109 | 110 | #if defined(__cplusplus) 111 | } 112 | #endif 113 | 114 | // ---------------------------------------------------------------------------- 115 | 116 | #endif // CORTEXM_EXCEPTION_HANDLERS_H_ 117 | -------------------------------------------------------------------------------- /system/include/cmsis/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Debug/system/src/diag/trace_impl.d: -------------------------------------------------------------------------------- 1 | system/src/diag/trace_impl.o: ../system/src/diag/trace_impl.c \ 2 | ../system/include/cmsis/cmsis_device.h \ 3 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 4 | ../system/include/cmsis/core_cmInstr.h \ 5 | ../system/include/cmsis/cmsis_gcc.h \ 6 | ../system/include/cmsis/core_cmFunc.h \ 7 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 8 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 9 | ../system/include/cmsis/stm32f10x.h \ 10 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 11 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 30 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 31 | ../system/include/stm32f1-stdperiph/misc.h \ 32 | ../system/include/diag/Trace.h ../system/include/arm/semihosting.h 33 | 34 | ../system/include/cmsis/cmsis_device.h: 35 | 36 | ../system/include/cmsis/stm32f10x.h: 37 | 38 | ../system/include/cmsis/core_cm3.h: 39 | 40 | ../system/include/cmsis/core_cmInstr.h: 41 | 42 | ../system/include/cmsis/cmsis_gcc.h: 43 | 44 | ../system/include/cmsis/core_cmFunc.h: 45 | 46 | ../system/include/cmsis/system_stm32f10x.h: 47 | 48 | ../include/stm32f10x_conf.h: 49 | 50 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 51 | 52 | ../system/include/cmsis/stm32f10x.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 55 | 56 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 89 | 90 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 91 | 92 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 93 | 94 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 95 | 96 | ../system/include/stm32f1-stdperiph/misc.h: 97 | 98 | ../system/include/diag/Trace.h: 99 | 100 | ../system/include/arm/semihosting.h: 101 | -------------------------------------------------------------------------------- /system/include/cmsis/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /system/src/stm32f1-stdperiph/stm32f10x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the CRC firmware functions. 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 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_crc.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup CRC 30 | * @brief CRC driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup CRC_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup CRC_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Private_Macros 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup CRC_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief Resets the CRC Data register (DR). 80 | * @param None 81 | * @retval None 82 | */ 83 | void CRC_ResetDR(void) 84 | { 85 | /* Reset CRC generator */ 86 | CRC->CR = CRC_CR_RESET; 87 | } 88 | 89 | /** 90 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 91 | * @param Data: data word(32-bit) to compute its CRC 92 | * @retval 32-bit CRC 93 | */ 94 | uint32_t CRC_CalcCRC(uint32_t Data) 95 | { 96 | CRC->DR = Data; 97 | 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 103 | * @param pBuffer: pointer to the buffer containing the data to be computed 104 | * @param BufferLength: length of the buffer to be computed 105 | * @retval 32-bit CRC 106 | */ 107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 108 | { 109 | uint32_t index = 0; 110 | 111 | for(index = 0; index < BufferLength; index++) 112 | { 113 | CRC->DR = pBuffer[index]; 114 | } 115 | return (CRC->DR); 116 | } 117 | 118 | /** 119 | * @brief Returns the current CRC value. 120 | * @param None 121 | * @retval 32-bit CRC 122 | */ 123 | uint32_t CRC_GetCRC(void) 124 | { 125 | return (CRC->DR); 126 | } 127 | 128 | /** 129 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 130 | * @param IDValue: 8-bit value to be stored in the ID register 131 | * @retval None 132 | */ 133 | void CRC_SetIDRegister(uint8_t IDValue) 134 | { 135 | CRC->IDR = IDValue; 136 | } 137 | 138 | /** 139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 140 | * @param None 141 | * @retval 8-bit value of the ID register 142 | */ 143 | uint8_t CRC_GetIDRegister(void) 144 | { 145 | return (CRC->IDR); 146 | } 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /Debug/system/src/cortexm/exception_handlers.d: -------------------------------------------------------------------------------- 1 | system/src/cortexm/exception_handlers.o: \ 2 | ../system/src/cortexm/exception_handlers.c \ 3 | ../system/include/cortexm/ExceptionHandlers.h \ 4 | ../system/include/cmsis/cmsis_device.h \ 5 | ../system/include/cmsis/stm32f10x.h ../system/include/cmsis/core_cm3.h \ 6 | ../system/include/cmsis/core_cmInstr.h \ 7 | ../system/include/cmsis/cmsis_gcc.h \ 8 | ../system/include/cmsis/core_cmFunc.h \ 9 | ../system/include/cmsis/system_stm32f10x.h ../include/stm32f10x_conf.h \ 10 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h \ 11 | ../system/include/cmsis/stm32f10x.h \ 12 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h \ 13 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h \ 14 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h \ 15 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h \ 16 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h \ 17 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h \ 18 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h \ 19 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h \ 20 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h \ 21 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h \ 22 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h \ 23 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h \ 24 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h \ 25 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h \ 26 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h \ 27 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h \ 28 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h \ 29 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h \ 30 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h \ 31 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h \ 32 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h \ 33 | ../system/include/stm32f1-stdperiph/misc.h \ 34 | ../system/include/arm/semihosting.h ../system/include/diag/Trace.h 35 | 36 | ../system/include/cortexm/ExceptionHandlers.h: 37 | 38 | ../system/include/cmsis/cmsis_device.h: 39 | 40 | ../system/include/cmsis/stm32f10x.h: 41 | 42 | ../system/include/cmsis/core_cm3.h: 43 | 44 | ../system/include/cmsis/core_cmInstr.h: 45 | 46 | ../system/include/cmsis/cmsis_gcc.h: 47 | 48 | ../system/include/cmsis/core_cmFunc.h: 49 | 50 | ../system/include/cmsis/system_stm32f10x.h: 51 | 52 | ../include/stm32f10x_conf.h: 53 | 54 | ../system/include/stm32f1-stdperiph/stm32f10x_adc.h: 55 | 56 | ../system/include/cmsis/stm32f10x.h: 57 | 58 | ../system/include/stm32f1-stdperiph/stm32f10x_bkp.h: 59 | 60 | ../system/include/stm32f1-stdperiph/stm32f10x_can.h: 61 | 62 | ../system/include/stm32f1-stdperiph/stm32f10x_cec.h: 63 | 64 | ../system/include/stm32f1-stdperiph/stm32f10x_crc.h: 65 | 66 | ../system/include/stm32f1-stdperiph/stm32f10x_dac.h: 67 | 68 | ../system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: 69 | 70 | ../system/include/stm32f1-stdperiph/stm32f10x_dma.h: 71 | 72 | ../system/include/stm32f1-stdperiph/stm32f10x_exti.h: 73 | 74 | ../system/include/stm32f1-stdperiph/stm32f10x_flash.h: 75 | 76 | ../system/include/stm32f1-stdperiph/stm32f10x_fsmc.h: 77 | 78 | ../system/include/stm32f1-stdperiph/stm32f10x_gpio.h: 79 | 80 | ../system/include/stm32f1-stdperiph/stm32f10x_i2c.h: 81 | 82 | ../system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: 83 | 84 | ../system/include/stm32f1-stdperiph/stm32f10x_pwr.h: 85 | 86 | ../system/include/stm32f1-stdperiph/stm32f10x_rcc.h: 87 | 88 | ../system/include/stm32f1-stdperiph/stm32f10x_rtc.h: 89 | 90 | ../system/include/stm32f1-stdperiph/stm32f10x_sdio.h: 91 | 92 | ../system/include/stm32f1-stdperiph/stm32f10x_spi.h: 93 | 94 | ../system/include/stm32f1-stdperiph/stm32f10x_tim.h: 95 | 96 | ../system/include/stm32f1-stdperiph/stm32f10x_usart.h: 97 | 98 | ../system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: 99 | 100 | ../system/include/stm32f1-stdperiph/misc.h: 101 | 102 | ../system/include/arm/semihosting.h: 103 | 104 | ../system/include/diag/Trace.h: 105 | -------------------------------------------------------------------------------- /system/include/cmsis/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /system/src/cortexm/_initialize_hardware.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | // ---------------------------------------------------------------------------- 29 | 30 | #include "cmsis_device.h" 31 | 32 | // ---------------------------------------------------------------------------- 33 | 34 | extern unsigned int __vectors_start; 35 | 36 | // Forward declarations. 37 | 38 | void 39 | __initialize_hardware_early(void); 40 | 41 | void 42 | __initialize_hardware(void); 43 | 44 | // ---------------------------------------------------------------------------- 45 | 46 | // This is the early hardware initialisation routine, it can be 47 | // redefined in the application for more complex cases that 48 | // require early inits (before BSS init). 49 | // 50 | // Called early from _start(), right before data & bss init. 51 | // 52 | // After Reset the Cortex-M processor is in Thread mode, 53 | // priority is Privileged, and the Stack is set to Main. 54 | 55 | void 56 | __attribute__((weak)) 57 | __initialize_hardware_early(void) 58 | { 59 | // Call the CSMSIS system initialisation routine. 60 | SystemInit(); 61 | 62 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 63 | // Set VTOR to the actual address, provided by the linker script. 64 | // Override the manual, possibly wrong, SystemInit() setting. 65 | SCB->VTOR = (uint32_t)(&__vectors_start); 66 | #endif 67 | 68 | // The current version of SystemInit() leaves the value of the clock 69 | // in a RAM variable (SystemCoreClock), which will be cleared shortly, 70 | // so it needs to be recomputed after the RAM initialisations 71 | // are completed. 72 | 73 | #if defined(OS_INCLUDE_STARTUP_INIT_FP) || (defined (__VFP_FP__) && !defined (__SOFTFP__)) 74 | 75 | // Normally FP init is done by SystemInit(). In case this is not done 76 | // there, it is possible to force its inclusion by defining 77 | // OS_INCLUDE_STARTUP_INIT_FP. 78 | 79 | // Enable the Cortex-M4 FPU only when -mfloat-abi=hard. 80 | // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) 81 | 82 | // Set bits 20-23 to enable CP10 and CP11 coprocessor 83 | SCB->CPACR |= (0xF << 20); 84 | 85 | #endif // (__VFP_FP__) && !(__SOFTFP__) 86 | 87 | #if defined(OS_DEBUG_SEMIHOSTING_FAULTS) 88 | SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk; 89 | #endif 90 | } 91 | 92 | // This is the second hardware initialisation routine, it can be 93 | // redefined in the application for more complex cases that 94 | // require custom inits (before constructors), otherwise these can 95 | // be done in main(). 96 | // 97 | // Called from _start(), right after data & bss init, before 98 | // constructors. 99 | 100 | void 101 | __attribute__((weak)) 102 | __initialize_hardware(void) 103 | { 104 | // Call the CSMSIS system clock routine to store the clock frequency 105 | // in the SystemCoreClock global RAM location. 106 | SystemCoreClockUpdate(); 107 | } 108 | 109 | // ---------------------------------------------------------------------------- 110 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the DBGMCU 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_DBGMCU_H 25 | #define __STM32F10x_DBGMCU_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup DBGMCU 39 | * @{ 40 | */ 41 | 42 | /** @defgroup DBGMCU_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 55 | #define DBGMCU_STOP ((uint32_t)0x00000002) 56 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 57 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 58 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 59 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) 60 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) 61 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) 62 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) 63 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) 64 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) 65 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) 66 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) 67 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) 68 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) 69 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) 70 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) 71 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) 72 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) 73 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) 74 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) 75 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) 76 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) 77 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) 78 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) 79 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) 80 | 81 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup DBGMCU_Exported_Macros 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup DBGMCU_Exported_Functions 95 | * @{ 96 | */ 97 | 98 | uint32_t DBGMCU_GetREVID(void); 99 | uint32_t DBGMCU_GetDEVID(void); 100 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* __STM32F10x_DBGMCU_H */ 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_IWDG_H 25 | #define __STM32F10x_IWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup IWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup IWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup IWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup IWDG_WriteAccess 55 | * @{ 56 | */ 57 | 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | 70 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 71 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 72 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 73 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 74 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 75 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 76 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 77 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 78 | ((PRESCALER) == IWDG_Prescaler_8) || \ 79 | ((PRESCALER) == IWDG_Prescaler_16) || \ 80 | ((PRESCALER) == IWDG_Prescaler_32) || \ 81 | ((PRESCALER) == IWDG_Prescaler_64) || \ 82 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 83 | ((PRESCALER) == IWDG_Prescaler_256)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup IWDG_Flag 89 | * @{ 90 | */ 91 | 92 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 93 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 94 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 95 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup IWDG_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup IWDG_Exported_Functions 113 | * @{ 114 | */ 115 | 116 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 117 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 118 | void IWDG_SetReload(uint16_t Reload); 119 | void IWDG_ReloadCounter(void); 120 | void IWDG_Enable(void); 121 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif /* __STM32F10x_IWDG_H */ 128 | /** 129 | * @} 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_RTC_H 25 | #define __STM32F10x_RTC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup RTC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup RTC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup RTC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup RTC_interrupts_define 55 | * @{ 56 | */ 57 | 58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 63 | ((IT) == RTC_IT_SEC)) 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup RTC_interrupts_flags 69 | * @{ 70 | */ 71 | 72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 80 | ((FLAG) == RTC_FLAG_SEC)) 81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup RTC_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup RTC_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 104 | void RTC_EnterConfigMode(void); 105 | void RTC_ExitConfigMode(void); 106 | uint32_t RTC_GetCounter(void); 107 | void RTC_SetCounter(uint32_t CounterValue); 108 | void RTC_SetPrescaler(uint32_t PrescalerValue); 109 | void RTC_SetAlarm(uint32_t AlarmValue); 110 | uint32_t RTC_GetDivider(void); 111 | void RTC_WaitForLastTask(void); 112 | void RTC_WaitForSynchro(void); 113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 114 | void RTC_ClearFlag(uint16_t RTC_FLAG); 115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 116 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __STM32F10x_RTC_H */ 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /system/include/diag/Trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | #ifndef DIAG_TRACE_H_ 29 | #define DIAG_TRACE_H_ 30 | 31 | // ---------------------------------------------------------------------------- 32 | 33 | #include 34 | 35 | // ---------------------------------------------------------------------------- 36 | 37 | // The trace device is an independent output channel, intended for debug 38 | // purposes. 39 | // 40 | // The API is simple, and mimics the standard output calls: 41 | // - trace_printf() 42 | // - trace_puts() 43 | // - trace_putchar(); 44 | // 45 | // The implementation is done in 46 | // - trace_write() 47 | // 48 | // Trace support is enabled by adding the TRACE definition. 49 | // By default the trace messages are forwarded to the ITM output, 50 | // but can be rerouted via any device or completely suppressed by 51 | // changing the definitions required in system/src/diag/trace_impl.c 52 | // (currently OS_USE_TRACE_ITM, OS_USE_TRACE_SEMIHOSTING_DEBUG/_STDOUT). 53 | // 54 | // When TRACE is not defined, all functions are inlined to empty bodies. 55 | // This has the advantage that the trace call do not need to be conditionally 56 | // compiled with #ifdef TRACE/#endif 57 | 58 | 59 | #if defined(TRACE) 60 | 61 | #if defined(__cplusplus) 62 | extern "C" 63 | { 64 | #endif 65 | 66 | void 67 | trace_initialize(void); 68 | 69 | // Implementation dependent 70 | ssize_t 71 | trace_write(const char* buf, size_t nbyte); 72 | 73 | // ----- Portable ----- 74 | 75 | int 76 | trace_printf(const char* format, ...); 77 | 78 | int 79 | trace_puts(const char *s); 80 | 81 | int 82 | trace_putchar(int c); 83 | 84 | void 85 | trace_dump_args(int argc, char* argv[]); 86 | 87 | #if defined(__cplusplus) 88 | } 89 | #endif 90 | 91 | #else // !defined(TRACE) 92 | 93 | #if defined(__cplusplus) 94 | extern "C" 95 | { 96 | #endif 97 | 98 | inline void 99 | trace_initialize(void); 100 | 101 | // Implementation dependent 102 | inline ssize_t 103 | trace_write(const char* buf, size_t nbyte); 104 | 105 | inline int 106 | trace_printf(const char* format, ...); 107 | 108 | inline int 109 | trace_puts(const char *s); 110 | 111 | inline int 112 | trace_putchar(int c); 113 | 114 | inline void 115 | trace_dump_args(int argc, char* argv[]); 116 | 117 | #if defined(__cplusplus) 118 | } 119 | #endif 120 | 121 | inline void 122 | __attribute__((always_inline)) 123 | trace_initialize(void) 124 | { 125 | } 126 | 127 | // Empty definitions when trace is not defined 128 | inline ssize_t 129 | __attribute__((always_inline)) 130 | trace_write(const char* buf __attribute__((unused)), 131 | size_t nbyte __attribute__((unused))) 132 | { 133 | return 0; 134 | } 135 | 136 | inline int 137 | __attribute__((always_inline)) 138 | trace_printf(const char* format __attribute__((unused)), ...) 139 | { 140 | return 0; 141 | } 142 | 143 | inline int 144 | __attribute__((always_inline)) 145 | trace_puts(const char *s __attribute__((unused))) 146 | { 147 | return 0; 148 | } 149 | 150 | inline int 151 | __attribute__((always_inline)) 152 | trace_putchar(int c) 153 | { 154 | return c; 155 | } 156 | 157 | inline void 158 | __attribute__((always_inline)) 159 | trace_dump_args(int argc __attribute__((unused)), 160 | char* argv[] __attribute__((unused))) 161 | { 162 | } 163 | 164 | #endif // defined(TRACE) 165 | 166 | // ---------------------------------------------------------------------------- 167 | 168 | #endif // DIAG_TRACE_H_ 169 | -------------------------------------------------------------------------------- /system/include/stm32f1-stdperiph/stm32f10x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_PWR_H 25 | #define __STM32F10x_PWR_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup PWR 39 | * @{ 40 | */ 41 | 42 | /** @defgroup PWR_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup PWR_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup PVD_detection_level 55 | * @{ 56 | */ 57 | 58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup Regulator_state_is_STOP_mode 75 | * @{ 76 | */ 77 | 78 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 81 | ((REGULATOR) == PWR_Regulator_LowPower)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup STOP_mode_entry 87 | * @{ 88 | */ 89 | 90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup PWR_Flag 99 | * @{ 100 | */ 101 | 102 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 103 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 106 | ((FLAG) == PWR_FLAG_PVDO)) 107 | 108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup PWR_Exported_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup PWR_Exported_Functions 126 | * @{ 127 | */ 128 | 129 | void PWR_DeInit(void); 130 | void PWR_BackupAccessCmd(FunctionalState NewState); 131 | void PWR_PVDCmd(FunctionalState NewState); 132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 133 | void PWR_WakeUpPinCmd(FunctionalState NewState); 134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 135 | void PWR_EnterSTANDBYMode(void); 136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 137 | void PWR_ClearFlag(uint32_t PWR_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F10x_PWR_H */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /include/RCC_interface.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************/ 2 | /* Author : Ahmed Hassan */ 3 | /* Version : V02 */ 4 | /* Date : Feb 19, 2021 */ 5 | /*********************************************************************************/ 6 | #ifndef RCC_INTERFACE_H 7 | #define RCC_INTERFACE_H 8 | 9 | void RCC_vidInitSysClock ( void ); 10 | void RCC_vidEnableClock ( u8 copy_u8BusId , u8 copy_u8PeriheralId ); 11 | 12 | /* 13 | ----------------------------------------------------------------------- 14 | --> copy_u8BusId Options: 15 | RCC_AHB 16 | RCC_APB1 17 | RCC_APB2 18 | ----------------------------------------------------------------------- 19 | --> copy_u8BusSource Options: 20 | RCC_AHB 21 | RCC_APB1 22 | RCC_APB2 23 | RCC_SYSCLK 24 | ----------------------------------------------------------------------- 25 | --> copy_u8PeriheralId options for RCC_AHB 26 | SDIOEN: SDIO clock enable 27 | FSMCEN: FSMC clock enable 28 | CRCEN: CRC clock enable 29 | FLITFEN: FLITF clock enable 30 | SRAMEN: SRAM interface clock enable 31 | DMA2EN: DMA2 clock enable 32 | DMA1EN: DMA1 clock enable 33 | ----------------------------------------------------------------------- 34 | --> copy_u8PeriheralId options for RCC_APB1 35 | DACEN: DAC interface clock enable 36 | PWREN: Power interface clock enable 37 | BKPEN: Backup interface clock enable 38 | CANEN: CAN clock enable 39 | USBEN: USB clock enable 40 | I2C2EN: I2C 2 clock enable 41 | I2C1EN: I2C 1 clock enable 42 | UART5EN: USART 5 clock enable 43 | UART4EN: USART 4 clock enable 44 | USART3EN: USART 3 clock enable 45 | USART2EN: USART 2 clock enable 46 | SPI3EN: SPI 3 clock enable 47 | SPI2EN: SPI 2 clock enable 48 | WWDGEN: Window watchdog clock enable 49 | TIM14EN: Timer 14 clock enable 50 | TIM13EN: Timer 13 clock enable 51 | TIM12EN: Timer 12 clock enable 52 | TIM7EN: Timer 7 clock enable 53 | TIM6EN: Timer 6 clock enable 54 | TIM5EN: Timer 5 clock enable 55 | TIM4EN: Timer 4 clock enable 56 | TIM3EN: Timer 3 clock enable 57 | TIM2EN: Timer 2 clock enable 58 | ----------------------------------------------------------------------- 59 | --> copy_u8PeriheralId options for RCC_APB2 60 | TIM11EN: TIM11 timer clock enable 61 | TIM10EN: TIM10 timer clock enable 62 | TIM9EN: TIM9 timer clock enable 63 | ADC3EN: ADC3 interface clock enable 64 | USART1EN: USART1 clock enable 65 | TIM8EN: TIM8 Timer clock enable 66 | SPI1EN: SPI 1 clock enable 67 | TIM1EN: TIM1 Timer clock enable 68 | ADC2EN: ADC 2 interface clock enable 69 | ADC1EN: ADC 1 interface clock enable 70 | IOPCEN: I/O port C clock enable 71 | IOPBEN: I/O port B clock enable 72 | IOPAEN: I/O port A clock enable 73 | AFIOEN: Alternate function I/O clock enable 74 | ----------------------------------------------------------------------- 75 | */ 76 | 77 | /* Bus */ 78 | #define RCC_AHB 0 79 | #define RCC_APB1 1 80 | #define RCC_APB2 2 81 | #define RCC_SYSCLK 3 82 | 83 | /* AHB */ 84 | #define SDIOEN 10 85 | #define FSMCEN 8 86 | #define CRCEN 6 87 | #define FLITFEN 4 88 | #define SRAMEN 2 89 | #define DMA2EN 1 90 | #define DMA1EN 0 91 | 92 | 93 | /* APB1 */ 94 | #define DACEN 29 95 | #define PWREN 28 96 | #define BKPEN 27 97 | #define CANEN 25 98 | #define USBEN 23 99 | #define I2C2EN 22 100 | #define I2C1EN 21 101 | #define UART5EN 20 102 | #define UART4EN 19 103 | #define USART3EN 18 104 | #define USART2EN 17 105 | #define SPI3EN 15 106 | #define SPI2EN 14 107 | #define WWDGEN 11 108 | #define TIM14EN 8 109 | #define TIM13EN 7 110 | #define TIM12EN 6 111 | #define TIM7EN 5 112 | #define TIM6EN 4 113 | #define TIM5EN 3 114 | #define TIM4EN 2 115 | #define TIM3EN 1 116 | #define TIM2EN 0 117 | 118 | /* APB2 */ 119 | #define TIM11EN 21 120 | #define TIM10EN 20 121 | #define TIM9EN 19 122 | #define ADC3EN 15 123 | #define USART1EN 14 124 | #define TIM8EN 13 125 | #define SPI1EN 12 126 | #define TIM1EN 11 127 | #define ADC2EN 10 128 | #define ADC1EN 9 129 | #define IOPCEN 4 130 | #define IOPBEN 3 131 | #define IOPAEN 2 132 | #define AFIOEN 0 133 | 134 | 135 | #endif 136 | -------------------------------------------------------------------------------- /system/include/arm/semihosting.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the µOS++ distribution. 3 | * (https://github.com/micro-os-plus) 4 | * Copyright (c) 2014 Liviu Ionescu. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom 12 | * the Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | * OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | #ifndef ARM_SEMIHOSTING_H_ 29 | #define ARM_SEMIHOSTING_H_ 30 | 31 | // ---------------------------------------------------------------------------- 32 | 33 | // Semihosting operations. 34 | enum OperationNumber 35 | { 36 | // Regular operations 37 | SEMIHOSTING_EnterSVC = 0x17, 38 | SEMIHOSTING_ReportException = 0x18, 39 | SEMIHOSTING_SYS_CLOSE = 0x02, 40 | SEMIHOSTING_SYS_CLOCK = 0x10, 41 | SEMIHOSTING_SYS_ELAPSED = 0x30, 42 | SEMIHOSTING_SYS_ERRNO = 0x13, 43 | SEMIHOSTING_SYS_FLEN = 0x0C, 44 | SEMIHOSTING_SYS_GET_CMDLINE = 0x15, 45 | SEMIHOSTING_SYS_HEAPINFO = 0x16, 46 | SEMIHOSTING_SYS_ISERROR = 0x08, 47 | SEMIHOSTING_SYS_ISTTY = 0x09, 48 | SEMIHOSTING_SYS_OPEN = 0x01, 49 | SEMIHOSTING_SYS_READ = 0x06, 50 | SEMIHOSTING_SYS_READC = 0x07, 51 | SEMIHOSTING_SYS_REMOVE = 0x0E, 52 | SEMIHOSTING_SYS_RENAME = 0x0F, 53 | SEMIHOSTING_SYS_SEEK = 0x0A, 54 | SEMIHOSTING_SYS_SYSTEM = 0x12, 55 | SEMIHOSTING_SYS_TICKFREQ = 0x31, 56 | SEMIHOSTING_SYS_TIME = 0x11, 57 | SEMIHOSTING_SYS_TMPNAM = 0x0D, 58 | SEMIHOSTING_SYS_WRITE = 0x05, 59 | SEMIHOSTING_SYS_WRITEC = 0x03, 60 | SEMIHOSTING_SYS_WRITE0 = 0x04, 61 | 62 | // Codes returned by SEMIHOSTING_ReportException 63 | ADP_Stopped_ApplicationExit = ((2 << 16) + 38), 64 | ADP_Stopped_RunTimeError = ((2 << 16) + 35), 65 | 66 | }; 67 | 68 | // ---------------------------------------------------------------------------- 69 | 70 | // SWI numbers and reason codes for RDI (Angel) monitors. 71 | #define AngelSWI_ARM 0x123456 72 | #ifdef __thumb__ 73 | #define AngelSWI 0xAB 74 | #else 75 | #define AngelSWI AngelSWI_ARM 76 | #endif 77 | // For thumb only architectures use the BKPT instruction instead of SWI. 78 | #if defined(__ARM_ARCH_7M__) \ 79 | || defined(__ARM_ARCH_7EM__) \ 80 | || defined(__ARM_ARCH_6M__) 81 | #define AngelSWIInsn "bkpt" 82 | #define AngelSWIAsm bkpt 83 | #else 84 | #define AngelSWIInsn "swi" 85 | #define AngelSWIAsm swi 86 | #endif 87 | 88 | #if defined(OS_DEBUG_SEMIHOSTING_FAULTS) 89 | // Testing the local semihosting handler cannot use another BKPT, since this 90 | // configuration cannot trigger HaedFault exceptions while the debugger is 91 | // connected, so we use an illegal op code, that will trigger an 92 | // UsageFault exception. 93 | #define AngelSWITestFault "setend be" 94 | #define AngelSWITestFaultOpCode (0xB658) 95 | #endif 96 | 97 | static inline int 98 | __attribute__ ((always_inline)) 99 | call_host (int reason, void* arg) 100 | { 101 | int value; 102 | asm volatile ( 103 | 104 | " mov r0, %[rsn] \n" 105 | " mov r1, %[arg] \n" 106 | #if defined(OS_DEBUG_SEMIHOSTING_FAULTS) 107 | " " AngelSWITestFault " \n" 108 | #else 109 | " " AngelSWIInsn " %[swi] \n" 110 | #endif 111 | " mov %[val], r0" 112 | 113 | : [val] "=r" (value) /* Outputs */ 114 | : [rsn] "r" (reason), [arg] "r" (arg), [swi] "i" (AngelSWI) /* Inputs */ 115 | : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" 116 | // Clobbers r0 and r1, and lr if in supervisor mode 117 | ); 118 | 119 | // Accordingly to page 13-77 of ARM DUI 0040D other registers 120 | // can also be clobbered. Some memory positions may also be 121 | // changed by a system call, so they should not be kept in 122 | // registers. Note: we are assuming the manual is right and 123 | // Angel is respecting the APCS. 124 | return value; 125 | } 126 | 127 | // ---------------------------------------------------------------------------- 128 | 129 | // Function used in _exit() to return the status code as Angel exception. 130 | static inline void 131 | __attribute__ ((always_inline,noreturn)) 132 | report_exception (int reason) 133 | { 134 | call_host (SEMIHOSTING_ReportException, (void*) reason); 135 | 136 | for (;;) 137 | ; 138 | } 139 | 140 | // ---------------------------------------------------------------------------- 141 | 142 | #endif // ARM_SEMIHOSTING_H_ 143 | -------------------------------------------------------------------------------- /system/src/stm32f1-stdperiph/stm32f10x_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the IWDG firmware functions. 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 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_iwdg.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup IWDG 30 | * @brief IWDG driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup IWDG_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup IWDG_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /* ---------------------- IWDG registers bit mask ----------------------------*/ 47 | 48 | /* KR register bit mask */ 49 | #define KR_KEY_Reload ((uint16_t)0xAAAA) 50 | #define KR_KEY_Enable ((uint16_t)0xCCCC) 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup IWDG_Private_Macros 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup IWDG_Private_Variables 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup IWDG_Private_FunctionPrototypes 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup IWDG_Private_Functions 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 86 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 87 | * This parameter can be one of the following values: 88 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 89 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 90 | * @retval None 91 | */ 92 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 93 | { 94 | /* Check the parameters */ 95 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 96 | IWDG->KR = IWDG_WriteAccess; 97 | } 98 | 99 | /** 100 | * @brief Sets IWDG Prescaler value. 101 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 102 | * This parameter can be one of the following values: 103 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 104 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 105 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 106 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 107 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 108 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 109 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 110 | * @retval None 111 | */ 112 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 113 | { 114 | /* Check the parameters */ 115 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 116 | IWDG->PR = IWDG_Prescaler; 117 | } 118 | 119 | /** 120 | * @brief Sets IWDG Reload value. 121 | * @param Reload: specifies the IWDG Reload value. 122 | * This parameter must be a number between 0 and 0x0FFF. 123 | * @retval None 124 | */ 125 | void IWDG_SetReload(uint16_t Reload) 126 | { 127 | /* Check the parameters */ 128 | assert_param(IS_IWDG_RELOAD(Reload)); 129 | IWDG->RLR = Reload; 130 | } 131 | 132 | /** 133 | * @brief Reloads IWDG counter with value defined in the reload register 134 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 135 | * @param None 136 | * @retval None 137 | */ 138 | void IWDG_ReloadCounter(void) 139 | { 140 | IWDG->KR = KR_KEY_Reload; 141 | } 142 | 143 | /** 144 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 145 | * @param None 146 | * @retval None 147 | */ 148 | void IWDG_Enable(void) 149 | { 150 | IWDG->KR = KR_KEY_Enable; 151 | } 152 | 153 | /** 154 | * @brief Checks whether the specified IWDG flag is set or not. 155 | * @param IWDG_FLAG: specifies the flag to check. 156 | * This parameter can be one of the following values: 157 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 158 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 159 | * @retval The new state of IWDG_FLAG (SET or RESET). 160 | */ 161 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 162 | { 163 | FlagStatus bitstatus = RESET; 164 | /* Check the parameters */ 165 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 166 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 167 | { 168 | bitstatus = SET; 169 | } 170 | else 171 | { 172 | bitstatus = RESET; 173 | } 174 | /* Return the flag status */ 175 | return bitstatus; 176 | } 177 | 178 | /** 179 | * @} 180 | */ 181 | 182 | /** 183 | * @} 184 | */ 185 | 186 | /** 187 | * @} 188 | */ 189 | 190 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 191 | -------------------------------------------------------------------------------- /system/src/stm32f1-stdperiph/stm32f10x_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the DBGMCU firmware functions. 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 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_dbgmcu.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup DBGMCU 30 | * @brief DBGMCU driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup DBGMCU_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup DBGMCU_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup DBGMCU_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup DBGMCU_Private_Variables 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup DBGMCU_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup DBGMCU_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Returns the device revision identifier. 81 | * @param None 82 | * @retval Device revision identifier 83 | */ 84 | uint32_t DBGMCU_GetREVID(void) 85 | { 86 | return(DBGMCU->IDCODE >> 16); 87 | } 88 | 89 | /** 90 | * @brief Returns the device identifier. 91 | * @param None 92 | * @retval Device identifier 93 | */ 94 | uint32_t DBGMCU_GetDEVID(void) 95 | { 96 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 97 | } 98 | 99 | /** 100 | * @brief Configures the specified peripheral and low power mode behavior 101 | * when the MCU under Debug mode. 102 | * @param DBGMCU_Periph: specifies the peripheral and low power mode. 103 | * This parameter can be any combination of the following values: 104 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 105 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 106 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 108 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 109 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 110 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 111 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 112 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 113 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 114 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 115 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 116 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 117 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 118 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 119 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 120 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted 121 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted 122 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted 123 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted 124 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 125 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 126 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 127 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 128 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 129 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 130 | * @param NewState: new state of the specified peripheral in Debug mode. 131 | * This parameter can be: ENABLE or DISABLE. 132 | * @retval None 133 | */ 134 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 135 | { 136 | /* Check the parameters */ 137 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 138 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 139 | 140 | if (NewState != DISABLE) 141 | { 142 | DBGMCU->CR |= DBGMCU_Periph; 143 | } 144 | else 145 | { 146 | DBGMCU->CR &= ~DBGMCU_Periph; 147 | } 148 | } 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 163 | -------------------------------------------------------------------------------- /system/src/stm32f1-stdperiph/stm32f10x_wwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the WWDG firmware functions. 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 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_wwdg.h" 24 | #include "stm32f10x_rcc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup WWDG 31 | * @brief WWDG driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup WWDG_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup WWDG_Private_Defines 44 | * @{ 45 | */ 46 | 47 | /* ----------- WWDG registers bit address in the alias region ----------- */ 48 | #define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE) 49 | 50 | /* Alias word address of EWI bit */ 51 | #define CFR_OFFSET (WWDG_OFFSET + 0x04) 52 | #define EWI_BitNumber 0x09 53 | #define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4)) 54 | 55 | /* --------------------- WWDG registers bit mask ------------------------ */ 56 | 57 | /* CR register bit mask */ 58 | #define CR_WDGA_Set ((uint32_t)0x00000080) 59 | 60 | /* CFR register bit mask */ 61 | #define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F) 62 | #define CFR_W_Mask ((uint32_t)0xFFFFFF80) 63 | #define BIT_Mask ((uint8_t)0x7F) 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup WWDG_Private_Macros 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Private_Variables 78 | * @{ 79 | */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup WWDG_Private_FunctionPrototypes 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup WWDG_Private_Functions 94 | * @{ 95 | */ 96 | 97 | /** 98 | * @brief Deinitializes the WWDG peripheral registers to their default reset values. 99 | * @param None 100 | * @retval None 101 | */ 102 | void WWDG_DeInit(void) 103 | { 104 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); 105 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); 106 | } 107 | 108 | /** 109 | * @brief Sets the WWDG Prescaler. 110 | * @param WWDG_Prescaler: specifies the WWDG Prescaler. 111 | * This parameter can be one of the following values: 112 | * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1 113 | * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2 114 | * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4 115 | * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8 116 | * @retval None 117 | */ 118 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler) 119 | { 120 | uint32_t tmpreg = 0; 121 | /* Check the parameters */ 122 | assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler)); 123 | /* Clear WDGTB[1:0] bits */ 124 | tmpreg = WWDG->CFR & CFR_WDGTB_Mask; 125 | /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */ 126 | tmpreg |= WWDG_Prescaler; 127 | /* Store the new value */ 128 | WWDG->CFR = tmpreg; 129 | } 130 | 131 | /** 132 | * @brief Sets the WWDG window value. 133 | * @param WindowValue: specifies the window value to be compared to the downcounter. 134 | * This parameter value must be lower than 0x80. 135 | * @retval None 136 | */ 137 | void WWDG_SetWindowValue(uint8_t WindowValue) 138 | { 139 | __IO uint32_t tmpreg = 0; 140 | 141 | /* Check the parameters */ 142 | assert_param(IS_WWDG_WINDOW_VALUE(WindowValue)); 143 | /* Clear W[6:0] bits */ 144 | 145 | tmpreg = WWDG->CFR & CFR_W_Mask; 146 | 147 | /* Set W[6:0] bits according to WindowValue value */ 148 | tmpreg |= WindowValue & (uint32_t) BIT_Mask; 149 | 150 | /* Store the new value */ 151 | WWDG->CFR = tmpreg; 152 | } 153 | 154 | /** 155 | * @brief Enables the WWDG Early Wakeup interrupt(EWI). 156 | * @param None 157 | * @retval None 158 | */ 159 | void WWDG_EnableIT(void) 160 | { 161 | *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE; 162 | } 163 | 164 | /** 165 | * @brief Sets the WWDG counter value. 166 | * @param Counter: specifies the watchdog counter value. 167 | * This parameter must be a number between 0x40 and 0x7F. 168 | * @retval None 169 | */ 170 | void WWDG_SetCounter(uint8_t Counter) 171 | { 172 | /* Check the parameters */ 173 | assert_param(IS_WWDG_COUNTER(Counter)); 174 | /* Write to T[6:0] bits to configure the counter value, no need to do 175 | a read-modify-write; writing a 0 to WDGA bit does nothing */ 176 | WWDG->CR = Counter & BIT_Mask; 177 | } 178 | 179 | /** 180 | * @brief Enables WWDG and load the counter value. 181 | * @param Counter: specifies the watchdog counter value. 182 | * This parameter must be a number between 0x40 and 0x7F. 183 | * @retval None 184 | */ 185 | void WWDG_Enable(uint8_t Counter) 186 | { 187 | /* Check the parameters */ 188 | assert_param(IS_WWDG_COUNTER(Counter)); 189 | WWDG->CR = CR_WDGA_Set | Counter; 190 | } 191 | 192 | /** 193 | * @brief Checks whether the Early Wakeup interrupt flag is set or not. 194 | * @param None 195 | * @retval The new state of the Early Wakeup interrupt flag (SET or RESET) 196 | */ 197 | FlagStatus WWDG_GetFlagStatus(void) 198 | { 199 | return (FlagStatus)(WWDG->SR); 200 | } 201 | 202 | /** 203 | * @brief Clears Early Wakeup interrupt flag. 204 | * @param None 205 | * @retval None 206 | */ 207 | void WWDG_ClearFlag(void) 208 | { 209 | WWDG->SR = (uint32_t)RESET; 210 | } 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | /** 221 | * @} 222 | */ 223 | 224 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 225 | -------------------------------------------------------------------------------- /src/OTA_program.c: -------------------------------------------------------------------------------- 1 | #include "STD_TYPES.h" 2 | #include "BIT_MATH.h" 3 | 4 | #include "OTA_interface.h" 5 | #include "OTA_private.h" 6 | #include "OTA_config.h" 7 | 8 | #include "RCC_interface.h" 9 | #include "GPIO_interface.h" 10 | #include "NVIC_interface.h" 11 | #include "STK_interface.h" 12 | #include "USART_interface.h" 13 | #include "STK_interface.h" 14 | #include "FPEC_interface.h" 15 | 16 | volatile u8 g_recieveBuffer[100]; /* Array to store the received line */ 17 | volatile u8 g_recieveCounter = 0; /* Counter for received line chars */ 18 | volatile u16 g_data[100] = {0}; /* Array to store the data of line to pass it to Flash Writer */ 19 | volatile u32 g_address; /* Pointer to store the address in to write */ 20 | 21 | volatile boolean g_lineReceivedFlag = FALSE; /* Flag to check if the NodeMCU finished sending a complete line */ 22 | volatile boolean g_finishReceiveFlag = FALSE; /* Flag to check if NodeMCU finished sending the code to run application code */ 23 | 24 | /* Pointer to function to run application code */ 25 | typedef void (*Function_t)(void); 26 | Function_t addr_to_call = 0; 27 | 28 | void OTA_vidInit(void) 29 | { 30 | 31 | RCC_vidInitSysClock(); /* Init System Clock */ 32 | FPEC_vidEnableClock(); /* Enable Flash Driver Clock */ 33 | USART1_vidEnableClock(); /* Enable UART Clock */ 34 | GPIO_vidEnablePortClock(GPIOA); /* Enable PORTA Clock for UART pins (Rx, Tx) */ 35 | 36 | USART1_vidInit(); /* Init USART1 */ 37 | STK_vidInit(); /* Init SysTick */ 38 | 39 | /* Set direction of UART Pins */ 40 | GPIO_vidSetPinDirection(GPIOA, PIN9, OUTPUT_SPEED_50MHZ_AFPP); /* A09 - Tx */ 41 | GPIO_vidSetPinDirection(GPIOA, PIN10, INPUT_FLOATING); /* A10 - Rx */ 42 | 43 | /* If did not recieve any data through UART for (OTA_RECIEVE_TIMEOUT_S) seconds, the old application code will run */ 44 | STK_vidSetIntervalSingle(OTA_RECIEVE_TIMEOUT_S * 1000000, OTA_vidRunAppCode); 45 | 46 | /* Enable interrupt for UART */ 47 | NVIC_vidEnableInterrupt(NVIC_USART1); 48 | USART1_vidEnableRecieveInterrupt(OTA_vidCharReceived); 49 | } 50 | 51 | void OTA_vidRun(void) 52 | { 53 | while (g_finishReceiveFlag == FALSE) 54 | { 55 | 56 | if (g_lineReceivedFlag == TRUE) 57 | { 58 | switch (g_recieveBuffer[g_recieveCounter]) 59 | { 60 | case OTA_DATA_START_CHAR: 61 | g_recieveCounter = 0; 62 | STK_vidStopInterval(); 63 | FPEC_voidEraseArea(8, 64); 64 | USART1_vidTransmit(OTA_READ_CONFIRM_CHAR); 65 | break; 66 | case OTA_LINE_BREAK_CHAR: 67 | OTA_vidParseRecord(); 68 | g_recieveCounter = 0; 69 | USART1_vidTransmit(OTA_READ_CONFIRM_CHAR); 70 | break; 71 | default: 72 | break; 73 | } 74 | g_lineReceivedFlag = FALSE; 75 | } 76 | } 77 | USART1_vidDisableRecieveInterrupt(); 78 | OTA_vidRunAppCode(); 79 | } 80 | 81 | static void OTA_vidRunAppCode(void) 82 | { 83 | *((volatile u32 *)0xE000ED08) = 0x08002000; 84 | addr_to_call = *(Function_t *)(0x08002004); 85 | addr_to_call(); 86 | } 87 | 88 | void OTA_vidCharReceived(u8 rec) 89 | { 90 | g_recieveBuffer[g_recieveCounter] = rec; 91 | switch (rec) 92 | { 93 | case OTA_DATA_START_CHAR: 94 | case OTA_LINE_BREAK_CHAR: 95 | g_lineReceivedFlag = TRUE; 96 | break; 97 | case OTA_DATA_END_CHAR: 98 | g_finishReceiveFlag = TRUE; 99 | break; 100 | default: 101 | g_recieveCounter++; 102 | break; 103 | } 104 | } 105 | 106 | static u8 getHex(u8 Copy_u8Asci) 107 | { 108 | u8 Result = 0; 109 | 110 | /*0 ... 9*/ 111 | if ((Copy_u8Asci >= 48) && (Copy_u8Asci <= 57)) 112 | { 113 | Result = Copy_u8Asci - 48; 114 | } 115 | 116 | /*A ... F*/ 117 | else if ((Copy_u8Asci >= 65) && (Copy_u8Asci <= 70)) 118 | { 119 | Result = Copy_u8Asci - 55; 120 | } 121 | 122 | return Result; 123 | } 124 | 125 | static void OTA_vidParseRecord() 126 | { 127 | u8 CC, i; 128 | u8 dataDigits[4]; 129 | u8 dataCounter = 0; 130 | 131 | switch (getHex(g_recieveBuffer[8])) 132 | { 133 | 134 | case 4: /* Extended Linear Address Record: used to identify the extended linear address */ 135 | OTA_vidSetHighAddress(); 136 | break; 137 | 138 | case 5: /* Start Linear Address Record: the address where the program starts to run */ 139 | break; 140 | 141 | case 0: /* Data Rrecord: used to record data, most records of HEX files are data records */ 142 | 143 | /* Get Character Count */ 144 | CC = (getHex(g_recieveBuffer[1]) << 4) | getHex(g_recieveBuffer[2]); 145 | 146 | /* Get low part of address */ 147 | dataDigits[0] = getHex(g_recieveBuffer[3]); 148 | dataDigits[1] = getHex(g_recieveBuffer[4]); 149 | dataDigits[2] = getHex(g_recieveBuffer[5]); 150 | dataDigits[3] = getHex(g_recieveBuffer[6]); 151 | 152 | /* Set full address */ 153 | g_address = g_address & 0xFFFF0000; 154 | g_address = g_address | 155 | (dataDigits[3]) | 156 | (dataDigits[2] << 4) | 157 | (dataDigits[1] << 8) | 158 | (dataDigits[0] << 12); 159 | 160 | /* Get the data of the record */ 161 | for (i = 0; i < CC / 2; i++) 162 | { 163 | dataDigits[0] = getHex(g_recieveBuffer[4 * i + 9]); 164 | dataDigits[1] = getHex(g_recieveBuffer[4 * i + 10]); 165 | dataDigits[2] = getHex(g_recieveBuffer[4 * i + 11]); 166 | dataDigits[3] = getHex(g_recieveBuffer[4 * i + 12]); 167 | g_data[dataCounter] = (dataDigits[3] << 8) | 168 | (dataDigits[2] << 12) | 169 | (dataDigits[1] << 0) | 170 | (dataDigits[0] << 4); 171 | dataCounter++; 172 | } 173 | 174 | if (CC % 2 != 0) 175 | { 176 | dataDigits[0] = getHex(g_recieveBuffer[4 * (CC / 2) + 9]); 177 | dataDigits[1] = getHex(g_recieveBuffer[4 * (CC / 2) + 10]); 178 | g_data[dataCounter] = 0xFF00 | (dataDigits[0] << 4) | (dataDigits[1] << 0); 179 | FPEC_voidFlashWrite(g_address, (u16 *)g_data, CC / 2 + 1); 180 | } 181 | else 182 | { 183 | FPEC_voidFlashWrite(g_address, (u16 *)g_data, CC / 2); 184 | } 185 | 186 | break; 187 | default: 188 | break; 189 | } 190 | } 191 | 192 | static void OTA_vidSetHighAddress(void) 193 | { 194 | g_address = (getHex(g_recieveBuffer[9]) << 28) | 195 | (getHex(g_recieveBuffer[10]) << 24) | 196 | (getHex(g_recieveBuffer[11]) << 20) | 197 | (getHex(g_recieveBuffer[12]) << 16); 198 | } 199 | --------------------------------------------------------------------------------