├── user ├── driver │ ├── uart.c │ └── uart.h ├── hardware │ ├── uart_log.h │ └── uart_log.c ├── config.h ├── main.c └── config.c ├── bin └── README.md ├── docs ├── develop board.jpeg ├── STM32F105_107_datasheet.pdf └── STM32F107_development board schematics.pdf ├── stm32f10x_libraries ├── STM32F10x_StdPeriph_Driver │ ├── src │ │ ├── stm32f10x_i2c.c │ │ ├── stm32f10x_flash.c │ │ ├── stm32f10x_usart.c │ │ ├── stm32f10x_crc.c │ │ ├── stm32f10x_iwdg.c │ │ ├── stm32f10x_dbgmcu.c │ │ ├── stm32f10x_wwdg.c │ │ ├── misc.c │ │ ├── stm32f10x_exti.c │ │ ├── stm32f10x_bkp.c │ │ ├── stm32f10x_pwr.c │ │ └── stm32f10x_rtc.c │ ├── inc │ │ ├── stm32f10x_crc.h │ │ ├── stm32f10x_wwdg.h │ │ ├── stm32f10x_dbgmcu.h │ │ ├── stm32f10x_iwdg.h │ │ ├── stm32f10x_rtc.h │ │ ├── stm32f10x_pwr.h │ │ ├── stm32f10x_cec.h │ │ ├── stm32f10x_exti.h │ │ ├── stm32f10x_bkp.h │ │ └── misc.h │ └── stm32f10x_conf.h └── CMSIS │ └── CM3 │ └── DeviceSupport │ └── ST │ └── STM32F10x │ ├── stm32f10x.h │ ├── system_stm32f10x.h │ └── startup │ └── gcc_ride7 │ └── startup_stm32f10x_ld.s ├── .travis.yml ├── .gitignore ├── makefile_freertos.mk ├── freertos ├── readme.txt ├── include │ ├── stdint.readme │ ├── FreeRTOSConfig.h │ ├── projdefs.h │ ├── StackMacros.h │ ├── portable.h │ └── mpu_wrappers.h └── portable │ └── MemMang │ ├── heap_3.c │ └── heap_1.c ├── README.md ├── makefile_std_lib.mk ├── LICENSE ├── Makefile └── stm32_flash.ld /user/driver/uart.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/4/2. 3 | // 4 | 5 | #include "uart.h" 6 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | # bin 2 | 3 | project_name.bin 4 | 5 | project_name.elf 6 | 7 | project_name.hex 8 | 9 | project_name.map -------------------------------------------------------------------------------- /docs/develop board.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/docs/develop board.jpeg -------------------------------------------------------------------------------- /docs/STM32F105_107_datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/docs/STM32F105_107_datasheet.pdf -------------------------------------------------------------------------------- /docs/STM32F107_development board schematics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/docs/STM32F107_development board schematics.pdf -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /stm32f10x_libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/stm32f10x_libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freelamb/stm32f107_makefile_freertos/master/stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /user/driver/uart.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/4/2. 3 | // 4 | 5 | #ifndef STM32F107_MAKEFILE_FREERTOS_UART_H 6 | #define STM32F107_MAKEFILE_FREERTOS_UART_H 7 | 8 | #endif //STM32F107_MAKEFILE_FREERTOS_UART_H 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | dist: trusty 3 | 4 | sudo: required 5 | 6 | before_install: 7 | - sudo apt-get -qq update 8 | - sudo apt-get install -y gcc-arm-none-eabi 9 | 10 | compiler: 11 | - arm-none-eabi-gcc 12 | 13 | script: 14 | - make 15 | 16 | notifications: 17 | email: true -------------------------------------------------------------------------------- /user/hardware/uart_log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/3/18. 3 | // 4 | 5 | #ifndef STM32F10X_MAKEFILE_FREERTOS_UART_LOG_H 6 | #define STM32F10X_MAKEFILE_FREERTOS_UART_LOG_H 7 | 8 | #include 9 | 10 | void uart_log_init(void); 11 | 12 | void debug(const char *format, ...); 13 | 14 | #endif //STM32F10X_MAKEFILE_FREERTOS_UART_LOG_H 15 | -------------------------------------------------------------------------------- /user/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/4/27. 3 | // 4 | 5 | #ifndef STM32F107_MAKEFILE_FREERTOS_CONFIG_H 6 | #define STM32F107_MAKEFILE_FREERTOS_CONFIG_H 7 | 8 | #include 9 | 10 | void NVIC_Configuration(void); 11 | 12 | void RCC_Configuration(void); 13 | 14 | void GPIO_Configuration(void); 15 | 16 | void sleep(uint32_t ms); 17 | 18 | #endif //STM32F107_MAKEFILE_FREERTOS_CONFIG_H 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | *.lst 7 | *.bin 8 | *.map 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Libraries 15 | *.lib 16 | *.a 17 | *.la 18 | *.lo 19 | 20 | # Shared objects (inc. Windows DLLs) 21 | *.dll 22 | *.so 23 | *.so.* 24 | *.dylib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | *.i*86 31 | *.x86_64 32 | *.hex 33 | 34 | # Debug files 35 | *.dSYM/ 36 | *.su 37 | -------------------------------------------------------------------------------- /makefile_freertos.mk: -------------------------------------------------------------------------------- 1 | 2 | # source director 3 | FREERTOS_SRC_DIR = $(FREERTOS_DIR) 4 | FREERTOS_INC_DIR = $(FREERTOS_DIR)/include 5 | FREERTOS_ARM_CM3_DIR = $(FREERTOS_DIR)/portable/GCC/ARM_CM3 6 | FREERTOS_MemMang_DIR = $(FREERTOS_DIR)/portable/MemMang 7 | 8 | # add freertos source 9 | SRC += $(FREERTOS_SRC_DIR)/list.c 10 | SRC += $(FREERTOS_SRC_DIR)/queue.c 11 | SRC += $(FREERTOS_SRC_DIR)/croutine.c 12 | SRC += $(FREERTOS_SRC_DIR)/tasks.c 13 | 14 | SRC += $(FREERTOS_ARM_CM3_DIR)/port.c 15 | 16 | SRC += $(FREERTOS_MemMang_DIR)/heap_4.c 17 | 18 | # include directories 19 | INCLUDE_DIRS += $(FREERTOS_INC_DIR) 20 | INCLUDE_DIRS += $(FREERTOS_ARM_CM3_DIR) 21 | 22 | 23 | -------------------------------------------------------------------------------- /freertos/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and or compiler. 4 | 5 | + The FreeRTOS/Source directory contains the three files that are common to 6 | every port - list.c, queue.c and tasks.c. The kernel is contained within these 7 | three files. croutine.c implements the optional co-routine functionality - which 8 | is normally only used on very memory limited systems. 9 | 10 | + The FreeRTOS/Source/Portable directory contains the files that are specific to 11 | a particular microcontroller and or compiler. 12 | 13 | + The FreeRTOS/Source/include directory contains the real time kernel header 14 | files. 15 | 16 | See the readme file in the FreeRTOS/Source/Portable directory for more 17 | information. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # STM32F107 Makefile FreeRTOS 2 | 3 | [![Build Status](https://travis-ci.org/freelamb/stm32f107_makefile_freertos.svg?branch=master)](https://travis-ci.org/freelamb/stm32f107_makefile_freertos) 4 | 5 | ## Requirement 6 | 7 | Working GNU ARM GCC (https://launchpad.net/gcc-arm-embedded) 8 | 9 | Texane stlink to flash the STM32F10x (https://github.com/texane/stlink) 10 | 11 | FreeRTOS Source (http://www.freertos.org) 12 | 13 | LWIP Source (https://savannah.nongnu.org/projects/lwip/) 14 | 15 | STM32F10x Library3.5 16 | 17 | FreeRTOS V9.0 18 | 19 | LWIP 2.0.2 20 | 21 | ## Usage 22 | 23 | ### build project 24 | 25 | ```$ make``` 26 | 27 | ### clean project 28 | 29 | ```$ make clean``` 30 | 31 | ### download to mcu by stlink 32 | ```$ make flash``` 33 | 34 | ### erase flash 35 | ```$ make erase``` 36 | 37 | ## Example 38 | 39 | mcu: STM32F107VCT6 40 | 41 | GPIOE13--Led 42 | 43 | -------------------------------------------------------------------------------- /user/main.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/3/16. 3 | // 4 | 5 | #include "stm32f10x.h" 6 | #include "stm32f10x_conf.h" 7 | #include "FreeRTOS.h" 8 | #include "task.h" 9 | #include "uart_log.h" 10 | #include "config.h" 11 | 12 | void vTaskFunction(void * pvParameters) 13 | { 14 | while (1) { 15 | GPIO_ResetBits(GPIOE, GPIO_Pin_13); 16 | sleep(1000); 17 | debug("test"); 18 | GPIO_SetBits(GPIOE, GPIO_Pin_13); 19 | sleep(1000); 20 | debug("test"); 21 | } 22 | } 23 | 24 | int main() 25 | { 26 | // init uart log 27 | uart_log_init(); 28 | 29 | NVIC_Configuration(); 30 | RCC_Configuration(); 31 | GPIO_Configuration(); 32 | 33 | debug("start main"); 34 | const char* pcTextForTask1 = "Task1 is running\r\n"; 35 | 36 | xTaskCreate(vTaskFunction, "Task 1", 1000, (void*)pcTextForTask1, 1, NULL); 37 | vTaskStartScheduler(); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /freertos/include/stdint.readme: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FREERTOS_STDINT 3 | #define FREERTOS_STDINT 4 | 5 | /******************************************************************************* 6 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions 7 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be 8 | * built using compilers that do not provide their own stdint.h definition. 9 | * 10 | * To use this file: 11 | * 12 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h 13 | * header file, as that directory will already be in the compilers include 14 | * path. 15 | * 16 | * 2) Rename the copied file stdint.h. 17 | * 18 | */ 19 | 20 | typedef signed char int8_t; 21 | typedef unsigned char uint8_t; 22 | typedef short int16_t; 23 | typedef unsigned short uint16_t; 24 | typedef long int32_t; 25 | typedef unsigned long uint32_t; 26 | 27 | #endif /* FREERTOS_STDINT */ 28 | -------------------------------------------------------------------------------- /makefile_std_lib.mk: -------------------------------------------------------------------------------- 1 | 2 | # STD Defines 3 | DDEFS += -DSTM32F10X_CL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 4 | 5 | # source director 6 | STM32F1_STD_LIB = $(LIB_DIR)/STM32F10x_StdPeriph_Driver 7 | STM32F1_CORE_DIR = $(LIB_DIR)/CMSIS/CM3/CoreSupport 8 | STM32F1_DEVICE_DIR = $(LIB_DIR)/CMSIS/CM3/DeviceSupport/ST/STM32F10x 9 | STM32F1_SRC_DIR = $(STM32F1_STD_LIB)/src 10 | STM32F1_INC_DIR = $(STM32F1_STD_LIB)/inc 11 | 12 | # startup 13 | ASM_SRC += $(STM32F1_DEVICE_DIR)/startup/gcc_ride7/startup_stm32f10x_cl.s 14 | 15 | # CMSIS 16 | SRC += $(STM32F1_DEVICE_DIR)/system_stm32f10x.c 17 | SRC += $(STM32F1_CORE_DIR)/core_cm3.c 18 | 19 | # use libraries, please add or remove when you use or remove it. 20 | SRC += $(STM32F1_SRC_DIR)/stm32f10x_rcc.c 21 | SRC += $(STM32F1_SRC_DIR)/stm32f10x_gpio.c 22 | SRC += $(STM32F1_SRC_DIR)/stm32f10x_exti.c 23 | SRC += $(STM32F1_SRC_DIR)/stm32f10x_usart.c 24 | SRC += $(STM32F1_SRC_DIR)/misc.c 25 | 26 | # include directories 27 | INCLUDE_DIRS += $(STM32F1_CORE_DIR) 28 | INCLUDE_DIRS += $(STM32F1_DEVICE_DIR) 29 | INCLUDE_DIRS += $(STM32F1_INC_DIR) 30 | INCLUDE_DIRS += $(STM32F1_STD_LIB) 31 | 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yongbao Yang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /stm32f10x_libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | # toolchain 3 | TOOLCHAIN = arm-none-eabi- 4 | CC = $(TOOLCHAIN)gcc 5 | CP = $(TOOLCHAIN)objcopy 6 | AS = $(TOOLCHAIN)gcc -x assembler-with-cpp 7 | HEX = $(CP) -O ihex 8 | BIN = $(CP) -O binary -S 9 | 10 | # define mcu, specify the target processor 11 | MCU = cortex-m3 12 | 13 | # define root dir 14 | ROOT_DIR = . 15 | 16 | # define include dir 17 | INCLUDE_DIRS = 18 | 19 | # define bin dir 20 | BIN_DIR = $(ROOT_DIR)/bin 21 | 22 | # define lib dir 23 | LIB_DIR = $(ROOT_DIR)/stm32f10x_libraries 24 | 25 | # define freertos dir 26 | FREERTOS_DIR = $(ROOT_DIR)/freertos 27 | 28 | # define user dir 29 | USER_DIR = $(ROOT_DIR)/user 30 | 31 | # link file 32 | LINK_SCRIPT = $(ROOT_DIR)/stm32_flash.ld 33 | 34 | # user specific 35 | SRC = 36 | ASM_SRC = 37 | SRC += $(USER_DIR)/main.c 38 | SRC += $(USER_DIR)/config.c 39 | SRC += $(USER_DIR)/hardware/uart_log.c 40 | 41 | # user include 42 | INCLUDE_DIRS += $(USER_DIR) 43 | 44 | #user include 45 | INCLUDE_DIRS +=$(USER_DIR)/hardware 46 | 47 | # include sub makefiles 48 | include makefile_std_lib.mk # STM32 Standard Peripheral Library 49 | include makefile_freertos.mk # freertos source 50 | 51 | INCDIR = $(patsubst %, -I%, $(INCLUDE_DIRS)) 52 | 53 | # run from Flash 54 | DEFS = $(DDEFS) -DRUN_FROM_FLASH=1 55 | 56 | OBJECTS = $(ASM_SRC:.s=.o) $(SRC:.c=.o) 57 | 58 | # Define optimisation level here 59 | OPT = -Os 60 | 61 | MC_FLAGS = -mcpu=$(MCU) 62 | 63 | AS_FLAGS = $(MC_FLAGS) -g -gdwarf-2 -mthumb -Wa,-amhls=$(<:.s=.lst) 64 | CP_FLAGS = $(MC_FLAGS) $(OPT) -g -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS) 65 | LD_FLAGS = $(MC_FLAGS) -g -gdwarf-2 -mthumb -nostartfiles -Xlinker --gc-sections -T$(LINK_SCRIPT) -Wl,-Map=$(PROJECT_NAME).map,--cref,--no-warn-mismatch $(LIBDIR) $(LIB) 66 | 67 | # all the files will be generated with this name (main.elf, main.bin, main.hex, etc) 68 | PROJECT_NAME=$(BIN_DIR)/main 69 | 70 | # 71 | # makefile rules 72 | # 73 | all: $(OBJECTS) $(PROJECT_NAME).elf $(PROJECT_NAME).hex $(PROJECT_NAME).bin 74 | $(TOOLCHAIN)size $(PROJECT_NAME).elf 75 | 76 | %o: %c 77 | $(CC) -c $(CP_FLAGS) -I . $(INCDIR) $< -o $@ 78 | 79 | %o: %s 80 | $(AS) -c $(AS_FLAGS) $< -o $@ 81 | 82 | %elf: $(OBJECTS) 83 | $(CC) $(OBJECTS) $(LD_FLAGS) $(LIBS) -o $@ 84 | 85 | %hex: %elf 86 | $(HEX) $< $@ 87 | 88 | %bin: %elf 89 | $(BIN) $< $@ 90 | 91 | flash: $(PROJECT).bin 92 | st-flash write $(PROJECT).bin 0x8000000 93 | 94 | erase: 95 | st-flash erase 96 | 97 | clean: 98 | -rm -rf $(OBJECTS) 99 | -rm -rf $(PROJECT_NAME).elf 100 | -rm -rf $(PROJECT_NAME).map 101 | -rm -rf $(PROJECT_NAME).hex 102 | -rm -rf $(PROJECT_NAME).bin 103 | -rm -rf $(SRC:.c=.lst) 104 | -rm -rf $(ASM_SRC:.s=.lst) 105 | 106 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/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 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /user/config.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/4/27. 3 | // 4 | 5 | #include "config.h" 6 | #include "FreeRTOS.h" 7 | #include "FreeRTOSConfig.h" 8 | #include "task.h" 9 | 10 | void NVIC_Configuration(void) 11 | { 12 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); 13 | } 14 | 15 | void RCC_Configuration(void) 16 | { 17 | ErrorStatus HSEStartUpStatus; 18 | 19 | /* RCC system reset(for debug purpose) */ 20 | RCC_DeInit(); 21 | 22 | /* Enable HSE */ 23 | RCC_HSEConfig(RCC_HSE_ON); 24 | 25 | /* Wait till HSE is ready */ 26 | HSEStartUpStatus = RCC_WaitForHSEStartUp(); 27 | 28 | if (HSEStartUpStatus == SUCCESS) { 29 | /* Enable Prefetch Buffer */ 30 | // FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); 31 | 32 | /* Flash 2 wait state */ 33 | // FLASH_SetLatency(FLASH_Latency_2); 34 | 35 | /* HCLK = SYSCLK */ 36 | RCC_HCLKConfig(RCC_SYSCLK_Div1); 37 | 38 | /* PCLK2 = HCLK */ 39 | RCC_PCLK2Config(RCC_HCLK_Div1); 40 | 41 | /* PCLK1 = HCLK/2 */ 42 | RCC_PCLK1Config(RCC_HCLK_Div2); 43 | 44 | /* ADCCLK = PCLK2/4 */ 45 | RCC_ADCCLKConfig(RCC_PCLK2_Div4); 46 | 47 | /**************************** Configure PLLs ******************************/ 48 | /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ 49 | RCC_PREDIV2Config(RCC_PREDIV2_Div5); 50 | RCC_PLL2Config(RCC_PLL2Mul_8); 51 | 52 | /* Enable PLL2 */ 53 | RCC_PLL2Cmd(ENABLE); 54 | 55 | /* Wait till PLL2 is ready */ 56 | while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {} 57 | 58 | /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */ 59 | RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5); 60 | RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9); 61 | 62 | /* Enable PLL */ 63 | RCC_PLLCmd(ENABLE); 64 | 65 | /* Wait till PLL is ready */ 66 | while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {} 67 | 68 | /* Select PLL as system clock source */ 69 | RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); 70 | 71 | /* Wait till PLL is used as system clock source */ 72 | while (RCC_GetSYSCLKSource() != 0x08) {} 73 | } 74 | 75 | /*******************************Enable peripheral clocks***************************/ 76 | 77 | /* Enable DMA1 clock */ 78 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); 79 | 80 | /* DMA2 clock enable */ 81 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); 82 | 83 | /* Enable ADC1 and GPIOC clock */ 84 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOC, ENABLE); 85 | 86 | /* GPIOA Periph clock enable */ 87 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); 88 | /* DAC Periph clock enable */ 89 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); 90 | /* TIM2 Periph clock enable */ 91 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); 92 | } 93 | 94 | void GPIO_Configuration(void) 95 | { 96 | GPIO_InitTypeDef GPIO_InitStructure; 97 | 98 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; 99 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 100 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 101 | GPIO_Init(GPIOE, &GPIO_InitStructure); 102 | } 103 | 104 | void sleep(uint32_t ms) 105 | { 106 | if (ms < 10) { // last 10 ms 107 | ms = 10; 108 | } 109 | 110 | vTaskDelay( ms * configTICK_RATE_HZ / 1000); 111 | } 112 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/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 | -------------------------------------------------------------------------------- /stm32_flash.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * GCC linker script for STM32 microcontrollers (ARM Cortex-M). 3 | * 4 | * It exports the symbols needed for the CMSIS assembler startup script for GCC 5 | * ARM toolchains (_sidata, _sdata, _edata, _sbss, _ebss) and sets the entry 6 | * point to Reset_Handler. 7 | * 8 | * Adapt FLASH/RAM size for your particular device below. 9 | * 10 | * @author Bjørn Forsman 11 | */ 12 | 13 | MEMORY 14 | { 15 | flash (rx) : ORIGIN = 0x08000000, LENGTH = 256K 16 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K 17 | } 18 | 19 | ENTRY(Reset_Handler) 20 | 21 | /* 22 | * Reserve memory for heap and stack. The linker will issue an error if there 23 | * is not enough memory. 24 | * 25 | * NOTE: The reserved heap and stack will be added to the bss column of the 26 | * binutils size command. 27 | */ 28 | _heap_size = 0; /* required amount of heap */ 29 | _stack_size = 0; /* required amount of stack */ 30 | 31 | /* 32 | * The stack starts at the end of RAM and grows downwards. Full-descending 33 | * stack; decrement first, then store. 34 | */ 35 | _estack = ORIGIN(ram) + LENGTH(ram); 36 | 37 | SECTIONS 38 | { 39 | /* Reset and ISR vectors */ 40 | .isr_vector : 41 | { 42 | __isr_vector_start__ = .; 43 | KEEP(*(.isr_vector)) /* without 'KEEP' the garbage collector discards this section */ 44 | ASSERT(. != __isr_vector_start__, "The .isr_vector section is empty"); 45 | } >flash 46 | 47 | 48 | /* Text section (code and read-only data) */ 49 | .text : 50 | { 51 | . = ALIGN(4); 52 | _stext = .; 53 | *(.text*) /* code */ 54 | *(.rodata*) /* read only data */ 55 | 56 | /* 57 | * NOTE: .glue_7 and .glue_7t sections are not needed because Cortex-M 58 | * only supports Thumb instructions, no ARM/Thumb interworking. 59 | */ 60 | 61 | /* Static constructors and destructors */ 62 | KEEP(*(.init)) 63 | KEEP(*(.fini)) 64 | 65 | . = ALIGN(4); 66 | _etext = .; 67 | } >flash 68 | 69 | 70 | /* 71 | * Stack unwinding and exception handling sections. 72 | * 73 | * ARM compilers emit object files with .ARM.extab and .ARM.exidx sections 74 | * when using C++ exceptions. Also, at least GCC emits those sections when 75 | * dividing large numbers (64-bit) in C. So we have to handle them. 76 | * 77 | * (ARM uses .ARM.extab and .ARM.exidx instead of the .eh_frame section 78 | * used on x86.) 79 | */ 80 | .ARM.extab : /* exception unwinding information */ 81 | { 82 | *(.ARM.extab*) 83 | } >flash 84 | .ARM.exidx : /* index entries for section unwinding */ 85 | { 86 | *(.ARM.exidx*) 87 | } >flash 88 | 89 | 90 | /* 91 | * Newlib and Eglibc (at least) need these for C++ support. 92 | * 93 | * (Copied from Sourcery CodeBench Lite: arm-none-eabi-gcc -V) 94 | */ 95 | .preinit_array : 96 | { 97 | PROVIDE_HIDDEN(__preinit_array_start = .); 98 | KEEP(*(.preinit_array*)) 99 | PROVIDE_HIDDEN(__preinit_array_end = .); 100 | } >flash 101 | .init_array : 102 | { 103 | PROVIDE_HIDDEN(__init_array_start = .); 104 | KEEP(*(SORT(.init_array.*))) 105 | KEEP(*(.init_array*)) 106 | PROVIDE_HIDDEN(__init_array_end = .); 107 | } >flash 108 | .fini_array : 109 | { 110 | PROVIDE_HIDDEN(__fini_array_start = .); 111 | KEEP(*(SORT(.fini_array.*))) 112 | KEEP(*(.fini_array*)) 113 | PROVIDE_HIDDEN(__fini_array_end = .); 114 | } >flash 115 | 116 | 117 | /* 118 | * Initialized data section. This section is programmed into FLASH (LMA 119 | * address) and copied to RAM (VMA address) in startup code. 120 | */ 121 | _sidata = .; 122 | .data : AT(_sidata) /* LMA address is _sidata (in FLASH) */ 123 | { 124 | . = ALIGN(4); 125 | _sdata = .; /* data section VMA address */ 126 | *(.data*) 127 | . = ALIGN(4); 128 | _edata = .; 129 | } >ram 130 | 131 | 132 | /* Uninitialized data section (zeroed out by startup code) */ 133 | .bss : 134 | { 135 | . = ALIGN(4); 136 | _sbss = .; 137 | *(.bss*) 138 | *(COMMON) 139 | . = ALIGN(4); 140 | _ebss = .; 141 | } >ram 142 | 143 | 144 | /* 145 | * Reserve memory for heap and stack. The linker will issue an error if 146 | * there is not enough memory. 147 | */ 148 | ._heap : 149 | { 150 | . = ALIGN(4); 151 | . = . + _heap_size; 152 | . = ALIGN(4); 153 | } >ram 154 | ._stack : 155 | { 156 | . = ALIGN(4); 157 | . = . + _stack_size; 158 | . = ALIGN(4); 159 | } >ram 160 | } 161 | 162 | /* Nice to have */ 163 | __isr_vector_size__ = SIZEOF(.isr_vector); 164 | __text_size__ = SIZEOF(.text); 165 | __data_size__ = SIZEOF(.data); 166 | __bss_size__ = SIZEOF(.bss); 167 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/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 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/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 | -------------------------------------------------------------------------------- /freertos/portable/MemMang/heap_3.c: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | 71 | /* 72 | * Implementation of pvPortMalloc() and vPortFree() that relies on the 73 | * compilers own malloc() and free() implementations. 74 | * 75 | * This file can only be used if the linker is configured to to generate 76 | * a heap memory area. 77 | * 78 | * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the 79 | * memory management pages of http://www.FreeRTOS.org for more information. 80 | */ 81 | 82 | #include 83 | 84 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining 85 | all the API functions to use the MPU wrappers. That should only be done when 86 | task.h is included from an application file. */ 87 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 88 | 89 | #include "FreeRTOS.h" 90 | #include "task.h" 91 | 92 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 93 | 94 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) 95 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 96 | #endif 97 | 98 | /*-----------------------------------------------------------*/ 99 | 100 | void *pvPortMalloc( size_t xWantedSize ) 101 | { 102 | void *pvReturn; 103 | 104 | vTaskSuspendAll(); 105 | { 106 | pvReturn = malloc( xWantedSize ); 107 | traceMALLOC( pvReturn, xWantedSize ); 108 | } 109 | ( void ) xTaskResumeAll(); 110 | 111 | #if( configUSE_MALLOC_FAILED_HOOK == 1 ) 112 | { 113 | if( pvReturn == NULL ) 114 | { 115 | extern void vApplicationMallocFailedHook( void ); 116 | vApplicationMallocFailedHook(); 117 | } 118 | } 119 | #endif 120 | 121 | return pvReturn; 122 | } 123 | /*-----------------------------------------------------------*/ 124 | 125 | void vPortFree( void *pv ) 126 | { 127 | if( pv ) 128 | { 129 | vTaskSuspendAll(); 130 | { 131 | free( pv ); 132 | traceFREE( pv, 0 ); 133 | } 134 | ( void ) xTaskResumeAll(); 135 | } 136 | } 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/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 | -------------------------------------------------------------------------------- /user/hardware/uart_log.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by YangYongbao on 2017/3/18. 3 | // 4 | 5 | #include "uart_log.h" 6 | #include "stm32f10x.h" 7 | #include "stm32f10x_conf.h" 8 | 9 | void uart_log_init(void) 10 | { 11 | GPIO_InitTypeDef GPIO_InitStructure; 12 | USART_InitTypeDef USART_InitStructure; 13 | 14 | RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE); 15 | RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART3, ENABLE); 16 | 17 | /* USART3 GPIO config */ 18 | /* Configure USART3 Tx (PB10) as alternate function push-pull */ 19 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 20 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 21 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 22 | GPIO_Init(GPIOB, &GPIO_InitStructure); 23 | 24 | /* Configure USART3 Rx (PB11) as input floating */ 25 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; 26 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 27 | GPIO_Init(GPIOB, &GPIO_InitStructure); 28 | 29 | /* USART3 mode config */ 30 | USART_InitStructure.USART_BaudRate = 9600; 31 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 32 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 33 | USART_InitStructure.USART_Parity = USART_Parity_No ; 34 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 35 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 36 | USART_Init(USART3, &USART_InitStructure); 37 | USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); 38 | 39 | USART_Cmd(USART3, ENABLE); 40 | } 41 | 42 | static void printchar(char **str, unsigned int c) 43 | { 44 | while (USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); 45 | USART_SendData(USART3, (uint16_t)c); 46 | } 47 | 48 | #define PAD_RIGHT 1 49 | #define PAD_ZERO 2 50 | 51 | static int prints(char **out, const char *string, int width, int pad) 52 | { 53 | register int pc = 0, padchar = ' '; 54 | 55 | if (width > 0) { 56 | register int len = 0; 57 | register const char *ptr; 58 | for (ptr = string; *ptr; ++ptr) ++len; 59 | if (len >= width) width = 0; 60 | else width -= len; 61 | if (pad & PAD_ZERO) padchar = '0'; 62 | } 63 | if (!(pad & PAD_RIGHT)) { 64 | for ( ; width > 0; --width) { 65 | printchar (out, padchar); 66 | ++pc; 67 | } 68 | } 69 | for ( ; *string ; ++string) { 70 | printchar (out, *string); 71 | ++pc; 72 | } 73 | for ( ; width > 0; --width) { 74 | printchar (out, padchar); 75 | ++pc; 76 | } 77 | 78 | return pc; 79 | } 80 | 81 | /* the following should be enough for 32 bit int */ 82 | #define PRINT_BUF_LEN 12 83 | 84 | static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase) 85 | { 86 | char print_buf[PRINT_BUF_LEN]; 87 | register char *s; 88 | register int t, neg = 0, pc = 0; 89 | register unsigned int u = i; 90 | 91 | if (i == 0) { 92 | print_buf[0] = '0'; 93 | print_buf[1] = '\0'; 94 | return prints (out, print_buf, width, pad); 95 | } 96 | 97 | if (sg && b == 10 && i < 0) { 98 | neg = 1; 99 | u = -i; 100 | } 101 | 102 | s = print_buf + PRINT_BUF_LEN-1; 103 | *s = '\0'; 104 | 105 | while (u) { 106 | t = u % b; 107 | if( t >= 10 ) 108 | t += letbase - '0' - 10; 109 | *--s = t + '0'; 110 | u /= b; 111 | } 112 | 113 | if (neg) { 114 | if( width && (pad & PAD_ZERO) ) { 115 | printchar (out, '-'); 116 | ++pc; 117 | --width; 118 | } 119 | else { 120 | *--s = '-'; 121 | } 122 | } 123 | 124 | return pc + prints (out, s, width, pad); 125 | } 126 | 127 | static int print( char **out, const char *format, va_list args ) 128 | { 129 | register int width, pad; 130 | register int pc = 0; 131 | char scr[2]; 132 | 133 | for (; *format != 0; ++format) { 134 | if (*format == '%') { 135 | ++format; 136 | width = pad = 0; 137 | if (*format == '\0') break; 138 | if (*format == '%') goto out; 139 | if (*format == '-') { 140 | ++format; 141 | pad = PAD_RIGHT; 142 | } 143 | while (*format == '0') { 144 | ++format; 145 | pad |= PAD_ZERO; 146 | } 147 | for ( ; *format >= '0' && *format <= '9'; ++format) { 148 | width *= 10; 149 | width += *format - '0'; 150 | } 151 | if( *format == 's' ) { 152 | register char *s = (char *)va_arg( args, int ); 153 | pc += prints (out, s?s:"(null)", width, pad); 154 | continue; 155 | } 156 | if( *format == 'd' ) { 157 | pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a'); 158 | continue; 159 | } 160 | if( *format == 'x' ) { 161 | pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a'); 162 | continue; 163 | } 164 | if( *format == 'X' ) { 165 | pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A'); 166 | continue; 167 | } 168 | if( *format == 'u' ) { 169 | pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a'); 170 | continue; 171 | } 172 | if( *format == 'c' ) { 173 | /* char are converted to int then pushed on the stack */ 174 | scr[0] = (char)va_arg( args, int ); 175 | scr[1] = '\0'; 176 | pc += prints (out, scr, width, pad); 177 | continue; 178 | } 179 | } 180 | else { 181 | out: 182 | printchar (out, *format); 183 | ++pc; 184 | } 185 | } 186 | if (out) **out = '\0'; 187 | va_end( args ); 188 | return pc; 189 | } 190 | 191 | int printf(const char *format, ...) 192 | { 193 | va_list args; 194 | 195 | va_start( args, format ); 196 | return print( 0, format, args ); 197 | } 198 | 199 | void debug(const char *format, ...) 200 | { 201 | va_list args; 202 | 203 | va_start( args, format ); 204 | print( 0, format, args ); 205 | print(0, "\n", args); 206 | } 207 | 208 | int sprintf(char *out, const char *format, ...) 209 | { 210 | va_list args; 211 | 212 | va_start( args, format ); 213 | return print( &out, format, args ); 214 | } 215 | 216 | int snprintf( char *buf, unsigned int count, const char *format, ... ) 217 | { 218 | va_list args; 219 | 220 | ( void ) count; 221 | 222 | va_start( args, format ); 223 | return print( &buf, format, args ); 224 | } 225 | 226 | 227 | // UART3 interrupt 228 | void USART3_IRQHandler(void) 229 | { 230 | // uint8_t data; 231 | if (USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) 232 | { 233 | // data = USART_ReceiveData(USART3); 234 | // add usart receive here 235 | // uart_receive_input(data); 236 | 237 | USART_ClearFlag(USART3, USART_FLAG_RXNE); 238 | USART_ClearITPendingBit(USART3, USART_IT_RXNE); 239 | } 240 | } 241 | 242 | 243 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_cec.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_cec.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 CEC 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_CEC_H 25 | #define __STM32F10x_CEC_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 CEC 39 | * @{ 40 | */ 41 | 42 | 43 | /** @defgroup CEC_Exported_Types 44 | * @{ 45 | */ 46 | 47 | /** 48 | * @brief CEC Init structure definition 49 | */ 50 | typedef struct 51 | { 52 | uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode. 53 | This parameter can be a value of @ref CEC_BitTiming_Mode */ 54 | uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode. 55 | This parameter can be a value of @ref CEC_BitPeriod_Mode */ 56 | }CEC_InitTypeDef; 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup CEC_Exported_Constants 63 | * @{ 64 | */ 65 | 66 | /** @defgroup CEC_BitTiming_Mode 67 | * @{ 68 | */ 69 | #define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */ 70 | #define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */ 71 | 72 | #define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \ 73 | ((MODE) == CEC_BitTimingErrFreeMode)) 74 | /** 75 | * @} 76 | */ 77 | 78 | /** @defgroup CEC_BitPeriod_Mode 79 | * @{ 80 | */ 81 | #define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */ 82 | #define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */ 83 | 84 | #define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \ 85 | ((MODE) == CEC_BitPeriodFlexibleMode)) 86 | /** 87 | * @} 88 | */ 89 | 90 | 91 | /** @defgroup CEC_interrupts_definition 92 | * @{ 93 | */ 94 | #define CEC_IT_TERR CEC_CSR_TERR 95 | #define CEC_IT_TBTRF CEC_CSR_TBTRF 96 | #define CEC_IT_RERR CEC_CSR_RERR 97 | #define CEC_IT_RBTF CEC_CSR_RBTF 98 | #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \ 99 | ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF)) 100 | /** 101 | * @} 102 | */ 103 | 104 | 105 | /** @defgroup CEC_Own_Address 106 | * @{ 107 | */ 108 | #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** @defgroup CEC_Prescaler 114 | * @{ 115 | */ 116 | #define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF) 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup CEC_flags_definition 123 | * @{ 124 | */ 125 | 126 | /** 127 | * @brief ESR register flags 128 | */ 129 | #define CEC_FLAG_BTE ((uint32_t)0x10010000) 130 | #define CEC_FLAG_BPE ((uint32_t)0x10020000) 131 | #define CEC_FLAG_RBTFE ((uint32_t)0x10040000) 132 | #define CEC_FLAG_SBE ((uint32_t)0x10080000) 133 | #define CEC_FLAG_ACKE ((uint32_t)0x10100000) 134 | #define CEC_FLAG_LINE ((uint32_t)0x10200000) 135 | #define CEC_FLAG_TBTFE ((uint32_t)0x10400000) 136 | 137 | /** 138 | * @brief CSR register flags 139 | */ 140 | #define CEC_FLAG_TEOM ((uint32_t)0x00000002) 141 | #define CEC_FLAG_TERR ((uint32_t)0x00000004) 142 | #define CEC_FLAG_TBTRF ((uint32_t)0x00000008) 143 | #define CEC_FLAG_RSOM ((uint32_t)0x00000010) 144 | #define CEC_FLAG_REOM ((uint32_t)0x00000020) 145 | #define CEC_FLAG_RERR ((uint32_t)0x00000040) 146 | #define CEC_FLAG_RBTF ((uint32_t)0x00000080) 147 | 148 | #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00)) 149 | 150 | #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \ 151 | ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \ 152 | ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \ 153 | ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \ 154 | ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \ 155 | ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \ 156 | ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF)) 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /** @defgroup CEC_Exported_Macros 167 | * @{ 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** @defgroup CEC_Exported_Functions 175 | * @{ 176 | */ 177 | void CEC_DeInit(void); 178 | void CEC_Init(CEC_InitTypeDef* CEC_InitStruct); 179 | void CEC_Cmd(FunctionalState NewState); 180 | void CEC_ITConfig(FunctionalState NewState); 181 | void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress); 182 | void CEC_SetPrescaler(uint16_t CEC_Prescaler); 183 | void CEC_SendDataByte(uint8_t Data); 184 | uint8_t CEC_ReceiveDataByte(void); 185 | void CEC_StartOfMessage(void); 186 | void CEC_EndOfMessageCmd(FunctionalState NewState); 187 | FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG); 188 | void CEC_ClearFlag(uint32_t CEC_FLAG); 189 | ITStatus CEC_GetITStatus(uint8_t CEC_IT); 190 | void CEC_ClearITPendingBit(uint16_t CEC_IT); 191 | 192 | #ifdef __cplusplus 193 | } 194 | #endif 195 | 196 | #endif /* __STM32F10x_CEC_H */ 197 | 198 | /** 199 | * @} 200 | */ 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** 207 | * @} 208 | */ 209 | 210 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 211 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_exti.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_exti.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 EXTI 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_EXTI_H 25 | #define __STM32F10x_EXTI_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 EXTI 39 | * @{ 40 | */ 41 | 42 | /** @defgroup EXTI_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief EXTI mode enumeration 48 | */ 49 | 50 | typedef enum 51 | { 52 | EXTI_Mode_Interrupt = 0x00, 53 | EXTI_Mode_Event = 0x04 54 | }EXTIMode_TypeDef; 55 | 56 | #define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event)) 57 | 58 | /** 59 | * @brief EXTI Trigger enumeration 60 | */ 61 | 62 | typedef enum 63 | { 64 | EXTI_Trigger_Rising = 0x08, 65 | EXTI_Trigger_Falling = 0x0C, 66 | EXTI_Trigger_Rising_Falling = 0x10 67 | }EXTITrigger_TypeDef; 68 | 69 | #define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \ 70 | ((TRIGGER) == EXTI_Trigger_Falling) || \ 71 | ((TRIGGER) == EXTI_Trigger_Rising_Falling)) 72 | /** 73 | * @brief EXTI Init Structure definition 74 | */ 75 | 76 | typedef struct 77 | { 78 | uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. 79 | This parameter can be any combination of @ref EXTI_Lines */ 80 | 81 | EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. 82 | This parameter can be a value of @ref EXTIMode_TypeDef */ 83 | 84 | EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. 85 | This parameter can be a value of @ref EXTIMode_TypeDef */ 86 | 87 | FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. 88 | This parameter can be set either to ENABLE or DISABLE */ 89 | }EXTI_InitTypeDef; 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @defgroup EXTI_Exported_Constants 96 | * @{ 97 | */ 98 | 99 | /** @defgroup EXTI_Lines 100 | * @{ 101 | */ 102 | 103 | #define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */ 104 | #define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */ 105 | #define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */ 106 | #define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */ 107 | #define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */ 108 | #define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */ 109 | #define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */ 110 | #define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */ 111 | #define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */ 112 | #define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */ 113 | #define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */ 114 | #define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */ 115 | #define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */ 116 | #define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */ 117 | #define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */ 118 | #define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */ 119 | #define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */ 120 | #define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 121 | #define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB Device/USB OTG FS 122 | Wakeup from suspend event */ 123 | #define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 124 | 125 | #define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFFF00000) == 0x00) && ((LINE) != (uint16_t)0x00)) 126 | #define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \ 127 | ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \ 128 | ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \ 129 | ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \ 130 | ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \ 131 | ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \ 132 | ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \ 133 | ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \ 134 | ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \ 135 | ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19)) 136 | 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup EXTI_Exported_Macros 147 | * @{ 148 | */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** @defgroup EXTI_Exported_Functions 155 | * @{ 156 | */ 157 | 158 | void EXTI_DeInit(void); 159 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); 160 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); 161 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line); 162 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); 163 | void EXTI_ClearFlag(uint32_t EXTI_Line); 164 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); 165 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line); 166 | 167 | #ifdef __cplusplus 168 | } 169 | #endif 170 | 171 | #endif /* __STM32F10x_EXTI_H */ 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | /** 181 | * @} 182 | */ 183 | 184 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 185 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/misc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the miscellaneous firmware functions (add-on 8 | * to CMSIS functions). 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 | /* Includes ------------------------------------------------------------------*/ 24 | #include "misc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup MISC 31 | * @brief MISC driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup MISC_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup MISC_Private_Defines 44 | * @{ 45 | */ 46 | 47 | #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000) 48 | /** 49 | * @} 50 | */ 51 | 52 | /** @defgroup MISC_Private_Macros 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup MISC_Private_Variables 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup MISC_Private_FunctionPrototypes 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup MISC_Private_Functions 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @brief Configures the priority grouping: pre-emption priority and subpriority. 82 | * @param NVIC_PriorityGroup: specifies the priority grouping bits length. 83 | * This parameter can be one of the following values: 84 | * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority 85 | * 4 bits for subpriority 86 | * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority 87 | * 3 bits for subpriority 88 | * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority 89 | * 2 bits for subpriority 90 | * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority 91 | * 1 bits for subpriority 92 | * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority 93 | * 0 bits for subpriority 94 | * @retval None 95 | */ 96 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup) 97 | { 98 | /* Check the parameters */ 99 | assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup)); 100 | 101 | /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */ 102 | SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup; 103 | } 104 | 105 | /** 106 | * @brief Initializes the NVIC peripheral according to the specified 107 | * parameters in the NVIC_InitStruct. 108 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains 109 | * the configuration information for the specified NVIC peripheral. 110 | * @retval None 111 | */ 112 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) 113 | { 114 | uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F; 115 | 116 | /* Check the parameters */ 117 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); 118 | assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority)); 119 | assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority)); 120 | 121 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) 122 | { 123 | /* Compute the Corresponding IRQ Priority --------------------------------*/ 124 | tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; 125 | tmppre = (0x4 - tmppriority); 126 | tmpsub = tmpsub >> tmppriority; 127 | 128 | tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre; 129 | tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub; 130 | tmppriority = tmppriority << 0x04; 131 | 132 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority; 133 | 134 | /* Enable the Selected IRQ Channels --------------------------------------*/ 135 | NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 136 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 137 | } 138 | else 139 | { 140 | /* Disable the Selected IRQ Channels -------------------------------------*/ 141 | NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 142 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 143 | } 144 | } 145 | 146 | /** 147 | * @brief Sets the vector table location and Offset. 148 | * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory. 149 | * This parameter can be one of the following values: 150 | * @arg NVIC_VectTab_RAM 151 | * @arg NVIC_VectTab_FLASH 152 | * @param Offset: Vector Table base offset field. This value must be a multiple 153 | * of 0x200. 154 | * @retval None 155 | */ 156 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset) 157 | { 158 | /* Check the parameters */ 159 | assert_param(IS_NVIC_VECTTAB(NVIC_VectTab)); 160 | assert_param(IS_NVIC_OFFSET(Offset)); 161 | 162 | SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80); 163 | } 164 | 165 | /** 166 | * @brief Selects the condition for the system to enter low power mode. 167 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. 168 | * This parameter can be one of the following values: 169 | * @arg NVIC_LP_SEVONPEND 170 | * @arg NVIC_LP_SLEEPDEEP 171 | * @arg NVIC_LP_SLEEPONEXIT 172 | * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE. 173 | * @retval None 174 | */ 175 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) 176 | { 177 | /* Check the parameters */ 178 | assert_param(IS_NVIC_LP(LowPowerMode)); 179 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 180 | 181 | if (NewState != DISABLE) 182 | { 183 | SCB->SCR |= LowPowerMode; 184 | } 185 | else 186 | { 187 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); 188 | } 189 | } 190 | 191 | /** 192 | * @brief Configures the SysTick clock source. 193 | * @param SysTick_CLKSource: specifies the SysTick clock source. 194 | * This parameter can be one of the following values: 195 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. 196 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. 197 | * @retval None 198 | */ 199 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) 200 | { 201 | /* Check the parameters */ 202 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); 203 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK) 204 | { 205 | SysTick->CTRL |= SysTick_CLKSource_HCLK; 206 | } 207 | else 208 | { 209 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; 210 | } 211 | } 212 | 213 | /** 214 | * @} 215 | */ 216 | 217 | /** 218 | * @} 219 | */ 220 | 221 | /** 222 | * @} 223 | */ 224 | 225 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 226 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_exti.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the EXTI 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_exti.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup EXTI 30 | * @brief EXTI driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup EXTI_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup EXTI_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */ 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | /** @defgroup EXTI_Private_Macros 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup EXTI_Private_Variables 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup EXTI_Private_FunctionPrototypes 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup EXTI_Private_Functions 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @brief Deinitializes the EXTI peripheral registers to their default reset values. 82 | * @param None 83 | * @retval None 84 | */ 85 | void EXTI_DeInit(void) 86 | { 87 | EXTI->IMR = 0x00000000; 88 | EXTI->EMR = 0x00000000; 89 | EXTI->RTSR = 0x00000000; 90 | EXTI->FTSR = 0x00000000; 91 | EXTI->PR = 0x000FFFFF; 92 | } 93 | 94 | /** 95 | * @brief Initializes the EXTI peripheral according to the specified 96 | * parameters in the EXTI_InitStruct. 97 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure 98 | * that contains the configuration information for the EXTI peripheral. 99 | * @retval None 100 | */ 101 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) 102 | { 103 | uint32_t tmp = 0; 104 | 105 | /* Check the parameters */ 106 | assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode)); 107 | assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger)); 108 | assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line)); 109 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd)); 110 | 111 | tmp = (uint32_t)EXTI_BASE; 112 | 113 | if (EXTI_InitStruct->EXTI_LineCmd != DISABLE) 114 | { 115 | /* Clear EXTI line configuration */ 116 | EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line; 117 | EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line; 118 | 119 | tmp += EXTI_InitStruct->EXTI_Mode; 120 | 121 | *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; 122 | 123 | /* Clear Rising Falling edge configuration */ 124 | EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line; 125 | EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line; 126 | 127 | /* Select the trigger for the selected external interrupts */ 128 | if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling) 129 | { 130 | /* Rising Falling edge */ 131 | EXTI->RTSR |= EXTI_InitStruct->EXTI_Line; 132 | EXTI->FTSR |= EXTI_InitStruct->EXTI_Line; 133 | } 134 | else 135 | { 136 | tmp = (uint32_t)EXTI_BASE; 137 | tmp += EXTI_InitStruct->EXTI_Trigger; 138 | 139 | *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; 140 | } 141 | } 142 | else 143 | { 144 | tmp += EXTI_InitStruct->EXTI_Mode; 145 | 146 | /* Disable the selected external lines */ 147 | *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line; 148 | } 149 | } 150 | 151 | /** 152 | * @brief Fills each EXTI_InitStruct member with its reset value. 153 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will 154 | * be initialized. 155 | * @retval None 156 | */ 157 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) 158 | { 159 | EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; 160 | EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; 161 | EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; 162 | EXTI_InitStruct->EXTI_LineCmd = DISABLE; 163 | } 164 | 165 | /** 166 | * @brief Generates a Software interrupt. 167 | * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled. 168 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). 169 | * @retval None 170 | */ 171 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) 172 | { 173 | /* Check the parameters */ 174 | assert_param(IS_EXTI_LINE(EXTI_Line)); 175 | 176 | EXTI->SWIER |= EXTI_Line; 177 | } 178 | 179 | /** 180 | * @brief Checks whether the specified EXTI line flag is set or not. 181 | * @param EXTI_Line: specifies the EXTI line flag to check. 182 | * This parameter can be: 183 | * @arg EXTI_Linex: External interrupt line x where x(0..19) 184 | * @retval The new state of EXTI_Line (SET or RESET). 185 | */ 186 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) 187 | { 188 | FlagStatus bitstatus = RESET; 189 | /* Check the parameters */ 190 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 191 | 192 | if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET) 193 | { 194 | bitstatus = SET; 195 | } 196 | else 197 | { 198 | bitstatus = RESET; 199 | } 200 | return bitstatus; 201 | } 202 | 203 | /** 204 | * @brief Clears the EXTI's line pending flags. 205 | * @param EXTI_Line: specifies the EXTI lines flags to clear. 206 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). 207 | * @retval None 208 | */ 209 | void EXTI_ClearFlag(uint32_t EXTI_Line) 210 | { 211 | /* Check the parameters */ 212 | assert_param(IS_EXTI_LINE(EXTI_Line)); 213 | 214 | EXTI->PR = EXTI_Line; 215 | } 216 | 217 | /** 218 | * @brief Checks whether the specified EXTI line is asserted or not. 219 | * @param EXTI_Line: specifies the EXTI line to check. 220 | * This parameter can be: 221 | * @arg EXTI_Linex: External interrupt line x where x(0..19) 222 | * @retval The new state of EXTI_Line (SET or RESET). 223 | */ 224 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) 225 | { 226 | ITStatus bitstatus = RESET; 227 | uint32_t enablestatus = 0; 228 | /* Check the parameters */ 229 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 230 | 231 | enablestatus = EXTI->IMR & EXTI_Line; 232 | if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET)) 233 | { 234 | bitstatus = SET; 235 | } 236 | else 237 | { 238 | bitstatus = RESET; 239 | } 240 | return bitstatus; 241 | } 242 | 243 | /** 244 | * @brief Clears the EXTI's line pending bits. 245 | * @param EXTI_Line: specifies the EXTI lines to clear. 246 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). 247 | * @retval None 248 | */ 249 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line) 250 | { 251 | /* Check the parameters */ 252 | assert_param(IS_EXTI_LINE(EXTI_Line)); 253 | 254 | EXTI->PR = EXTI_Line; 255 | } 256 | 257 | /** 258 | * @} 259 | */ 260 | 261 | /** 262 | * @} 263 | */ 264 | 265 | /** 266 | * @} 267 | */ 268 | 269 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 270 | -------------------------------------------------------------------------------- /freertos/include/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | #ifndef FREERTOS_CONFIG_H 71 | #define FREERTOS_CONFIG_H 72 | 73 | #include "stm32f10x.h" 74 | 75 | /*----------------------------------------------------------- 76 | * Application specific definitions. 77 | * 78 | * These definitions should be adjusted for your particular hardware and 79 | * application requirements. 80 | * 81 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 82 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 83 | * 84 | * See http://www.freertos.org/a00110.html. 85 | *----------------------------------------------------------*/ 86 | 87 | #define configUSE_PREEMPTION 1 88 | #define configUSE_IDLE_HOOK 0 89 | #define configUSE_TICK_HOOK 0 90 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) 91 | #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) 92 | #define configMAX_PRIORITIES ( 5 ) 93 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 120 ) 94 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 18 * 1024 ) ) 95 | #define configMAX_TASK_NAME_LEN ( 16 ) 96 | #define configUSE_TRACE_FACILITY 1 97 | #define configUSE_16_BIT_TICKS 0 98 | #define configIDLE_SHOULD_YIELD 1 99 | 100 | /* Co-routine definitions. */ 101 | #define configUSE_CO_ROUTINES 0 102 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 103 | 104 | #define configUSE_MUTEXES 1 105 | #define configUSE_COUNTING_SEMAPHORES 1 106 | #define configUSE_ALTERNATIVE_API 0 107 | #define configCHECK_FOR_STACK_OVERFLOW 0 108 | #define configUSE_RECURSIVE_MUTEXES 1 109 | #define configQUEUE_REGISTRY_SIZE 0 110 | #define configGENERATE_RUN_TIME_STATS 0 111 | 112 | /* Set the following definitions to 1 to include the API function, or zero 113 | to exclude the API function. */ 114 | 115 | #define INCLUDE_vTaskPrioritySet 1 116 | #define INCLUDE_uxTaskPriorityGet 1 117 | #define INCLUDE_vTaskDelete 1 118 | #define INCLUDE_vTaskCleanUpResources 0 119 | #define INCLUDE_vTaskSuspend 1 120 | #define INCLUDE_vTaskDelayUntil 1 121 | #define INCLUDE_vTaskDelay 1 122 | 123 | #ifdef __NVIC_PRIO_BITS 124 | #define configPRIO_BITS __NVIC_PRIO_BITS 125 | #else 126 | #define configPRIO_BITS 4 127 | #endif 128 | 129 | 130 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x0f // config SysTick and PendSv interrupt priority 131 | #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 0x01 // config max interrupt priority of freeRTOS manager 132 | 133 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 134 | (lowest) to 0 (1?) (highest). */ 135 | #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 136 | //#define configKERNEL_INTERRUPT_PRIORITY 255 137 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! 138 | See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ 139 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 140 | //#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 141 | 142 | 143 | /* This is the value being used as per the ST library which permits 16 144 | priority values, 0 to 15. This must correspond to the 145 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 146 | NVIC value of 255. */ 147 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 148 | 149 | /*----------------------------------------------------------- 150 | * UART configuration. 151 | *-----------------------------------------------------------*/ 152 | #define configCOM0_RX_BUFFER_LENGTH 128 153 | #define configCOM0_TX_BUFFER_LENGTH 128 154 | #define configCOM1_RX_BUFFER_LENGTH 128 155 | #define configCOM1_TX_BUFFER_LENGTH 128 156 | 157 | // add freeRTOS to stm32 158 | #define vPortSVCHandler SVC_Handler 159 | #define xPortPendSVHandler PendSV_Handler 160 | #define xPortSysTickHandler SysTick_Handler 161 | 162 | #endif /* FREERTOS_CONFIG_H */ 163 | 164 | -------------------------------------------------------------------------------- /freertos/portable/MemMang/heap_1.c: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | 71 | /* 72 | * The simplest possible implementation of pvPortMalloc(). Note that this 73 | * implementation does NOT allow allocated memory to be freed again. 74 | * 75 | * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the 76 | * memory management pages of http://www.FreeRTOS.org for more information. 77 | */ 78 | #include 79 | 80 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining 81 | all the API functions to use the MPU wrappers. That should only be done when 82 | task.h is included from an application file. */ 83 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 84 | 85 | #include "FreeRTOS.h" 86 | #include "task.h" 87 | 88 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 89 | 90 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) 91 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 92 | #endif 93 | 94 | /* A few bytes might be lost to byte aligning the heap start address. */ 95 | #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) 96 | 97 | /* Allocate the memory for the heap. */ 98 | /* Allocate the memory for the heap. */ 99 | #if( configAPPLICATION_ALLOCATED_HEAP == 1 ) 100 | /* The application writer has already defined the array used for the RTOS 101 | heap - probably so it can be placed in a special segment or address. */ 102 | extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 103 | #else 104 | static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 105 | #endif /* configAPPLICATION_ALLOCATED_HEAP */ 106 | 107 | static size_t xNextFreeByte = ( size_t ) 0; 108 | 109 | /*-----------------------------------------------------------*/ 110 | 111 | void *pvPortMalloc( size_t xWantedSize ) 112 | { 113 | void *pvReturn = NULL; 114 | static uint8_t *pucAlignedHeap = NULL; 115 | 116 | /* Ensure that blocks are always aligned to the required number of bytes. */ 117 | #if( portBYTE_ALIGNMENT != 1 ) 118 | { 119 | if( xWantedSize & portBYTE_ALIGNMENT_MASK ) 120 | { 121 | /* Byte alignment required. */ 122 | xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); 123 | } 124 | } 125 | #endif 126 | 127 | vTaskSuspendAll(); 128 | { 129 | if( pucAlignedHeap == NULL ) 130 | { 131 | /* Ensure the heap starts on a correctly aligned boundary. */ 132 | pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); 133 | } 134 | 135 | /* Check there is enough room left for the allocation. */ 136 | if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && 137 | ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ 138 | { 139 | /* Return the next free byte then increment the index past this 140 | block. */ 141 | pvReturn = pucAlignedHeap + xNextFreeByte; 142 | xNextFreeByte += xWantedSize; 143 | } 144 | 145 | traceMALLOC( pvReturn, xWantedSize ); 146 | } 147 | ( void ) xTaskResumeAll(); 148 | 149 | #if( configUSE_MALLOC_FAILED_HOOK == 1 ) 150 | { 151 | if( pvReturn == NULL ) 152 | { 153 | extern void vApplicationMallocFailedHook( void ); 154 | vApplicationMallocFailedHook(); 155 | } 156 | } 157 | #endif 158 | 159 | return pvReturn; 160 | } 161 | /*-----------------------------------------------------------*/ 162 | 163 | void vPortFree( void *pv ) 164 | { 165 | /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and 166 | heap_4.c for alternative implementations, and the memory management pages of 167 | http://www.FreeRTOS.org for more information. */ 168 | ( void ) pv; 169 | 170 | /* Force an assert as it is invalid to call this function. */ 171 | configASSERT( pv == NULL ); 172 | } 173 | /*-----------------------------------------------------------*/ 174 | 175 | void vPortInitialiseBlocks( void ) 176 | { 177 | /* Only required when static memory is not cleared. */ 178 | xNextFreeByte = ( size_t ) 0; 179 | } 180 | /*-----------------------------------------------------------*/ 181 | 182 | size_t xPortGetFreeHeapSize( void ) 183 | { 184 | return ( configADJUSTED_HEAP_SIZE - xNextFreeByte ); 185 | } 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_bkp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_bkp.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 BKP 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_BKP_H 25 | #define __STM32F10x_BKP_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 BKP 39 | * @{ 40 | */ 41 | 42 | /** @defgroup BKP_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup BKP_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup Tamper_Pin_active_level 55 | * @{ 56 | */ 57 | 58 | #define BKP_TamperPinLevel_High ((uint16_t)0x0000) 59 | #define BKP_TamperPinLevel_Low ((uint16_t)0x0001) 60 | #define IS_BKP_TAMPER_PIN_LEVEL(LEVEL) (((LEVEL) == BKP_TamperPinLevel_High) || \ 61 | ((LEVEL) == BKP_TamperPinLevel_Low)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup RTC_output_source_to_output_on_the_Tamper_pin 67 | * @{ 68 | */ 69 | 70 | #define BKP_RTCOutputSource_None ((uint16_t)0x0000) 71 | #define BKP_RTCOutputSource_CalibClock ((uint16_t)0x0080) 72 | #define BKP_RTCOutputSource_Alarm ((uint16_t)0x0100) 73 | #define BKP_RTCOutputSource_Second ((uint16_t)0x0300) 74 | #define IS_BKP_RTC_OUTPUT_SOURCE(SOURCE) (((SOURCE) == BKP_RTCOutputSource_None) || \ 75 | ((SOURCE) == BKP_RTCOutputSource_CalibClock) || \ 76 | ((SOURCE) == BKP_RTCOutputSource_Alarm) || \ 77 | ((SOURCE) == BKP_RTCOutputSource_Second)) 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup Data_Backup_Register 83 | * @{ 84 | */ 85 | 86 | #define BKP_DR1 ((uint16_t)0x0004) 87 | #define BKP_DR2 ((uint16_t)0x0008) 88 | #define BKP_DR3 ((uint16_t)0x000C) 89 | #define BKP_DR4 ((uint16_t)0x0010) 90 | #define BKP_DR5 ((uint16_t)0x0014) 91 | #define BKP_DR6 ((uint16_t)0x0018) 92 | #define BKP_DR7 ((uint16_t)0x001C) 93 | #define BKP_DR8 ((uint16_t)0x0020) 94 | #define BKP_DR9 ((uint16_t)0x0024) 95 | #define BKP_DR10 ((uint16_t)0x0028) 96 | #define BKP_DR11 ((uint16_t)0x0040) 97 | #define BKP_DR12 ((uint16_t)0x0044) 98 | #define BKP_DR13 ((uint16_t)0x0048) 99 | #define BKP_DR14 ((uint16_t)0x004C) 100 | #define BKP_DR15 ((uint16_t)0x0050) 101 | #define BKP_DR16 ((uint16_t)0x0054) 102 | #define BKP_DR17 ((uint16_t)0x0058) 103 | #define BKP_DR18 ((uint16_t)0x005C) 104 | #define BKP_DR19 ((uint16_t)0x0060) 105 | #define BKP_DR20 ((uint16_t)0x0064) 106 | #define BKP_DR21 ((uint16_t)0x0068) 107 | #define BKP_DR22 ((uint16_t)0x006C) 108 | #define BKP_DR23 ((uint16_t)0x0070) 109 | #define BKP_DR24 ((uint16_t)0x0074) 110 | #define BKP_DR25 ((uint16_t)0x0078) 111 | #define BKP_DR26 ((uint16_t)0x007C) 112 | #define BKP_DR27 ((uint16_t)0x0080) 113 | #define BKP_DR28 ((uint16_t)0x0084) 114 | #define BKP_DR29 ((uint16_t)0x0088) 115 | #define BKP_DR30 ((uint16_t)0x008C) 116 | #define BKP_DR31 ((uint16_t)0x0090) 117 | #define BKP_DR32 ((uint16_t)0x0094) 118 | #define BKP_DR33 ((uint16_t)0x0098) 119 | #define BKP_DR34 ((uint16_t)0x009C) 120 | #define BKP_DR35 ((uint16_t)0x00A0) 121 | #define BKP_DR36 ((uint16_t)0x00A4) 122 | #define BKP_DR37 ((uint16_t)0x00A8) 123 | #define BKP_DR38 ((uint16_t)0x00AC) 124 | #define BKP_DR39 ((uint16_t)0x00B0) 125 | #define BKP_DR40 ((uint16_t)0x00B4) 126 | #define BKP_DR41 ((uint16_t)0x00B8) 127 | #define BKP_DR42 ((uint16_t)0x00BC) 128 | 129 | #define IS_BKP_DR(DR) (((DR) == BKP_DR1) || ((DR) == BKP_DR2) || ((DR) == BKP_DR3) || \ 130 | ((DR) == BKP_DR4) || ((DR) == BKP_DR5) || ((DR) == BKP_DR6) || \ 131 | ((DR) == BKP_DR7) || ((DR) == BKP_DR8) || ((DR) == BKP_DR9) || \ 132 | ((DR) == BKP_DR10) || ((DR) == BKP_DR11) || ((DR) == BKP_DR12) || \ 133 | ((DR) == BKP_DR13) || ((DR) == BKP_DR14) || ((DR) == BKP_DR15) || \ 134 | ((DR) == BKP_DR16) || ((DR) == BKP_DR17) || ((DR) == BKP_DR18) || \ 135 | ((DR) == BKP_DR19) || ((DR) == BKP_DR20) || ((DR) == BKP_DR21) || \ 136 | ((DR) == BKP_DR22) || ((DR) == BKP_DR23) || ((DR) == BKP_DR24) || \ 137 | ((DR) == BKP_DR25) || ((DR) == BKP_DR26) || ((DR) == BKP_DR27) || \ 138 | ((DR) == BKP_DR28) || ((DR) == BKP_DR29) || ((DR) == BKP_DR30) || \ 139 | ((DR) == BKP_DR31) || ((DR) == BKP_DR32) || ((DR) == BKP_DR33) || \ 140 | ((DR) == BKP_DR34) || ((DR) == BKP_DR35) || ((DR) == BKP_DR36) || \ 141 | ((DR) == BKP_DR37) || ((DR) == BKP_DR38) || ((DR) == BKP_DR39) || \ 142 | ((DR) == BKP_DR40) || ((DR) == BKP_DR41) || ((DR) == BKP_DR42)) 143 | 144 | #define IS_BKP_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x7F) 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /** @defgroup BKP_Exported_Macros 154 | * @{ 155 | */ 156 | 157 | /** 158 | * @} 159 | */ 160 | 161 | /** @defgroup BKP_Exported_Functions 162 | * @{ 163 | */ 164 | 165 | void BKP_DeInit(void); 166 | void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel); 167 | void BKP_TamperPinCmd(FunctionalState NewState); 168 | void BKP_ITConfig(FunctionalState NewState); 169 | void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource); 170 | void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue); 171 | void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data); 172 | uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR); 173 | FlagStatus BKP_GetFlagStatus(void); 174 | void BKP_ClearFlag(void); 175 | ITStatus BKP_GetITStatus(void); 176 | void BKP_ClearITPendingBit(void); 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* __STM32F10x_BKP_H */ 183 | /** 184 | * @} 185 | */ 186 | 187 | /** 188 | * @} 189 | */ 190 | 191 | /** 192 | * @} 193 | */ 194 | 195 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 196 | -------------------------------------------------------------------------------- /freertos/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | #ifndef PROJDEFS_H 71 | #define PROJDEFS_H 72 | 73 | /* 74 | * Defines the prototype to which task functions must conform. Defined in this 75 | * file to ensure the type is known before portable.h is included. 76 | */ 77 | typedef void (*TaskFunction_t)( void * ); 78 | 79 | /* Converts a time in milliseconds to a time in ticks. This macro can be 80 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 81 | definition here is not suitable for your application. */ 82 | #ifndef pdMS_TO_TICKS 83 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) 84 | #endif 85 | 86 | #define pdFALSE ( ( BaseType_t ) 0 ) 87 | #define pdTRUE ( ( BaseType_t ) 1 ) 88 | 89 | #define pdPASS ( pdTRUE ) 90 | #define pdFAIL ( pdFALSE ) 91 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 92 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 93 | 94 | /* FreeRTOS error definitions. */ 95 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 96 | #define errQUEUE_BLOCKED ( -4 ) 97 | #define errQUEUE_YIELD ( -5 ) 98 | 99 | /* Macros used for basic data corruption checks. */ 100 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 101 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 102 | #endif 103 | 104 | #if( configUSE_16_BIT_TICKS == 1 ) 105 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 106 | #else 107 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 108 | #endif 109 | 110 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 111 | itself. */ 112 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 113 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 114 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 115 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 116 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 117 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 118 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 119 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 120 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 121 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 122 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 123 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 124 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 125 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 126 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 127 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 128 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 129 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 130 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 131 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 132 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 133 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 134 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 135 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 136 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 137 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 138 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 139 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 140 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 141 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 142 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 143 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 144 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 145 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 146 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 147 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 148 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 149 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 150 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 151 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 152 | 153 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 154 | itself. */ 155 | #define pdFREERTOS_LITTLE_ENDIAN 0 156 | #define pdFREERTOS_BIG_ENDIAN 1 157 | 158 | #endif /* PROJDEFS_H */ 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /freertos/include/StackMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | #ifndef STACK_MACROS_H 71 | #define STACK_MACROS_H 72 | 73 | /* 74 | * Call the stack overflow hook function if the stack of the task being swapped 75 | * out is currently overflowed, or looks like it might have overflowed in the 76 | * past. 77 | * 78 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 79 | * the current stack state only - comparing the current top of stack value to 80 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 81 | * will also cause the last few stack bytes to be checked to ensure the value 82 | * to which the bytes were set when the task was created have not been 83 | * overwritten. Note this second test does not guarantee that an overflowed 84 | * stack will always be recognised. 85 | */ 86 | 87 | /*-----------------------------------------------------------*/ 88 | 89 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 90 | 91 | /* Only the current stack state is to be checked. */ 92 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 93 | { \ 94 | /* Is the currently saved stack pointer within the stack limit? */ \ 95 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 96 | { \ 97 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 98 | } \ 99 | } 100 | 101 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 102 | /*-----------------------------------------------------------*/ 103 | 104 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 105 | 106 | /* Only the current stack state is to be checked. */ 107 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 108 | { \ 109 | \ 110 | /* Is the currently saved stack pointer within the stack limit? */ \ 111 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 112 | { \ 113 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 114 | } \ 115 | } 116 | 117 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 118 | /*-----------------------------------------------------------*/ 119 | 120 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 121 | 122 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 123 | { \ 124 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 125 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 126 | \ 127 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 128 | ( pulStack[ 1 ] != ulCheckValue ) || \ 129 | ( pulStack[ 2 ] != ulCheckValue ) || \ 130 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 131 | { \ 132 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 133 | } \ 134 | } 135 | 136 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 137 | /*-----------------------------------------------------------*/ 138 | 139 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 140 | 141 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 142 | { \ 143 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 144 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 145 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 146 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 147 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 148 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 149 | \ 150 | \ 151 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 152 | \ 153 | /* Has the extremity of the task stack ever been written over? */ \ 154 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 155 | { \ 156 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 157 | } \ 158 | } 159 | 160 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 161 | /*-----------------------------------------------------------*/ 162 | 163 | /* Remove stack overflow macro if not being used. */ 164 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 165 | #define taskCHECK_FOR_STACK_OVERFLOW() 166 | #endif 167 | 168 | 169 | 170 | #endif /* STACK_MACROS_H */ 171 | 172 | -------------------------------------------------------------------------------- /freertos/include/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | /*----------------------------------------------------------- 71 | * Portable layer API. Each function must be defined for each port. 72 | *----------------------------------------------------------*/ 73 | 74 | #ifndef PORTABLE_H 75 | #define PORTABLE_H 76 | 77 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 78 | pre-processor definition was used to ensure the pre-processor found the correct 79 | portmacro.h file for the port being used. That scheme was deprecated in favour 80 | of setting the compiler's include path such that it found the correct 81 | portmacro.h file - removing the need for the constant and allowing the 82 | portmacro.h file to be located anywhere in relation to the port being used. 83 | Purely for reasons of backward compatibility the old method is still valid, but 84 | to make it clear that new projects should not use it, support for the port 85 | specific constants has been moved into the deprecated_definitions.h header 86 | file. */ 87 | #include "deprecated_definitions.h" 88 | 89 | /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h 90 | did not result in a portmacro.h header file being included - and it should be 91 | included here. In this case the path to the correct portmacro.h header file 92 | must be set in the compiler's include path. */ 93 | #ifndef portENTER_CRITICAL 94 | #include "portmacro.h" 95 | #endif 96 | 97 | #if portBYTE_ALIGNMENT == 32 98 | #define portBYTE_ALIGNMENT_MASK ( 0x001f ) 99 | #endif 100 | 101 | #if portBYTE_ALIGNMENT == 16 102 | #define portBYTE_ALIGNMENT_MASK ( 0x000f ) 103 | #endif 104 | 105 | #if portBYTE_ALIGNMENT == 8 106 | #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) 107 | #endif 108 | 109 | #if portBYTE_ALIGNMENT == 4 110 | #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) 111 | #endif 112 | 113 | #if portBYTE_ALIGNMENT == 2 114 | #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) 115 | #endif 116 | 117 | #if portBYTE_ALIGNMENT == 1 118 | #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) 119 | #endif 120 | 121 | #ifndef portBYTE_ALIGNMENT_MASK 122 | #error "Invalid portBYTE_ALIGNMENT definition" 123 | #endif 124 | 125 | #ifndef portNUM_CONFIGURABLE_REGIONS 126 | #define portNUM_CONFIGURABLE_REGIONS 1 127 | #endif 128 | 129 | #ifdef __cplusplus 130 | extern "C" { 131 | #endif 132 | 133 | #include "mpu_wrappers.h" 134 | 135 | /* 136 | * Setup the stack of a new task so it is ready to be placed under the 137 | * scheduler control. The registers have to be placed on the stack in 138 | * the order that the port expects to find them. 139 | * 140 | */ 141 | #if( portUSING_MPU_WRAPPERS == 1 ) 142 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 143 | #else 144 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 145 | #endif 146 | 147 | /* Used by heap_5.c. */ 148 | typedef struct HeapRegion 149 | { 150 | uint8_t *pucStartAddress; 151 | size_t xSizeInBytes; 152 | } HeapRegion_t; 153 | 154 | /* 155 | * Used to define multiple heap regions for use by heap_5.c. This function 156 | * must be called before any calls to pvPortMalloc() - not creating a task, 157 | * queue, semaphore, mutex, software timer, event group, etc. will result in 158 | * pvPortMalloc being called. 159 | * 160 | * pxHeapRegions passes in an array of HeapRegion_t structures - each of which 161 | * defines a region of memory that can be used as the heap. The array is 162 | * terminated by a HeapRegions_t structure that has a size of 0. The region 163 | * with the lowest start address must appear first in the array. 164 | */ 165 | void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; 166 | 167 | 168 | /* 169 | * Map to the memory management routines required for the port. 170 | */ 171 | void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; 172 | void vPortFree( void *pv ) PRIVILEGED_FUNCTION; 173 | void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; 174 | size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; 175 | size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; 176 | 177 | /* 178 | * Setup the hardware ready for the scheduler to take control. This generally 179 | * sets up a tick interrupt and sets timers for the correct tick frequency. 180 | */ 181 | BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; 182 | 183 | /* 184 | * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so 185 | * the hardware is left in its original condition after the scheduler stops 186 | * executing. 187 | */ 188 | void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; 189 | 190 | /* 191 | * The structures and methods of manipulating the MPU are contained within the 192 | * port layer. 193 | * 194 | * Fills the xMPUSettings structure with the memory region information 195 | * contained in xRegions. 196 | */ 197 | #if( portUSING_MPU_WRAPPERS == 1 ) 198 | struct xMEMORY_REGION; 199 | void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; 200 | #endif 201 | 202 | #ifdef __cplusplus 203 | } 204 | #endif 205 | 206 | #endif /* PORTABLE_H */ 207 | 208 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_bkp.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the BKP 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_bkp.h" 24 | #include "stm32f10x_rcc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup BKP 31 | * @brief BKP driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup BKP_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup BKP_Private_Defines 44 | * @{ 45 | */ 46 | 47 | /* ------------ BKP registers bit address in the alias region --------------- */ 48 | #define BKP_OFFSET (BKP_BASE - PERIPH_BASE) 49 | 50 | /* --- CR Register ----*/ 51 | 52 | /* Alias word address of TPAL bit */ 53 | #define CR_OFFSET (BKP_OFFSET + 0x30) 54 | #define TPAL_BitNumber 0x01 55 | #define CR_TPAL_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPAL_BitNumber * 4)) 56 | 57 | /* Alias word address of TPE bit */ 58 | #define TPE_BitNumber 0x00 59 | #define CR_TPE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPE_BitNumber * 4)) 60 | 61 | /* --- CSR Register ---*/ 62 | 63 | /* Alias word address of TPIE bit */ 64 | #define CSR_OFFSET (BKP_OFFSET + 0x34) 65 | #define TPIE_BitNumber 0x02 66 | #define CSR_TPIE_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TPIE_BitNumber * 4)) 67 | 68 | /* Alias word address of TIF bit */ 69 | #define TIF_BitNumber 0x09 70 | #define CSR_TIF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TIF_BitNumber * 4)) 71 | 72 | /* Alias word address of TEF bit */ 73 | #define TEF_BitNumber 0x08 74 | #define CSR_TEF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEF_BitNumber * 4)) 75 | 76 | /* ---------------------- BKP registers bit mask ------------------------ */ 77 | 78 | /* RTCCR register bit mask */ 79 | #define RTCCR_CAL_MASK ((uint16_t)0xFF80) 80 | #define RTCCR_MASK ((uint16_t)0xFC7F) 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | 87 | /** @defgroup BKP_Private_Macros 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @defgroup BKP_Private_Variables 96 | * @{ 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** @defgroup BKP_Private_FunctionPrototypes 104 | * @{ 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** @defgroup BKP_Private_Functions 112 | * @{ 113 | */ 114 | 115 | /** 116 | * @brief Deinitializes the BKP peripheral registers to their default reset values. 117 | * @param None 118 | * @retval None 119 | */ 120 | void BKP_DeInit(void) 121 | { 122 | RCC_BackupResetCmd(ENABLE); 123 | RCC_BackupResetCmd(DISABLE); 124 | } 125 | 126 | /** 127 | * @brief Configures the Tamper Pin active level. 128 | * @param BKP_TamperPinLevel: specifies the Tamper Pin active level. 129 | * This parameter can be one of the following values: 130 | * @arg BKP_TamperPinLevel_High: Tamper pin active on high level 131 | * @arg BKP_TamperPinLevel_Low: Tamper pin active on low level 132 | * @retval None 133 | */ 134 | void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel) 135 | { 136 | /* Check the parameters */ 137 | assert_param(IS_BKP_TAMPER_PIN_LEVEL(BKP_TamperPinLevel)); 138 | *(__IO uint32_t *) CR_TPAL_BB = BKP_TamperPinLevel; 139 | } 140 | 141 | /** 142 | * @brief Enables or disables the Tamper Pin activation. 143 | * @param NewState: new state of the Tamper Pin activation. 144 | * This parameter can be: ENABLE or DISABLE. 145 | * @retval None 146 | */ 147 | void BKP_TamperPinCmd(FunctionalState NewState) 148 | { 149 | /* Check the parameters */ 150 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 151 | *(__IO uint32_t *) CR_TPE_BB = (uint32_t)NewState; 152 | } 153 | 154 | /** 155 | * @brief Enables or disables the Tamper Pin Interrupt. 156 | * @param NewState: new state of the Tamper Pin Interrupt. 157 | * This parameter can be: ENABLE or DISABLE. 158 | * @retval None 159 | */ 160 | void BKP_ITConfig(FunctionalState NewState) 161 | { 162 | /* Check the parameters */ 163 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 164 | *(__IO uint32_t *) CSR_TPIE_BB = (uint32_t)NewState; 165 | } 166 | 167 | /** 168 | * @brief Select the RTC output source to output on the Tamper pin. 169 | * @param BKP_RTCOutputSource: specifies the RTC output source. 170 | * This parameter can be one of the following values: 171 | * @arg BKP_RTCOutputSource_None: no RTC output on the Tamper pin. 172 | * @arg BKP_RTCOutputSource_CalibClock: output the RTC clock with frequency 173 | * divided by 64 on the Tamper pin. 174 | * @arg BKP_RTCOutputSource_Alarm: output the RTC Alarm pulse signal on 175 | * the Tamper pin. 176 | * @arg BKP_RTCOutputSource_Second: output the RTC Second pulse signal on 177 | * the Tamper pin. 178 | * @retval None 179 | */ 180 | void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource) 181 | { 182 | uint16_t tmpreg = 0; 183 | /* Check the parameters */ 184 | assert_param(IS_BKP_RTC_OUTPUT_SOURCE(BKP_RTCOutputSource)); 185 | tmpreg = BKP->RTCCR; 186 | /* Clear CCO, ASOE and ASOS bits */ 187 | tmpreg &= RTCCR_MASK; 188 | 189 | /* Set CCO, ASOE and ASOS bits according to BKP_RTCOutputSource value */ 190 | tmpreg |= BKP_RTCOutputSource; 191 | /* Store the new value */ 192 | BKP->RTCCR = tmpreg; 193 | } 194 | 195 | /** 196 | * @brief Sets RTC Clock Calibration value. 197 | * @param CalibrationValue: specifies the RTC Clock Calibration value. 198 | * This parameter must be a number between 0 and 0x7F. 199 | * @retval None 200 | */ 201 | void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue) 202 | { 203 | uint16_t tmpreg = 0; 204 | /* Check the parameters */ 205 | assert_param(IS_BKP_CALIBRATION_VALUE(CalibrationValue)); 206 | tmpreg = BKP->RTCCR; 207 | /* Clear CAL[6:0] bits */ 208 | tmpreg &= RTCCR_CAL_MASK; 209 | /* Set CAL[6:0] bits according to CalibrationValue value */ 210 | tmpreg |= CalibrationValue; 211 | /* Store the new value */ 212 | BKP->RTCCR = tmpreg; 213 | } 214 | 215 | /** 216 | * @brief Writes user data to the specified Data Backup Register. 217 | * @param BKP_DR: specifies the Data Backup Register. 218 | * This parameter can be BKP_DRx where x:[1, 42] 219 | * @param Data: data to write 220 | * @retval None 221 | */ 222 | void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data) 223 | { 224 | __IO uint32_t tmp = 0; 225 | 226 | /* Check the parameters */ 227 | assert_param(IS_BKP_DR(BKP_DR)); 228 | 229 | tmp = (uint32_t)BKP_BASE; 230 | tmp += BKP_DR; 231 | 232 | *(__IO uint32_t *) tmp = Data; 233 | } 234 | 235 | /** 236 | * @brief Reads data from the specified Data Backup Register. 237 | * @param BKP_DR: specifies the Data Backup Register. 238 | * This parameter can be BKP_DRx where x:[1, 42] 239 | * @retval The content of the specified Data Backup Register 240 | */ 241 | uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR) 242 | { 243 | __IO uint32_t tmp = 0; 244 | 245 | /* Check the parameters */ 246 | assert_param(IS_BKP_DR(BKP_DR)); 247 | 248 | tmp = (uint32_t)BKP_BASE; 249 | tmp += BKP_DR; 250 | 251 | return (*(__IO uint16_t *) tmp); 252 | } 253 | 254 | /** 255 | * @brief Checks whether the Tamper Pin Event flag is set or not. 256 | * @param None 257 | * @retval The new state of the Tamper Pin Event flag (SET or RESET). 258 | */ 259 | FlagStatus BKP_GetFlagStatus(void) 260 | { 261 | return (FlagStatus)(*(__IO uint32_t *) CSR_TEF_BB); 262 | } 263 | 264 | /** 265 | * @brief Clears Tamper Pin Event pending flag. 266 | * @param None 267 | * @retval None 268 | */ 269 | void BKP_ClearFlag(void) 270 | { 271 | /* Set CTE bit to clear Tamper Pin Event flag */ 272 | BKP->CSR |= BKP_CSR_CTE; 273 | } 274 | 275 | /** 276 | * @brief Checks whether the Tamper Pin Interrupt has occurred or not. 277 | * @param None 278 | * @retval The new state of the Tamper Pin Interrupt (SET or RESET). 279 | */ 280 | ITStatus BKP_GetITStatus(void) 281 | { 282 | return (ITStatus)(*(__IO uint32_t *) CSR_TIF_BB); 283 | } 284 | 285 | /** 286 | * @brief Clears Tamper Pin Interrupt pending bit. 287 | * @param None 288 | * @retval None 289 | */ 290 | void BKP_ClearITPendingBit(void) 291 | { 292 | /* Set CTI bit to clear Tamper Pin Interrupt pending bit */ 293 | BKP->CSR |= BKP_CSR_CTI; 294 | } 295 | 296 | /** 297 | * @} 298 | */ 299 | 300 | /** 301 | * @} 302 | */ 303 | 304 | /** 305 | * @} 306 | */ 307 | 308 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 309 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/inc/misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.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 miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 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 __MISC_H 25 | #define __MISC_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 MISC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup MISC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief NVIC Init Structure definition 48 | */ 49 | 50 | typedef struct 51 | { 52 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 53 | This parameter can be a value of @ref IRQn_Type 54 | (For the complete STM32 Devices IRQ Channels list, please 55 | refer to stm32f10x.h file) */ 56 | 57 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 58 | specified in NVIC_IRQChannel. This parameter can be a value 59 | between 0 and 15 as described in the table @ref NVIC_Priority_Table */ 60 | 61 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 62 | in NVIC_IRQChannel. This parameter can be a value 63 | between 0 and 15 as described in the table @ref NVIC_Priority_Table */ 64 | 65 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 66 | will be enabled or disabled. 67 | This parameter can be set either to ENABLE or DISABLE */ 68 | } NVIC_InitTypeDef; 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup NVIC_Priority_Table 75 | * @{ 76 | */ 77 | 78 | /** 79 | @code 80 | The table below gives the allowed values of the pre-emption priority and subpriority according 81 | to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function 82 | ============================================================================================================================ 83 | NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description 84 | ============================================================================================================================ 85 | NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority 86 | | | | 4 bits for subpriority 87 | ---------------------------------------------------------------------------------------------------------------------------- 88 | NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority 89 | | | | 3 bits for subpriority 90 | ---------------------------------------------------------------------------------------------------------------------------- 91 | NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority 92 | | | | 2 bits for subpriority 93 | ---------------------------------------------------------------------------------------------------------------------------- 94 | NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority 95 | | | | 1 bits for subpriority 96 | ---------------------------------------------------------------------------------------------------------------------------- 97 | NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority 98 | | | | 0 bits for subpriority 99 | ============================================================================================================================ 100 | @endcode 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** @defgroup MISC_Exported_Constants 108 | * @{ 109 | */ 110 | 111 | /** @defgroup Vector_Table_Base 112 | * @{ 113 | */ 114 | 115 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 116 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 117 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ 118 | ((VECTTAB) == NVIC_VectTab_FLASH)) 119 | /** 120 | * @} 121 | */ 122 | 123 | /** @defgroup System_Low_Power 124 | * @{ 125 | */ 126 | 127 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 128 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 129 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 130 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 131 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 132 | ((LP) == NVIC_LP_SLEEPONEXIT)) 133 | /** 134 | * @} 135 | */ 136 | 137 | /** @defgroup Preemption_Priority_Group 138 | * @{ 139 | */ 140 | 141 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 142 | 4 bits for subpriority */ 143 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 144 | 3 bits for subpriority */ 145 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 146 | 2 bits for subpriority */ 147 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 148 | 1 bits for subpriority */ 149 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 150 | 0 bits for subpriority */ 151 | 152 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ 153 | ((GROUP) == NVIC_PriorityGroup_1) || \ 154 | ((GROUP) == NVIC_PriorityGroup_2) || \ 155 | ((GROUP) == NVIC_PriorityGroup_3) || \ 156 | ((GROUP) == NVIC_PriorityGroup_4)) 157 | 158 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 159 | 160 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 161 | 162 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** @defgroup SysTick_clock_source 169 | * @{ 170 | */ 171 | 172 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 173 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 174 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 175 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 176 | /** 177 | * @} 178 | */ 179 | 180 | /** 181 | * @} 182 | */ 183 | 184 | /** @defgroup MISC_Exported_Macros 185 | * @{ 186 | */ 187 | 188 | /** 189 | * @} 190 | */ 191 | 192 | /** @defgroup MISC_Exported_Functions 193 | * @{ 194 | */ 195 | 196 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 197 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 198 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 199 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 200 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 201 | 202 | #ifdef __cplusplus 203 | } 204 | #endif 205 | 206 | #endif /* __MISC_H */ 207 | 208 | /** 209 | * @} 210 | */ 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 221 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_pwr.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the PWR 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_pwr.h" 24 | #include "stm32f10x_rcc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup PWR 31 | * @brief PWR driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup PWR_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup PWR_Private_Defines 44 | * @{ 45 | */ 46 | 47 | /* --------- PWR registers bit address in the alias region ---------- */ 48 | #define PWR_OFFSET (PWR_BASE - PERIPH_BASE) 49 | 50 | /* --- CR Register ---*/ 51 | 52 | /* Alias word address of DBP bit */ 53 | #define CR_OFFSET (PWR_OFFSET + 0x00) 54 | #define DBP_BitNumber 0x08 55 | #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4)) 56 | 57 | /* Alias word address of PVDE bit */ 58 | #define PVDE_BitNumber 0x04 59 | #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4)) 60 | 61 | /* --- CSR Register ---*/ 62 | 63 | /* Alias word address of EWUP bit */ 64 | #define CSR_OFFSET (PWR_OFFSET + 0x04) 65 | #define EWUP_BitNumber 0x08 66 | #define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4)) 67 | 68 | /* ------------------ PWR registers bit mask ------------------------ */ 69 | 70 | /* CR register bit mask */ 71 | #define CR_DS_MASK ((uint32_t)0xFFFFFFFC) 72 | #define CR_PLS_MASK ((uint32_t)0xFFFFFF1F) 73 | 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** @defgroup PWR_Private_Macros 80 | * @{ 81 | */ 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup PWR_Private_Variables 88 | * @{ 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @defgroup PWR_Private_FunctionPrototypes 96 | * @{ 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** @defgroup PWR_Private_Functions 104 | * @{ 105 | */ 106 | 107 | /** 108 | * @brief Deinitializes the PWR peripheral registers to their default reset values. 109 | * @param None 110 | * @retval None 111 | */ 112 | void PWR_DeInit(void) 113 | { 114 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); 115 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE); 116 | } 117 | 118 | /** 119 | * @brief Enables or disables access to the RTC and backup registers. 120 | * @param NewState: new state of the access to the RTC and backup registers. 121 | * This parameter can be: ENABLE or DISABLE. 122 | * @retval None 123 | */ 124 | void PWR_BackupAccessCmd(FunctionalState NewState) 125 | { 126 | /* Check the parameters */ 127 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 128 | *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState; 129 | } 130 | 131 | /** 132 | * @brief Enables or disables the Power Voltage Detector(PVD). 133 | * @param NewState: new state of the PVD. 134 | * This parameter can be: ENABLE or DISABLE. 135 | * @retval None 136 | */ 137 | void PWR_PVDCmd(FunctionalState NewState) 138 | { 139 | /* Check the parameters */ 140 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 141 | *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState; 142 | } 143 | 144 | /** 145 | * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). 146 | * @param PWR_PVDLevel: specifies the PVD detection level 147 | * This parameter can be one of the following values: 148 | * @arg PWR_PVDLevel_2V2: PVD detection level set to 2.2V 149 | * @arg PWR_PVDLevel_2V3: PVD detection level set to 2.3V 150 | * @arg PWR_PVDLevel_2V4: PVD detection level set to 2.4V 151 | * @arg PWR_PVDLevel_2V5: PVD detection level set to 2.5V 152 | * @arg PWR_PVDLevel_2V6: PVD detection level set to 2.6V 153 | * @arg PWR_PVDLevel_2V7: PVD detection level set to 2.7V 154 | * @arg PWR_PVDLevel_2V8: PVD detection level set to 2.8V 155 | * @arg PWR_PVDLevel_2V9: PVD detection level set to 2.9V 156 | * @retval None 157 | */ 158 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) 159 | { 160 | uint32_t tmpreg = 0; 161 | /* Check the parameters */ 162 | assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); 163 | tmpreg = PWR->CR; 164 | /* Clear PLS[7:5] bits */ 165 | tmpreg &= CR_PLS_MASK; 166 | /* Set PLS[7:5] bits according to PWR_PVDLevel value */ 167 | tmpreg |= PWR_PVDLevel; 168 | /* Store the new value */ 169 | PWR->CR = tmpreg; 170 | } 171 | 172 | /** 173 | * @brief Enables or disables the WakeUp Pin functionality. 174 | * @param NewState: new state of the WakeUp Pin functionality. 175 | * This parameter can be: ENABLE or DISABLE. 176 | * @retval None 177 | */ 178 | void PWR_WakeUpPinCmd(FunctionalState NewState) 179 | { 180 | /* Check the parameters */ 181 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 182 | *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)NewState; 183 | } 184 | 185 | /** 186 | * @brief Enters STOP mode. 187 | * @param PWR_Regulator: specifies the regulator state in STOP mode. 188 | * This parameter can be one of the following values: 189 | * @arg PWR_Regulator_ON: STOP mode with regulator ON 190 | * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode 191 | * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction. 192 | * This parameter can be one of the following values: 193 | * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction 194 | * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction 195 | * @retval None 196 | */ 197 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry) 198 | { 199 | uint32_t tmpreg = 0; 200 | /* Check the parameters */ 201 | assert_param(IS_PWR_REGULATOR(PWR_Regulator)); 202 | assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry)); 203 | 204 | /* Select the regulator state in STOP mode ---------------------------------*/ 205 | tmpreg = PWR->CR; 206 | /* Clear PDDS and LPDS bits */ 207 | tmpreg &= CR_DS_MASK; 208 | /* Set LPDS bit according to PWR_Regulator value */ 209 | tmpreg |= PWR_Regulator; 210 | /* Store the new value */ 211 | PWR->CR = tmpreg; 212 | /* Set SLEEPDEEP bit of Cortex System Control Register */ 213 | SCB->SCR |= SCB_SCR_SLEEPDEEP; 214 | 215 | /* Select STOP mode entry --------------------------------------------------*/ 216 | if(PWR_STOPEntry == PWR_STOPEntry_WFI) 217 | { 218 | /* Request Wait For Interrupt */ 219 | __WFI(); 220 | } 221 | else 222 | { 223 | /* Request Wait For Event */ 224 | __WFE(); 225 | } 226 | 227 | /* Reset SLEEPDEEP bit of Cortex System Control Register */ 228 | SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); 229 | } 230 | 231 | /** 232 | * @brief Enters STANDBY mode. 233 | * @param None 234 | * @retval None 235 | */ 236 | void PWR_EnterSTANDBYMode(void) 237 | { 238 | /* Clear Wake-up flag */ 239 | PWR->CR |= PWR_CR_CWUF; 240 | /* Select STANDBY mode */ 241 | PWR->CR |= PWR_CR_PDDS; 242 | /* Set SLEEPDEEP bit of Cortex System Control Register */ 243 | SCB->SCR |= SCB_SCR_SLEEPDEEP; 244 | /* This option is used to ensure that store operations are completed */ 245 | #if defined ( __CC_ARM ) 246 | __force_stores(); 247 | #endif 248 | /* Request Wait For Interrupt */ 249 | __WFI(); 250 | } 251 | 252 | /** 253 | * @brief Checks whether the specified PWR flag is set or not. 254 | * @param PWR_FLAG: specifies the flag to check. 255 | * This parameter can be one of the following values: 256 | * @arg PWR_FLAG_WU: Wake Up flag 257 | * @arg PWR_FLAG_SB: StandBy flag 258 | * @arg PWR_FLAG_PVDO: PVD Output 259 | * @retval The new state of PWR_FLAG (SET or RESET). 260 | */ 261 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG) 262 | { 263 | FlagStatus bitstatus = RESET; 264 | /* Check the parameters */ 265 | assert_param(IS_PWR_GET_FLAG(PWR_FLAG)); 266 | 267 | if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET) 268 | { 269 | bitstatus = SET; 270 | } 271 | else 272 | { 273 | bitstatus = RESET; 274 | } 275 | /* Return the flag status */ 276 | return bitstatus; 277 | } 278 | 279 | /** 280 | * @brief Clears the PWR's pending flags. 281 | * @param PWR_FLAG: specifies the flag to clear. 282 | * This parameter can be one of the following values: 283 | * @arg PWR_FLAG_WU: Wake Up flag 284 | * @arg PWR_FLAG_SB: StandBy flag 285 | * @retval None 286 | */ 287 | void PWR_ClearFlag(uint32_t PWR_FLAG) 288 | { 289 | /* Check the parameters */ 290 | assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG)); 291 | 292 | PWR->CR |= PWR_FLAG << 2; 293 | } 294 | 295 | /** 296 | * @} 297 | */ 298 | 299 | /** 300 | * @} 301 | */ 302 | 303 | /** 304 | * @} 305 | */ 306 | 307 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 308 | -------------------------------------------------------------------------------- /stm32f10x_libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the RTC 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_rtc.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup RTC 30 | * @brief RTC driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup RTC_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | /** 38 | * @} 39 | */ 40 | 41 | /** @defgroup RTC_Private_Defines 42 | * @{ 43 | */ 44 | #define RTC_LSB_MASK ((uint32_t)0x0000FFFF) /*!< RTC LSB Mask */ 45 | #define PRLH_MSB_MASK ((uint32_t)0x000F0000) /*!< RTC Prescaler MSB Mask */ 46 | 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup RTC_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup RTC_Private_Variables 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup RTC_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup RTC_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Enables or disables the specified RTC interrupts. 81 | * @param RTC_IT: specifies the RTC interrupts sources to be enabled or disabled. 82 | * This parameter can be any combination of the following values: 83 | * @arg RTC_IT_OW: Overflow interrupt 84 | * @arg RTC_IT_ALR: Alarm interrupt 85 | * @arg RTC_IT_SEC: Second interrupt 86 | * @param NewState: new state of the specified RTC interrupts. 87 | * This parameter can be: ENABLE or DISABLE. 88 | * @retval None 89 | */ 90 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState) 91 | { 92 | /* Check the parameters */ 93 | assert_param(IS_RTC_IT(RTC_IT)); 94 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 95 | 96 | if (NewState != DISABLE) 97 | { 98 | RTC->CRH |= RTC_IT; 99 | } 100 | else 101 | { 102 | RTC->CRH &= (uint16_t)~RTC_IT; 103 | } 104 | } 105 | 106 | /** 107 | * @brief Enters the RTC configuration mode. 108 | * @param None 109 | * @retval None 110 | */ 111 | void RTC_EnterConfigMode(void) 112 | { 113 | /* Set the CNF flag to enter in the Configuration Mode */ 114 | RTC->CRL |= RTC_CRL_CNF; 115 | } 116 | 117 | /** 118 | * @brief Exits from the RTC configuration mode. 119 | * @param None 120 | * @retval None 121 | */ 122 | void RTC_ExitConfigMode(void) 123 | { 124 | /* Reset the CNF flag to exit from the Configuration Mode */ 125 | RTC->CRL &= (uint16_t)~((uint16_t)RTC_CRL_CNF); 126 | } 127 | 128 | /** 129 | * @brief Gets the RTC counter value. 130 | * @param None 131 | * @retval RTC counter value. 132 | */ 133 | uint32_t RTC_GetCounter(void) 134 | { 135 | uint16_t tmp = 0; 136 | tmp = RTC->CNTL; 137 | return (((uint32_t)RTC->CNTH << 16 ) | tmp) ; 138 | } 139 | 140 | /** 141 | * @brief Sets the RTC counter value. 142 | * @param CounterValue: RTC counter new value. 143 | * @retval None 144 | */ 145 | void RTC_SetCounter(uint32_t CounterValue) 146 | { 147 | RTC_EnterConfigMode(); 148 | /* Set RTC COUNTER MSB word */ 149 | RTC->CNTH = CounterValue >> 16; 150 | /* Set RTC COUNTER LSB word */ 151 | RTC->CNTL = (CounterValue & RTC_LSB_MASK); 152 | RTC_ExitConfigMode(); 153 | } 154 | 155 | /** 156 | * @brief Sets the RTC prescaler value. 157 | * @param PrescalerValue: RTC prescaler new value. 158 | * @retval None 159 | */ 160 | void RTC_SetPrescaler(uint32_t PrescalerValue) 161 | { 162 | /* Check the parameters */ 163 | assert_param(IS_RTC_PRESCALER(PrescalerValue)); 164 | 165 | RTC_EnterConfigMode(); 166 | /* Set RTC PRESCALER MSB word */ 167 | RTC->PRLH = (PrescalerValue & PRLH_MSB_MASK) >> 16; 168 | /* Set RTC PRESCALER LSB word */ 169 | RTC->PRLL = (PrescalerValue & RTC_LSB_MASK); 170 | RTC_ExitConfigMode(); 171 | } 172 | 173 | /** 174 | * @brief Sets the RTC alarm value. 175 | * @param AlarmValue: RTC alarm new value. 176 | * @retval None 177 | */ 178 | void RTC_SetAlarm(uint32_t AlarmValue) 179 | { 180 | RTC_EnterConfigMode(); 181 | /* Set the ALARM MSB word */ 182 | RTC->ALRH = AlarmValue >> 16; 183 | /* Set the ALARM LSB word */ 184 | RTC->ALRL = (AlarmValue & RTC_LSB_MASK); 185 | RTC_ExitConfigMode(); 186 | } 187 | 188 | /** 189 | * @brief Gets the RTC divider value. 190 | * @param None 191 | * @retval RTC Divider value. 192 | */ 193 | uint32_t RTC_GetDivider(void) 194 | { 195 | uint32_t tmp = 0x00; 196 | tmp = ((uint32_t)RTC->DIVH & (uint32_t)0x000F) << 16; 197 | tmp |= RTC->DIVL; 198 | return tmp; 199 | } 200 | 201 | /** 202 | * @brief Waits until last write operation on RTC registers has finished. 203 | * @note This function must be called before any write to RTC registers. 204 | * @param None 205 | * @retval None 206 | */ 207 | void RTC_WaitForLastTask(void) 208 | { 209 | /* Loop until RTOFF flag is set */ 210 | while ((RTC->CRL & RTC_FLAG_RTOFF) == (uint16_t)RESET) 211 | { 212 | } 213 | } 214 | 215 | /** 216 | * @brief Waits until the RTC registers (RTC_CNT, RTC_ALR and RTC_PRL) 217 | * are synchronized with RTC APB clock. 218 | * @note This function must be called before any read operation after an APB reset 219 | * or an APB clock stop. 220 | * @param None 221 | * @retval None 222 | */ 223 | void RTC_WaitForSynchro(void) 224 | { 225 | /* Clear RSF flag */ 226 | RTC->CRL &= (uint16_t)~RTC_FLAG_RSF; 227 | /* Loop until RSF flag is set */ 228 | while ((RTC->CRL & RTC_FLAG_RSF) == (uint16_t)RESET) 229 | { 230 | } 231 | } 232 | 233 | /** 234 | * @brief Checks whether the specified RTC flag is set or not. 235 | * @param RTC_FLAG: specifies the flag to check. 236 | * This parameter can be one the following values: 237 | * @arg RTC_FLAG_RTOFF: RTC Operation OFF flag 238 | * @arg RTC_FLAG_RSF: Registers Synchronized flag 239 | * @arg RTC_FLAG_OW: Overflow flag 240 | * @arg RTC_FLAG_ALR: Alarm flag 241 | * @arg RTC_FLAG_SEC: Second flag 242 | * @retval The new state of RTC_FLAG (SET or RESET). 243 | */ 244 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG) 245 | { 246 | FlagStatus bitstatus = RESET; 247 | 248 | /* Check the parameters */ 249 | assert_param(IS_RTC_GET_FLAG(RTC_FLAG)); 250 | 251 | if ((RTC->CRL & RTC_FLAG) != (uint16_t)RESET) 252 | { 253 | bitstatus = SET; 254 | } 255 | else 256 | { 257 | bitstatus = RESET; 258 | } 259 | return bitstatus; 260 | } 261 | 262 | /** 263 | * @brief Clears the RTC's pending flags. 264 | * @param RTC_FLAG: specifies the flag to clear. 265 | * This parameter can be any combination of the following values: 266 | * @arg RTC_FLAG_RSF: Registers Synchronized flag. This flag is cleared only after 267 | * an APB reset or an APB Clock stop. 268 | * @arg RTC_FLAG_OW: Overflow flag 269 | * @arg RTC_FLAG_ALR: Alarm flag 270 | * @arg RTC_FLAG_SEC: Second flag 271 | * @retval None 272 | */ 273 | void RTC_ClearFlag(uint16_t RTC_FLAG) 274 | { 275 | /* Check the parameters */ 276 | assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG)); 277 | 278 | /* Clear the corresponding RTC flag */ 279 | RTC->CRL &= (uint16_t)~RTC_FLAG; 280 | } 281 | 282 | /** 283 | * @brief Checks whether the specified RTC interrupt has occurred or not. 284 | * @param RTC_IT: specifies the RTC interrupts sources to check. 285 | * This parameter can be one of the following values: 286 | * @arg RTC_IT_OW: Overflow interrupt 287 | * @arg RTC_IT_ALR: Alarm interrupt 288 | * @arg RTC_IT_SEC: Second interrupt 289 | * @retval The new state of the RTC_IT (SET or RESET). 290 | */ 291 | ITStatus RTC_GetITStatus(uint16_t RTC_IT) 292 | { 293 | ITStatus bitstatus = RESET; 294 | /* Check the parameters */ 295 | assert_param(IS_RTC_GET_IT(RTC_IT)); 296 | 297 | bitstatus = (ITStatus)(RTC->CRL & RTC_IT); 298 | if (((RTC->CRH & RTC_IT) != (uint16_t)RESET) && (bitstatus != (uint16_t)RESET)) 299 | { 300 | bitstatus = SET; 301 | } 302 | else 303 | { 304 | bitstatus = RESET; 305 | } 306 | return bitstatus; 307 | } 308 | 309 | /** 310 | * @brief Clears the RTC's interrupt pending bits. 311 | * @param RTC_IT: specifies the interrupt pending bit to clear. 312 | * This parameter can be any combination of the following values: 313 | * @arg RTC_IT_OW: Overflow interrupt 314 | * @arg RTC_IT_ALR: Alarm interrupt 315 | * @arg RTC_IT_SEC: Second interrupt 316 | * @retval None 317 | */ 318 | void RTC_ClearITPendingBit(uint16_t RTC_IT) 319 | { 320 | /* Check the parameters */ 321 | assert_param(IS_RTC_IT(RTC_IT)); 322 | 323 | /* Clear the corresponding RTC pending bit */ 324 | RTC->CRL &= (uint16_t)~RTC_IT; 325 | } 326 | 327 | /** 328 | * @} 329 | */ 330 | 331 | /** 332 | * @} 333 | */ 334 | 335 | /** 336 | * @} 337 | */ 338 | 339 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 340 | -------------------------------------------------------------------------------- /freertos/include/mpu_wrappers.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | This file is part of the FreeRTOS distribution. 8 | 9 | FreeRTOS is free software; you can redistribute it and/or modify it under 10 | the terms of the GNU General Public License (version 2) as published by the 11 | Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. 12 | 13 | *************************************************************************** 14 | >>! NOTE: The modification to the GPL is included to allow you to !<< 15 | >>! distribute a combined work that includes FreeRTOS without being !<< 16 | >>! obliged to provide the source code for proprietary components !<< 17 | >>! outside of the FreeRTOS kernel. !<< 18 | *************************************************************************** 19 | 20 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 22 | FOR A PARTICULAR PURPOSE. Full license text is available on the following 23 | link: http://www.freertos.org/a00114.html 24 | 25 | *************************************************************************** 26 | * * 27 | * FreeRTOS provides completely free yet professionally developed, * 28 | * robust, strictly quality controlled, supported, and cross * 29 | * platform software that is more than just the market leader, it * 30 | * is the industry's de facto standard. * 31 | * * 32 | * Help yourself get started quickly while simultaneously helping * 33 | * to support the FreeRTOS project by purchasing a FreeRTOS * 34 | * tutorial book, reference manual, or both: * 35 | * http://www.FreeRTOS.org/Documentation * 36 | * * 37 | *************************************************************************** 38 | 39 | http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 40 | the FAQ page "My application does not run, what could be wrong?". Have you 41 | defined configASSERT()? 42 | 43 | http://www.FreeRTOS.org/support - In return for receiving this top quality 44 | embedded software for free we request you assist our global community by 45 | participating in the support forum. 46 | 47 | http://www.FreeRTOS.org/training - Investing in training allows your team to 48 | be as productive as possible as early as possible. Now you can receive 49 | FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 50 | Ltd, and the world's leading authority on the world's leading RTOS. 51 | 52 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 53 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 54 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 55 | 56 | http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 57 | Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 58 | 59 | http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 60 | Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 61 | licenses offer ticketed support, indemnification and commercial middleware. 62 | 63 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 64 | engineered and independently SIL3 certified version for use in safety and 65 | mission critical applications that require provable dependability. 66 | 67 | 1 tab == 4 spaces! 68 | */ 69 | 70 | #ifndef MPU_WRAPPERS_H 71 | #define MPU_WRAPPERS_H 72 | 73 | /* This file redefines API functions to be called through a wrapper macro, but 74 | only for ports that are using the MPU. */ 75 | #ifdef portUSING_MPU_WRAPPERS 76 | 77 | /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is 78 | included from queue.c or task.c to prevent it from having an effect within 79 | those files. */ 80 | #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 81 | 82 | /* 83 | * Map standard (non MPU) API functions to equivalents that start 84 | * "MPU_". This will cause the application code to call the MPU_ 85 | * version, which wraps the non-MPU version with privilege promoting 86 | * then demoting code, so the kernel code always runs will full 87 | * privileges. 88 | */ 89 | 90 | /* Map standard tasks.h API functions to the MPU equivalents. */ 91 | #define xTaskCreate MPU_xTaskCreate 92 | #define xTaskCreateStatic MPU_xTaskCreateStatic 93 | #define xTaskCreateRestricted MPU_xTaskCreateRestricted 94 | #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions 95 | #define vTaskDelete MPU_vTaskDelete 96 | #define vTaskDelay MPU_vTaskDelay 97 | #define vTaskDelayUntil MPU_vTaskDelayUntil 98 | #define xTaskAbortDelay MPU_xTaskAbortDelay 99 | #define uxTaskPriorityGet MPU_uxTaskPriorityGet 100 | #define eTaskGetState MPU_eTaskGetState 101 | #define vTaskGetInfo MPU_vTaskGetInfo 102 | #define vTaskPrioritySet MPU_vTaskPrioritySet 103 | #define vTaskSuspend MPU_vTaskSuspend 104 | #define vTaskResume MPU_vTaskResume 105 | #define vTaskSuspendAll MPU_vTaskSuspendAll 106 | #define xTaskResumeAll MPU_xTaskResumeAll 107 | #define xTaskGetTickCount MPU_xTaskGetTickCount 108 | #define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks 109 | #define pcTaskGetName MPU_pcTaskGetName 110 | #define xTaskGetHandle MPU_xTaskGetHandle 111 | #define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark 112 | #define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag 113 | #define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag 114 | #define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer 115 | #define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer 116 | #define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook 117 | #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle 118 | #define uxTaskGetSystemState MPU_uxTaskGetSystemState 119 | #define vTaskList MPU_vTaskList 120 | #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats 121 | #define xTaskGenericNotify MPU_xTaskGenericNotify 122 | #define xTaskNotifyWait MPU_xTaskNotifyWait 123 | #define ulTaskNotifyTake MPU_ulTaskNotifyTake 124 | #define xTaskNotifyStateClear MPU_xTaskNotifyStateClear 125 | 126 | #define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle 127 | #define vTaskSetTimeOutState MPU_vTaskSetTimeOutState 128 | #define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut 129 | #define xTaskGetSchedulerState MPU_xTaskGetSchedulerState 130 | 131 | /* Map standard queue.h API functions to the MPU equivalents. */ 132 | #define xQueueGenericSend MPU_xQueueGenericSend 133 | #define xQueueGenericReceive MPU_xQueueGenericReceive 134 | #define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting 135 | #define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable 136 | #define vQueueDelete MPU_vQueueDelete 137 | #define xQueueCreateMutex MPU_xQueueCreateMutex 138 | #define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic 139 | #define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore 140 | #define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic 141 | #define xQueueGetMutexHolder MPU_xQueueGetMutexHolder 142 | #define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive 143 | #define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive 144 | #define xQueueGenericCreate MPU_xQueueGenericCreate 145 | #define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic 146 | #define xQueueCreateSet MPU_xQueueCreateSet 147 | #define xQueueAddToSet MPU_xQueueAddToSet 148 | #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet 149 | #define xQueueSelectFromSet MPU_xQueueSelectFromSet 150 | #define xQueueGenericReset MPU_xQueueGenericReset 151 | 152 | #if( configQUEUE_REGISTRY_SIZE > 0 ) 153 | #define vQueueAddToRegistry MPU_vQueueAddToRegistry 154 | #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue 155 | #define pcQueueGetName MPU_pcQueueGetName 156 | #endif 157 | 158 | /* Map standard timer.h API functions to the MPU equivalents. */ 159 | #define xTimerCreate MPU_xTimerCreate 160 | #define xTimerCreateStatic MPU_xTimerCreateStatic 161 | #define pvTimerGetTimerID MPU_pvTimerGetTimerID 162 | #define vTimerSetTimerID MPU_vTimerSetTimerID 163 | #define xTimerIsTimerActive MPU_xTimerIsTimerActive 164 | #define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle 165 | #define xTimerPendFunctionCall MPU_xTimerPendFunctionCall 166 | #define pcTimerGetName MPU_pcTimerGetName 167 | #define xTimerGetPeriod MPU_xTimerGetPeriod 168 | #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime 169 | #define xTimerGenericCommand MPU_xTimerGenericCommand 170 | 171 | /* Map standard event_group.h API functions to the MPU equivalents. */ 172 | #define xEventGroupCreate MPU_xEventGroupCreate 173 | #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic 174 | #define xEventGroupWaitBits MPU_xEventGroupWaitBits 175 | #define xEventGroupClearBits MPU_xEventGroupClearBits 176 | #define xEventGroupSetBits MPU_xEventGroupSetBits 177 | #define xEventGroupSync MPU_xEventGroupSync 178 | #define vEventGroupDelete MPU_vEventGroupDelete 179 | 180 | /* Remove the privileged function macro. */ 181 | #define PRIVILEGED_FUNCTION 182 | 183 | #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ 184 | 185 | /* Ensure API functions go in the privileged execution section. */ 186 | #define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) 187 | #define PRIVILEGED_DATA __attribute__((section("privileged_data"))) 188 | 189 | #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ 190 | 191 | #else /* portUSING_MPU_WRAPPERS */ 192 | 193 | #define PRIVILEGED_FUNCTION 194 | #define PRIVILEGED_DATA 195 | #define portUSING_MPU_WRAPPERS 0 196 | 197 | #endif /* portUSING_MPU_WRAPPERS */ 198 | 199 | 200 | #endif /* MPU_WRAPPERS_H */ 201 | 202 | -------------------------------------------------------------------------------- /stm32f10x_libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_ld.s: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file startup_stm32f10x_ld.s 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief STM32F10x Low Density Devices vector table for RIDE7 toolchain. 8 | * This module performs: 9 | * - Set the initial SP 10 | * - Set the initial PC == Reset_Handler, 11 | * - Set the vector table entries with the exceptions ISR address 12 | * - Configure the clock system 13 | * - Branches to main in the C library (which eventually 14 | * calls main()). 15 | * After Reset the Cortex-M3 processor is in Thread mode, 16 | * priority is Privileged, and the Stack is set to Main. 17 | ****************************************************************************** 18 | * @attention 19 | * 20 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 21 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 22 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 23 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 24 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 25 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 26 | * 27 | *

© COPYRIGHT 2011 STMicroelectronics

28 | ****************************************************************************** 29 | */ 30 | 31 | .syntax unified 32 | .cpu cortex-m3 33 | .fpu softvfp 34 | .thumb 35 | 36 | .global g_pfnVectors 37 | .global Default_Handler 38 | 39 | /* start address for the initialization values of the .data section. 40 | defined in linker script */ 41 | .word _sidata 42 | /* start address for the .data section. defined in linker script */ 43 | .word _sdata 44 | /* end address for the .data section. defined in linker script */ 45 | .word _edata 46 | /* start address for the .bss section. defined in linker script */ 47 | .word _sbss 48 | /* end address for the .bss section. defined in linker script */ 49 | .word _ebss 50 | 51 | .equ BootRAM, 0xF108F85F 52 | /** 53 | * @brief This is the code that gets called when the processor first 54 | * starts execution following a reset event. Only the absolutely 55 | * necessary set is performed, after which the application 56 | * supplied main() routine is called. 57 | * @param None 58 | * @retval : None 59 | */ 60 | 61 | .section .text.Reset_Handler 62 | .weak Reset_Handler 63 | .type Reset_Handler, %function 64 | Reset_Handler: 65 | 66 | /* Copy the data segment initializers from flash to SRAM */ 67 | movs r1, #0 68 | b LoopCopyDataInit 69 | 70 | CopyDataInit: 71 | ldr r3, =_sidata 72 | ldr r3, [r3, r1] 73 | str r3, [r0, r1] 74 | adds r1, r1, #4 75 | 76 | LoopCopyDataInit: 77 | ldr r0, =_sdata 78 | ldr r3, =_edata 79 | adds r2, r0, r1 80 | cmp r2, r3 81 | bcc CopyDataInit 82 | ldr r2, =_sbss 83 | b LoopFillZerobss 84 | /* Zero fill the bss segment. */ 85 | FillZerobss: 86 | movs r3, #0 87 | str r3, [r2], #4 88 | 89 | LoopFillZerobss: 90 | ldr r3, = _ebss 91 | cmp r2, r3 92 | bcc FillZerobss 93 | /* Call the clock system intitialization function.*/ 94 | bl SystemInit 95 | /* Call the application's entry point.*/ 96 | bl main 97 | bx lr 98 | .size Reset_Handler, .-Reset_Handler 99 | 100 | /** 101 | * @brief This is the code that gets called when the processor receives an 102 | * unexpected interrupt. This simply enters an infinite loop, preserving 103 | * the system state for examination by a debugger. 104 | * @param None 105 | * @retval None 106 | */ 107 | .section .text.Default_Handler,"ax",%progbits 108 | Default_Handler: 109 | Infinite_Loop: 110 | b Infinite_Loop 111 | .size Default_Handler, .-Default_Handler 112 | /****************************************************************************** 113 | * 114 | * The minimal vector table for a Cortex M3. Note that the proper constructs 115 | * must be placed on this to ensure that it ends up at physical address 116 | * 0x0000.0000. 117 | * 118 | ******************************************************************************/ 119 | .section .isr_vector,"a",%progbits 120 | .type g_pfnVectors, %object 121 | .size g_pfnVectors, .-g_pfnVectors 122 | 123 | 124 | g_pfnVectors: 125 | .word _estack 126 | .word Reset_Handler 127 | .word NMI_Handler 128 | .word HardFault_Handler 129 | .word MemManage_Handler 130 | .word BusFault_Handler 131 | .word UsageFault_Handler 132 | .word 0 133 | .word 0 134 | .word 0 135 | .word 0 136 | .word SVC_Handler 137 | .word DebugMon_Handler 138 | .word 0 139 | .word PendSV_Handler 140 | .word SysTick_Handler 141 | .word WWDG_IRQHandler 142 | .word PVD_IRQHandler 143 | .word TAMPER_IRQHandler 144 | .word RTC_IRQHandler 145 | .word FLASH_IRQHandler 146 | .word RCC_IRQHandler 147 | .word EXTI0_IRQHandler 148 | .word EXTI1_IRQHandler 149 | .word EXTI2_IRQHandler 150 | .word EXTI3_IRQHandler 151 | .word EXTI4_IRQHandler 152 | .word DMA1_Channel1_IRQHandler 153 | .word DMA1_Channel2_IRQHandler 154 | .word DMA1_Channel3_IRQHandler 155 | .word DMA1_Channel4_IRQHandler 156 | .word DMA1_Channel5_IRQHandler 157 | .word DMA1_Channel6_IRQHandler 158 | .word DMA1_Channel7_IRQHandler 159 | .word ADC1_2_IRQHandler 160 | .word USB_HP_CAN1_TX_IRQHandler 161 | .word USB_LP_CAN1_RX0_IRQHandler 162 | .word CAN1_RX1_IRQHandler 163 | .word CAN1_SCE_IRQHandler 164 | .word EXTI9_5_IRQHandler 165 | .word TIM1_BRK_IRQHandler 166 | .word TIM1_UP_IRQHandler 167 | .word TIM1_TRG_COM_IRQHandler 168 | .word TIM1_CC_IRQHandler 169 | .word TIM2_IRQHandler 170 | .word TIM3_IRQHandler 171 | .word 0 172 | .word I2C1_EV_IRQHandler 173 | .word I2C1_ER_IRQHandler 174 | .word 0 175 | .word 0 176 | .word SPI1_IRQHandler 177 | .word 0 178 | .word USART1_IRQHandler 179 | .word USART2_IRQHandler 180 | .word 0 181 | .word EXTI15_10_IRQHandler 182 | .word RTCAlarm_IRQHandler 183 | .word USBWakeUp_IRQHandler 184 | .word 0 185 | .word 0 186 | .word 0 187 | .word 0 188 | .word 0 189 | .word 0 190 | .word 0 191 | .word BootRAM /* @0x108. This is for boot in RAM mode for 192 | STM32F10x Low Density devices.*/ 193 | 194 | /******************************************************************************* 195 | * 196 | * Provide weak aliases for each Exception handler to the Default_Handler. 197 | * As they are weak aliases, any function with the same name will override 198 | * this definition. 199 | * 200 | *******************************************************************************/ 201 | 202 | .weak NMI_Handler 203 | .thumb_set NMI_Handler,Default_Handler 204 | 205 | .weak HardFault_Handler 206 | .thumb_set HardFault_Handler,Default_Handler 207 | 208 | .weak MemManage_Handler 209 | .thumb_set MemManage_Handler,Default_Handler 210 | 211 | .weak BusFault_Handler 212 | .thumb_set BusFault_Handler,Default_Handler 213 | 214 | .weak UsageFault_Handler 215 | .thumb_set UsageFault_Handler,Default_Handler 216 | 217 | .weak SVC_Handler 218 | .thumb_set SVC_Handler,Default_Handler 219 | 220 | .weak DebugMon_Handler 221 | .thumb_set DebugMon_Handler,Default_Handler 222 | 223 | .weak PendSV_Handler 224 | .thumb_set PendSV_Handler,Default_Handler 225 | 226 | .weak SysTick_Handler 227 | .thumb_set SysTick_Handler,Default_Handler 228 | 229 | .weak WWDG_IRQHandler 230 | .thumb_set WWDG_IRQHandler,Default_Handler 231 | 232 | .weak PVD_IRQHandler 233 | .thumb_set PVD_IRQHandler,Default_Handler 234 | 235 | .weak TAMPER_IRQHandler 236 | .thumb_set TAMPER_IRQHandler,Default_Handler 237 | 238 | .weak RTC_IRQHandler 239 | .thumb_set RTC_IRQHandler,Default_Handler 240 | 241 | .weak FLASH_IRQHandler 242 | .thumb_set FLASH_IRQHandler,Default_Handler 243 | 244 | .weak RCC_IRQHandler 245 | .thumb_set RCC_IRQHandler,Default_Handler 246 | 247 | .weak EXTI0_IRQHandler 248 | .thumb_set EXTI0_IRQHandler,Default_Handler 249 | 250 | .weak EXTI1_IRQHandler 251 | .thumb_set EXTI1_IRQHandler,Default_Handler 252 | 253 | .weak EXTI2_IRQHandler 254 | .thumb_set EXTI2_IRQHandler,Default_Handler 255 | 256 | .weak EXTI3_IRQHandler 257 | .thumb_set EXTI3_IRQHandler,Default_Handler 258 | 259 | .weak EXTI4_IRQHandler 260 | .thumb_set EXTI4_IRQHandler,Default_Handler 261 | 262 | .weak DMA1_Channel1_IRQHandler 263 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler 264 | 265 | .weak DMA1_Channel2_IRQHandler 266 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler 267 | 268 | .weak DMA1_Channel3_IRQHandler 269 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler 270 | 271 | .weak DMA1_Channel4_IRQHandler 272 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler 273 | 274 | .weak DMA1_Channel5_IRQHandler 275 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler 276 | 277 | .weak DMA1_Channel6_IRQHandler 278 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler 279 | 280 | .weak DMA1_Channel7_IRQHandler 281 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler 282 | 283 | .weak ADC1_2_IRQHandler 284 | .thumb_set ADC1_2_IRQHandler,Default_Handler 285 | 286 | .weak USB_HP_CAN1_TX_IRQHandler 287 | .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler 288 | 289 | .weak USB_LP_CAN1_RX0_IRQHandler 290 | .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler 291 | 292 | .weak CAN1_RX1_IRQHandler 293 | .thumb_set CAN1_RX1_IRQHandler,Default_Handler 294 | 295 | .weak CAN1_SCE_IRQHandler 296 | .thumb_set CAN1_SCE_IRQHandler,Default_Handler 297 | 298 | .weak EXTI9_5_IRQHandler 299 | .thumb_set EXTI9_5_IRQHandler,Default_Handler 300 | 301 | .weak TIM1_BRK_IRQHandler 302 | .thumb_set TIM1_BRK_IRQHandler,Default_Handler 303 | 304 | .weak TIM1_UP_IRQHandler 305 | .thumb_set TIM1_UP_IRQHandler,Default_Handler 306 | 307 | .weak TIM1_TRG_COM_IRQHandler 308 | .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler 309 | 310 | .weak TIM1_CC_IRQHandler 311 | .thumb_set TIM1_CC_IRQHandler,Default_Handler 312 | 313 | .weak TIM2_IRQHandler 314 | .thumb_set TIM2_IRQHandler,Default_Handler 315 | 316 | .weak TIM3_IRQHandler 317 | .thumb_set TIM3_IRQHandler,Default_Handler 318 | 319 | .weak I2C1_EV_IRQHandler 320 | .thumb_set I2C1_EV_IRQHandler,Default_Handler 321 | 322 | .weak I2C1_ER_IRQHandler 323 | .thumb_set I2C1_ER_IRQHandler,Default_Handler 324 | 325 | .weak SPI1_IRQHandler 326 | .thumb_set SPI1_IRQHandler,Default_Handler 327 | 328 | .weak USART1_IRQHandler 329 | .thumb_set USART1_IRQHandler,Default_Handler 330 | 331 | .weak USART2_IRQHandler 332 | .thumb_set USART2_IRQHandler,Default_Handler 333 | 334 | .weak EXTI15_10_IRQHandler 335 | .thumb_set EXTI15_10_IRQHandler,Default_Handler 336 | 337 | .weak RTCAlarm_IRQHandler 338 | .thumb_set RTCAlarm_IRQHandler,Default_Handler 339 | 340 | .weak USBWakeUp_IRQHandler 341 | .thumb_set USBWakeUp_IRQHandler,Default_Handler 342 | 343 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 344 | --------------------------------------------------------------------------------