├── .gitmodules ├── README.md ├── main.c ├── .gitignore ├── LICENSE ├── Makefile ├── mcuconf.h ├── halconf.h └── chconf.h /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ChibiOS"] 2 | path = ChibiOS 3 | url = https://github.com/ChibiOS/ChibiOS.git 4 | branch = stable_16.1.x 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BluePill-ChibiOS 2 | ChibiOS blink with stable 16.1.5 3 | 4 | How to: 5 | ``` 6 | git clone https://github.com/InvalidExcepti0n/BluePill-ChibiOS.git 7 | cd BluePill-ChibiOS 8 | git submodule update --init 9 | make 10 | ``` 11 | 12 | Enjoy :) 13 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include "hal.h" 2 | #include "ch.h" 3 | 4 | int main(void) { 5 | halInit(); 6 | chSysInit(); 7 | 8 | while(1) { 9 | palSetPad(GPIOC, GPIOC_LED); 10 | chThdSleepMilliseconds(1000); 11 | palClearPad(GPIOC, GPIOC_LED); 12 | chThdSleepMilliseconds(1000); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | 35 | # ignore folders 36 | build/* 37 | .dep/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 InvalidExcepti0n 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Build global options 3 | # NOTE: Can be overridden externally. 4 | # 5 | 6 | # Compiler options here. 7 | ifeq ($(USE_OPT),) 8 | USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 9 | endif 10 | 11 | # C specific options here (added to USE_OPT). 12 | ifeq ($(USE_COPT),) 13 | USE_COPT = 14 | endif 15 | 16 | # C++ specific options here (added to USE_OPT). 17 | ifeq ($(USE_CPPOPT),) 18 | USE_CPPOPT = -fno-rtti 19 | endif 20 | 21 | # Enable this if you want the linker to remove unused code and data 22 | ifeq ($(USE_LINK_GC),) 23 | USE_LINK_GC = yes 24 | endif 25 | 26 | # Linker extra options here. 27 | ifeq ($(USE_LDOPT),) 28 | USE_LDOPT = 29 | endif 30 | 31 | # Enable this if you want link time optimizations (LTO) 32 | ifeq ($(USE_LTO),) 33 | USE_LTO = yes 34 | endif 35 | 36 | # If enabled, this option allows to compile the application in THUMB mode. 37 | ifeq ($(USE_THUMB),) 38 | USE_THUMB = yes 39 | endif 40 | 41 | # Enable this if you want to see the full log while compiling. 42 | ifeq ($(USE_VERBOSE_COMPILE),) 43 | USE_VERBOSE_COMPILE = no 44 | endif 45 | 46 | # If enabled, this option makes the build process faster by not compiling 47 | # modules not used in the current configuration. 48 | ifeq ($(USE_SMART_BUILD),) 49 | USE_SMART_BUILD = yes 50 | endif 51 | 52 | # 53 | # Build global options 54 | ############################################################################## 55 | 56 | ############################################################################## 57 | # Architecture or project specific options 58 | # 59 | 60 | # Stack size to be allocated to the Cortex-M process stack. This stack is 61 | # the stack used by the main() thread. 62 | ifeq ($(USE_PROCESS_STACKSIZE),) 63 | USE_PROCESS_STACKSIZE = 0x400 64 | endif 65 | 66 | # Stack size to the allocated to the Cortex-M main/exceptions stack. This 67 | # stack is used for processing interrupts and exceptions. 68 | ifeq ($(USE_EXCEPTIONS_STACKSIZE),) 69 | USE_EXCEPTIONS_STACKSIZE = 0x400 70 | endif 71 | 72 | # Enables the use of FPU on Cortex-M4 (no, softfp, hard). 73 | ifeq ($(USE_FPU),) 74 | USE_FPU = no 75 | endif 76 | 77 | # 78 | # Architecture or project specific options 79 | ############################################################################## 80 | 81 | ############################################################################## 82 | # Project, sources and paths 83 | # 84 | 85 | # Define project name here 86 | PROJECT = ch 87 | 88 | # Imported source files and paths 89 | CHIBIOS = ChibiOS 90 | # Startup files. 91 | include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_stm32f1xx.mk 92 | # HAL-OSAL files (optional). 93 | include $(CHIBIOS)/os/hal/hal.mk 94 | include $(CHIBIOS)/os/hal/ports/STM32/STM32F1xx/platform.mk 95 | include $(CHIBIOS)/os/hal/boards/STM32F103C8_MINIMAL/board.mk 96 | include $(CHIBIOS)/os/hal/osal/rt/osal.mk 97 | # RTOS files (optional). 98 | include $(CHIBIOS)/os/rt/rt.mk 99 | include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk 100 | # Other files (optional). 101 | include $(CHIBIOS)/test/rt/test.mk 102 | 103 | # Define linker script file here 104 | LDSCRIPT= $(STARTUPLD)/STM32F103xB.ld 105 | 106 | # C sources that can be compiled in ARM or THUMB mode depending on the global 107 | # setting. 108 | CSRC = $(STARTUPSRC) \ 109 | $(KERNSRC) \ 110 | $(PORTSRC) \ 111 | $(OSALSRC) \ 112 | $(HALSRC) \ 113 | $(PLATFORMSRC) \ 114 | $(BOARDSRC) \ 115 | $(TESTSRC) \ 116 | main.c 117 | 118 | # C++ sources that can be compiled in ARM or THUMB mode depending on the global 119 | # setting. 120 | CPPSRC = 121 | 122 | # C sources to be compiled in ARM mode regardless of the global setting. 123 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 124 | # option that results in lower performance and larger code size. 125 | ACSRC = 126 | 127 | # C++ sources to be compiled in ARM mode regardless of the global setting. 128 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 129 | # option that results in lower performance and larger code size. 130 | ACPPSRC = 131 | 132 | # C sources to be compiled in THUMB mode regardless of the global setting. 133 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 134 | # option that results in lower performance and larger code size. 135 | TCSRC = 136 | 137 | # C sources to be compiled in THUMB mode regardless of the global setting. 138 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 139 | # option that results in lower performance and larger code size. 140 | TCPPSRC = 141 | 142 | # List ASM source files here 143 | ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) 144 | 145 | INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ 146 | $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ 147 | $(CHIBIOS)/os/various 148 | 149 | # 150 | # Project, sources and paths 151 | ############################################################################## 152 | 153 | ############################################################################## 154 | # Compiler settings 155 | # 156 | 157 | MCU = cortex-m3 158 | 159 | #TRGT = arm-elf- 160 | TRGT = arm-none-eabi- 161 | CC = $(TRGT)gcc 162 | CPPC = $(TRGT)g++ 163 | # Enable loading with g++ only if you need C++ runtime support. 164 | # NOTE: You can use C++ even without C++ support if you are careful. C++ 165 | # runtime support makes code size explode. 166 | LD = $(TRGT)gcc 167 | #LD = $(TRGT)g++ 168 | CP = $(TRGT)objcopy 169 | AS = $(TRGT)gcc -x assembler-with-cpp 170 | AR = $(TRGT)ar 171 | OD = $(TRGT)objdump 172 | SZ = $(TRGT)size 173 | HEX = $(CP) -O ihex 174 | BIN = $(CP) -O binary 175 | 176 | # ARM-specific options here 177 | AOPT = 178 | 179 | # THUMB-specific options here 180 | TOPT = -mthumb -DTHUMB 181 | 182 | # Define C warning options here 183 | CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes 184 | 185 | # Define C++ warning options here 186 | CPPWARN = -Wall -Wextra -Wundef 187 | 188 | # 189 | # Compiler settings 190 | ############################################################################## 191 | 192 | ############################################################################## 193 | # Start of user section 194 | # 195 | 196 | # List all user C define here, like -D_DEBUG=1 197 | UDEFS = 198 | 199 | # Define ASM defines here 200 | UADEFS = 201 | 202 | # List all user directories here 203 | UINCDIR = 204 | 205 | # List the user directory to look for the libraries here 206 | ULIBDIR = 207 | 208 | # List all user libraries here 209 | ULIBS = 210 | 211 | # 212 | # End of user defines 213 | ############################################################################## 214 | 215 | RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC 216 | include $(RULESPATH)/rules.mk 217 | -------------------------------------------------------------------------------- /mcuconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _MCUCONF_H_ 18 | #define _MCUCONF_H_ 19 | 20 | #define STM32F103_MCUCONF 21 | 22 | /* 23 | * STM32F103 drivers configuration. 24 | * The following settings override the default settings present in 25 | * the various device driver implementation headers. 26 | * Note that the settings for each driver only have effect if the whole 27 | * driver is enabled in halconf.h. 28 | * 29 | * IRQ priorities: 30 | * 15...0 Lowest...Highest. 31 | * 32 | * DMA priorities: 33 | * 0...3 Lowest...Highest. 34 | */ 35 | 36 | /* 37 | * HAL driver system settings. 38 | */ 39 | #define STM32_NO_INIT FALSE 40 | #define STM32_HSI_ENABLED TRUE 41 | #define STM32_LSI_ENABLED FALSE 42 | #define STM32_HSE_ENABLED TRUE 43 | #define STM32_LSE_ENABLED FALSE 44 | #define STM32_SW STM32_SW_PLL 45 | #define STM32_PLLSRC STM32_PLLSRC_HSE 46 | #define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1 47 | #define STM32_PLLMUL_VALUE 9 48 | #define STM32_HPRE STM32_HPRE_DIV1 49 | #define STM32_PPRE1 STM32_PPRE1_DIV2 50 | #define STM32_PPRE2 STM32_PPRE2_DIV2 51 | #define STM32_ADCPRE STM32_ADCPRE_DIV4 52 | #define STM32_USB_CLOCK_REQUIRED TRUE 53 | #define STM32_USBPRE STM32_USBPRE_DIV1P5 54 | #define STM32_MCOSEL STM32_MCOSEL_NOCLOCK 55 | #define STM32_RTCSEL STM32_RTCSEL_HSEDIV 56 | #define STM32_PVD_ENABLE FALSE 57 | #define STM32_PLS STM32_PLS_LEV0 58 | 59 | /* 60 | * ADC driver system settings. 61 | */ 62 | #define STM32_ADC_USE_ADC1 FALSE 63 | #define STM32_ADC_ADC1_DMA_PRIORITY 2 64 | #define STM32_ADC_ADC1_IRQ_PRIORITY 6 65 | 66 | /* 67 | * CAN driver system settings. 68 | */ 69 | #define STM32_CAN_USE_CAN1 FALSE 70 | #define STM32_CAN_CAN1_IRQ_PRIORITY 11 71 | 72 | /* 73 | * EXT driver system settings. 74 | */ 75 | #define STM32_EXT_EXTI0_IRQ_PRIORITY 6 76 | #define STM32_EXT_EXTI1_IRQ_PRIORITY 6 77 | #define STM32_EXT_EXTI2_IRQ_PRIORITY 6 78 | #define STM32_EXT_EXTI3_IRQ_PRIORITY 6 79 | #define STM32_EXT_EXTI4_IRQ_PRIORITY 6 80 | #define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6 81 | #define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6 82 | #define STM32_EXT_EXTI16_IRQ_PRIORITY 6 83 | #define STM32_EXT_EXTI17_IRQ_PRIORITY 6 84 | #define STM32_EXT_EXTI18_IRQ_PRIORITY 6 85 | #define STM32_EXT_EXTI19_IRQ_PRIORITY 6 86 | 87 | /* 88 | * GPT driver system settings. 89 | */ 90 | #define STM32_GPT_USE_TIM1 FALSE 91 | #define STM32_GPT_USE_TIM2 FALSE 92 | #define STM32_GPT_USE_TIM3 FALSE 93 | #define STM32_GPT_USE_TIM4 FALSE 94 | #define STM32_GPT_USE_TIM5 FALSE 95 | #define STM32_GPT_USE_TIM8 FALSE 96 | #define STM32_GPT_TIM1_IRQ_PRIORITY 7 97 | #define STM32_GPT_TIM2_IRQ_PRIORITY 7 98 | #define STM32_GPT_TIM3_IRQ_PRIORITY 7 99 | #define STM32_GPT_TIM4_IRQ_PRIORITY 7 100 | #define STM32_GPT_TIM5_IRQ_PRIORITY 7 101 | #define STM32_GPT_TIM8_IRQ_PRIORITY 7 102 | 103 | /* 104 | * I2C driver system settings. 105 | */ 106 | #define STM32_I2C_USE_I2C1 FALSE 107 | #define STM32_I2C_USE_I2C2 FALSE 108 | #define STM32_I2C_BUSY_TIMEOUT 50 109 | #define STM32_I2C_I2C1_IRQ_PRIORITY 5 110 | #define STM32_I2C_I2C2_IRQ_PRIORITY 5 111 | #define STM32_I2C_I2C1_DMA_PRIORITY 3 112 | #define STM32_I2C_I2C2_DMA_PRIORITY 3 113 | #define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") 114 | 115 | /* 116 | * ICU driver system settings. 117 | */ 118 | #define STM32_ICU_USE_TIM1 FALSE 119 | #define STM32_ICU_USE_TIM2 FALSE 120 | #define STM32_ICU_USE_TIM3 FALSE 121 | #define STM32_ICU_USE_TIM4 FALSE 122 | #define STM32_ICU_USE_TIM5 FALSE 123 | #define STM32_ICU_USE_TIM8 FALSE 124 | #define STM32_ICU_TIM1_IRQ_PRIORITY 7 125 | #define STM32_ICU_TIM2_IRQ_PRIORITY 7 126 | #define STM32_ICU_TIM3_IRQ_PRIORITY 7 127 | #define STM32_ICU_TIM4_IRQ_PRIORITY 7 128 | #define STM32_ICU_TIM5_IRQ_PRIORITY 7 129 | #define STM32_ICU_TIM8_IRQ_PRIORITY 7 130 | 131 | /* 132 | * PWM driver system settings. 133 | */ 134 | #define STM32_PWM_USE_ADVANCED FALSE 135 | #define STM32_PWM_USE_TIM1 FALSE 136 | #define STM32_PWM_USE_TIM2 FALSE 137 | #define STM32_PWM_USE_TIM3 FALSE 138 | #define STM32_PWM_USE_TIM4 FALSE 139 | #define STM32_PWM_USE_TIM5 FALSE 140 | #define STM32_PWM_USE_TIM8 FALSE 141 | #define STM32_PWM_TIM1_IRQ_PRIORITY 7 142 | #define STM32_PWM_TIM2_IRQ_PRIORITY 7 143 | #define STM32_PWM_TIM3_IRQ_PRIORITY 7 144 | #define STM32_PWM_TIM4_IRQ_PRIORITY 7 145 | #define STM32_PWM_TIM5_IRQ_PRIORITY 7 146 | #define STM32_PWM_TIM8_IRQ_PRIORITY 7 147 | 148 | /* 149 | * RTC driver system settings. 150 | */ 151 | #define STM32_RTC_IRQ_PRIORITY 15 152 | 153 | /* 154 | * SERIAL driver system settings. 155 | */ 156 | #define STM32_SERIAL_USE_USART1 FALSE 157 | #define STM32_SERIAL_USE_USART2 FALSE 158 | #define STM32_SERIAL_USE_USART3 FALSE 159 | #define STM32_SERIAL_USE_UART4 FALSE 160 | #define STM32_SERIAL_USE_UART5 FALSE 161 | #define STM32_SERIAL_USART1_PRIORITY 12 162 | #define STM32_SERIAL_USART2_PRIORITY 12 163 | #define STM32_SERIAL_USART3_PRIORITY 12 164 | #define STM32_SERIAL_UART4_PRIORITY 12 165 | #define STM32_SERIAL_UART5_PRIORITY 12 166 | 167 | /* 168 | * SPI driver system settings. 169 | */ 170 | #define STM32_SPI_USE_SPI1 FALSE 171 | #define STM32_SPI_USE_SPI2 FALSE 172 | #define STM32_SPI_USE_SPI3 FALSE 173 | #define STM32_SPI_SPI1_DMA_PRIORITY 1 174 | #define STM32_SPI_SPI2_DMA_PRIORITY 1 175 | #define STM32_SPI_SPI3_DMA_PRIORITY 1 176 | #define STM32_SPI_SPI1_IRQ_PRIORITY 10 177 | #define STM32_SPI_SPI2_IRQ_PRIORITY 10 178 | #define STM32_SPI_SPI3_IRQ_PRIORITY 10 179 | #define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") 180 | 181 | /* 182 | * ST driver system settings. 183 | */ 184 | #define STM32_ST_IRQ_PRIORITY 8 185 | #define STM32_ST_USE_TIMER 2 186 | 187 | /* 188 | * UART driver system settings. 189 | */ 190 | #define STM32_UART_USE_USART1 FALSE 191 | #define STM32_UART_USE_USART2 FALSE 192 | #define STM32_UART_USE_USART3 FALSE 193 | #define STM32_UART_USART1_IRQ_PRIORITY 12 194 | #define STM32_UART_USART2_IRQ_PRIORITY 12 195 | #define STM32_UART_USART3_IRQ_PRIORITY 12 196 | #define STM32_UART_USART1_DMA_PRIORITY 0 197 | #define STM32_UART_USART2_DMA_PRIORITY 0 198 | #define STM32_UART_USART3_DMA_PRIORITY 0 199 | #define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") 200 | 201 | /* 202 | * USB driver system settings. 203 | */ 204 | #define STM32_USB_USE_USB1 FALSE 205 | #define STM32_USB_LOW_POWER_ON_SUSPEND FALSE 206 | #define STM32_USB_USB1_HP_IRQ_PRIORITY 13 207 | #define STM32_USB_USB1_LP_IRQ_PRIORITY 14 208 | 209 | /* 210 | * WDG driver system settings. 211 | */ 212 | #define STM32_WDG_USE_IWDG FALSE 213 | 214 | #endif /* _MCUCONF_H_ */ 215 | -------------------------------------------------------------------------------- /halconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file templates/halconf.h 19 | * @brief HAL configuration header. 20 | * @details HAL configuration file, this file allows to enable or disable the 21 | * various device drivers from your application. You may also use 22 | * this file in order to override the device drivers default settings. 23 | * 24 | * @addtogroup HAL_CONF 25 | * @{ 26 | */ 27 | 28 | #ifndef _HALCONF_H_ 29 | #define _HALCONF_H_ 30 | 31 | #include "mcuconf.h" 32 | 33 | /** 34 | * @brief Enables the PAL subsystem. 35 | */ 36 | #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) 37 | #define HAL_USE_PAL TRUE 38 | #endif 39 | 40 | /** 41 | * @brief Enables the ADC subsystem. 42 | */ 43 | #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) 44 | #define HAL_USE_ADC FALSE 45 | #endif 46 | 47 | /** 48 | * @brief Enables the CAN subsystem. 49 | */ 50 | #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) 51 | #define HAL_USE_CAN FALSE 52 | #endif 53 | 54 | /** 55 | * @brief Enables the DAC subsystem. 56 | */ 57 | #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) 58 | #define HAL_USE_DAC FALSE 59 | #endif 60 | 61 | /** 62 | * @brief Enables the EXT subsystem. 63 | */ 64 | #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) 65 | #define HAL_USE_EXT FALSE 66 | #endif 67 | 68 | /** 69 | * @brief Enables the GPT subsystem. 70 | */ 71 | #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) 72 | #define HAL_USE_GPT FALSE 73 | #endif 74 | 75 | /** 76 | * @brief Enables the I2C subsystem. 77 | */ 78 | #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) 79 | #define HAL_USE_I2C FALSE 80 | #endif 81 | 82 | /** 83 | * @brief Enables the I2S subsystem. 84 | */ 85 | #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) 86 | #define HAL_USE_I2S FALSE 87 | #endif 88 | 89 | /** 90 | * @brief Enables the ICU subsystem. 91 | */ 92 | #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) 93 | #define HAL_USE_ICU FALSE 94 | #endif 95 | 96 | /** 97 | * @brief Enables the MAC subsystem. 98 | */ 99 | #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) 100 | #define HAL_USE_MAC FALSE 101 | #endif 102 | 103 | /** 104 | * @brief Enables the MMC_SPI subsystem. 105 | */ 106 | #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) 107 | #define HAL_USE_MMC_SPI FALSE 108 | #endif 109 | 110 | /** 111 | * @brief Enables the PWM subsystem. 112 | */ 113 | #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) 114 | #define HAL_USE_PWM FALSE 115 | #endif 116 | 117 | /** 118 | * @brief Enables the RTC subsystem. 119 | */ 120 | #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) 121 | #define HAL_USE_RTC FALSE 122 | #endif 123 | 124 | /** 125 | * @brief Enables the SDC subsystem. 126 | */ 127 | #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) 128 | #define HAL_USE_SDC FALSE 129 | #endif 130 | 131 | /** 132 | * @brief Enables the SERIAL subsystem. 133 | */ 134 | #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) 135 | #define HAL_USE_SERIAL FALSE 136 | #endif 137 | 138 | /** 139 | * @brief Enables the SERIAL over USB subsystem. 140 | */ 141 | #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) 142 | #define HAL_USE_SERIAL_USB FALSE 143 | #endif 144 | 145 | /** 146 | * @brief Enables the SPI subsystem. 147 | */ 148 | #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) 149 | #define HAL_USE_SPI FALSE 150 | #endif 151 | 152 | /** 153 | * @brief Enables the UART subsystem. 154 | */ 155 | #if !defined(HAL_USE_UART) || defined(__DOXYGEN__) 156 | #define HAL_USE_UART FALSE 157 | #endif 158 | 159 | /** 160 | * @brief Enables the USB subsystem. 161 | */ 162 | #if !defined(HAL_USE_USB) || defined(__DOXYGEN__) 163 | #define HAL_USE_USB FALSE 164 | #endif 165 | 166 | /** 167 | * @brief Enables the WDG subsystem. 168 | */ 169 | #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) 170 | #define HAL_USE_WDG FALSE 171 | #endif 172 | 173 | /*===========================================================================*/ 174 | /* ADC driver related settings. */ 175 | /*===========================================================================*/ 176 | 177 | /** 178 | * @brief Enables synchronous APIs. 179 | * @note Disabling this option saves both code and data space. 180 | */ 181 | #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) 182 | #define ADC_USE_WAIT TRUE 183 | #endif 184 | 185 | /** 186 | * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. 187 | * @note Disabling this option saves both code and data space. 188 | */ 189 | #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 190 | #define ADC_USE_MUTUAL_EXCLUSION TRUE 191 | #endif 192 | 193 | /*===========================================================================*/ 194 | /* CAN driver related settings. */ 195 | /*===========================================================================*/ 196 | 197 | /** 198 | * @brief Sleep mode related APIs inclusion switch. 199 | */ 200 | #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) 201 | #define CAN_USE_SLEEP_MODE TRUE 202 | #endif 203 | 204 | /*===========================================================================*/ 205 | /* I2C driver related settings. */ 206 | /*===========================================================================*/ 207 | 208 | /** 209 | * @brief Enables the mutual exclusion APIs on the I2C bus. 210 | */ 211 | #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 212 | #define I2C_USE_MUTUAL_EXCLUSION TRUE 213 | #endif 214 | 215 | /*===========================================================================*/ 216 | /* MAC driver related settings. */ 217 | /*===========================================================================*/ 218 | 219 | /** 220 | * @brief Enables an event sources for incoming packets. 221 | */ 222 | #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) 223 | #define MAC_USE_ZERO_COPY FALSE 224 | #endif 225 | 226 | /** 227 | * @brief Enables an event sources for incoming packets. 228 | */ 229 | #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) 230 | #define MAC_USE_EVENTS TRUE 231 | #endif 232 | 233 | /*===========================================================================*/ 234 | /* MMC_SPI driver related settings. */ 235 | /*===========================================================================*/ 236 | 237 | /** 238 | * @brief Delays insertions. 239 | * @details If enabled this options inserts delays into the MMC waiting 240 | * routines releasing some extra CPU time for the threads with 241 | * lower priority, this may slow down the driver a bit however. 242 | * This option is recommended also if the SPI driver does not 243 | * use a DMA channel and heavily loads the CPU. 244 | */ 245 | #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) 246 | #define MMC_NICE_WAITING TRUE 247 | #endif 248 | 249 | /*===========================================================================*/ 250 | /* SDC driver related settings. */ 251 | /*===========================================================================*/ 252 | 253 | /** 254 | * @brief Number of initialization attempts before rejecting the card. 255 | * @note Attempts are performed at 10mS intervals. 256 | */ 257 | #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) 258 | #define SDC_INIT_RETRY 100 259 | #endif 260 | 261 | /** 262 | * @brief Include support for MMC cards. 263 | * @note MMC support is not yet implemented so this option must be kept 264 | * at @p FALSE. 265 | */ 266 | #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) 267 | #define SDC_MMC_SUPPORT FALSE 268 | #endif 269 | 270 | /** 271 | * @brief Delays insertions. 272 | * @details If enabled this options inserts delays into the MMC waiting 273 | * routines releasing some extra CPU time for the threads with 274 | * lower priority, this may slow down the driver a bit however. 275 | */ 276 | #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) 277 | #define SDC_NICE_WAITING TRUE 278 | #endif 279 | 280 | /*===========================================================================*/ 281 | /* SERIAL driver related settings. */ 282 | /*===========================================================================*/ 283 | 284 | /** 285 | * @brief Default bit rate. 286 | * @details Configuration parameter, this is the baud rate selected for the 287 | * default configuration. 288 | */ 289 | #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) 290 | #define SERIAL_DEFAULT_BITRATE 38400 291 | #endif 292 | 293 | /** 294 | * @brief Serial buffers size. 295 | * @details Configuration parameter, you can change the depth of the queue 296 | * buffers depending on the requirements of your application. 297 | * @note The default is 16 bytes for both the transmission and receive 298 | * buffers. 299 | */ 300 | #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) 301 | #define SERIAL_BUFFERS_SIZE 16 302 | #endif 303 | 304 | /*===========================================================================*/ 305 | /* SERIAL_USB driver related setting. */ 306 | /*===========================================================================*/ 307 | 308 | /** 309 | * @brief Serial over USB buffers size. 310 | * @details Configuration parameter, the buffer size must be a multiple of 311 | * the USB data endpoint maximum packet size. 312 | * @note The default is 256 bytes for both the transmission and receive 313 | * buffers. 314 | */ 315 | #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) 316 | #define SERIAL_USB_BUFFERS_SIZE 256 317 | #endif 318 | 319 | /** 320 | * @brief Serial over USB number of buffers. 321 | * @note The default is 2 buffers. 322 | */ 323 | #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) 324 | #define SERIAL_USB_BUFFERS_NUMBER 2 325 | #endif 326 | 327 | /*===========================================================================*/ 328 | /* SPI driver related settings. */ 329 | /*===========================================================================*/ 330 | 331 | /** 332 | * @brief Enables synchronous APIs. 333 | * @note Disabling this option saves both code and data space. 334 | */ 335 | #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) 336 | #define SPI_USE_WAIT TRUE 337 | #endif 338 | 339 | /** 340 | * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. 341 | * @note Disabling this option saves both code and data space. 342 | */ 343 | #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 344 | #define SPI_USE_MUTUAL_EXCLUSION TRUE 345 | #endif 346 | 347 | /*===========================================================================*/ 348 | /* UART driver related settings. */ 349 | /*===========================================================================*/ 350 | 351 | /** 352 | * @brief Enables synchronous APIs. 353 | * @note Disabling this option saves both code and data space. 354 | */ 355 | #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) 356 | #define UART_USE_WAIT FALSE 357 | #endif 358 | 359 | /** 360 | * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. 361 | * @note Disabling this option saves both code and data space. 362 | */ 363 | #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 364 | #define UART_USE_MUTUAL_EXCLUSION FALSE 365 | #endif 366 | 367 | /*===========================================================================*/ 368 | /* USB driver related settings. */ 369 | /*===========================================================================*/ 370 | 371 | /** 372 | * @brief Enables synchronous APIs. 373 | * @note Disabling this option saves both code and data space. 374 | */ 375 | #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) 376 | #define USB_USE_WAIT FALSE 377 | #endif 378 | 379 | #endif /* _HALCONF_H_ */ 380 | 381 | /** @} */ 382 | -------------------------------------------------------------------------------- /chconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file templates/chconf.h 19 | * @brief Configuration file template. 20 | * @details A copy of this file must be placed in each project directory, it 21 | * contains the application specific kernel settings. 22 | * 23 | * @addtogroup config 24 | * @details Kernel related settings and hooks. 25 | * @{ 26 | */ 27 | 28 | #ifndef _CHCONF_H_ 29 | #define _CHCONF_H_ 30 | 31 | /*===========================================================================*/ 32 | /** 33 | * @name System timers settings 34 | * @{ 35 | */ 36 | /*===========================================================================*/ 37 | 38 | /** 39 | * @brief System time counter resolution. 40 | * @note Allowed values are 16 or 32 bits. 41 | */ 42 | #define CH_CFG_ST_RESOLUTION 16 43 | 44 | /** 45 | * @brief System tick frequency. 46 | * @details Frequency of the system timer that drives the system ticks. This 47 | * setting also defines the system tick time unit. 48 | */ 49 | #define CH_CFG_ST_FREQUENCY 2000 50 | 51 | /** 52 | * @brief Time delta constant for the tick-less mode. 53 | * @note If this value is zero then the system uses the classic 54 | * periodic tick. This value represents the minimum number 55 | * of ticks that is safe to specify in a timeout directive. 56 | * The value one is not valid, timeouts are rounded up to 57 | * this value. 58 | */ 59 | #define CH_CFG_ST_TIMEDELTA 2 60 | 61 | /** @} */ 62 | 63 | /*===========================================================================*/ 64 | /** 65 | * @name Kernel parameters and options 66 | * @{ 67 | */ 68 | /*===========================================================================*/ 69 | 70 | /** 71 | * @brief Round robin interval. 72 | * @details This constant is the number of system ticks allowed for the 73 | * threads before preemption occurs. Setting this value to zero 74 | * disables the preemption for threads with equal priority and the 75 | * round robin becomes cooperative. Note that higher priority 76 | * threads can still preempt, the kernel is always preemptive. 77 | * @note Disabling the round robin preemption makes the kernel more compact 78 | * and generally faster. 79 | * @note The round robin preemption is not supported in tickless mode and 80 | * must be set to zero in that case. 81 | */ 82 | #define CH_CFG_TIME_QUANTUM 0 83 | 84 | /** 85 | * @brief Managed RAM size. 86 | * @details Size of the RAM area to be managed by the OS. If set to zero 87 | * then the whole available RAM is used. The core memory is made 88 | * available to the heap allocator and/or can be used directly through 89 | * the simplified core memory allocator. 90 | * 91 | * @note In order to let the OS manage the whole RAM the linker script must 92 | * provide the @p __heap_base__ and @p __heap_end__ symbols. 93 | * @note Requires @p CH_CFG_USE_MEMCORE. 94 | */ 95 | #define CH_CFG_MEMCORE_SIZE 0 96 | 97 | /** 98 | * @brief Idle thread automatic spawn suppression. 99 | * @details When this option is activated the function @p chSysInit() 100 | * does not spawn the idle thread. The application @p main() 101 | * function becomes the idle thread and must implement an 102 | * infinite loop. 103 | */ 104 | #define CH_CFG_NO_IDLE_THREAD FALSE 105 | 106 | /** @} */ 107 | 108 | /*===========================================================================*/ 109 | /** 110 | * @name Performance options 111 | * @{ 112 | */ 113 | /*===========================================================================*/ 114 | 115 | /** 116 | * @brief OS optimization. 117 | * @details If enabled then time efficient rather than space efficient code 118 | * is used when two possible implementations exist. 119 | * 120 | * @note This is not related to the compiler optimization options. 121 | * @note The default is @p TRUE. 122 | */ 123 | #define CH_CFG_OPTIMIZE_SPEED TRUE 124 | 125 | /** @} */ 126 | 127 | /*===========================================================================*/ 128 | /** 129 | * @name Subsystem options 130 | * @{ 131 | */ 132 | /*===========================================================================*/ 133 | 134 | /** 135 | * @brief Time Measurement APIs. 136 | * @details If enabled then the time measurement APIs are included in 137 | * the kernel. 138 | * 139 | * @note The default is @p TRUE. 140 | */ 141 | #define CH_CFG_USE_TM TRUE 142 | 143 | /** 144 | * @brief Threads registry APIs. 145 | * @details If enabled then the registry APIs are included in the kernel. 146 | * 147 | * @note The default is @p TRUE. 148 | */ 149 | #define CH_CFG_USE_REGISTRY TRUE 150 | 151 | /** 152 | * @brief Threads synchronization APIs. 153 | * @details If enabled then the @p chThdWait() function is included in 154 | * the kernel. 155 | * 156 | * @note The default is @p TRUE. 157 | */ 158 | #define CH_CFG_USE_WAITEXIT TRUE 159 | 160 | /** 161 | * @brief Semaphores APIs. 162 | * @details If enabled then the Semaphores APIs are included in the kernel. 163 | * 164 | * @note The default is @p TRUE. 165 | */ 166 | #define CH_CFG_USE_SEMAPHORES TRUE 167 | 168 | /** 169 | * @brief Semaphores queuing mode. 170 | * @details If enabled then the threads are enqueued on semaphores by 171 | * priority rather than in FIFO order. 172 | * 173 | * @note The default is @p FALSE. Enable this if you have special 174 | * requirements. 175 | * @note Requires @p CH_CFG_USE_SEMAPHORES. 176 | */ 177 | #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE 178 | 179 | /** 180 | * @brief Mutexes APIs. 181 | * @details If enabled then the mutexes APIs are included in the kernel. 182 | * 183 | * @note The default is @p TRUE. 184 | */ 185 | #define CH_CFG_USE_MUTEXES TRUE 186 | 187 | /** 188 | * @brief Enables recursive behavior on mutexes. 189 | * @note Recursive mutexes are heavier and have an increased 190 | * memory footprint. 191 | * 192 | * @note The default is @p FALSE. 193 | * @note Requires @p CH_CFG_USE_MUTEXES. 194 | */ 195 | #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE 196 | 197 | /** 198 | * @brief Conditional Variables APIs. 199 | * @details If enabled then the conditional variables APIs are included 200 | * in the kernel. 201 | * 202 | * @note The default is @p TRUE. 203 | * @note Requires @p CH_CFG_USE_MUTEXES. 204 | */ 205 | #define CH_CFG_USE_CONDVARS TRUE 206 | 207 | /** 208 | * @brief Conditional Variables APIs with timeout. 209 | * @details If enabled then the conditional variables APIs with timeout 210 | * specification are included in the kernel. 211 | * 212 | * @note The default is @p TRUE. 213 | * @note Requires @p CH_CFG_USE_CONDVARS. 214 | */ 215 | #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE 216 | 217 | /** 218 | * @brief Events Flags APIs. 219 | * @details If enabled then the event flags APIs are included in the kernel. 220 | * 221 | * @note The default is @p TRUE. 222 | */ 223 | #define CH_CFG_USE_EVENTS TRUE 224 | 225 | /** 226 | * @brief Events Flags APIs with timeout. 227 | * @details If enabled then the events APIs with timeout specification 228 | * are included in the kernel. 229 | * 230 | * @note The default is @p TRUE. 231 | * @note Requires @p CH_CFG_USE_EVENTS. 232 | */ 233 | #define CH_CFG_USE_EVENTS_TIMEOUT TRUE 234 | 235 | /** 236 | * @brief Synchronous Messages APIs. 237 | * @details If enabled then the synchronous messages APIs are included 238 | * in the kernel. 239 | * 240 | * @note The default is @p TRUE. 241 | */ 242 | #define CH_CFG_USE_MESSAGES TRUE 243 | 244 | /** 245 | * @brief Synchronous Messages queuing mode. 246 | * @details If enabled then messages are served by priority rather than in 247 | * FIFO order. 248 | * 249 | * @note The default is @p FALSE. Enable this if you have special 250 | * requirements. 251 | * @note Requires @p CH_CFG_USE_MESSAGES. 252 | */ 253 | #define CH_CFG_USE_MESSAGES_PRIORITY FALSE 254 | 255 | /** 256 | * @brief Mailboxes APIs. 257 | * @details If enabled then the asynchronous messages (mailboxes) APIs are 258 | * included in the kernel. 259 | * 260 | * @note The default is @p TRUE. 261 | * @note Requires @p CH_CFG_USE_SEMAPHORES. 262 | */ 263 | #define CH_CFG_USE_MAILBOXES TRUE 264 | 265 | /** 266 | * @brief I/O Queues APIs. 267 | * @details If enabled then the I/O queues APIs are included in the kernel. 268 | * 269 | * @note The default is @p TRUE. 270 | */ 271 | #define CH_CFG_USE_QUEUES TRUE 272 | 273 | /** 274 | * @brief Core Memory Manager APIs. 275 | * @details If enabled then the core memory manager APIs are included 276 | * in the kernel. 277 | * 278 | * @note The default is @p TRUE. 279 | */ 280 | #define CH_CFG_USE_MEMCORE TRUE 281 | 282 | /** 283 | * @brief Heap Allocator APIs. 284 | * @details If enabled then the memory heap allocator APIs are included 285 | * in the kernel. 286 | * 287 | * @note The default is @p TRUE. 288 | * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or 289 | * @p CH_CFG_USE_SEMAPHORES. 290 | * @note Mutexes are recommended. 291 | */ 292 | #define CH_CFG_USE_HEAP TRUE 293 | 294 | /** 295 | * @brief Memory Pools Allocator APIs. 296 | * @details If enabled then the memory pools allocator APIs are included 297 | * in the kernel. 298 | * 299 | * @note The default is @p TRUE. 300 | */ 301 | #define CH_CFG_USE_MEMPOOLS TRUE 302 | 303 | /** 304 | * @brief Dynamic Threads APIs. 305 | * @details If enabled then the dynamic threads creation APIs are included 306 | * in the kernel. 307 | * 308 | * @note The default is @p TRUE. 309 | * @note Requires @p CH_CFG_USE_WAITEXIT. 310 | * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. 311 | */ 312 | #define CH_CFG_USE_DYNAMIC TRUE 313 | 314 | /** @} */ 315 | 316 | /*===========================================================================*/ 317 | /** 318 | * @name Debug options 319 | * @{ 320 | */ 321 | /*===========================================================================*/ 322 | 323 | /** 324 | * @brief Debug option, kernel statistics. 325 | * 326 | * @note The default is @p FALSE. 327 | */ 328 | #define CH_DBG_STATISTICS FALSE 329 | 330 | /** 331 | * @brief Debug option, system state check. 332 | * @details If enabled the correct call protocol for system APIs is checked 333 | * at runtime. 334 | * 335 | * @note The default is @p FALSE. 336 | */ 337 | #define CH_DBG_SYSTEM_STATE_CHECK FALSE 338 | 339 | /** 340 | * @brief Debug option, parameters checks. 341 | * @details If enabled then the checks on the API functions input 342 | * parameters are activated. 343 | * 344 | * @note The default is @p FALSE. 345 | */ 346 | #define CH_DBG_ENABLE_CHECKS FALSE 347 | 348 | /** 349 | * @brief Debug option, consistency checks. 350 | * @details If enabled then all the assertions in the kernel code are 351 | * activated. This includes consistency checks inside the kernel, 352 | * runtime anomalies and port-defined checks. 353 | * 354 | * @note The default is @p FALSE. 355 | */ 356 | #define CH_DBG_ENABLE_ASSERTS FALSE 357 | 358 | /** 359 | * @brief Debug option, trace buffer. 360 | * @details If enabled then the context switch circular trace buffer is 361 | * activated. 362 | * 363 | * @note The default is @p FALSE. 364 | */ 365 | #define CH_DBG_ENABLE_TRACE FALSE 366 | 367 | /** 368 | * @brief Debug option, stack checks. 369 | * @details If enabled then a runtime stack check is performed. 370 | * 371 | * @note The default is @p FALSE. 372 | * @note The stack check is performed in a architecture/port dependent way. 373 | * It may not be implemented or some ports. 374 | * @note The default failure mode is to halt the system with the global 375 | * @p panic_msg variable set to @p NULL. 376 | */ 377 | #define CH_DBG_ENABLE_STACK_CHECK FALSE 378 | 379 | /** 380 | * @brief Debug option, stacks initialization. 381 | * @details If enabled then the threads working area is filled with a byte 382 | * value when a thread is created. This can be useful for the 383 | * runtime measurement of the used stack. 384 | * 385 | * @note The default is @p FALSE. 386 | */ 387 | #define CH_DBG_FILL_THREADS FALSE 388 | 389 | /** 390 | * @brief Debug option, threads profiling. 391 | * @details If enabled then a field is added to the @p thread_t structure that 392 | * counts the system ticks occurred while executing the thread. 393 | * 394 | * @note The default is @p FALSE. 395 | * @note This debug option is not currently compatible with the 396 | * tickless mode. 397 | */ 398 | #define CH_DBG_THREADS_PROFILING FALSE 399 | 400 | /** @} */ 401 | 402 | /*===========================================================================*/ 403 | /** 404 | * @name Kernel hooks 405 | * @{ 406 | */ 407 | /*===========================================================================*/ 408 | 409 | /** 410 | * @brief Threads descriptor structure extension. 411 | * @details User fields added to the end of the @p thread_t structure. 412 | */ 413 | #define CH_CFG_THREAD_EXTRA_FIELDS \ 414 | /* Add threads custom fields here.*/ 415 | 416 | /** 417 | * @brief Threads initialization hook. 418 | * @details User initialization code added to the @p chThdInit() API. 419 | * 420 | * @note It is invoked from within @p chThdInit() and implicitly from all 421 | * the threads creation APIs. 422 | */ 423 | #define CH_CFG_THREAD_INIT_HOOK(tp) { \ 424 | /* Add threads initialization code here.*/ \ 425 | } 426 | 427 | /** 428 | * @brief Threads finalization hook. 429 | * @details User finalization code added to the @p chThdExit() API. 430 | * 431 | * @note It is inserted into lock zone. 432 | * @note It is also invoked when the threads simply return in order to 433 | * terminate. 434 | */ 435 | #define CH_CFG_THREAD_EXIT_HOOK(tp) { \ 436 | /* Add threads finalization code here.*/ \ 437 | } 438 | 439 | /** 440 | * @brief Context switch hook. 441 | * @details This hook is invoked just before switching between threads. 442 | */ 443 | #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ 444 | /* Context switch code here.*/ \ 445 | } 446 | 447 | /** 448 | * @brief Idle thread enter hook. 449 | * @note This hook is invoked within a critical zone, no OS functions 450 | * should be invoked from here. 451 | * @note This macro can be used to activate a power saving mode. 452 | */ 453 | #define CH_CFG_IDLE_ENTER_HOOK() { \ 454 | } 455 | 456 | /** 457 | * @brief Idle thread leave hook. 458 | * @note This hook is invoked within a critical zone, no OS functions 459 | * should be invoked from here. 460 | * @note This macro can be used to deactivate a power saving mode. 461 | */ 462 | #define CH_CFG_IDLE_LEAVE_HOOK() { \ 463 | } 464 | 465 | /** 466 | * @brief Idle Loop hook. 467 | * @details This hook is continuously invoked by the idle thread loop. 468 | */ 469 | #define CH_CFG_IDLE_LOOP_HOOK() { \ 470 | /* Idle loop code here.*/ \ 471 | } 472 | 473 | /** 474 | * @brief System tick event hook. 475 | * @details This hook is invoked in the system tick handler immediately 476 | * after processing the virtual timers queue. 477 | */ 478 | #define CH_CFG_SYSTEM_TICK_HOOK() { \ 479 | /* System tick event code here.*/ \ 480 | } 481 | 482 | /** 483 | * @brief System halt hook. 484 | * @details This hook is invoked in case to a system halting error before 485 | * the system is halted. 486 | */ 487 | #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ 488 | /* System halt code here.*/ \ 489 | } 490 | 491 | /** @} */ 492 | 493 | /*===========================================================================*/ 494 | /* Port-specific settings (override port settings defaulted in chcore.h). */ 495 | /*===========================================================================*/ 496 | 497 | #endif /* _CHCONF_H_ */ 498 | 499 | /** @} */ 500 | --------------------------------------------------------------------------------