diff --git a/examples/ArmTimerCallbacks/ArmTimerCallbacks.uvoptx b/examples/ArmTimerCallbacks/ArmTimerCallbacks.uvoptx
new file mode 100644
index 00000000..8a5d0503
--- /dev/null
+++ b/examples/ArmTimerCallbacks/ArmTimerCallbacks.uvoptx
@@ -0,0 +1,274 @@
+
+
+
+ 1.0
+
+ ### uVision Project, (C) Keil Software
+
+
+ *.c
+ *.s*; *.src; *.a*
+ *.obj; *.o
+ *.lib
+ *.txt; *.h; *.inc
+ *.plm
+ *.cpp
+ 0
+
+
+
+ 0
+ 0
+
+
+
+ Target 1
+ 0x4
+ ARM-ADS
+
+ 12000000
+
+ 1
+ 1
+ 0
+ 1
+ 0
+
+
+ 1
+ 65535
+ 0
+ 0
+ 0
+
+
+ 79
+ 66
+ 8
+ .\Listings\
+
+
+ 1
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+
+
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+
+
+ 1
+ 0
+ 1
+
+ 18
+
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ 1
+ 5
+
+
+
+
+
+
+
+
+
+
+ STLink\ST-LINKIII-KEIL_SWO.dll
+
+
+
+ 0
+ ARMRTXEVENTFLAGS
+ -L70 -Z18 -C0 -M0 -T1
+
+
+ 0
+ DLGTARM
+ (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)
+
+
+ 0
+ ARMDBGFLAGS
+
+
+
+ 0
+ DLGUARM
+ (105=-1,-1,-1,-1,0)
+
+
+ 0
+ ST-LINKIII-KEIL_SWO
+ -U066CFF485550707267024134 -O207 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F401RETx$CMSIS\Flash\STM32F4xx_512.FLM)
+
+
+ 0
+ UL2CM3
+ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32F401RETx$CMSIS\Flash\STM32F4xx_512.FLM))
+
+
+
+
+
+ 0
+ 1
+ returnCode
+
+
+ 1
+ 1
+ short_toggle
+
+
+ 2
+ 1
+ timer
+
+
+
+ 0
+
+
+ 0
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+ 1
+ 0
+ 2
+ 10000000
+
+
+
+
+
+ Source Group 1
+ 1
+ 0
+ 0
+ 0
+
+ 1
+ 1
+ 8
+ 0
+ 0
+ 0
+ .\main.cpp
+ main.cpp
+ 0
+ 0
+
+
+ 1
+ 2
+ 5
+ 0
+ 0
+ 0
+ .\etl_profile.h
+ etl_profile.h
+ 0
+ 0
+
+
+
+
+ ::Board Support
+ 1
+ 0
+ 0
+ 1
+
+
+
+ ::CMSIS
+ 0
+ 0
+ 0
+ 1
+
+
+
+ ::Device
+ 1
+ 0
+ 0
+ 1
+
+
+
diff --git a/examples/ArmTimerCallbacks/ArmTimerCallbacks.uvprojx b/examples/ArmTimerCallbacks/ArmTimerCallbacks.uvprojx
new file mode 100644
index 00000000..1d18e62d
--- /dev/null
+++ b/examples/ArmTimerCallbacks/ArmTimerCallbacks.uvprojx
@@ -0,0 +1,469 @@
+
+
+
+ 2.1
+
+ ### uVision Project, (C) Keil Software
+
+
+
+ Target 1
+ 0x4
+ ARM-ADS
+ 5060528::V5.06 update 5 (build 528)::ARMCC
+ 0
+
+
+ STM32F401RETx
+ STMicroelectronics
+ Keil.STM32F4xx_DFP.2.11.0
+ http://www.keil.com/pack
+ IRAM(0x20000000,0x18000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE
+
+
+ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32F401RETx$CMSIS\Flash\STM32F4xx_512.FLM))
+ 0
+ $$Device:STM32F401RETx$Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
+
+
+
+
+
+
+
+
+
+ $$Device:STM32F401RETx$CMSIS\SVD\STM32F401xE.svd
+ 0
+ 0
+
+
+
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 1
+
+ .\Objects\
+ ArmTimerCallbacks
+ 1
+ 0
+ 0
+ 1
+ 1
+ .\Listings\
+ 1
+ 0
+ 0
+
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+
+ 0
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 3
+
+
+ 1
+
+
+ SARMCM3.DLL
+ -REMAP -MPU
+ DCM.DLL
+ -pCM4
+ SARMCM3.DLL
+ -MPU
+ TCM.DLL
+ -pCM4
+
+
+
+ 1
+ 0
+ 0
+ 0
+ 16
+
+
+
+
+ 1
+ 0
+ 0
+ 1
+ 1
+ 4096
+
+ 1
+ BIN\UL2CM3.DLL
+ "" ()
+
+
+
+
+ 0
+
+
+
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ "Cortex-M4"
+
+ 0
+ 0
+ 0
+ 1
+ 1
+ 0
+ 0
+ 2
+ 0
+ 0
+ 8
+ 0
+ 0
+ 0
+ 0
+ 3
+ 3
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x20000000
+ 0x18000
+
+
+ 1
+ 0x8000000
+ 0x80000
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 1
+ 0x8000000
+ 0x80000
+
+
+ 1
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x0
+ 0x0
+
+
+ 0
+ 0x20000000
+ 0x18000
+
+
+ 0
+ 0x0
+ 0x0
+
+
+
+
+
+ 1
+ 4
+ 0
+ 0
+ 1
+ 0
+ 0
+ 1
+ 0
+ 0
+ 2
+ 0
+ 0
+ 1
+ 0
+ 3
+ 3
+ 1
+ 1
+ 0
+ 0
+ 0
+
+
+
+
+ ..\..\src;..\ArmTimerCallbacks
+
+
+
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0x08000000
+ 0x20000000
+
+
+
+
+
+
+
+
+
+
+
+
+ Source Group 1
+
+
+ main.cpp
+ 8
+ .\main.cpp
+
+
+ etl_profile.h
+ 5
+ .\etl_profile.h
+
+
+
+
+ ::Board Support
+
+
+ ::CMSIS
+
+
+ ::Device
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RTE\Device\STM32F401RETx\startup_stm32f401xe.s
+
+
+
+
+
+
+
+ RTE\Device\STM32F401RETx\system_stm32f4xx.c
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/startup_stm32f401xe.s b/examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/startup_stm32f401xe.s
new file mode 100644
index 00000000..dc82c615
--- /dev/null
+++ b/examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/startup_stm32f401xe.s
@@ -0,0 +1,392 @@
+;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
+;* File Name : startup_stm32f401xe.s
+;* Author : MCD Application Team
+;* Version : V2.6.0
+;* Date : 04-November-2016
+;* Description : STM32F401xe devices vector table for MDK-ARM toolchain.
+;* This module performs:
+;* - Set the initial SP
+;* - Set the initial PC == Reset_Handler
+;* - Set the vector table entries with the exceptions ISR address
+;* - Branches to __main in the C library (which eventually
+;* calls main()).
+;* After Reset the CortexM4 processor is in Thread mode,
+;* priority is Privileged, and the Stack is set to Main.
+;* <<< Use Configuration Wizard in Context Menu >>>
+;*******************************************************************************
+;
+;* Redistribution and use in source and binary forms, with or without modification,
+;* are permitted provided that the following conditions are met:
+;* 1. Redistributions of source code must retain the above copyright notice,
+;* this list of conditions and the following disclaimer.
+;* 2. Redistributions in binary form must reproduce the above copyright notice,
+;* this list of conditions and the following disclaimer in the documentation
+;* and/or other materials provided with the distribution.
+;* 3. Neither the name of STMicroelectronics nor the names of its contributors
+;* may be used to endorse or promote products derived from this software
+;* without specific prior written permission.
+;*
+;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;
+;*******************************************************************************
+
+; Amount of memory (in bytes) allocated for Stack
+; Tailor this value to your application needs
+; Stack Configuration
+; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
+;
+
+Stack_Size EQU 0x00000400
+
+ AREA STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem SPACE Stack_Size
+__initial_sp
+
+
+; Heap Configuration
+; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
+;
+
+Heap_Size EQU 0x00000200
+
+ AREA HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem SPACE Heap_Size
+__heap_limit
+
+ PRESERVE8
+ THUMB
+
+
+; Vector Table Mapped to Address 0 at Reset
+ AREA RESET, DATA, READONLY
+ EXPORT __Vectors
+ EXPORT __Vectors_End
+ EXPORT __Vectors_Size
+
+__Vectors DCD __initial_sp ; Top of Stack
+ DCD Reset_Handler ; Reset Handler
+ DCD NMI_Handler ; NMI Handler
+ DCD HardFault_Handler ; Hard Fault Handler
+ DCD MemManage_Handler ; MPU Fault Handler
+ DCD BusFault_Handler ; Bus Fault Handler
+ DCD UsageFault_Handler ; Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; SVCall Handler
+ DCD DebugMon_Handler ; Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; PendSV Handler
+ DCD SysTick_Handler ; SysTick Handler
+
+ ; External Interrupts
+ DCD WWDG_IRQHandler ; Window WatchDog
+ DCD PVD_IRQHandler ; PVD through EXTI Line detection
+ DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
+ DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
+ DCD FLASH_IRQHandler ; FLASH
+ DCD RCC_IRQHandler ; RCC
+ DCD EXTI0_IRQHandler ; EXTI Line0
+ DCD EXTI1_IRQHandler ; EXTI Line1
+ DCD EXTI2_IRQHandler ; EXTI Line2
+ DCD EXTI3_IRQHandler ; EXTI Line3
+ DCD EXTI4_IRQHandler ; EXTI Line4
+ DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
+ DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
+ DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
+ DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
+ DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
+ DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
+ DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
+ DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD EXTI9_5_IRQHandler ; External Line[9:5]s
+ DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
+ DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
+ DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
+ DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
+ DCD TIM2_IRQHandler ; TIM2
+ DCD TIM3_IRQHandler ; TIM3
+ DCD TIM4_IRQHandler ; TIM4
+ DCD I2C1_EV_IRQHandler ; I2C1 Event
+ DCD I2C1_ER_IRQHandler ; I2C1 Error
+ DCD I2C2_EV_IRQHandler ; I2C2 Event
+ DCD I2C2_ER_IRQHandler ; I2C2 Error
+ DCD SPI1_IRQHandler ; SPI1
+ DCD SPI2_IRQHandler ; SPI2
+ DCD USART1_IRQHandler ; USART1
+ DCD USART2_IRQHandler ; USART2
+ DCD 0 ; Reserved
+ DCD EXTI15_10_IRQHandler ; External Line[15:10]s
+ DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
+ DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
+ DCD 0 ; Reserved
+ DCD SDIO_IRQHandler ; SDIO
+ DCD TIM5_IRQHandler ; TIM5
+ DCD SPI3_IRQHandler ; SPI3
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
+ DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
+ DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
+ DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
+ DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD OTG_FS_IRQHandler ; USB OTG FS
+ DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
+ DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
+ DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
+ DCD USART6_IRQHandler ; USART6
+ DCD I2C3_EV_IRQHandler ; I2C3 event
+ DCD I2C3_ER_IRQHandler ; I2C3 error
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD FPU_IRQHandler ; FPU
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SPI4_IRQHandler ; SPI4
+
+__Vectors_End
+
+__Vectors_Size EQU __Vectors_End - __Vectors
+
+ AREA |.text|, CODE, READONLY
+
+; Reset handler
+Reset_Handler PROC
+ EXPORT Reset_Handler [WEAK]
+ IMPORT SystemInit
+ IMPORT __main
+
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__main
+ BX R0
+ ENDP
+
+; Dummy Exception Handlers (infinite loops which can be modified)
+
+NMI_Handler PROC
+ EXPORT NMI_Handler [WEAK]
+ B .
+ ENDP
+HardFault_Handler\
+ PROC
+ EXPORT HardFault_Handler [WEAK]
+ B .
+ ENDP
+MemManage_Handler\
+ PROC
+ EXPORT MemManage_Handler [WEAK]
+ B .
+ ENDP
+BusFault_Handler\
+ PROC
+ EXPORT BusFault_Handler [WEAK]
+ B .
+ ENDP
+UsageFault_Handler\
+ PROC
+ EXPORT UsageFault_Handler [WEAK]
+ B .
+ ENDP
+SVC_Handler PROC
+ EXPORT SVC_Handler [WEAK]
+ B .
+ ENDP
+DebugMon_Handler\
+ PROC
+ EXPORT DebugMon_Handler [WEAK]
+ B .
+ ENDP
+PendSV_Handler PROC
+ EXPORT PendSV_Handler [WEAK]
+ B .
+ ENDP
+SysTick_Handler PROC
+ EXPORT SysTick_Handler [WEAK]
+ B .
+ ENDP
+
+Default_Handler PROC
+
+ EXPORT WWDG_IRQHandler [WEAK]
+ EXPORT PVD_IRQHandler [WEAK]
+ EXPORT TAMP_STAMP_IRQHandler [WEAK]
+ EXPORT RTC_WKUP_IRQHandler [WEAK]
+ EXPORT FLASH_IRQHandler [WEAK]
+ EXPORT RCC_IRQHandler [WEAK]
+ EXPORT EXTI0_IRQHandler [WEAK]
+ EXPORT EXTI1_IRQHandler [WEAK]
+ EXPORT EXTI2_IRQHandler [WEAK]
+ EXPORT EXTI3_IRQHandler [WEAK]
+ EXPORT EXTI4_IRQHandler [WEAK]
+ EXPORT DMA1_Stream0_IRQHandler [WEAK]
+ EXPORT DMA1_Stream1_IRQHandler [WEAK]
+ EXPORT DMA1_Stream2_IRQHandler [WEAK]
+ EXPORT DMA1_Stream3_IRQHandler [WEAK]
+ EXPORT DMA1_Stream4_IRQHandler [WEAK]
+ EXPORT DMA1_Stream5_IRQHandler [WEAK]
+ EXPORT DMA1_Stream6_IRQHandler [WEAK]
+ EXPORT ADC_IRQHandler [WEAK]
+ EXPORT EXTI9_5_IRQHandler [WEAK]
+ EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
+ EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
+ EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
+ EXPORT TIM1_CC_IRQHandler [WEAK]
+ EXPORT TIM2_IRQHandler [WEAK]
+ EXPORT TIM3_IRQHandler [WEAK]
+ EXPORT TIM4_IRQHandler [WEAK]
+ EXPORT I2C1_EV_IRQHandler [WEAK]
+ EXPORT I2C1_ER_IRQHandler [WEAK]
+ EXPORT I2C2_EV_IRQHandler [WEAK]
+ EXPORT I2C2_ER_IRQHandler [WEAK]
+ EXPORT SPI1_IRQHandler [WEAK]
+ EXPORT SPI2_IRQHandler [WEAK]
+ EXPORT USART1_IRQHandler [WEAK]
+ EXPORT USART2_IRQHandler [WEAK]
+ EXPORT EXTI15_10_IRQHandler [WEAK]
+ EXPORT RTC_Alarm_IRQHandler [WEAK]
+ EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
+ EXPORT DMA1_Stream7_IRQHandler [WEAK]
+ EXPORT SDIO_IRQHandler [WEAK]
+ EXPORT TIM5_IRQHandler [WEAK]
+ EXPORT SPI3_IRQHandler [WEAK]
+ EXPORT DMA2_Stream0_IRQHandler [WEAK]
+ EXPORT DMA2_Stream1_IRQHandler [WEAK]
+ EXPORT DMA2_Stream2_IRQHandler [WEAK]
+ EXPORT DMA2_Stream3_IRQHandler [WEAK]
+ EXPORT DMA2_Stream4_IRQHandler [WEAK]
+ EXPORT OTG_FS_IRQHandler [WEAK]
+ EXPORT DMA2_Stream5_IRQHandler [WEAK]
+ EXPORT DMA2_Stream6_IRQHandler [WEAK]
+ EXPORT DMA2_Stream7_IRQHandler [WEAK]
+ EXPORT USART6_IRQHandler [WEAK]
+ EXPORT I2C3_EV_IRQHandler [WEAK]
+ EXPORT I2C3_ER_IRQHandler [WEAK]
+ EXPORT FPU_IRQHandler [WEAK]
+ EXPORT SPI4_IRQHandler [WEAK]
+
+WWDG_IRQHandler
+PVD_IRQHandler
+TAMP_STAMP_IRQHandler
+RTC_WKUP_IRQHandler
+FLASH_IRQHandler
+RCC_IRQHandler
+EXTI0_IRQHandler
+EXTI1_IRQHandler
+EXTI2_IRQHandler
+EXTI3_IRQHandler
+EXTI4_IRQHandler
+DMA1_Stream0_IRQHandler
+DMA1_Stream1_IRQHandler
+DMA1_Stream2_IRQHandler
+DMA1_Stream3_IRQHandler
+DMA1_Stream4_IRQHandler
+DMA1_Stream5_IRQHandler
+DMA1_Stream6_IRQHandler
+ADC_IRQHandler
+EXTI9_5_IRQHandler
+TIM1_BRK_TIM9_IRQHandler
+TIM1_UP_TIM10_IRQHandler
+TIM1_TRG_COM_TIM11_IRQHandler
+TIM1_CC_IRQHandler
+TIM2_IRQHandler
+TIM3_IRQHandler
+TIM4_IRQHandler
+I2C1_EV_IRQHandler
+I2C1_ER_IRQHandler
+I2C2_EV_IRQHandler
+I2C2_ER_IRQHandler
+SPI1_IRQHandler
+SPI2_IRQHandler
+USART1_IRQHandler
+USART2_IRQHandler
+EXTI15_10_IRQHandler
+RTC_Alarm_IRQHandler
+OTG_FS_WKUP_IRQHandler
+DMA1_Stream7_IRQHandler
+SDIO_IRQHandler
+TIM5_IRQHandler
+SPI3_IRQHandler
+DMA2_Stream0_IRQHandler
+DMA2_Stream1_IRQHandler
+DMA2_Stream2_IRQHandler
+DMA2_Stream3_IRQHandler
+DMA2_Stream4_IRQHandler
+OTG_FS_IRQHandler
+DMA2_Stream5_IRQHandler
+DMA2_Stream6_IRQHandler
+DMA2_Stream7_IRQHandler
+USART6_IRQHandler
+I2C3_EV_IRQHandler
+I2C3_ER_IRQHandler
+FPU_IRQHandler
+SPI4_IRQHandler
+
+ B .
+
+ ENDP
+
+ ALIGN
+
+;*******************************************************************************
+; User Stack and Heap initialization
+;*******************************************************************************
+ IF :DEF:__MICROLIB
+
+ EXPORT __initial_sp
+ EXPORT __heap_base
+ EXPORT __heap_limit
+
+ ELSE
+
+ IMPORT __use_two_region_memory
+ EXPORT __user_initial_stackheap
+
+__user_initial_stackheap
+
+ LDR R0, = Heap_Mem
+ LDR R1, =(Stack_Mem + Stack_Size)
+ LDR R2, = (Heap_Mem + Heap_Size)
+ LDR R3, = Stack_Mem
+ BX LR
+
+ ALIGN
+
+ ENDIF
+
+ END
+
+;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
diff --git a/examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/system_stm32f4xx.c b/examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/system_stm32f4xx.c
new file mode 100644
index 00000000..bca0633d
--- /dev/null
+++ b/examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/system_stm32f4xx.c
@@ -0,0 +1,763 @@
+/**
+ ******************************************************************************
+ * @file system_stm32f4xx.c
+ * @author MCD Application Team
+ * @version V2.6.0
+ * @date 04-November-2016
+ * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
+ *
+ * This file provides two functions and one global variable to be called from
+ * user application:
+ * - SystemInit(): This function is called at startup just after reset and
+ * before branch to main program. This call is made inside
+ * the "startup_stm32f4xx.s" file.
+ *
+ * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
+ * by the user application to setup the SysTick
+ * timer or configure other parameters.
+ *
+ * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
+ * be called whenever the core clock is changed
+ * during program execution.
+ *
+ *
+ ******************************************************************************
+ * @attention
+ *
+ *
© COPYRIGHT 2016 STMicroelectronics
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/** @addtogroup CMSIS
+ * @{
+ */
+
+/** @addtogroup stm32f4xx_system
+ * @{
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Includes
+ * @{
+ */
+
+
+#include "stm32f4xx.h"
+
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Defines
+ * @{
+ */
+
+/************************* Miscellaneous Configuration ************************/
+/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */
+#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
+ || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
+/* #define DATA_IN_ExtSRAM */
+#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\
+ STM32F412Zx || STM32F412Vx */
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
+/* #define DATA_IN_ExtSDRAM */
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
+ STM32F479xx */
+
+/*!< Uncomment the following line if you need to relocate your vector Table in
+ Internal SRAM. */
+/* #define VECT_TAB_SRAM */
+#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+/******************************************************************************/
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Variables
+ * @{
+ */
+ /* This variable is updated in three ways:
+ 1) by calling CMSIS function SystemCoreClockUpdate()
+ 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
+ 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
+ Note: If you use this function to configure the system clock; then there
+ is no need to call the 2 first functions listed above, since SystemCoreClock
+ variable is updated automatically.
+ */
+uint32_t SystemCoreClock = 16000000;
+const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
+ * @{
+ */
+
+#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+ static void SystemInit_ExtMemCtl(void);
+#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Setup the microcontroller system
+ * Initialize the FPU setting, vector table location and External memory
+ * configuration.
+ * @param None
+ * @retval None
+ */
+void SystemInit(void)
+{
+ /* FPU settings ------------------------------------------------------------*/
+ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
+ SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
+ #endif
+ /* Reset the RCC clock configuration to the default reset state ------------*/
+ /* Set HSION bit */
+ RCC->CR |= (uint32_t)0x00000001;
+
+ /* Reset CFGR register */
+ RCC->CFGR = 0x00000000;
+
+ /* Reset HSEON, CSSON and PLLON bits */
+ RCC->CR &= (uint32_t)0xFEF6FFFF;
+
+ /* Reset PLLCFGR register */
+ RCC->PLLCFGR = 0x24003010;
+
+ /* Reset HSEBYP bit */
+ RCC->CR &= (uint32_t)0xFFFBFFFF;
+
+ /* Disable all interrupts */
+ RCC->CIR = 0x00000000;
+
+#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+ SystemInit_ExtMemCtl();
+#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
+
+ /* Configure the Vector Table location add offset address ------------------*/
+#ifdef VECT_TAB_SRAM
+ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
+#else
+ SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
+#endif
+}
+
+/**
+ * @brief Update SystemCoreClock variable according to Clock Register Values.
+ * The SystemCoreClock variable contains the core clock (HCLK), it can
+ * be used by the user application to setup the SysTick timer or configure
+ * other parameters.
+ *
+ * @note Each time the core clock (HCLK) changes, this function must be called
+ * to update SystemCoreClock variable value. Otherwise, any configuration
+ * based on this variable will be incorrect.
+ *
+ * @note - The system frequency computed by this function is not the real
+ * frequency in the chip. It is calculated based on the predefined
+ * constant and the selected clock source:
+ *
+ * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
+ *
+ * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
+ *
+ * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
+ * or HSI_VALUE(*) multiplied/divided by the PLL factors.
+ *
+ * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
+ * 16 MHz) but the real value may vary depending on the variations
+ * in voltage and temperature.
+ *
+ * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
+ * depends on the application requirements), user has to ensure that HSE_VALUE
+ * is same as the real frequency of the crystal used. Otherwise, this function
+ * may have wrong result.
+ *
+ * - The result of this function could be not correct when using fractional
+ * value for HSE crystal.
+ *
+ * @param None
+ * @retval None
+ */
+void SystemCoreClockUpdate(void)
+{
+ uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
+
+ /* Get SYSCLK source -------------------------------------------------------*/
+ tmp = RCC->CFGR & RCC_CFGR_SWS;
+
+ switch (tmp)
+ {
+ case 0x00: /* HSI used as system clock source */
+ SystemCoreClock = HSI_VALUE;
+ break;
+ case 0x04: /* HSE used as system clock source */
+ SystemCoreClock = HSE_VALUE;
+ break;
+ case 0x08: /* PLL used as system clock source */
+
+ /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
+ SYSCLK = PLL_VCO / PLL_P
+ */
+ pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
+ pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
+
+ if (pllsource != 0)
+ {
+ /* HSE used as PLL clock source */
+ pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+ }
+ else
+ {
+ /* HSI used as PLL clock source */
+ pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+ }
+
+ pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
+ SystemCoreClock = pllvco/pllp;
+ break;
+ default:
+ SystemCoreClock = HSI_VALUE;
+ break;
+ }
+ /* Compute HCLK frequency --------------------------------------------------*/
+ /* Get HCLK prescaler */
+ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
+ /* HCLK frequency */
+ SystemCoreClock >>= tmp;
+}
+
+#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx)
+/**
+ * @brief Setup the external memory controller.
+ * Called in startup_stm32f4xx.s before jump to main.
+ * This function configures the external memories (SRAM/SDRAM)
+ * This SRAM/SDRAM will be used as program data memory (including heap and stack).
+ * @param None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+ __IO uint32_t tmp = 0x00;
+
+ register uint32_t tmpreg = 0, timeout = 0xFFFF;
+ register __IO uint32_t index;
+
+ /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
+ RCC->AHB1ENR |= 0x000001F8;
+
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
+
+ /* Connect PDx pins to FMC Alternate function */
+ GPIOD->AFR[0] = 0x00CCC0CC;
+ GPIOD->AFR[1] = 0xCCCCCCCC;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOD->MODER = 0xAAAA0A8A;
+ /* Configure PDx pins speed to 100 MHz */
+ GPIOD->OSPEEDR = 0xFFFF0FCF;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOD->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOD->PUPDR = 0x00000000;
+
+ /* Connect PEx pins to FMC Alternate function */
+ GPIOE->AFR[0] = 0xC00CC0CC;
+ GPIOE->AFR[1] = 0xCCCCCCCC;
+ /* Configure PEx pins in Alternate function mode */
+ GPIOE->MODER = 0xAAAA828A;
+ /* Configure PEx pins speed to 100 MHz */
+ GPIOE->OSPEEDR = 0xFFFFC3CF;
+ /* Configure PEx pins Output type to push-pull */
+ GPIOE->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PEx pins */
+ GPIOE->PUPDR = 0x00000000;
+
+ /* Connect PFx pins to FMC Alternate function */
+ GPIOF->AFR[0] = 0xCCCCCCCC;
+ GPIOF->AFR[1] = 0xCCCCCCCC;
+ /* Configure PFx pins in Alternate function mode */
+ GPIOF->MODER = 0xAA800AAA;
+ /* Configure PFx pins speed to 50 MHz */
+ GPIOF->OSPEEDR = 0xAA800AAA;
+ /* Configure PFx pins Output type to push-pull */
+ GPIOF->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PFx pins */
+ GPIOF->PUPDR = 0x00000000;
+
+ /* Connect PGx pins to FMC Alternate function */
+ GPIOG->AFR[0] = 0xCCCCCCCC;
+ GPIOG->AFR[1] = 0xCCCCCCCC;
+ /* Configure PGx pins in Alternate function mode */
+ GPIOG->MODER = 0xAAAAAAAA;
+ /* Configure PGx pins speed to 50 MHz */
+ GPIOG->OSPEEDR = 0xAAAAAAAA;
+ /* Configure PGx pins Output type to push-pull */
+ GPIOG->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PGx pins */
+ GPIOG->PUPDR = 0x00000000;
+
+ /* Connect PHx pins to FMC Alternate function */
+ GPIOH->AFR[0] = 0x00C0CC00;
+ GPIOH->AFR[1] = 0xCCCCCCCC;
+ /* Configure PHx pins in Alternate function mode */
+ GPIOH->MODER = 0xAAAA08A0;
+ /* Configure PHx pins speed to 50 MHz */
+ GPIOH->OSPEEDR = 0xAAAA08A0;
+ /* Configure PHx pins Output type to push-pull */
+ GPIOH->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PHx pins */
+ GPIOH->PUPDR = 0x00000000;
+
+ /* Connect PIx pins to FMC Alternate function */
+ GPIOI->AFR[0] = 0xCCCCCCCC;
+ GPIOI->AFR[1] = 0x00000CC0;
+ /* Configure PIx pins in Alternate function mode */
+ GPIOI->MODER = 0x0028AAAA;
+ /* Configure PIx pins speed to 50 MHz */
+ GPIOI->OSPEEDR = 0x0028AAAA;
+ /* Configure PIx pins Output type to push-pull */
+ GPIOI->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PIx pins */
+ GPIOI->PUPDR = 0x00000000;
+
+/*-- FMC Configuration -------------------------------------------------------*/
+ /* Enable the FMC interface clock */
+ RCC->AHB3ENR |= 0x00000001;
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+
+ FMC_Bank5_6->SDCR[0] = 0x000019E4;
+ FMC_Bank5_6->SDTR[0] = 0x01115351;
+
+ /* SDRAM initialization sequence */
+ /* Clock enable command */
+ FMC_Bank5_6->SDCMR = 0x00000011;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Delay */
+ for (index = 0; index<1000; index++);
+
+ /* PALL command */
+ FMC_Bank5_6->SDCMR = 0x00000012;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Auto refresh command */
+ FMC_Bank5_6->SDCMR = 0x00000073;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* MRD register program */
+ FMC_Bank5_6->SDCMR = 0x00046014;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Set refresh count */
+ tmpreg = FMC_Bank5_6->SDRTR;
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
+
+ /* Disable write protection */
+ tmpreg = FMC_Bank5_6->SDCR[0];
+ FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001011;
+ FMC_Bank1->BTCR[3] = 0x00000201;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
+#if defined(STM32F469xx) || defined(STM32F479xx)
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001091;
+ FMC_Bank1->BTCR[3] = 0x00110212;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F469xx || STM32F479xx */
+
+ (void)(tmp);
+}
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
+#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+/**
+ * @brief Setup the external memory controller.
+ * Called in startup_stm32f4xx.s before jump to main.
+ * This function configures the external memories (SRAM/SDRAM)
+ * This SRAM/SDRAM will be used as program data memory (including heap and stack).
+ * @param None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+ __IO uint32_t tmp = 0x00;
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
+#if defined (DATA_IN_ExtSDRAM)
+ register uint32_t tmpreg = 0, timeout = 0xFFFF;
+ register __IO uint32_t index;
+
+#if defined(STM32F446xx)
+ /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface
+ clock */
+ RCC->AHB1ENR |= 0x0000007D;
+#else
+ /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
+ clock */
+ RCC->AHB1ENR |= 0x000001F8;
+#endif /* STM32F446xx */
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
+
+#if defined(STM32F446xx)
+ /* Connect PAx pins to FMC Alternate function */
+ GPIOA->AFR[0] |= 0xC0000000;
+ GPIOA->AFR[1] |= 0x00000000;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOA->MODER |= 0x00008000;
+ /* Configure PDx pins speed to 50 MHz */
+ GPIOA->OSPEEDR |= 0x00008000;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOA->OTYPER |= 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOA->PUPDR |= 0x00000000;
+
+ /* Connect PCx pins to FMC Alternate function */
+ GPIOC->AFR[0] |= 0x00CC0000;
+ GPIOC->AFR[1] |= 0x00000000;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOC->MODER |= 0x00000A00;
+ /* Configure PDx pins speed to 50 MHz */
+ GPIOC->OSPEEDR |= 0x00000A00;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOC->OTYPER |= 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOC->PUPDR |= 0x00000000;
+#endif /* STM32F446xx */
+
+ /* Connect PDx pins to FMC Alternate function */
+ GPIOD->AFR[0] = 0x000000CC;
+ GPIOD->AFR[1] = 0xCC000CCC;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOD->MODER = 0xA02A000A;
+ /* Configure PDx pins speed to 50 MHz */
+ GPIOD->OSPEEDR = 0xA02A000A;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOD->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOD->PUPDR = 0x00000000;
+
+ /* Connect PEx pins to FMC Alternate function */
+ GPIOE->AFR[0] = 0xC00000CC;
+ GPIOE->AFR[1] = 0xCCCCCCCC;
+ /* Configure PEx pins in Alternate function mode */
+ GPIOE->MODER = 0xAAAA800A;
+ /* Configure PEx pins speed to 50 MHz */
+ GPIOE->OSPEEDR = 0xAAAA800A;
+ /* Configure PEx pins Output type to push-pull */
+ GPIOE->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PEx pins */
+ GPIOE->PUPDR = 0x00000000;
+
+ /* Connect PFx pins to FMC Alternate function */
+ GPIOF->AFR[0] = 0xCCCCCCCC;
+ GPIOF->AFR[1] = 0xCCCCCCCC;
+ /* Configure PFx pins in Alternate function mode */
+ GPIOF->MODER = 0xAA800AAA;
+ /* Configure PFx pins speed to 50 MHz */
+ GPIOF->OSPEEDR = 0xAA800AAA;
+ /* Configure PFx pins Output type to push-pull */
+ GPIOF->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PFx pins */
+ GPIOF->PUPDR = 0x00000000;
+
+ /* Connect PGx pins to FMC Alternate function */
+ GPIOG->AFR[0] = 0xCCCCCCCC;
+ GPIOG->AFR[1] = 0xCCCCCCCC;
+ /* Configure PGx pins in Alternate function mode */
+ GPIOG->MODER = 0xAAAAAAAA;
+ /* Configure PGx pins speed to 50 MHz */
+ GPIOG->OSPEEDR = 0xAAAAAAAA;
+ /* Configure PGx pins Output type to push-pull */
+ GPIOG->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PGx pins */
+ GPIOG->PUPDR = 0x00000000;
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx)
+ /* Connect PHx pins to FMC Alternate function */
+ GPIOH->AFR[0] = 0x00C0CC00;
+ GPIOH->AFR[1] = 0xCCCCCCCC;
+ /* Configure PHx pins in Alternate function mode */
+ GPIOH->MODER = 0xAAAA08A0;
+ /* Configure PHx pins speed to 50 MHz */
+ GPIOH->OSPEEDR = 0xAAAA08A0;
+ /* Configure PHx pins Output type to push-pull */
+ GPIOH->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PHx pins */
+ GPIOH->PUPDR = 0x00000000;
+
+ /* Connect PIx pins to FMC Alternate function */
+ GPIOI->AFR[0] = 0xCCCCCCCC;
+ GPIOI->AFR[1] = 0x00000CC0;
+ /* Configure PIx pins in Alternate function mode */
+ GPIOI->MODER = 0x0028AAAA;
+ /* Configure PIx pins speed to 50 MHz */
+ GPIOI->OSPEEDR = 0x0028AAAA;
+ /* Configure PIx pins Output type to push-pull */
+ GPIOI->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PIx pins */
+ GPIOI->PUPDR = 0x00000000;
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
+
+/*-- FMC Configuration -------------------------------------------------------*/
+ /* Enable the FMC interface clock */
+ RCC->AHB3ENR |= 0x00000001;
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+
+ /* Configure and enable SDRAM bank1 */
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDCR[0] = 0x00001954;
+#else
+ FMC_Bank5_6->SDCR[0] = 0x000019E4;
+#endif /* STM32F446xx */
+ FMC_Bank5_6->SDTR[0] = 0x01115351;
+
+ /* SDRAM initialization sequence */
+ /* Clock enable command */
+ FMC_Bank5_6->SDCMR = 0x00000011;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Delay */
+ for (index = 0; index<1000; index++);
+
+ /* PALL command */
+ FMC_Bank5_6->SDCMR = 0x00000012;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Auto refresh command */
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDCMR = 0x000000F3;
+#else
+ FMC_Bank5_6->SDCMR = 0x00000073;
+#endif /* STM32F446xx */
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* MRD register program */
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDCMR = 0x00044014;
+#else
+ FMC_Bank5_6->SDCMR = 0x00046014;
+#endif /* STM32F446xx */
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Set refresh count */
+ tmpreg = FMC_Bank5_6->SDRTR;
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1));
+#else
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
+#endif /* STM32F446xx */
+
+ /* Disable write protection */
+ tmpreg = FMC_Bank5_6->SDCR[0];
+ FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
+#endif /* DATA_IN_ExtSDRAM */
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
+
+#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
+ || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
+
+#if defined(DATA_IN_ExtSRAM)
+/*-- GPIOs Configuration -----------------------------------------------------*/
+ /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
+ RCC->AHB1ENR |= 0x00000078;
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);
+
+ /* Connect PDx pins to FMC Alternate function */
+ GPIOD->AFR[0] = 0x00CCC0CC;
+ GPIOD->AFR[1] = 0xCCCCCCCC;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOD->MODER = 0xAAAA0A8A;
+ /* Configure PDx pins speed to 100 MHz */
+ GPIOD->OSPEEDR = 0xFFFF0FCF;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOD->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOD->PUPDR = 0x00000000;
+
+ /* Connect PEx pins to FMC Alternate function */
+ GPIOE->AFR[0] = 0xC00CC0CC;
+ GPIOE->AFR[1] = 0xCCCCCCCC;
+ /* Configure PEx pins in Alternate function mode */
+ GPIOE->MODER = 0xAAAA828A;
+ /* Configure PEx pins speed to 100 MHz */
+ GPIOE->OSPEEDR = 0xFFFFC3CF;
+ /* Configure PEx pins Output type to push-pull */
+ GPIOE->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PEx pins */
+ GPIOE->PUPDR = 0x00000000;
+
+ /* Connect PFx pins to FMC Alternate function */
+ GPIOF->AFR[0] = 0x00CCCCCC;
+ GPIOF->AFR[1] = 0xCCCC0000;
+ /* Configure PFx pins in Alternate function mode */
+ GPIOF->MODER = 0xAA000AAA;
+ /* Configure PFx pins speed to 100 MHz */
+ GPIOF->OSPEEDR = 0xFF000FFF;
+ /* Configure PFx pins Output type to push-pull */
+ GPIOF->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PFx pins */
+ GPIOF->PUPDR = 0x00000000;
+
+ /* Connect PGx pins to FMC Alternate function */
+ GPIOG->AFR[0] = 0x00CCCCCC;
+ GPIOG->AFR[1] = 0x000000C0;
+ /* Configure PGx pins in Alternate function mode */
+ GPIOG->MODER = 0x00085AAA;
+ /* Configure PGx pins speed to 100 MHz */
+ GPIOG->OSPEEDR = 0x000CAFFF;
+ /* Configure PGx pins Output type to push-pull */
+ GPIOG->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PGx pins */
+ GPIOG->PUPDR = 0x00000000;
+
+/*-- FMC/FSMC Configuration --------------------------------------------------*/
+ /* Enable the FMC/FSMC interface clock */
+ RCC->AHB3ENR |= 0x00000001;
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001011;
+ FMC_Bank1->BTCR[3] = 0x00000201;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
+#if defined(STM32F469xx) || defined(STM32F479xx)
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001091;
+ FMC_Bank1->BTCR[3] = 0x00110212;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F469xx || STM32F479xx */
+#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\
+ || defined(STM32F412Zx) || defined(STM32F412Vx)
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);
+ /* Configure and enable Bank1_SRAM2 */
+ FSMC_Bank1->BTCR[2] = 0x00001011;
+ FSMC_Bank1->BTCR[3] = 0x00000201;
+ FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
+#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */
+
+#endif /* DATA_IN_ExtSRAM */
+#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
+ STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
+ (void)(tmp);
+}
+#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/examples/ArmTimerCallbacks/RTE/_Target_1/RTE_Components.h b/examples/ArmTimerCallbacks/RTE/_Target_1/RTE_Components.h
new file mode 100644
index 00000000..c72d4b59
--- /dev/null
+++ b/examples/ArmTimerCallbacks/RTE/_Target_1/RTE_Components.h
@@ -0,0 +1,21 @@
+
+/*
+ * Auto generated Run-Time-Environment Component Configuration File
+ * *** Do not modify ! ***
+ *
+ * Project: 'ArmTimerCallbacks'
+ * Target: 'Target 1'
+ */
+
+#ifndef RTE_COMPONENTS_H
+#define RTE_COMPONENTS_H
+
+
+/*
+ * Define the Device Header File:
+ */
+#define CMSIS_device_header "stm32f4xx.h"
+
+#define RTE_DEVICE_STARTUP_STM32F4XX /* Device Startup for STM32F4 */
+
+#endif /* RTE_COMPONENTS_H */
diff --git a/examples/ArmTimerCallbacks/Retarget.c b/examples/ArmTimerCallbacks/Retarget.c
new file mode 100644
index 00000000..675056c8
--- /dev/null
+++ b/examples/ArmTimerCallbacks/Retarget.c
@@ -0,0 +1,52 @@
+/*----------------------------------------------------------------------------
+ * Name: Retarget.c
+ * Purpose: 'Retarget' layer for target-dependent low level functions
+ * Note(s):
+ *----------------------------------------------------------------------------
+ * This file is part of the uVision/ARM development tools.
+ * This software may only be used under the terms of a valid, current,
+ * end user licence from KEIL for a compatible version of KEIL software
+ * development tools. Nothing else gives you the right to use this software.
+ *
+ * This software is supplied "AS IS" without warranties of any kind.
+ *
+ * Copyright (c) 2011 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------*/
+
+#include
+#include
+#include "Serial.h"
+
+//#pragma import(__use_no_semihosting_swi)
+
+
+
+//struct __FILE { int handle; /* Add whatever you need here */ };
+FILE __stdout;
+FILE __stdin;
+
+
+int fputc(int c, FILE *f) {
+ return (SER_PutChar(c));
+}
+
+
+int fgetc(FILE *f) {
+ return (SER_GetChar());
+}
+
+
+int ferror(FILE *f) {
+ /* Your implementation of ferror */
+ return EOF;
+}
+
+
+void _ttywrch(int c) {
+ SER_PutChar(c);
+}
+
+
+void _sys_exit(int return_code) {
+label: goto label; /* endless loop */
+}
diff --git a/examples/ArmTimerCallbacks/Serial.c b/examples/ArmTimerCallbacks/Serial.c
new file mode 100644
index 00000000..80840c44
--- /dev/null
+++ b/examples/ArmTimerCallbacks/Serial.c
@@ -0,0 +1,98 @@
+/*----------------------------------------------------------------------------
+ * Name: Serial.c
+ * Purpose: Low Level Serial Routines
+ * Note(s): possible defines select the used communication interface:
+ * __DBG_ITM - ITM SWO interface
+ * - USART2 interface (default)
+ *----------------------------------------------------------------------------
+ * This file is part of the uVision/ARM development tools.
+ * This software may only be used under the terms of a valid, current,
+ * end user licence from KEIL for a compatible version of KEIL software
+ * development tools. Nothing else gives you the right to use this software.
+ *
+ * This software is supplied "AS IS" without warranties of any kind.
+ *
+ * Copyright (c) 2014 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------*/
+
+#include "stm32f4xx.h" // Device header
+#include "Serial.h"
+
+#ifdef __DBG_ITM
+volatile int ITM_RxBuffer; /* CMSIS Debug Input */
+#endif
+
+/*----------------------------------------------------------------------------
+ Define USART
+ *----------------------------------------------------------------------------*/
+#define USARTx USART2
+
+
+/*----------------------------------------------------------------------------
+ Define Baudrate setting (BRR) for USART
+ *----------------------------------------------------------------------------*/
+#define __DIV(__PCLK, __BAUD) ((__PCLK*25)/(4*__BAUD))
+#define __DIVMANT(__PCLK, __BAUD) (__DIV(__PCLK, __BAUD)/100)
+#define __DIVFRAQ(__PCLK, __BAUD) (((__DIV(__PCLK, __BAUD) - (__DIVMANT(__PCLK, __BAUD) * 100)) * 16 + 50) / 100)
+#define __USART_BRR(__PCLK, __BAUD) ((__DIVMANT(__PCLK, __BAUD) << 4)|(__DIVFRAQ(__PCLK, __BAUD) & 0x0F))
+
+
+/*----------------------------------------------------------------------------
+ Initialize UART pins, Baudrate
+ *----------------------------------------------------------------------------*/
+void SER_Initialize (void) {
+
+#ifdef __DBG_ITM
+ ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* CMSIS Debug Input */
+#else
+ RCC->AHB1ENR |= ( 1ul << 0); /* Enable GPIOA clock */
+ RCC->APB1ENR |= ( 1ul << 17); /* Enable USART#2 clock */
+
+ /* Configure PA3 to USART2_RX, PA2 to USART2_TX */
+ GPIOA->AFR[0] &= ~((15ul << 4* 3) | (15ul << 4* 2) );
+ GPIOA->AFR[0] |= (( 7ul << 4* 3) | ( 7ul << 4* 2) );
+ GPIOA->MODER &= ~(( 3ul << 2* 3) | ( 3ul << 2* 2) );
+ GPIOA->MODER |= (( 2ul << 2* 3) | ( 2ul << 2* 2) );
+
+ USARTx->BRR = __USART_BRR(12000000ul, 115200ul); /* 115200 baud @ 12MHz */
+ USARTx->CR3 = 0x0000; /* no flow control */
+ USARTx->CR2 = 0x0000; /* 1 stop bit */
+ USARTx->CR1 = (( 1ul << 2) | /* enable RX */
+ ( 1ul << 3) | /* enable TX */
+ ( 0ul << 12) | /* 1 start bit, 8 data bits */
+ ( 1ul << 13) ); /* enable USART */
+#endif
+}
+
+
+/*----------------------------------------------------------------------------
+ Write character to Serial Port
+ *----------------------------------------------------------------------------*/
+int SER_PutChar (int ch) {
+
+#ifdef __DBG_ITM
+ ITM_SendChar (ch & 0xFF);
+#else
+ while (!(USARTx->SR & 0x0080));
+ USARTx->DR = (ch & 0xFF);
+#endif
+
+ return (ch);
+}
+
+/*----------------------------------------------------------------------------
+ Read character from Serial Port
+ *----------------------------------------------------------------------------*/
+int SER_GetChar (void) {
+
+#ifdef __DBG_ITM
+ if (ITM_CheckChar())
+ return ITM_ReceiveChar();
+#else
+ if (USARTx->SR & 0x0020)
+ return (USARTx->DR);
+#endif
+
+ return (-1);
+}
+
diff --git a/examples/ArmTimerCallbacks/Serial.h b/examples/ArmTimerCallbacks/Serial.h
new file mode 100644
index 00000000..f8ebf812
--- /dev/null
+++ b/examples/ArmTimerCallbacks/Serial.h
@@ -0,0 +1,23 @@
+/*----------------------------------------------------------------------------
+ * Name: Serial.h
+ * Purpose: Low level serial definitions
+ * Note(s):
+ *----------------------------------------------------------------------------
+ * This file is part of the uVision/ARM development tools.
+ * This software may only be used under the terms of a valid, current,
+ * end user licence from KEIL for a compatible version of KEIL software
+ * development tools. Nothing else gives you the right to use this software.
+ *
+ * This software is supplied "AS IS" without warranties of any kind.
+ *
+ * Copyright (c) 2014 Keil - An ARM Company. All rights reserved.
+ *----------------------------------------------------------------------------*/
+
+#ifndef SERIAL_H
+#define SERIAL_H
+
+extern void SER_Initialize(void);
+extern int SER_GetChar (void);
+extern int SER_PutChar (int c);
+
+#endif
diff --git a/examples/ArmTimerCallbacks/etl_profile.h b/examples/ArmTimerCallbacks/etl_profile.h
new file mode 100644
index 00000000..4560ba1e
--- /dev/null
+++ b/examples/ArmTimerCallbacks/etl_profile.h
@@ -0,0 +1,21 @@
+
+#ifndef __ETL_PROFILE_H__
+#define __ETL_PROFILE_H__
+
+#define ETL_THROW_EXCEPTIONS
+#define ETL_VERBOSE_ERRORS
+#define ETL_CHECK_PUSH_POP
+#define ETL_ISTRING_REPAIR_ENABLE
+#define ETL_IVECTOR_REPAIR_ENABLE
+#define ETL_IDEQUE_REPAIR_ENABLE
+#define ETL_IN_UNIT_TEST
+
+#if (__CC_ARM == 1)
+ // ARM5 compiler
+ #include "profiles/armv5.h"
+#else
+ // ARM6 compiler
+ #include "profiles/armv6.h"
+#endif
+
+#endif
diff --git a/examples/ArmTimerCallbacks/main.cpp b/examples/ArmTimerCallbacks/main.cpp
new file mode 100644
index 00000000..05f19b17
--- /dev/null
+++ b/examples/ArmTimerCallbacks/main.cpp
@@ -0,0 +1,147 @@
+
+#include
+
+extern "C"
+{
+ #include "Board_LED.h" // ::Board Support:LED
+ #include "Board_Buttons.h" // ::Board Support:Buttons
+
+ #include "stm32f4xx.h" // Device header
+}
+
+#include "function.h"
+#include "callback_timer.h"
+
+const int N_TIMERS = 4;
+
+etl::callback_timer callback_timer;
+
+etl::timer::id::type short_toggle;
+etl::timer::id::type long_toggle;
+etl::timer::id::type start_timers;
+etl::timer::id::type swap_timers;
+
+/*----------------------------------------------------------------------------
+ * SystemCoreClockConfigure: configure SystemCoreClock using HSI
+ (HSE is not populated on Nucleo board)
+ *----------------------------------------------------------------------------*/
+void SystemCoreClockConfigure(void) {
+
+ RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
+ while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
+
+ RCC->CFGR = RCC_CFGR_SW_HSI; // HSI is system clock
+ while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); // Wait for HSI used as system clock
+
+ FLASH->ACR = FLASH_ACR_PRFTEN; // Enable Prefetch Buffer
+ FLASH->ACR |= FLASH_ACR_ICEN; // Instruction cache enable
+ FLASH->ACR |= FLASH_ACR_DCEN; // Data cache enable
+ FLASH->ACR |= FLASH_ACR_LATENCY_5WS; // Flash 5 wait state
+
+ RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // HCLK = SYSCLK
+ RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; // APB1 = HCLK/4
+ RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; // APB2 = HCLK/2
+
+ RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
+
+ // PLL configuration: VCO = HSI/M * N, Sysclk = VCO/P
+ RCC->PLLCFGR = ( 16ul | // PLL_M = 16
+ (384ul << 6) | // PLL_N = 384
+ ( 3ul << 16) | // PLL_P = 8
+ (RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
+ ( 8ul << 24) ); // PLL_Q = 8
+
+ RCC->CR |= RCC_CR_PLLON; // Enable PLL
+ while((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
+
+ RCC->CFGR &= ~RCC_CFGR_SW; // Select PLL as system clock source
+ RCC->CFGR |= RCC_CFGR_SW_PLL;
+ while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // Wait till PLL is system clock src
+}
+
+void StartTimers()
+{
+ callback_timer.start(short_toggle);
+ callback_timer.start(swap_timers);
+}
+
+void SwapTimers()
+{
+ static bool state = false;
+
+ if (!state)
+ {
+ callback_timer.stop(short_toggle);
+ callback_timer.start(long_toggle);
+ }
+ else
+ {
+ callback_timer.start(short_toggle);
+ callback_timer.stop(long_toggle);
+ }
+
+ state = !state;
+
+ callback_timer.start(swap_timers);
+}
+
+void LedToggle()
+{
+ static bool state = false;
+
+ if (state)
+ {
+ LED_On(0);
+ }
+ else
+ {
+ LED_Off(0);
+ }
+
+ state = !state;
+}
+
+int main()
+{
+ SystemCoreClockConfigure(); // configure HSI as System Clock
+ SystemCoreClockUpdate();
+
+ LED_Initialize();
+ Buttons_Initialize();
+
+ // The LEDs will start flashing fast after 2 seconds.
+ // After another 5 seconds they will start flashing slower.
+ short_toggle = callback_timer.register_timer(LedToggle, 50, etl::timer::mode::REPEATING);
+ long_toggle = callback_timer.register_timer(LedToggle, 100, etl::timer::mode::REPEATING);
+ start_timers = callback_timer.register_timer(StartTimers, 2000, etl::timer::mode::SINGLE_SHOT);
+ swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
+
+ SysTick_Config(SystemCoreClock / 1000);
+
+ callback_timer.enable(true);
+
+ callback_timer.start(start_timers);
+
+ while (true)
+ {
+ __NOP();
+ }
+}
+
+extern "C"
+{
+ void SysTick_Handler()
+ {
+ const uint32_t TICK = 1;
+ static uint32_t nticks = TICK;
+
+ if (callback_timer.tick(nticks))
+ {
+ nticks = TICK;
+ }
+ else
+ {
+ nticks += TICK;
+ }
+ }
+}
diff --git a/examples/FunctionInterruptSimulation/etl_profile.h b/examples/FunctionInterruptSimulation/etl_profile.h
new file mode 100644
index 00000000..a321fa85
--- /dev/null
+++ b/examples/FunctionInterruptSimulation/etl_profile.h
@@ -0,0 +1,48 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_PROFILE_H__
+#define __ETL_PROFILE_H__
+
+#define ETL_THROW_EXCEPTIONS
+#define ETL_VERBOSE_ERRORS
+#define ETL_CHECK_PUSH_POP
+#define ETL_ISTRING_REPAIR_ENABLE
+#define ETL_IVECTOR_REPAIR_ENABLE
+#define ETL_IDEQUE_REPAIR_ENABLE
+#define ETL_IN_UNIT_TEST
+
+#ifdef _MSC_VER
+ #include "profiles/msvc_x86.h"
+#else
+ #include "profiles/gcc_windows_x86.h"
+#endif
+
+#endif
diff --git a/examples/FunctionInterruptSimulation/etl_user.h b/examples/FunctionInterruptSimulation/etl_user.h
deleted file mode 100644
index 8ff4c6fe..00000000
--- a/examples/FunctionInterruptSimulation/etl_user.h
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#define ETL_THROW_EXCEPTIONS
-#define ETL_VERBOSE_ERRORS
\ No newline at end of file
diff --git a/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.sln b/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.sln
index e19d8e7f..bfec4d4e 100644
--- a/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.sln
+++ b/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FunctionInterruptSimulation", "FunctionInterruptSimulation.vcxproj", "{2873A2D7-5112-4941-83AA-F98751BE5289}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FunctionInterruptSimulation", "FunctionInterruptSimulation.vcxproj", "{5157DB15-C255-4E47-9FB1-AF388437F90F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -13,19 +13,19 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x64.ActiveCfg = Debug|x64
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x64.Build.0 = Debug|x64
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x86.ActiveCfg = Debug|Win32
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x86.Build.0 = Debug|Win32
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x64.ActiveCfg = Release|x64
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x64.Build.0 = Release|x64
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x86.ActiveCfg = Release|Win32
- {2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x86.Build.0 = Release|Win32
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x64.ActiveCfg = Debug|x64
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x64.Build.0 = Debug|x64
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x86.ActiveCfg = Debug|Win32
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x86.Build.0 = Debug|Win32
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x64.ActiveCfg = Release|x64
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x64.Build.0 = Release|x64
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x86.ActiveCfg = Release|Win32
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {C8193019-E546-4904-A25F-27FC525CC526}
+ SolutionGuid = {260225EB-60CB-44CC-A60C-16A23BBC10EB}
EndGlobalSection
EndGlobal
diff --git a/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj b/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj
index 50cf05be..3c2ce147 100644
--- a/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj
+++ b/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj
@@ -18,9 +18,15 @@
x64
+
+
+
+
+
+
15.0
- {2873A2D7-5112-4941-83AA-F98751BE5289}
+ {5157DB15-C255-4E47-9FB1-AF388437F90F}
Win32Proj
FunctionInterruptSimulation
10.0.15063.0
@@ -89,6 +95,7 @@
Disabled
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
+ ../../../src
Console
@@ -97,12 +104,12 @@
- NotUsing
+ Use
Level3
Disabled
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- ../../../src;%(AdditionalIncludeDirectories)
+ ../../../src
Console
@@ -143,12 +150,6 @@
true
-
-
-
-
-
-
diff --git a/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj.filters b/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj.filters
index 91680b76..9901d8b7 100644
--- a/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj.filters
+++ b/examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj.filters
@@ -20,7 +20,7 @@
-
+
Header Files
diff --git a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp
new file mode 100644
index 00000000..c66d389e
--- /dev/null
+++ b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp
@@ -0,0 +1,164 @@
+
+#include "queue.h"
+#include "message_router.h"
+
+#include
+#include
+
+//*****************************************************************************
+// The messages.
+//*****************************************************************************
+struct Message1 : public etl::message<1>
+{
+ Message1(int i_)
+ : i(i_)
+ {
+ }
+
+ int i;
+};
+
+struct Message2 : public etl::message<2>
+{
+ Message2(double d_)
+ : d(d_)
+ {
+ }
+
+ double d;
+};
+
+struct Message3 : public etl::message<3>
+{
+ Message3(const std::string& s_)
+ : s(s_)
+ {
+ }
+
+ std::string s;
+};
+
+struct Message4 : public etl::message<4>
+{
+};
+
+//*****************************************************************************
+// The message router.
+// Handles message types Message1, Message2, Message3.
+//*****************************************************************************
+class Router : public etl::message_router
+{
+public:
+
+ typedef etl::message_router Base_t;
+
+ using Base_t::receive;
+
+ //***************************************************************************
+ Router()
+ : message_router(1)
+ {
+ }
+
+ //***************************************************************************
+ // Override the base class's receive function.
+ void receive(etl::imessage_router& sender_, const etl::imessage& msg_)
+ {
+ if (accepts(msg_))
+ {
+ // Place in queue.
+ queue.emplace(&sender_, msg_);
+
+ std::cout << "Queueing message " << int(msg_.message_id) << std::endl;
+ }
+ else
+ {
+ std::cout << "Ignoring message " << int(msg_.message_id) << std::endl;
+ }
+ }
+
+ //***************************************************************************
+ void process_queue()
+ {
+ while (!queue.empty())
+ {
+ Item& item = queue.front();
+ etl::imessage& msg = item.packet.get();
+ etl::imessage_router& sender = *item.sender;
+ std::cout << "Processing message " << int(msg.message_id) << std::endl;
+
+ // Call the base class's receive function.
+ // This will route it to the correct on_receive handler.
+ Base_t::receive(sender, msg);
+
+ queue.pop();
+ }
+ }
+
+ //***************************************************************************
+ void on_receive(etl::imessage_router& sender, const Message1& msg)
+ {
+ std::cout << " Received message " << int(msg.message_id) << " : '" << msg.i << "'" << std::endl;
+ }
+
+ //***************************************************************************
+ void on_receive(etl::imessage_router& sender, const Message2& msg)
+ {
+ std::cout << " Received message " << int(msg.message_id) << " : '" << msg.d << "'" << std::endl;
+ }
+
+ //***************************************************************************
+ void on_receive(etl::imessage_router& sender, const Message3& msg)
+ {
+ std::cout << " Received message " << int(msg.message_id) << " : '" << msg.s << "'" << std::endl;
+ }
+
+ //***************************************************************************
+ void on_receive_unknown(etl::imessage_router& sender, const etl::imessage& msg)
+ {
+ std::cout << " Received unknown message " << int(msg.message_id) << std::endl;
+ }
+
+private:
+
+ struct Item
+ {
+ Item(etl::imessage_router* sender_, const etl::imessage& msg_)
+ : sender(sender_),
+ packet(msg_)
+ {
+ }
+
+ etl::imessage_router* sender;
+ message_packet packet;
+ };
+
+ etl::queue- queue;
+};
+
+//*****************************************************************************
+// The test application.
+//*****************************************************************************
+int main()
+{
+ Router router;
+
+ Message1 m1(1);
+ Message2 m2(1.2);
+ Message3 m3("Hello");
+
+ etl::send_message(router, m1);
+ etl::send_message(router, Message1(2));
+ etl::send_message(router, m2);
+ etl::send_message(router, Message2(3.4));
+ etl::send_message(router, m3);
+ etl::send_message(router, Message3("World"));
+ etl::send_message(router, Message4());
+
+ std::cout << std::endl;
+
+ router.process_queue();
+
+ return 0;
+}
+
diff --git a/examples/QueuedMessageRouter/vs2017/.vs/QueuedMessageRouter.sqlite b/examples/QueuedMessageRouter/vs2017/.vs/QueuedMessageRouter.sqlite
new file mode 100644
index 00000000..2572d76e
Binary files /dev/null and b/examples/QueuedMessageRouter/vs2017/.vs/QueuedMessageRouter.sqlite differ
diff --git a/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.sln b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.sln
new file mode 100644
index 00000000..95115bc1
--- /dev/null
+++ b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.10
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QueuedMessageRouter", "QueuedMessageRouter.vcxproj", "{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x64.ActiveCfg = Debug|x64
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x64.Build.0 = Debug|x64
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.ActiveCfg = Debug|Win32
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.Build.0 = Debug|Win32
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.ActiveCfg = Release|x64
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.Build.0 = Release|x64
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.ActiveCfg = Release|Win32
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {98B87835-6672-45D4-95BF-CC5C22C87D2C}
+ EndGlobalSection
+EndGlobal
diff --git a/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj
new file mode 100644
index 00000000..98bf7e9e
--- /dev/null
+++ b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj
@@ -0,0 +1,157 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 15.0
+ {2BB47D48-5EFC-4C38-B2BE-002172F00E3B}
+ Win32Proj
+ QueuedMessageRouter
+ 10.0.15063.0
+
+
+
+ Application
+ true
+ v141
+ Unicode
+
+
+ Application
+ false
+ v141
+ true
+ Unicode
+
+
+ Application
+ true
+ v141
+ Unicode
+
+
+ Application
+ false
+ v141
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ Use
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ../../../src;../vs2017
+
+
+
+ Console
+ true
+
+
+
+
+ Use
+ Level3
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Use
+ Level3
+ MaxSpeed
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ %(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj.filters b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj.filters
new file mode 100644
index 00000000..ef62273b
--- /dev/null
+++ b/examples/QueuedMessageRouter/vs2017/QueuedMessageRouter.vcxproj.filters
@@ -0,0 +1,27 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+
\ No newline at end of file
diff --git a/examples/QueuedMessageRouter/vs2017/etl_profile.h b/examples/QueuedMessageRouter/vs2017/etl_profile.h
new file mode 100644
index 00000000..a321fa85
--- /dev/null
+++ b/examples/QueuedMessageRouter/vs2017/etl_profile.h
@@ -0,0 +1,48 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_PROFILE_H__
+#define __ETL_PROFILE_H__
+
+#define ETL_THROW_EXCEPTIONS
+#define ETL_VERBOSE_ERRORS
+#define ETL_CHECK_PUSH_POP
+#define ETL_ISTRING_REPAIR_ENABLE
+#define ETL_IVECTOR_REPAIR_ENABLE
+#define ETL_IDEQUE_REPAIR_ENABLE
+#define ETL_IN_UNIT_TEST
+
+#ifdef _MSC_VER
+ #include "profiles/msvc_x86.h"
+#else
+ #include "profiles/gcc_windows_x86.h"
+#endif
+
+#endif
diff --git a/library.properties b/library.properties
index 2e0be5a4..0d293558 100644
--- a/library.properties
+++ b/library.properties
@@ -1,9 +1,9 @@
name=Embedded Template Library
-version=9.6.1
+version=10.0.0
author= John Wellbelove
maintainer=John Wellbelove
sentence=A C++ template library tailored for embedded systems.
-paragraph=Requires some support from STL. See http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/
+paragraph=Requires some support from STL. See http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/ or https://github.com/mike-matera/ArduinoSTL.git for Arduino.
category=Other
-url=http://www.etlcpp.com/
+url=https://www.etlcpp.com/
architectures=*
diff --git a/src/algorithm.h b/src/algorithm.h
index 3f2b0575..ba94a610 100644
--- a/src/algorithm.h
+++ b/src/algorithm.h
@@ -43,6 +43,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "iterator.h"
#include "type_traits.h"
diff --git a/src/alignment.h b/src/alignment.h
index eac7fe2d..f54ee145 100644
--- a/src/alignment.h
+++ b/src/alignment.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"
diff --git a/src/array.h b/src/array.h
index 7505c1e0..22d7a5c9 100644
--- a/src/array.h
+++ b/src/array.h
@@ -36,6 +36,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "exception.h"
#include "type_traits.h"
#include "parameter_type.h"
diff --git a/src/atomic.h b/src/atomic.h
new file mode 100644
index 00000000..652f815d
--- /dev/null
+++ b/src/atomic.h
@@ -0,0 +1,51 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ATOMIC__
+#define __ETL_ATOMIC__
+
+#include "platform.h"
+
+#if ETL_ATOMIC_SUPPORTED == 1
+ #include
+
+ namespace etl
+ {
+ typedef std::atomic atomic_uint32_t;
+ }
+#elif defined(ETL_COMPILER_ARM)
+ #include "atomic/atomic_arm.h"
+#elif defined(ETL_COMPILER_GCC)
+ #include "atomic/atomic_gcc.h"
+#elif defined(ETL_COMPILER_MSVC)
+ #include "atomic/atomic_windows.h"
+#else
+ #warning NO ATOMIC SUPPORT DEFINED!
+#endif
+
+#endif
diff --git a/src/atomic/atomic_arm.h b/src/atomic/atomic_arm.h
new file mode 100644
index 00000000..fb776409
--- /dev/null
+++ b/src/atomic/atomic_arm.h
@@ -0,0 +1,613 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ATOMIC_ARM__
+#define __ETL_ATOMIC_ARM__
+
+#include "../platform.h"
+#include "../type_traits.h"
+#include "../char_traits.h"
+#include "../static_assert.h"
+#include "../nullptr.h"
+
+#include
+
+namespace etl
+{
+ //***************************************************************************
+ // Atomic type for pre C++11 GCC compilers that support the builtin 'fetch' functions.
+ // Only integral and pointer types are supported.
+ //***************************************************************************
+ template
+ class atomic
+ {
+ public:
+
+ STATIC_ASSERT(etl::is_integral::value, "Only integral types are supported");
+
+ atomic()
+ : value(0)
+ {
+ }
+
+ atomic(T v)
+ : value(v)
+ {
+ }
+
+ // Assignment
+ T operator =(T v)
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ T operator =(T v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ // Pre-increment
+ T operator ++()
+ {
+ return fetch_add(1) + 1;
+ }
+
+ T operator ++() volatile
+ {
+ return fetch_add(1) + 1;
+ }
+
+ // Post-increment
+ T operator ++(int)
+ {
+ return fetch_add(1);
+ }
+
+ T operator ++(int) volatile
+ {
+ return fetch_add(1);
+ }
+
+ // Pre-decrement
+ T operator --()
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ T operator --() volatile
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ // Post-decrement
+ T operator --(int)
+ {
+ return fetch_sub(1);
+ }
+
+ T operator --(int) volatile
+ {
+ return fetch_sub(1);
+ }
+
+ // Add
+ T operator +=(T v)
+ {
+ return fetch_add(v) + v;
+ }
+
+ T operator +=(T v) volatile
+ {
+ return fetch_add(v) + v;
+ }
+
+ // Subtract
+ T operator -=(T v)
+ {
+ return fetch_sub(v) - v;
+ }
+
+ T operator -=(T v) volatile
+ {
+ return fetch_sub(v) - v;
+ }
+
+ // And
+ T operator &=(T v)
+ {
+ return fetch_and(v) & v;
+ }
+
+ T operator &=(T v) volatile
+ {
+ return fetch_and(v) & v;
+ }
+
+ // Or
+ T operator |=(T v)
+ {
+ return fetch_or(v) | v;
+ }
+
+ T operator |=(T v) volatile
+ {
+ return fetch_or(v) | v;
+ }
+
+ // Exclusive or
+ T operator ^=(T v)
+ {
+ return fetch_xor(v) ^ v;
+ }
+
+ T operator ^=(T v) volatile
+ {
+ return fetch_xor(v) ^ v;
+ }
+
+ // Conversion operator
+ operator T () const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ operator T() volatile const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ // Is lock free?
+ bool is_lock_free() const
+ {
+ return true;
+ }
+
+ bool is_lock_free() const volatile
+ {
+ return true;
+ }
+
+ // Store
+ void store(T v)
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ void store(T v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ // Load
+ T load()
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ T load() volatile
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ // Fetch add
+ T fetch_add(T v)
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ T fetch_add(T v) volatile
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ // Fetch subtract
+ T fetch_sub(T v)
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ T fetch_sub(T v) volatile
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ // Fetch or
+ T fetch_or(T v)
+ {
+ return __sync_fetch_and_or(&value, v);
+ }
+
+ T fetch_or(T v) volatile
+ {
+ return __sync_fetch_and_or(&value, v);
+ }
+
+ // Fetch and
+ T fetch_and(T v)
+ {
+ return __sync_fetch_and_and(&value, v);
+ }
+
+ T fetch_and(T v) volatile
+ {
+ return __sync_fetch_and_and(&value, v);
+ }
+
+ // Fetch exclusive or
+ T fetch_xor(T v)
+ {
+ return __sync_fetch_and_xor(&value, v);
+ }
+
+ T fetch_xor(T v) volatile
+ {
+ return __sync_fetch_and_xor(&value, v);
+ }
+
+ // Exchange
+ T exchange(T v)
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ T exchange(T v) volatile
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ // Compare exchange weak
+ bool compare_exchange_weak(T& expected, T desired)
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ bool compare_exchange_weak(T& expected, T desired) volatile
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ // Compare exchange strong
+ bool compare_exchange_strong(T& expected, T desired)
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ bool compare_exchange_strong(T& expected, T desired) volatile
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private:
+
+ atomic& operator =(const atomic&);
+ atomic& operator =(const atomic&) volatile;
+
+ T value;
+ };
+
+ //***************************************************************************
+ // Specialisation for pointers.
+ //***************************************************************************
+ template
+ class atomic
+ {
+ public:
+
+ atomic()
+ : value(nullptr)
+ {
+ }
+
+ atomic(T v)
+ : value(v)
+ {
+ }
+
+ // Assignment
+ T operator =(T* v)
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ T operator =(T* v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ // Pre-increment
+ T operator ++()
+ {
+ return fetch_add(1) + 1;
+ }
+
+ T operator ++() volatile
+ {
+ return fetch_add(1) + 1;
+ }
+
+ // Post-increment
+ T operator ++(int)
+ {
+ return fetch_add(1);
+ }
+
+ T operator ++(int) volatile
+ {
+ return fetch_add(1);
+ }
+
+ // Pre-decrement
+ T operator --()
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ T operator --() volatile
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ // Post-decrement
+ T operator --(int)
+ {
+ return fetch_sub(1);
+ }
+
+ T operator --(int) volatile
+ {
+ return fetch_sub(1);
+ }
+
+ // Add
+ T* operator +=(std::ptrdiff_t v)
+ {
+ return fetch_add(v) + v;
+ }
+
+ T* operator +=(std::ptrdiff_t v) volatile
+ {
+ return fetch_add(v) + v;
+ }
+
+ // Subtract
+ T* operator -=(std::ptrdiff_t v)
+ {
+ return fetch_sub(v) - v;
+ }
+
+ T* operator -=(std::ptrdiff_t v) volatile
+ {
+ return fetch_sub(v) - v;
+ }
+
+ // Conversion operator
+ operator T () const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ operator T() volatile const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ // Is lock free?
+ bool is_lock_free() const
+ {
+ return true;
+ }
+
+ bool is_lock_free() const volatile
+ {
+ return true;
+ }
+
+ // Store
+ void store(T v)
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ void store(T v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ // Load
+ T load()
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ T load() volatile
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ // Fetch add
+ T* fetch_add(std::ptrdiff_t v)
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ T* fetch_add(std::ptrdiff_t v) volatile
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ // Fetch subtract
+ T* fetch_sub(std::ptrdiff_t v)
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ T* fetch_sub(std::ptrdiff_t v) volatile
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ // Exchange
+ T exchange(T v)
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ T exchange(T v) volatile
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ // Compare exchange weak
+ bool compare_exchange_weak(T& expected, T desired)
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ bool compare_exchange_weak(T& expected, T desired) volatile
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ // Compare exchange strong
+ bool compare_exchange_strong(T& expected, T desired)
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ bool compare_exchange_strong(T& expected, T desired) volatile
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private:
+
+ atomic& operator =(const atomic&);
+ atomic& operator =(const atomic&) volatile;
+
+ T* value;
+ };
+
+ typedef etl::atomic atomic_char;
+ typedef etl::atomic atomic_schar;
+ typedef etl::atomic atomic_uchar;
+ typedef etl::atomic atomic_short;
+ typedef etl::atomic atomic_ushort;
+ typedef etl::atomic atomic_int;
+ typedef etl::atomic atomic_uint;
+ typedef etl::atomic atomic_long;
+ typedef etl::atomic atomic_ulong;
+ typedef etl::atomic atomic_llong;
+ typedef etl::atomic atomic_ullong;
+ typedef etl::atomic atomic_wchar_t;
+ typedef etl::atomic atomic_char16_t;
+ typedef etl::atomic atomic_char32_t;
+ typedef etl::atomic atomic_uint8_t;
+ typedef etl::atomic atomic_int8_t;
+ typedef etl::atomic atomic_uint16_t;
+ typedef etl::atomic atomic_int16_t;
+ typedef etl::atomic atomic_uint32_t;
+ typedef etl::atomic atomic_int32_t;
+ typedef etl::atomic atomic_uint64_t;
+ typedef etl::atomic atomic_int64_t;
+ typedef etl::atomic atomic_int_least8_t;
+ typedef etl::atomic atomic_uint_least8_t;
+ typedef etl::atomic atomic_int_least16_t;
+ typedef etl::atomic atomic_uint_least16_t;
+ typedef etl::atomic atomic_int_least32_t;
+ typedef etl::atomic atomic_uint_least32_t;
+ typedef etl::atomic atomic_int_least64_t;
+ typedef etl::atomic atomic_uint_least64_t;
+ typedef etl::atomic atomic_int_fast8_t;
+ typedef etl::atomic atomic_uint_fast8_t;
+ typedef etl::atomic atomic_int_fast16_t;
+ typedef etl::atomic atomic_uint_fast16_t;
+ typedef etl::atomic atomic_int_fast32_t;
+ typedef etl::atomic atomic_uint_fast32_t;
+ typedef etl::atomic atomic_int_fast64_t;
+ typedef etl::atomic atomic_uint_fast64_t;
+ typedef etl::atomic atomic_intptr_t;
+ typedef etl::atomic atomic_uintptr_t;
+ typedef etl::atomic atomic_size_t;
+ typedef etl::atomic atomic_ptrdiff_t;
+ typedef etl::atomic atomic_intmax_t;
+ typedef etl::atomic atomic_uintmax_t;
+}
+
+#endif
diff --git a/src/atomic/atomic_gcc.h b/src/atomic/atomic_gcc.h
new file mode 100644
index 00000000..f2e6c402
--- /dev/null
+++ b/src/atomic/atomic_gcc.h
@@ -0,0 +1,613 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ATOMIC_GCC__
+#define __ETL_ATOMIC_GCC__
+
+#include "../platform.h"
+#include "../type_traits.h"
+#include "../char_traits.h"
+#include "../static_assert.h"
+#include "../nullptr.h"
+
+#include
+
+namespace etl
+{
+ //***************************************************************************
+ // Atomic type for pre C++11 GCC compilers that support the builtin 'fetch' functions.
+ // Only integral and pointer types are supported.
+ //***************************************************************************
+ template
+ class atomic
+ {
+ public:
+
+ STATIC_ASSERT(etl::is_integral::value, "Only integral types are supported");
+
+ atomic()
+ : value(0)
+ {
+ }
+
+ atomic(T v)
+ : value(v)
+ {
+ }
+
+ // Assignment
+ T operator =(T v)
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ T operator =(T v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ // Pre-increment
+ T operator ++()
+ {
+ return fetch_add(1) + 1;
+ }
+
+ T operator ++() volatile
+ {
+ return fetch_add(1) + 1;
+ }
+
+ // Post-increment
+ T operator ++(int)
+ {
+ return fetch_add(1);
+ }
+
+ T operator ++(int) volatile
+ {
+ return fetch_add(1);
+ }
+
+ // Pre-decrement
+ T operator --()
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ T operator --() volatile
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ // Post-decrement
+ T operator --(int)
+ {
+ return fetch_sub(1);
+ }
+
+ T operator --(int) volatile
+ {
+ return fetch_sub(1);
+ }
+
+ // Add
+ T operator +=(T v)
+ {
+ return fetch_add(v) + v;
+ }
+
+ T operator +=(T v) volatile
+ {
+ return fetch_add(v) + v;
+ }
+
+ // Subtract
+ T operator -=(T v)
+ {
+ return fetch_sub(v) - v;
+ }
+
+ T operator -=(T v) volatile
+ {
+ return fetch_sub(v) - v;
+ }
+
+ // And
+ T operator &=(T v)
+ {
+ return fetch_and(v) & v;
+ }
+
+ T operator &=(T v) volatile
+ {
+ return fetch_and(v) & v;
+ }
+
+ // Or
+ T operator |=(T v)
+ {
+ return fetch_or(v) | v;
+ }
+
+ T operator |=(T v) volatile
+ {
+ return fetch_or(v) | v;
+ }
+
+ // Exclusive or
+ T operator ^=(T v)
+ {
+ return fetch_xor(v) ^ v;
+ }
+
+ T operator ^=(T v) volatile
+ {
+ return fetch_xor(v) ^ v;
+ }
+
+ // Conversion operator
+ operator T () const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ operator T() volatile const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ // Is lock free?
+ bool is_lock_free() const
+ {
+ return true;
+ }
+
+ bool is_lock_free() const volatile
+ {
+ return true;
+ }
+
+ // Store
+ void store(T v)
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ void store(T v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ // Load
+ T load()
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ T load() volatile
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ // Fetch add
+ T fetch_add(T v)
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ T fetch_add(T v) volatile
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ // Fetch subtract
+ T fetch_sub(T v)
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ T fetch_sub(T v) volatile
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ // Fetch or
+ T fetch_or(T v)
+ {
+ return __sync_fetch_and_or(&value, v);
+ }
+
+ T fetch_or(T v) volatile
+ {
+ return __sync_fetch_and_or(&value, v);
+ }
+
+ // Fetch and
+ T fetch_and(T v)
+ {
+ return __sync_fetch_and_and(&value, v);
+ }
+
+ T fetch_and(T v) volatile
+ {
+ return __sync_fetch_and_and(&value, v);
+ }
+
+ // Fetch exclusive or
+ T fetch_xor(T v)
+ {
+ return __sync_fetch_and_xor(&value, v);
+ }
+
+ T fetch_xor(T v) volatile
+ {
+ return __sync_fetch_and_xor(&value, v);
+ }
+
+ // Exchange
+ T exchange(T v)
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ T exchange(T v) volatile
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ // Compare exchange weak
+ bool compare_exchange_weak(T& expected, T desired)
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ bool compare_exchange_weak(T& expected, T desired) volatile
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ // Compare exchange strong
+ bool compare_exchange_strong(T& expected, T desired)
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ bool compare_exchange_strong(T& expected, T desired) volatile
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private:
+
+ atomic& operator =(const atomic&);
+ atomic& operator =(const atomic&) volatile;
+
+ T value;
+ };
+
+ //***************************************************************************
+ // Specialisation for pointers.
+ //***************************************************************************
+ template
+ class atomic
+ {
+ public:
+
+ atomic()
+ : value(nullptr)
+ {
+ }
+
+ atomic(T v)
+ : value(v)
+ {
+ }
+
+ // Assignment
+ T operator =(T* v)
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ T operator =(T* v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+
+ return v;
+ }
+
+ // Pre-increment
+ T operator ++()
+ {
+ return fetch_add(1) + 1;
+ }
+
+ T operator ++() volatile
+ {
+ return fetch_add(1) + 1;
+ }
+
+ // Post-increment
+ T operator ++(int)
+ {
+ return fetch_add(1);
+ }
+
+ T operator ++(int) volatile
+ {
+ return fetch_add(1);
+ }
+
+ // Pre-decrement
+ T operator --()
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ T operator --() volatile
+ {
+ return fetch_sub(1) + 1;
+ }
+
+ // Post-decrement
+ T operator --(int)
+ {
+ return fetch_sub(1);
+ }
+
+ T operator --(int) volatile
+ {
+ return fetch_sub(1);
+ }
+
+ // Add
+ T* operator +=(std::ptrdiff_t v)
+ {
+ return fetch_add(v) + v;
+ }
+
+ T* operator +=(std::ptrdiff_t v) volatile
+ {
+ return fetch_add(v) + v;
+ }
+
+ // Subtract
+ T* operator -=(std::ptrdiff_t v)
+ {
+ return fetch_sub(v) - v;
+ }
+
+ T* operator -=(std::ptrdiff_t v) volatile
+ {
+ return fetch_sub(v) - v;
+ }
+
+ // Conversion operator
+ operator T () const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ operator T() volatile const
+ {
+ return __sync_fetch_and_add(const_cast(&value), 0);
+ }
+
+ // Is lock free?
+ bool is_lock_free() const
+ {
+ return true;
+ }
+
+ bool is_lock_free() const volatile
+ {
+ return true;
+ }
+
+ // Store
+ void store(T v)
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ void store(T v) volatile
+ {
+ __sync_lock_test_and_set(&value, v);
+ }
+
+ // Load
+ T load()
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ T load() volatile
+ {
+ return __sync_fetch_and_add(&value, 0);
+ }
+
+ // Fetch add
+ T* fetch_add(std::ptrdiff_t v)
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ T* fetch_add(std::ptrdiff_t v) volatile
+ {
+ return __sync_fetch_and_add(&value, v);
+ }
+
+ // Fetch subtract
+ T* fetch_sub(std::ptrdiff_t v)
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ T* fetch_sub(std::ptrdiff_t v) volatile
+ {
+ return __sync_fetch_and_sub(&value, v);
+ }
+
+ // Exchange
+ T exchange(T v)
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ T exchange(T v) volatile
+ {
+ return __sync_lock_test_and_set(&value, v);
+ }
+
+ // Compare exchange weak
+ bool compare_exchange_weak(T& expected, T desired)
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ bool compare_exchange_weak(T& expected, T desired) volatile
+ {
+ return __sync_bool_compare_and_swap(&value, expected, desired);
+ }
+
+ // Compare exchange strong
+ bool compare_exchange_strong(T& expected, T desired)
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ bool compare_exchange_strong(T& expected, T desired) volatile
+ {
+ T old = expected;
+
+ while (!compare_exchange_weak(old, desired))
+ {
+ if (memcmp(&old, &expected, sizeof(T)))
+ {
+ expected = old;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private:
+
+ atomic& operator =(const atomic&);
+ atomic& operator =(const atomic&) volatile;
+
+ T* value;
+ };
+
+ typedef etl::atomic atomic_char;
+ typedef etl::atomic atomic_schar;
+ typedef etl::atomic atomic_uchar;
+ typedef etl::atomic atomic_short;
+ typedef etl::atomic atomic_ushort;
+ typedef etl::atomic atomic_int;
+ typedef etl::atomic atomic_uint;
+ typedef etl::atomic atomic_long;
+ typedef etl::atomic atomic_ulong;
+ typedef etl::atomic atomic_llong;
+ typedef etl::atomic atomic_ullong;
+ typedef etl::atomic atomic_wchar_t;
+ typedef etl::atomic atomic_char16_t;
+ typedef etl::atomic atomic_char32_t;
+ typedef etl::atomic atomic_uint8_t;
+ typedef etl::atomic atomic_int8_t;
+ typedef etl::atomic atomic_uint16_t;
+ typedef etl::atomic atomic_int16_t;
+ typedef etl::atomic atomic_uint32_t;
+ typedef etl::atomic atomic_int32_t;
+ typedef etl::atomic atomic_uint64_t;
+ typedef etl::atomic atomic_int64_t;
+ typedef etl::atomic atomic_int_least8_t;
+ typedef etl::atomic atomic_uint_least8_t;
+ typedef etl::atomic atomic_int_least16_t;
+ typedef etl::atomic atomic_uint_least16_t;
+ typedef etl::atomic atomic_int_least32_t;
+ typedef etl::atomic atomic_uint_least32_t;
+ typedef etl::atomic atomic_int_least64_t;
+ typedef etl::atomic atomic_uint_least64_t;
+ typedef etl::atomic atomic_int_fast8_t;
+ typedef etl::atomic atomic_uint_fast8_t;
+ typedef etl::atomic atomic_int_fast16_t;
+ typedef etl::atomic atomic_uint_fast16_t;
+ typedef etl::atomic atomic_int_fast32_t;
+ typedef etl::atomic atomic_uint_fast32_t;
+ typedef etl::atomic atomic_int_fast64_t;
+ typedef etl::atomic atomic_uint_fast64_t;
+ typedef etl::atomic atomic_intptr_t;
+ typedef etl::atomic atomic_uintptr_t;
+ typedef etl::atomic atomic_size_t;
+ typedef etl::atomic atomic_ptrdiff_t;
+ typedef etl::atomic atomic_intmax_t;
+ typedef etl::atomic atomic_uintmax_t;
+}
+
+#endif
diff --git a/src/atomic/atomic_windows.h b/src/atomic/atomic_windows.h
new file mode 100644
index 00000000..9b7a2ed3
--- /dev/null
+++ b/src/atomic/atomic_windows.h
@@ -0,0 +1,104 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ATOMIC_WINDOWS__
+#define __ETL_ATOMIC_WINDOWS__
+
+#include "../platform.h"
+
+#include
+#include
+
+namespace etl
+{
+ class atomic_uint32_t
+ {
+ public:
+
+ atomic_uint32_t()
+ {
+ InterlockedExchange(&value, 0);
+ }
+
+ atomic_uint32_t(uint32_t v)
+ {
+ InterlockedExchange(&value, v);
+ }
+
+ atomic_uint32_t& operator =(uint32_t v)
+ {
+ InterlockedExchange(&value, v);
+
+ return *this;
+ }
+
+ atomic_uint32_t& operator ++()
+ {
+ InterlockedIncrement(&value);
+
+ return *this;
+ }
+
+ volatile atomic_uint32_t& operator ++() volatile
+ {
+ InterlockedIncrement(&value);
+
+ return *this;
+ }
+
+ atomic_uint32_t& operator --()
+ {
+ InterlockedDecrement(&value);
+
+ return *this;
+ }
+
+ volatile atomic_uint32_t& operator --() volatile
+ {
+ InterlockedDecrement(&value);
+
+ return *this;
+ }
+
+ operator uint32_t () const
+ {
+ return InterlockedAdd((volatile long*)&value, 0);
+ }
+
+ operator uint32_t() volatile const
+ {
+ return InterlockedAdd((volatile long*)&value, 0);
+ }
+
+ private:
+
+ uint32_t value;
+ };
+}
+
+#endif
diff --git a/src/binary.h b/src/binary.h
index e5f6aa5d..1717168d 100644
--- a/src/binary.h
+++ b/src/binary.h
@@ -38,6 +38,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "type_traits.h"
#include "integral_limits.h"
#include "static_assert.h"
diff --git a/src/bloom_filter.h b/src/bloom_filter.h
index 3407d6e6..cb2cb48a 100644
--- a/src/bloom_filter.h
+++ b/src/bloom_filter.h
@@ -31,6 +31,7 @@ SOFTWARE.
#ifndef __ETL_BLOOM_FILTER__
#define __ETL_BLOOM_FILTER__
+#include "platform.h"
#include "parameter_type.h"
#include "bitset.h"
#include "type_traits.h"
diff --git a/src/callback_timer.h b/src/callback_timer.h
new file mode 100644
index 00000000..545c414a
--- /dev/null
+++ b/src/callback_timer.h
@@ -0,0 +1,684 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_CALLBACK_TIMER__
+#define __ETL_CALLBACK_TIMER__
+
+#include
+#include
+
+#include "platform.h"
+#include "nullptr.h"
+#include "function.h"
+#include "static_assert.h"
+#include "timer.h"
+#include "atomic.h"
+
+#undef ETL_FILE
+#define ETL_FILE "42"
+
+namespace etl
+{
+ //*************************************************************************
+ /// The configuration of a timer.
+ struct callback_timer_data
+ {
+ //*******************************************
+ callback_timer_data()
+ : p_callback(nullptr),
+ period(0),
+ delta(etl::timer::state::INACTIVE),
+ id(etl::timer::id::NO_TIMER),
+ previous(etl::timer::id::NO_TIMER),
+ next(etl::timer::id::NO_TIMER),
+ repeating(true),
+ is_c_callback(true)
+ {
+ }
+
+ //*******************************************
+ /// C function callback
+ //*******************************************
+ callback_timer_data(etl::timer::id::type id_,
+ void (*p_callback_)(),
+ uint32_t period_,
+ bool repeating_)
+ : p_callback(reinterpret_cast(p_callback_)),
+ period(period_),
+ delta(etl::timer::state::INACTIVE),
+ id(id_),
+ previous(etl::timer::id::NO_TIMER),
+ next(etl::timer::id::NO_TIMER),
+ repeating(repeating_),
+ is_c_callback(true)
+ {
+ }
+
+ //*******************************************
+ /// ETL function callback
+ //*******************************************
+ callback_timer_data(etl::timer::id::type id_,
+ etl::ifunction& callback_,
+ uint32_t period_,
+ bool repeating_)
+ : p_callback(reinterpret_cast(&callback_)),
+ period(period_),
+ delta(etl::timer::state::INACTIVE),
+ id(id_),
+ previous(etl::timer::id::NO_TIMER),
+ next(etl::timer::id::NO_TIMER),
+ repeating(repeating_),
+ is_c_callback(false)
+ {
+ }
+
+ //*******************************************
+ /// Returns true if the timer is active.
+ //*******************************************
+ bool is_active() const
+ {
+ return delta != etl::timer::state::INACTIVE;
+ }
+
+ //*******************************************
+ /// Sets the timer to the inactive state.
+ //*******************************************
+ void set_inactive()
+ {
+ delta = etl::timer::state::INACTIVE;
+ }
+
+ void* p_callback;
+ uint32_t period;
+ uint32_t delta;
+ etl::timer::id::type id;
+ uint_least8_t previous;
+ uint_least8_t next;
+ bool repeating;
+ bool is_c_callback;
+
+ private:
+
+ // Disabled.
+ callback_timer_data(const callback_timer_data& other);
+ callback_timer_data& operator =(const callback_timer_data& other);
+ };
+
+ namespace __private_callback_timer__
+ {
+ //*************************************************************************
+ /// A specialised intrusive linked list for timer data.
+ //*************************************************************************
+ class list
+ {
+ public:
+
+ //*******************************
+ list(etl::callback_timer_data* ptimers_)
+ : head(etl::timer::id::NO_TIMER),
+ tail(etl::timer::id::NO_TIMER),
+ current(etl::timer::id::NO_TIMER),
+ ptimers(ptimers_)
+ {
+ }
+
+ //*******************************
+ bool empty() const
+ {
+ return head == etl::timer::id::NO_TIMER;
+ }
+
+ //*******************************
+ // Inserts the timer at the correct delta position
+ //*******************************
+ void insert(etl::timer::id::type id_)
+ {
+ etl::callback_timer_data& timer = ptimers[id_];
+
+ if (head == etl::timer::id::NO_TIMER)
+ {
+ // No entries yet.
+ head = id_;
+ tail = id_;
+ timer.previous = etl::timer::id::NO_TIMER;
+ timer.next = etl::timer::id::NO_TIMER;
+ }
+ else
+ {
+ // We already have entries.
+ etl::timer::id::type test_id = begin();
+
+ while (test_id != etl::timer::id::NO_TIMER)
+ {
+ etl::callback_timer_data& test = ptimers[test_id];
+
+ // Find the correct place to insert.
+ if (timer.delta <= test.delta)
+ {
+ if (test.id == head)
+ {
+ head = timer.id;
+ }
+
+ // Insert before test.
+ timer.previous = test.previous;
+ test.previous = timer.id;
+ timer.next = test.id;
+
+ // Adjust the next delta to compensate.
+ test.delta -= timer.delta;
+
+ if (timer.previous != etl::timer::id::NO_TIMER)
+ {
+ ptimers[timer.previous].next = timer.id;
+ }
+ break;
+ }
+ else
+ {
+ timer.delta -= test.delta;
+ }
+
+ test_id = next(test_id);
+ }
+
+ // Reached the end?
+ if (test_id == etl::timer::id::NO_TIMER)
+ {
+ // Tag on to the tail.
+ ptimers[tail].next = timer.id;
+ timer.previous = tail;
+ timer.next = etl::timer::id::NO_TIMER;
+ tail = timer.id;
+ }
+ }
+ }
+
+ //*******************************
+ void remove(etl::timer::id::type id_, bool has_expired)
+ {
+ etl::callback_timer_data& timer = ptimers[id_];
+
+ if (head == id_)
+ {
+ head = timer.next;
+ }
+ else
+ {
+ ptimers[timer.previous].next = timer.next;
+ }
+
+ if (tail == id_)
+ {
+ tail = timer.previous;
+ }
+ else
+ {
+ ptimers[timer.next].previous = timer.previous;
+ }
+
+ if (!has_expired)
+ {
+ // Adjust the next delta.
+ if (timer.next != etl::timer::id::NO_TIMER)
+ {
+ ptimers[timer.next].delta += timer.delta;
+ }
+ }
+
+ timer.previous = etl::timer::id::NO_TIMER;
+ timer.next = etl::timer::id::NO_TIMER;
+ timer.delta = etl::timer::state::INACTIVE;
+ }
+
+ //*******************************
+ etl::callback_timer_data& front()
+ {
+ return ptimers[head];
+ }
+
+ //*******************************
+ etl::timer::id::type begin()
+ {
+ current = head;
+ return current;
+ }
+
+ //*******************************
+ etl::timer::id::type previous(etl::timer::id::type last)
+ {
+ current = ptimers[last].previous;
+ return current;
+ }
+
+ //*******************************
+ etl::timer::id::type next(etl::timer::id::type last)
+ {
+ current = ptimers[last].next;
+ return current;
+ }
+
+ //*******************************
+ void clear()
+ {
+ etl::timer::id::type id = begin();
+
+ while (id != etl::timer::id::NO_TIMER)
+ {
+ etl::callback_timer_data& timer = ptimers[id];
+ id = next(id);
+ timer.next = etl::timer::id::NO_TIMER;
+ }
+
+ head = etl::timer::id::NO_TIMER;
+ tail = etl::timer::id::NO_TIMER;
+ current = etl::timer::id::NO_TIMER;
+ }
+
+ private:
+
+ etl::timer::id::type head;
+ etl::timer::id::type tail;
+ etl::timer::id::type current;
+
+ etl::callback_timer_data* const ptimers;
+ };
+ }
+
+ //***************************************************************************
+ /// Interface for callback timer
+ //***************************************************************************
+ class icallback_timer
+ {
+ public:
+
+ //*******************************************
+ /// Register a timer.
+ //*******************************************
+ etl::timer::id::type register_timer(void (*p_callback_)(),
+ uint32_t period_,
+ bool repeating_)
+ {
+ etl::timer::id::type id = etl::timer::id::NO_TIMER;
+
+ disable_timer_updates();
+
+ bool is_space = (registered_timers < MAX_TIMERS);
+
+ if (is_space)
+ {
+ // Search for the free space.
+ for (uint_least8_t i = 0; i < MAX_TIMERS; ++i)
+ {
+ etl::callback_timer_data& timer = timer_array[i];
+
+ if (timer.id == etl::timer::id::NO_TIMER)
+ {
+ // Create in-place.
+ new (&timer) callback_timer_data(i, p_callback_, period_, repeating_);
+ ++registered_timers;
+ id = i;
+ break;
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return id;
+ }
+
+ //*******************************************
+ /// Register a timer.
+ //*******************************************
+ etl::timer::id::type register_timer(etl::ifunction& callback_,
+ uint32_t period_,
+ bool repeating_)
+ {
+ etl::timer::id::type id = etl::timer::id::NO_TIMER;
+
+ disable_timer_updates();
+
+ bool is_space = (registered_timers < MAX_TIMERS);
+
+ if (is_space)
+ {
+ // Search for the free space.
+ for (uint_least8_t i = 0; i < MAX_TIMERS; ++i)
+ {
+ etl::callback_timer_data& timer = timer_array[i];
+
+ if (timer.id == etl::timer::id::NO_TIMER)
+ {
+ // Create in-place.
+ new (&timer) callback_timer_data(i, callback_, period_, repeating_);
+ ++registered_timers;
+ id = i;
+ break;
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return id;
+ }
+
+ //*******************************************
+ /// Unregister a timer.
+ //*******************************************
+ bool unregister_timer(etl::timer::id::type id_)
+ {
+ bool result = false;
+
+ if (id_ != etl::timer::id::NO_TIMER)
+ {
+ disable_timer_updates();
+
+ etl::callback_timer_data& timer = timer_array[id_];
+
+ if (timer.id != etl::timer::id::NO_TIMER)
+ {
+ if (timer.is_active())
+ {
+ active_list.remove(timer.id, false);
+
+ // Reset in-place.
+ new (&timer) callback_timer_data();
+ --registered_timers;
+
+ result = true;
+ }
+ }
+
+ enable_timer_updates();
+ }
+
+ return result;
+ }
+
+ //*******************************************
+ /// Enable/disable the timer.
+ //*******************************************
+ void enable(bool state_)
+ {
+ enabled = state_;
+ }
+
+ //*******************************************
+ /// Get the enable/disable state.
+ //*******************************************
+ bool is_running() const
+ {
+ return enabled;
+ }
+
+ //*******************************************
+ /// Clears the timer of data.
+ //*******************************************
+ void clear()
+ {
+ disable_timer_updates();
+
+ active_list.clear();
+
+ for (int i = 0; i < MAX_TIMERS; ++i)
+ {
+ new (&timer_array[i]) callback_timer_data();
+ }
+
+ registered_timers = 0;
+ tick_count = 0;
+
+ enable_timer_updates();
+ }
+
+ //*******************************************
+ // Called by the timer service to indicate the
+ // amount of time that has elapsed since the
+ // last call to 'tick'.
+ //*******************************************
+ bool tick(uint32_t count)
+ {
+ if (enabled)
+ {
+ tick_count += count;
+
+ if (process_semaphore == 0)
+ {
+ // We have something to do?
+ while (!active_list.empty() && (tick_count >= active_list.front().delta))
+ {
+ etl::callback_timer_data& timer = active_list.front();
+
+ tick_count -= timer.delta;
+
+ active_list.remove(timer.id, true);
+
+ if (timer.repeating)
+ {
+ timer.delta = timer.period;
+ active_list.insert(timer.id);
+ }
+
+ if (timer.p_callback != nullptr)
+ {
+ if (timer.is_c_callback)
+ {
+ reinterpret_cast(timer.p_callback)();
+ }
+ else
+ {
+ (*reinterpret_cast*>(timer.p_callback))();
+ }
+ }
+ }
+ }
+ }
+
+ return enabled;
+ }
+
+ //*******************************************
+ /// Starts a timer.
+ //*******************************************
+ bool start(etl::timer::id::type id_, bool immediate_ = false)
+ {
+ bool result = false;
+
+ disable_timer_updates();
+
+ // Valid timer id?
+ if (id_ != etl::timer::id::NO_TIMER)
+ {
+ etl::callback_timer_data& timer = timer_array[id_];
+
+ // Registered timer?
+ if (timer.id != etl::timer::id::NO_TIMER)
+ {
+ // Has a valid period.
+ if (timer.period != etl::timer::state::INACTIVE)
+ {
+ if (timer.is_active())
+ {
+ active_list.remove(timer.id, false);
+ }
+
+ timer.delta = tick_count;
+
+ if (!immediate_)
+ {
+ timer.delta += timer.period;
+ }
+
+ active_list.insert(timer.id);
+ result = true;
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return result;
+ }
+
+ //*******************************************
+ /// Stops a timer.
+ //*******************************************
+ bool stop(etl::timer::id::type id_)
+ {
+ bool result = false;
+
+ disable_timer_updates();
+
+ // Valid timer id?
+ if (id_ != etl::timer::id::NO_TIMER)
+ {
+ etl::callback_timer_data& timer = timer_array[id_];
+
+ // Registered timer?
+ if (timer.id != etl::timer::id::NO_TIMER)
+ {
+ if (timer.is_active())
+ {
+ active_list.remove(timer.id, false);
+ result = true;
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return result;
+ }
+
+ //*******************************************
+ /// Sets a timer's period.
+ //*******************************************
+ bool set_period(etl::timer::id::type id_, uint32_t period_)
+ {
+ if (stop(id_))
+ {
+ timer_array[id_].period = period_;
+ return start(id_);
+ }
+
+ return false;
+ }
+
+ //*******************************************
+ /// Sets a timer's mode.
+ //*******************************************
+ bool set_mode(etl::timer::id::type id_, bool repeating_)
+ {
+ if (stop(id_))
+ {
+ timer_array[id_].repeating = repeating_;
+ return start(id_);
+ }
+
+ return false;
+ }
+
+ protected:
+
+ //*******************************************
+ /// Constructor.
+ //*******************************************
+ icallback_timer(callback_timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_)
+ : timer_array(timer_array_),
+ active_list(timer_array_),
+ enabled(false),
+ process_semaphore(0),
+ tick_count(0),
+ registered_timers(0),
+ MAX_TIMERS(MAX_TIMERS_)
+ {
+ }
+
+ private:
+
+ //*******************************************
+ /// Enable timer callback events.
+ //*******************************************
+ void enable_timer_updates()
+ {
+ --process_semaphore;
+ }
+
+ //*******************************************
+ /// Disable timer callback events.
+ //*******************************************
+ void disable_timer_updates()
+ {
+ ++process_semaphore;
+ }
+
+ // The array of timer data structures.
+ callback_timer_data* const timer_array;
+
+ // The list of active timers.
+ __private_callback_timer__::list active_list;
+
+ volatile bool enabled;
+ volatile etl::timer_semaphore_t process_semaphore;
+ volatile uint32_t tick_count;
+ volatile uint_least8_t registered_timers;
+
+ public:
+
+ const uint_least8_t MAX_TIMERS;
+ };
+
+ //***************************************************************************
+ /// The callback timer
+ //***************************************************************************
+ template
+ class callback_timer : public etl::icallback_timer
+ {
+ public:
+
+ STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed");
+
+ //*******************************************
+ /// Constructor.
+ //*******************************************
+ callback_timer()
+ : icallback_timer(timer_array, MAX_TIMERS_)
+ {
+ }
+
+ private:
+
+ callback_timer_data timer_array[MAX_TIMERS_];
+ };
+}
+
+#undef ETL_FILE
+
+#endif
diff --git a/src/checksum.h b/src/checksum.h
index b6bb0ee4..d981400a 100644
--- a/src/checksum.h
+++ b/src/checksum.h
@@ -29,6 +29,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "binary.h"
#include "frame_check_sequence.h"
diff --git a/src/constant.h b/src/constant.h
index 86a643b8..d9bb8302 100644
--- a/src/constant.h
+++ b/src/constant.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_CONSTANT__
#define __ETL_CONSTANT__
+#include "platform.h"
+
//*****************************************************************************
///\defgroup constant constant
///\ingroup utilities
diff --git a/src/container.h b/src/container.h
index 1cf87391..961ed90f 100644
--- a/src/container.h
+++ b/src/container.h
@@ -34,6 +34,8 @@ SOFTWARE.
#include
#include
+#include "platform.h"
+
///\defgroup container container
///\ingroup utilities
diff --git a/src/crc16.cpp b/src/crc16.cpp
index f5194058..734d379b 100644
--- a/src/crc16.cpp
+++ b/src/crc16.cpp
@@ -30,6 +30,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
//***************************************************************************
diff --git a/src/crc16_ccitt.cpp b/src/crc16_ccitt.cpp
index 6c800d74..443873a9 100644
--- a/src/crc16_ccitt.cpp
+++ b/src/crc16_ccitt.cpp
@@ -30,6 +30,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
//***************************************************************************
diff --git a/src/crc16_kermit.cpp b/src/crc16_kermit.cpp
index c7363d14..93836b02 100644
--- a/src/crc16_kermit.cpp
+++ b/src/crc16_kermit.cpp
@@ -30,6 +30,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
//***************************************************************************
diff --git a/src/crc32.cpp b/src/crc32.cpp
index 9b7c0be6..6ef84f49 100644
--- a/src/crc32.cpp
+++ b/src/crc32.cpp
@@ -30,6 +30,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
//***************************************************************************
diff --git a/src/crc64_ecma.cpp b/src/crc64_ecma.cpp
index 7b41a3d0..82a92b0e 100644
--- a/src/crc64_ecma.cpp
+++ b/src/crc64_ecma.cpp
@@ -30,6 +30,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
//***************************************************************************
diff --git a/src/cyclic_value.h b/src/cyclic_value.h
index e583c500..e3f6ac66 100644
--- a/src/cyclic_value.h
+++ b/src/cyclic_value.h
@@ -39,6 +39,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "static_assert.h"
#include "exception.h"
#include "static_assert.h"
diff --git a/src/debounce.h b/src/debounce.h
index 729451f2..19e26c20 100644
--- a/src/debounce.h
+++ b/src/debounce.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "static_assert.h"
namespace etl
diff --git a/src/deque.h b/src/deque.h
index 8aae018c..db9779af 100644
--- a/src/deque.h
+++ b/src/deque.h
@@ -36,6 +36,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "container.h"
#include "alignment.h"
#include "array.h"
diff --git a/src/endianness.h b/src/endianness.h
index c5600534..ec8ff167 100644
--- a/src/endianness.h
+++ b/src/endianness.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "enum_type.h"
///\defgroup endian endian
diff --git a/src/enum_type.h b/src/enum_type.h
index 82415064..00866597 100644
--- a/src/enum_type.h
+++ b/src/enum_type.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_ENUM_TYPE__
#define __ETL_ENUM_TYPE__
+#include "platform.h"
+
///\defgroup enum_type enum_type
/// Smart enumerations.
/// A method of declaring enumerations that allow grouping within a structure.
diff --git a/src/error_handler.cpp b/src/error_handler.cpp
index 5a02d220..2107e0b5 100644
--- a/src/error_handler.cpp
+++ b/src/error_handler.cpp
@@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
+#include "platform.h"
#include "error_handler.h"
#include "nullptr.h"
diff --git a/src/error_handler.h b/src/error_handler.h
index e9a8bba4..c107344f 100644
--- a/src/error_handler.h
+++ b/src/error_handler.h
@@ -38,6 +38,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "exception.h"
#include "function.h"
diff --git a/src/exception.h b/src/exception.h
index 3b39f1e9..8c4301a2 100644
--- a/src/exception.h
+++ b/src/exception.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_EXCEPTION__
#define __ETL_EXCEPTION__
+#include "platform.h"
+
///\defgroup exception exception
/// The base class for all ETL exceptions.
///\ingroup utilities
diff --git a/src/factorial.h b/src/factorial.h
index 07dedeed..688ae817 100644
--- a/src/factorial.h
+++ b/src/factorial.h
@@ -33,6 +33,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
///\defgroup factorial factorial
/// fibonacci : Calculates the Nth factorial value.
///\ingroup maths
diff --git a/src/factory.h b/src/factory.h
index c4406385..6aaeb11c 100644
--- a/src/factory.h
+++ b/src/factory.h
@@ -31,6 +31,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "error_handler.h"
#include "exception.h"
#include "largest.h"
diff --git a/src/fibonacci.h b/src/fibonacci.h
index d3765111..70930633 100644
--- a/src/fibonacci.h
+++ b/src/fibonacci.h
@@ -33,6 +33,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
///\defgroup fibonacci fibonacci
/// fibonacci : Calculates the Nth Fibonacci value.
///\ingroup maths
diff --git a/src/fixed_iterator.h b/src/fixed_iterator.h
index 8357f30a..12396ea3 100644
--- a/src/fixed_iterator.h
+++ b/src/fixed_iterator.h
@@ -33,6 +33,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
///\defgroup iterator Iterator types
namespace etl
diff --git a/src/forward_list.h b/src/forward_list.h
index 463ba95a..7154e072 100644
--- a/src/forward_list.h
+++ b/src/forward_list.h
@@ -36,6 +36,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "pool.h"
#include "container.h"
#include "exception.h"
diff --git a/src/fsm.h b/src/fsm.h
index 39ae4b85..7771c04b 100644
--- a/src/fsm.h
+++ b/src/fsm.h
@@ -53,6 +53,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "array.h"
#include "nullptr.h"
#include "error_handler.h"
diff --git a/src/fsm_generator.h b/src/fsm_generator.h
index 9dbf6066..fc18c240 100644
--- a/src/fsm_generator.h
+++ b/src/fsm_generator.h
@@ -65,6 +65,7 @@ cog.outl("//********************************************************************
#include
+#include "platform.h"
#include "array.h"
#include "nullptr.h"
#include "error_handler.h"
diff --git a/src/function.h b/src/function.h
index 198a23e9..f90ceaab 100644
--- a/src/function.h
+++ b/src/function.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_FUNCTION__
#define __ETL_FUNCTION__
+#include "platform.h"
+
//*****************************************************************************
///\defgroup function function
/// A set of wrapper templates to allow a member or static function to be called
diff --git a/src/functional.h b/src/functional.h
index 31353980..a2187d5c 100644
--- a/src/functional.h
+++ b/src/functional.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_FUNCTIONAL__
#define __ETL_FUNCTIONAL__
+#include "platform.h"
+
///\defgroup functional functional
///\ingroup utilities
diff --git a/src/hash.h b/src/hash.h
index 39408f3a..505b75a9 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -34,6 +34,8 @@ SOFTWARE.
#include
#include
+#include "platform.h"
+
// The default hash calculation.
#include "fnv_1.h"
#include "type_traits.h"
diff --git a/src/icache.h b/src/icache.h
index 3017ce77..1cd6fc62 100644
--- a/src/icache.h
+++ b/src/icache.h
@@ -35,6 +35,7 @@ SOFTWARE.
#ifndef __ETL_ICACHE__
#define __ETL_ICACHE__
+#include "platform.h"
#include "function.h"
#include "nullptr.h"
diff --git a/src/ihash.h b/src/ihash.h
index 4450e9c5..e5b2e3a1 100644
--- a/src/ihash.h
+++ b/src/ihash.h
@@ -34,6 +34,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "exception.h"
#include "error_handler.h"
diff --git a/src/instance_count.h b/src/instance_count.h
index 37e29e37..4c389663 100644
--- a/src/instance_count.h
+++ b/src/instance_count.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_INSTANCE_COUNT__
#define __ETL_INSTANCE_COUNT__
+#include "platform.h"
+
///\defgroup instance_count instance count
///\ingroup utilities
diff --git a/src/integral_limits.h b/src/integral_limits.h
index 25f917e2..f231bf48 100644
--- a/src/integral_limits.h
+++ b/src/integral_limits.h
@@ -34,8 +34,8 @@ SOFTWARE.
#include
#include
-#include "type_traits.h"
#include "platform.h"
+#include "type_traits.h"
#ifdef ETL_COMPILER_MICROSOFT
#undef min
diff --git a/src/intrusive_links.h b/src/intrusive_links.h
index 35a8e345..ee69a950 100644
--- a/src/intrusive_links.h
+++ b/src/intrusive_links.h
@@ -34,6 +34,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "nullptr.h"
#include "type_traits.h"
#include "exception.h"
diff --git a/src/intrusive_queue.h b/src/intrusive_queue.h
index 176fca44..d8910cf3 100644
--- a/src/intrusive_queue.h
+++ b/src/intrusive_queue.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "type_traits.h"
#include "error_handler.h"
#include "intrusive_links.h"
diff --git a/src/intrusive_stack.h b/src/intrusive_stack.h
index 7b00af72..16b7edf8 100644
--- a/src/intrusive_stack.h
+++ b/src/intrusive_stack.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "type_traits.h"
#include "error_handler.h"
#include "intrusive_links.h"
diff --git a/src/io_port.h b/src/io_port.h
index e60d0767..ed422983 100644
--- a/src/io_port.h
+++ b/src/io_port.h
@@ -38,6 +38,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "nullptr.h"
#include "parameter_type.h"
diff --git a/src/iterator.h b/src/iterator.h
index e451c62b..7b17e0cc 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "type_traits.h"
///\defgroup iterator iterator
diff --git a/src/largest.h b/src/largest.h
index a3334c99..bb82dc28 100644
--- a/src/largest.h
+++ b/src/largest.h
@@ -56,6 +56,7 @@ SOFTWARE.
///\defgroup largest largest
///\ingroup utilities
+#include "platform.h"
#include "type_traits.h"
#include "smallest.h"
#include "static_assert.h"
diff --git a/src/largest_generator.h b/src/largest_generator.h
index 27464662..202fde53 100644
--- a/src/largest_generator.h
+++ b/src/largest_generator.h
@@ -68,6 +68,7 @@ cog.outl("//********************************************************************
///\defgroup largest largest
///\ingroup utilities
+#include "platform.h"
#include "type_traits.h"
#include "smallest.h"
#include "static_assert.h"
diff --git a/src/log.h b/src/log.h
index 26d9b5fe..bf9aa7ab 100644
--- a/src/log.h
+++ b/src/log.h
@@ -33,6 +33,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
///\defgroup log log
/// log : Calculates logs to any base, rounded down to the nearest integer.
/// log2 : Calculates logs to base 2, rounded down to the nearest integer.
diff --git a/src/memory.h b/src/memory.h
index 6af5d1c5..2d440653 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -34,6 +34,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "type_traits.h"
///\defgroup memory memory
diff --git a/src/message.h b/src/message.h
index 4605bc71..b7139e2d 100644
--- a/src/message.h
+++ b/src/message.h
@@ -31,6 +31,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "error_handler.h"
#include "exception.h"
#include "message_types.h"
diff --git a/src/message_bus.h b/src/message_bus.h
index 5d5514e3..00d52a6d 100644
--- a/src/message_bus.h
+++ b/src/message_bus.h
@@ -32,6 +32,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "algorithm.h"
#include "vector.h"
#include "nullptr.h"
diff --git a/src/message_router.h b/src/message_router.h
index 9a63bea1..522716b7 100644
--- a/src/message_router.h
+++ b/src/message_router.h
@@ -53,6 +53,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "message.h"
#include "message_types.h"
#include "alignment.h"
diff --git a/src/message_router_generator.h b/src/message_router_generator.h
index 9e528136..16936bcf 100644
--- a/src/message_router_generator.h
+++ b/src/message_router_generator.h
@@ -65,6 +65,7 @@ cog.outl("//********************************************************************
#include
+#include "platform.h"
#include "message.h"
#include "message_types.h"
#include "alignment.h"
diff --git a/src/message_timer.h b/src/message_timer.h
new file mode 100644
index 00000000..ed238086
--- /dev/null
+++ b/src/message_timer.h
@@ -0,0 +1,651 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_MESSAGE_TIMER__
+#define __ETL_MESSAGE_TIMER__
+
+#include
+#include
+
+#include "platform.h"
+#include "nullptr.h"
+#include "message_types.h"
+#include "message.h"
+#include "message_router.h"
+#include "message_bus.h"
+#include "static_assert.h"
+#include "timer.h"
+
+#undef ETL_FILE
+#define ETL_FILE "41"
+
+namespace etl
+{
+ //*************************************************************************
+ /// The configuration of a timer.
+ struct message_timer_data
+ {
+ //*******************************************
+ message_timer_data()
+ : p_message(nullptr),
+ p_router(nullptr),
+ period(0),
+ delta(etl::timer::state::INACTIVE),
+ destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS),
+ id(etl::timer::id::NO_TIMER),
+ previous(etl::timer::id::NO_TIMER),
+ next(etl::timer::id::NO_TIMER),
+ repeating(true)
+ {
+ }
+
+ //*******************************************
+ message_timer_data(etl::timer::id::type id_,
+ const etl::imessage& message_,
+ etl::imessage_router& irouter_,
+ uint32_t period_,
+ bool repeating_,
+ etl::message_router_id_t destination_router_id_)
+ : p_message(&message_),
+ p_router(&irouter_),
+ period(period_),
+ delta(etl::timer::state::INACTIVE),
+ id(id_),
+ previous(etl::timer::id::NO_TIMER),
+ next(etl::timer::id::NO_TIMER),
+ repeating(repeating_)
+ {
+ if (irouter_.get_message_router_id() == etl::imessage_router::MESSAGE_BUS)
+ {
+ destination_router_id = destination_router_id_;
+ }
+ else
+ {
+ destination_router_id = etl::imessage_bus::ALL_MESSAGE_ROUTERS;
+ }
+ }
+
+ //*******************************************
+ /// Returns true if the timer is active.
+ //*******************************************
+ bool is_active() const
+ {
+ return delta != etl::timer::state::INACTIVE;
+ }
+
+ //*******************************************
+ /// Sets the timer to the inactive state.
+ //*******************************************
+ void set_inactive()
+ {
+ delta = etl::timer::state::INACTIVE;
+ }
+
+ const etl::imessage* p_message;
+ etl::imessage_router* p_router;
+ uint32_t period;
+ uint32_t delta;
+ etl::message_router_id_t destination_router_id;
+ etl::timer::id::type id;
+ uint_least8_t previous;
+ uint_least8_t next;
+ bool repeating;
+
+ private:
+
+ // Disabled.
+ message_timer_data(const message_timer_data& other);
+ message_timer_data& operator =(const message_timer_data& other);
+ };
+
+ namespace __private_message_timer__
+ {
+ //*************************************************************************
+ /// A specialised intrusive linked list for timer data.
+ //*************************************************************************
+ class list
+ {
+ public:
+
+ //*******************************
+ list(etl::message_timer_data* ptimers_)
+ : head(etl::timer::id::NO_TIMER),
+ tail(etl::timer::id::NO_TIMER),
+ current(etl::timer::id::NO_TIMER),
+ ptimers(ptimers_)
+ {
+ }
+
+ //*******************************
+ bool empty() const
+ {
+ return head == etl::timer::id::NO_TIMER;
+ }
+
+ //*******************************
+ // Inserts the timer at the correct delta position
+ //*******************************
+ void insert(etl::timer::id::type id_)
+ {
+ etl::message_timer_data& timer = ptimers[id_];
+
+ if (head == etl::timer::id::NO_TIMER)
+ {
+ // No entries yet.
+ head = id_;
+ tail = id_;
+ timer.previous = etl::timer::id::NO_TIMER;
+ timer.next = etl::timer::id::NO_TIMER;
+ }
+ else
+ {
+ // We already have entries.
+ etl::timer::id::type test_id = begin();
+
+ while (test_id != etl::timer::id::NO_TIMER)
+ {
+ etl::message_timer_data& test = ptimers[test_id];
+
+ // Find the correct place to insert.
+ if (timer.delta <= test.delta)
+ {
+ if (test.id == head)
+ {
+ head = timer.id;
+ }
+
+ // Insert before test.
+ timer.previous = test.previous;
+ test.previous = timer.id;
+ timer.next = test.id;
+
+ // Adjust the next delta to compensate.
+ test.delta -= timer.delta;
+
+ if (timer.previous != etl::timer::id::NO_TIMER)
+ {
+ ptimers[timer.previous].next = timer.id;
+ }
+ break;
+ }
+ else
+ {
+ timer.delta -= test.delta;
+ }
+
+ test_id = next(test_id);
+ }
+
+ // Reached the end?
+ if (test_id == etl::timer::id::NO_TIMER)
+ {
+ // Tag on to the tail.
+ ptimers[tail].next = timer.id;
+ timer.previous = tail;
+ timer.next = etl::timer::id::NO_TIMER;
+ tail = timer.id;
+ }
+ }
+ }
+
+ //*******************************
+ void remove(etl::timer::id::type id_, bool has_expired)
+ {
+ etl::message_timer_data& timer = ptimers[id_];
+
+ if (head == id_)
+ {
+ head = timer.next;
+ }
+ else
+ {
+ ptimers[timer.previous].next = timer.next;
+ }
+
+ if (tail == id_)
+ {
+ tail = timer.previous;
+ }
+ else
+ {
+ ptimers[timer.next].previous = timer.previous;
+ }
+
+ if (!has_expired)
+ {
+ // Adjust the next delta.
+ if (timer.next != etl::timer::id::NO_TIMER)
+ {
+ ptimers[timer.next].delta += timer.delta;
+ }
+ }
+
+ timer.previous = etl::timer::id::NO_TIMER;
+ timer.next = etl::timer::id::NO_TIMER;
+ timer.delta = etl::timer::state::INACTIVE;
+ }
+
+ //*******************************
+ etl::message_timer_data& front()
+ {
+ return ptimers[head];
+ }
+
+ //*******************************
+ etl::timer::id::type begin()
+ {
+ current = head;
+ return current;
+ }
+
+ //*******************************
+ etl::timer::id::type previous(etl::timer::id::type last)
+ {
+ current = ptimers[last].previous;
+ return current;
+ }
+
+ //*******************************
+ etl::timer::id::type next(etl::timer::id::type last)
+ {
+ current = ptimers[last].next;
+ return current;
+ }
+
+ //*******************************
+ void clear()
+ {
+ etl::timer::id::type id = begin();
+
+ while (id != etl::timer::id::NO_TIMER)
+ {
+ etl::message_timer_data& timer = ptimers[id];
+ id = next(id);
+ timer.next = etl::timer::id::NO_TIMER;
+ }
+
+ head = etl::timer::id::NO_TIMER;
+ tail = etl::timer::id::NO_TIMER;
+ current = etl::timer::id::NO_TIMER;
+ }
+
+ private:
+
+ etl::timer::id::type head;
+ etl::timer::id::type tail;
+ etl::timer::id::type current;
+
+ etl::message_timer_data* const ptimers;
+ };
+ }
+
+ //***************************************************************************
+ /// Interface for message timer
+ //***************************************************************************
+ class imessage_timer
+ {
+ public:
+
+ //*******************************************
+ /// Register a timer.
+ //*******************************************
+ etl::timer::id::type register_timer(const etl::imessage& message_,
+ etl::imessage_router& router_,
+ uint32_t period_,
+ bool repeating_,
+ etl::message_router_id_t destination_router_id_ = etl::imessage_router::ALL_MESSAGE_ROUTERS)
+ {
+ etl::timer::id::type id = etl::timer::id::NO_TIMER;
+
+ disable_timer_updates();
+
+ bool is_space = (registered_timers < MAX_TIMERS);
+
+ if (is_space)
+ {
+ // There's no point adding null message routers.
+ if (router_.get_message_router_id() != etl::imessage_router::NULL_MESSAGE_ROUTER)
+ {
+ // Search for the free space.
+ for (uint_least8_t i = 0; i < MAX_TIMERS; ++i)
+ {
+ etl::message_timer_data& timer = timer_array[i];
+
+ if (timer.id == etl::timer::id::NO_TIMER)
+ {
+ // Create in-place.
+ new (&timer) message_timer_data(i, message_, router_, period_, repeating_, destination_router_id_);
+ ++registered_timers;
+ id = i;
+ break;
+ }
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return id;
+ }
+
+ //*******************************************
+ /// Unregister a timer.
+ //*******************************************
+ bool unregister_timer(etl::timer::id::type id_)
+ {
+ bool result = false;
+
+ if (id_ != etl::timer::id::NO_TIMER)
+ {
+ disable_timer_updates();
+
+ etl::message_timer_data& timer = timer_array[id_];
+
+ if (timer.id != etl::timer::id::NO_TIMER)
+ {
+ if (timer.is_active())
+ {
+ active_list.remove(timer.id, true);
+
+ // Reset in-place.
+ new (&timer) message_timer_data();
+ --registered_timers;
+
+ result = true;
+ }
+ }
+
+ enable_timer_updates();
+ }
+
+ return result;
+ }
+
+ //*******************************************
+ /// Enable/disable the timer.
+ //*******************************************
+ void enable(bool state_)
+ {
+ enabled = state_;
+ }
+
+ //*******************************************
+ /// Get the enable/disable state.
+ //*******************************************
+ bool is_running() const
+ {
+ return enabled;
+ }
+
+ //*******************************************
+ /// Clears the timer of data.
+ //*******************************************
+ void clear()
+ {
+ disable_timer_updates();
+
+ active_list.clear();
+
+ for (int i = 0; i < MAX_TIMERS; ++i)
+ {
+ new (&timer_array[i]) message_timer_data();
+ }
+
+ registered_timers = 0;
+ tick_count = 0;
+
+ enable_timer_updates();
+ }
+
+ //*******************************************
+ // Called by the timer service to indicate the
+ // amount of time that has elapsed since the
+ // last call to 'tick'.
+ //*******************************************
+ bool tick(uint32_t count)
+ {
+ if (enabled)
+ {
+ tick_count += count;
+
+ if (process_semaphore == 0)
+ {
+ // We have something to do?
+ while (!active_list.empty() && (tick_count >= active_list.front().delta))
+ {
+ etl::message_timer_data& timer = active_list.front();
+
+ tick_count -= timer.delta;
+
+ active_list.remove(timer.id, true);
+
+ if (timer.repeating)
+ {
+ timer.delta = timer.period;
+ active_list.insert(timer.id);
+ }
+
+ if (timer.p_router != nullptr)
+ {
+ if (timer.p_router->get_message_router_id() == etl::imessage_router::MESSAGE_BUS)
+ {
+ // Send to a message bus.
+ etl::imessage_bus& bus = static_cast(*(timer.p_router));
+ bus.receive(timer.destination_router_id, *(timer.p_message));
+ }
+ else
+ {
+ // Send to a router.
+ timer.p_router->receive(*(timer.p_message));
+ }
+ }
+ }
+ }
+ }
+
+ return enabled;
+ }
+
+ //*******************************************
+ /// Starts a timer.
+ //*******************************************
+ bool start(etl::timer::id::type id_, bool immediate_ = false)
+ {
+ bool result = false;
+
+ disable_timer_updates();
+
+ // Valid timer id?
+ if (id_ != etl::timer::id::NO_TIMER)
+ {
+ etl::message_timer_data& timer = timer_array[id_];
+
+ // Registered timer?
+ if (timer.id != etl::timer::id::NO_TIMER)
+ {
+ // Has a valid period.
+ if (timer.period != etl::timer::state::INACTIVE)
+ {
+ if (timer.is_active())
+ {
+ active_list.remove(timer.id, false);
+ }
+
+ timer.delta = tick_count;
+
+ if (!immediate_)
+ {
+ timer.delta += timer.period;
+ }
+
+ active_list.insert(timer.id);
+ result = true;
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return result;
+ }
+
+ //*******************************************
+ /// Stops a timer.
+ //*******************************************
+ bool stop(etl::timer::id::type id_)
+ {
+ bool result = false;
+
+ disable_timer_updates();
+
+ // Valid timer id?
+ if (id_ != etl::timer::id::NO_TIMER)
+ {
+ etl::message_timer_data& timer = timer_array[id_];
+
+ // Registered timer?
+ if (timer.id != etl::timer::id::NO_TIMER)
+ {
+ if (timer.is_active())
+ {
+ active_list.remove(timer.id, false);
+ result = true;
+ }
+ }
+ }
+
+ enable_timer_updates();
+
+ return result;
+ }
+
+ //*******************************************
+ /// Sets a timer's period.
+ //*******************************************
+ bool set_period(etl::timer::id::type id_, uint32_t period_)
+ {
+ if (stop(id_))
+ {
+ timer_array[id_].period = period_;
+ return start(id_);
+ }
+
+ return false;
+ }
+
+ //*******************************************
+ /// Sets a timer's mode.
+ //*******************************************
+ bool set_mode(etl::timer::id::type id_, bool repeating_)
+ {
+ if (stop(id_))
+ {
+ timer_array[id_].repeating = repeating_;
+ return start(id_);
+ }
+
+ return false;
+ }
+
+ protected:
+
+ //*******************************************
+ /// Constructor.
+ //*******************************************
+ imessage_timer(message_timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_)
+ : timer_array(timer_array_),
+ active_list(timer_array_),
+ enabled(false),
+ process_semaphore(0),
+ tick_count(0),
+ registered_timers(0),
+ MAX_TIMERS(MAX_TIMERS_)
+ {
+ }
+
+ private:
+
+ //*******************************************
+ /// Enable timer callback events.
+ //*******************************************
+ void enable_timer_updates()
+ {
+ --process_semaphore;
+ }
+
+ //*******************************************
+ /// Disable timer callback events.
+ //*******************************************
+ void disable_timer_updates()
+ {
+ ++process_semaphore;
+ }
+
+ // The array of timer data structures.
+ message_timer_data* const timer_array;
+
+ // The list of active timers.
+ __private_message_timer__::list active_list;
+
+ volatile bool enabled;
+ volatile etl::timer_semaphore_t process_semaphore;
+ volatile uint32_t tick_count;
+ volatile uint_least8_t registered_timers;
+
+ public:
+
+ const uint_least8_t MAX_TIMERS;
+ };
+
+ //***************************************************************************
+ /// The message timer
+ //***************************************************************************
+ template
+ class message_timer : public etl::imessage_timer
+ {
+ public:
+
+ STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed");
+
+ //*******************************************
+ /// Constructor.
+ //*******************************************
+ message_timer()
+ : imessage_timer(timer_array, MAX_TIMERS_)
+ {
+ }
+
+ private:
+
+ message_timer_data timer_array[MAX_TIMERS_];
+ };
+}
+
+#undef ETL_FILE
+
+#endif
diff --git a/src/message_types.h b/src/message_types.h
index a049dae9..2e5f7b05 100644
--- a/src/message_types.h
+++ b/src/message_types.h
@@ -31,6 +31,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
/// Allow alternative type for message id.
diff --git a/src/numeric.h b/src/numeric.h
index 064bab64..ed3a4c08 100644
--- a/src/numeric.h
+++ b/src/numeric.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_NUMERIC__
#define __ETL_NUMERIC__
+#include "platform.h"
+
///\defgroup numeric numeric
///\ingroup utilities
diff --git a/src/observer.h b/src/observer.h
index f46e4256..4b6766dc 100644
--- a/src/observer.h
+++ b/src/observer.h
@@ -52,6 +52,8 @@ SOFTWARE.
//*****************************************************************************
#include
+
+#include "platform.h"
#include "vector.h"
#include "exception.h"
#include "error_handler.h"
diff --git a/src/parameter_type.h b/src/parameter_type.h
index a3b8ff43..75203c53 100644
--- a/src/parameter_type.h
+++ b/src/parameter_type.h
@@ -31,6 +31,7 @@ SOFTWARE.
#ifndef __ETL_PARAMETER__
#define __ETL_PARAMETER__
+#include "platform.h"
#include "type_traits.h"
namespace etl
diff --git a/src/platform.h b/src/platform.h
index 843d6eac..f862ee91 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -5,7 +5,7 @@ The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
-http://www.etlcpp.com
+https://www.etlcpp.com
Copyright(c) 2016 jwellbelove
@@ -28,70 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
-#include
-#include
-
-// Define the compiler.
-#if defined(__IAR_SYSTEMS_ICC__)
- #define ETL_COMPILER_IAR
-#elif defined(__KEIL__) && !defined(__GNUC__)
- #define ETL_COMPILER_KEIL
-#elif defined(__ghs__)
- #define ETL_COMPILER_GREEN_HILLS
-#elif defined(__INTEL_COMPILER)
- #define ETL_COMPILER_INTEL
-#elif defined(_MSC_VER)
- #define ETL_COMPILER_MICROSOFT
-#elif defined(__GNUC__)
- #define ETL_COMPILER_GCC
-#elif defined(__TI_COMPILER_VERSION__)
- #define ETL_COMPILER_TI
-#elif defined(_MRI)
- #define ETL_COMPILER_MICROTEC
-#elif defined(__HIGHC__)
- #define ETL_COMPILER_METAWARE_HIGH
-#elif defined(__llvm__)
- #define ETL_COMPILER_LLVM
-#elif defined(__KCC_VERSION)
- #define ETL_COMPILER_KAI
-#elif defined(_COMO__)
- #define ETL_COMPILER_COMEAU
-#elif defined(__BORLANDC__)
- #define ETL_COMPILER_BORLAND
-#elif defined(__CC_ARM)
- #define ETL_COMPILER_ARM
-#elif defined(__MRC__)
- #define ETL_COMPILER_MPW
-#else
- #define ETL_COMPILER_GENERIC
-#endif
-
-#if (__cplusplus >= 201103L) || (!defined(ARDUINO) && (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)))
- #define ETL_CPP11_SUPPORTED 1
-#else
- #define ETL_CPP11_SUPPORTED 0
-#endif
-
-#if (__cplusplus >= 201402L) || (!defined(ARDUINO) && (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1900)))
- #define ETL_CPP14_SUPPORTED 1
-#else
- #define ETL_CPP14_SUPPORTED 0
-#endif
-
-#if (ETL_CPP11_SUPPORTED)
- #define ETL_NO_NULLPTR_SUPPORT 0
- #define ETL_NO_LARGE_CHAR_SUPPORT 0
-#else
- #define ETL_NO_NULLPTR_SUPPORT 1
- #define ETL_NO_LARGE_CHAR_SUPPORT 1
-#endif
-
-// Check to see if the compiler supports C++11 'is_trivially_xxx' traits.
-#if (ETL_CPP14_SUPPORTED)
- #define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
-#else
- #define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
-#endif
+#ifndef __ETL_PLATFORM__
+#define __ETL_PLATFORM__
// Some targets do not support 8bit types.
#define ETL_8BIT_SUPPORT (CHAR_BIT == 8)
@@ -101,3 +39,7 @@ SOFTWARE.
#else
#define ETL_DEBUG 0
#endif
+
+#include "etl_profile.h"
+
+#endif
diff --git a/src/pool.h b/src/pool.h
index 2d0fd9dd..470386e5 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -31,11 +31,11 @@ SOFTWARE.
#ifndef __ETL_POOL__
#define __ETL_POOL__
+#include "platform.h"
#include "alignment.h"
#include "array.h"
#include "container.h"
#include "integral_limits.h"
-#include "platform.h"
#include "nullptr.h"
#include "alignment.h"
#include "error_handler.h"
diff --git a/src/power.h b/src/power.h
index fe306bb4..76f1f5c7 100644
--- a/src/power.h
+++ b/src/power.h
@@ -33,6 +33,8 @@ SOFTWARE.
#include
#include
+
+#include "platform.h"
#include "log.h"
///\defgroup power power
diff --git a/src/private/pvoidvector.cpp b/src/private/pvoidvector.cpp
index 6b74805d..e714921e 100644
--- a/src/private/pvoidvector.cpp
+++ b/src/private/pvoidvector.cpp
@@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
+#include "../platform.h"
#include "pvoidvector.h"
namespace etl
diff --git a/src/private/vector_base.h b/src/private/vector_base.h
index 84c7255e..e874f443 100644
--- a/src/private/vector_base.h
+++ b/src/private/vector_base.h
@@ -37,6 +37,7 @@ SOFTWARE.
#include
+#include "../platform.h"
#include "../exception.h"
#include "../error_handler.h"
#include "../debug_count.h"
diff --git a/src/profiles/arduino_arm.h b/src/profiles/arduino_arm.h
new file mode 100644
index 00000000..d67d29c0
--- /dev/null
+++ b/src/profiles/arduino_arm.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ARDUINO__
+#define __ETL_ARDUINO__
+
+//*****************************************************************************
+// Arduino
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_ARM
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_GCC
+#define ETL_CPP11_SUPPORTED 0
+#define ETL_CPP14_SUPPORTED 0
+#define ETL_NO_NULLPTR_SUPPORT 1
+#define ETL_NO_LARGE_CHAR_SUPPORT 1
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
+#define ETL_ATOMIC_SUPPORTED 0
+
+#endif
diff --git a/src/profiles/armv5.h b/src/profiles/armv5.h
new file mode 100644
index 00000000..2066a11d
--- /dev/null
+++ b/src/profiles/armv5.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ARMV5__
+#define __ETL_ARMV5__
+
+//*****************************************************************************
+// ARM Compiler Version 5
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_ARM
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_ARM
+#define ETL_CPP11_SUPPORTED 0
+#define ETL_CPP14_SUPPORTED 0
+#define ETL_NO_NULLPTR_SUPPORT 1
+#define ETL_NO_LARGE_CHAR_SUPPORT 1
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
+#define ETL_ATOMIC_SUPPORTED 0
+
+#endif
diff --git a/src/profiles/armv6.h b/src/profiles/armv6.h
new file mode 100644
index 00000000..2128fdbf
--- /dev/null
+++ b/src/profiles/armv6.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_ARMV6__
+#define __ETL_ARMV6__
+
+//*****************************************************************************
+// ARM Compiler Version 6
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_ARM
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_LLVM
+#define ETL_CPP11_SUPPORTED 1
+#define ETL_CPP14_SUPPORTED 0
+#define ETL_NO_NULLPTR_SUPPORT 0
+#define ETL_NO_LARGE_CHAR_SUPPORT 0
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
+#define ETL_ATOMIC_SUPPORTED 1
+
+#endif
diff --git a/src/profiles/cpp03.h b/src/profiles/cpp03.h
new file mode 100644
index 00000000..2faff448
--- /dev/null
+++ b/src/profiles/cpp03.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_CPP03__
+#define __ETL_CPP03__
+
+//*****************************************************************************
+// Generic C++03
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_GENERIC
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_GENERIC
+#define ETL_CPP11_SUPPORTED 0
+#define ETL_CPP14_SUPPORTED 0
+#define ETL_NO_NULLPTR_SUPPORT 1
+#define ETL_NO_LARGE_CHAR_SUPPORT 1
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
+#define ETL_ATOMIC_SUPPORTED 0
+
+#endif
diff --git a/src/profiles/cpp11.h b/src/profiles/cpp11.h
new file mode 100644
index 00000000..38a42b39
--- /dev/null
+++ b/src/profiles/cpp11.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_CPP11__
+#define __ETL_CPP11__
+
+//*****************************************************************************
+// Generic C++11
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_GENERIC
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_GENERIC
+#define ETL_CPP11_SUPPORTED 1
+#define ETL_CPP14_SUPPORTED 0
+#define ETL_NO_NULLPTR_SUPPORT 0
+#define ETL_NO_LARGE_CHAR_SUPPORT 0
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
+#define ETL_ATOMIC_SUPPORTED 1
+
+#endif
diff --git a/src/profiles/cpp14.h b/src/profiles/cpp14.h
new file mode 100644
index 00000000..f967aa05
--- /dev/null
+++ b/src/profiles/cpp14.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_CPP14__
+#define __ETL_CPP14__
+
+//*****************************************************************************
+// Generic C++14
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_GENERIC
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_GENERIC
+#define ETL_CPP11_SUPPORTED 1
+#define ETL_CPP14_SUPPORTED 1
+#define ETL_NO_NULLPTR_SUPPORT 0
+#define ETL_NO_LARGE_CHAR_SUPPORT 0
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
+#define ETL_ATOMIC_SUPPORTED 1
+
+#endif
diff --git a/src/profiles/gcc_generic.h b/src/profiles/gcc_generic.h
new file mode 100644
index 00000000..5a11b7b2
--- /dev/null
+++ b/src/profiles/gcc_generic.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_GCC__
+#define __ETL_GCC__
+
+//*****************************************************************************
+// GCC
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_GENERIC
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_GCC
+#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
+#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
+#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
+#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
+
+#endif
diff --git a/src/profiles/gcc_linux_x86.h b/src/profiles/gcc_linux_x86.h
new file mode 100644
index 00000000..d905a6ff
--- /dev/null
+++ b/src/profiles/gcc_linux_x86.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_GCC__
+#define __ETL_GCC__
+
+//*****************************************************************************
+// GCC
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_X86
+#define ETL_TARGET_OS_LINUX
+#define ETL_COMPILER_GCC
+#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
+#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
+#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
+#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
+
+#endif
diff --git a/src/profiles/gcc_windows_x86.h b/src/profiles/gcc_windows_x86.h
new file mode 100644
index 00000000..c8dea2c0
--- /dev/null
+++ b/src/profiles/gcc_windows_x86.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_GCC__
+#define __ETL_GCC__
+
+//*****************************************************************************
+// GCC
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_X86
+#define ETL_TARGET_OS_WINDOWS
+#define ETL_COMPILER_GCC
+#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
+#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
+#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
+#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
+
+#endif
diff --git a/src/profiles/msvc_x86.h b/src/profiles/msvc_x86.h
new file mode 100644
index 00000000..803eead8
--- /dev/null
+++ b/src/profiles/msvc_x86.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_MSVC__
+#define __ETL_MSVC__
+
+//*****************************************************************************
+// Microsoft Visual Studio
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_X86
+#define ETL_TARGET_OS_WINDOWS
+#define ETL_COMPILER_MICROSOFT
+#define ETL_CPP11_SUPPORTED (_MSC_VER >= 1600)
+#define ETL_CPP14_SUPPORTED (_MSC_VER >= 1900)
+#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
+#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
+
+#endif
diff --git a/src/profiles/ticc.h b/src/profiles/ticc.h
new file mode 100644
index 00000000..4f4d3c90
--- /dev/null
+++ b/src/profiles/ticc.h
@@ -0,0 +1,50 @@
+///\file
+
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_TICC__
+#define __ETL_TICC__
+
+//*****************************************************************************
+// Texas Instruments Code Composer
+//*****************************************************************************
+
+#include
+
+#define ETL_TARGET_DEVICE_GENERIC
+#define ETL_TARGET_OS_NONE
+#define ETL_COMPILER_TI
+#define ETL_CPP11_SUPPORTED 0
+#define ETL_CPP14_SUPPORTED 0
+#define ETL_NO_NULLPTR_SUPPORT 1
+#define ETL_NO_LARGE_CHAR_SUPPORT 1
+#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
+#define ETL_ATOMIC_SUPPORTED 0
+
+#endif
diff --git a/src/queue.h b/src/queue.h
index 7e9b35fe..3ba4d0fa 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -34,6 +34,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "container.h"
#include "alignment.h"
#include "array.h"
diff --git a/src/radix.h b/src/radix.h
index a2a1a8d9..2e830341 100644
--- a/src/radix.h
+++ b/src/radix.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "enum_type.h"
///\defgroup radix radix
diff --git a/src/random.cpp b/src/random.cpp
index 63b69718..4edb6188 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
+#include "platform.h"
#include "random.h"
namespace etl
diff --git a/src/random.h b/src/random.h
index 0cfdf05b..f47212f4 100644
--- a/src/random.h
+++ b/src/random.h
@@ -33,6 +33,8 @@ SOFTWARE.
#include
+#include "platform.h"
+
namespace etl
{
//***************************************************************************
diff --git a/src/reference_flat_multimap.h b/src/reference_flat_multimap.h
index 1f892593..5b78750b 100644
--- a/src/reference_flat_multimap.h
+++ b/src/reference_flat_multimap.h
@@ -33,6 +33,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "exception.h"
#include "error_handler.h"
#include "debug_count.h"
diff --git a/src/scheduler.h b/src/scheduler.h
index 388b0a8c..473d15ac 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -31,6 +31,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "vector.h"
#include "nullptr.h"
#include "error_handler.h"
diff --git a/src/smallest.h b/src/smallest.h
index 16a2ed7c..f6c8c36c 100644
--- a/src/smallest.h
+++ b/src/smallest.h
@@ -55,6 +55,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "integral_limits.h"
///\defgroup smallest smallest
diff --git a/src/smallest_generator.h b/src/smallest_generator.h
index 1c99c09c..99923b5e 100644
--- a/src/smallest_generator.h
+++ b/src/smallest_generator.h
@@ -67,6 +67,7 @@ cog.outl("//********************************************************************
#include
+#include "platform.h"
#include "integral_limits.h"
///\defgroup smallest smallest
diff --git a/src/sqrt.h b/src/sqrt.h
index 481122dd..faeb8806 100644
--- a/src/sqrt.h
+++ b/src/sqrt.h
@@ -32,6 +32,8 @@ SOFTWARE.
#define __ETL_SQRT__
#include
+
+#include "platform.h"
#include "type_traits.h"
#include "constant.h"
diff --git a/src/stack.h b/src/stack.h
index d41e38b3..6be1692b 100644
--- a/src/stack.h
+++ b/src/stack.h
@@ -35,6 +35,7 @@ SOFTWARE.
#include
#include
+#include "platform.h"
#include "container.h"
#include "alignment.h"
#include "array.h"
diff --git a/src/task.h b/src/task.h
index dbe410f1..0cd1f88e 100644
--- a/src/task.h
+++ b/src/task.h
@@ -31,6 +31,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "error_handler.h"
#include "exception.h"
diff --git a/src/timer.h b/src/timer.h
new file mode 100644
index 00000000..e91d1f5e
--- /dev/null
+++ b/src/timer.h
@@ -0,0 +1,101 @@
+/******************************************************************************
+The MIT License(MIT)
+
+Embedded Template Library.
+https://github.com/ETLCPP/etl
+https://www.etlcpp.com
+
+Copyright(c) 2017 jwellbelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files(the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions :
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+******************************************************************************/
+
+#ifndef __ETL_TIMER__
+#define __ETL_TIMER__
+
+#include
+
+#include "platform.h"
+
+#include "atomic.h"
+
+//*****************************************************************************
+// Definitions common to timers.
+//*****************************************************************************
+
+namespace etl
+{
+#ifdef ETL_TIMER_SEMAPHORE_TYPE
+ typedef ETL_TIMER_SEMAPHORE_TYPE timer_semaphore_t;
+#else
+ typedef etl::atomic_uint32_t timer_semaphore_t;
+#endif
+
+ //***************************************************************************
+ /// Common definitions for the timer framework.
+ //***************************************************************************
+ struct timer
+ {
+ // Timer modes.
+ struct mode
+ {
+ enum
+ {
+ SINGLE_SHOT = false,
+ REPEATING = true
+ };
+
+ typedef bool type;
+ };
+
+ // Timer start status.
+ struct start
+ {
+ enum
+ {
+ DELAYED = false,
+ IMMEDIATE = true
+ };
+
+ typedef bool type;
+ };
+
+ // Timer id.
+ struct id
+ {
+ enum
+ {
+ NO_TIMER = 255
+ };
+
+ typedef uint_least8_t type;
+ };
+
+ // Timer state.
+ struct state
+ {
+ enum
+ {
+ INACTIVE = 0xFFFFFFFF
+ };
+ };
+ };
+}
+
+#endif
diff --git a/src/type_def.h b/src/type_def.h
index e35257b1..7d486960 100644
--- a/src/type_def.h
+++ b/src/type_def.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_TYPE_DEF__
#define __ETL_TYPE_DEF__
+#include "platform.h"
+
namespace etl
{
#define ETL_TYPEDEF(T, name) class name##_tag; typedef etl::type_def name
diff --git a/src/type_lookup.h b/src/type_lookup.h
index 0a7eb03a..a00c4e76 100644
--- a/src/type_lookup.h
+++ b/src/type_lookup.h
@@ -31,6 +31,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"
diff --git a/src/type_lookup_generator.h b/src/type_lookup_generator.h
index f1316b46..7e363cb0 100644
--- a/src/type_lookup_generator.h
+++ b/src/type_lookup_generator.h
@@ -31,6 +31,7 @@ SOFTWARE.
#include
+#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"
diff --git a/src/user_type.h b/src/user_type.h
index 4ecb193c..4815ed55 100644
--- a/src/user_type.h
+++ b/src/user_type.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_USER_TYPE__
#define __ETL_USER_TYPE__
+#include "platform.h"
+
///\defgroup user_type user_type
/// Smart enumerations.
/// A method of declaring a user type that also contains a set of constants,
diff --git a/src/utility.h b/src/utility.h
index 81a27a17..db6aa911 100644
--- a/src/utility.h
+++ b/src/utility.h
@@ -31,6 +31,7 @@ SOFTWARE.
#ifndef __ETL_UTILITY__
#define __ETL_UTILITY__
+#include "platform.h"
#include "type_traits.h"
///\defgroup utility utility
diff --git a/src/visitor.h b/src/visitor.h
index c7af3547..b6c412d0 100644
--- a/src/visitor.h
+++ b/src/visitor.h
@@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_VISITOR__
#define __ETL_VISITOR__
+#include "platform.h"
+
//*****************************************************************************
///\defgroup visitor visitor
/// A set of template classes for easy implementation of the visitor pattern.
diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp
index 3d05f91b..f38ea2a7 100644
--- a/test/codeblocks/ETL.cbp
+++ b/test/codeblocks/ETL.cbp
@@ -16,9 +16,6 @@
-
-
-
@@ -37,9 +34,6 @@
-
-
-
@@ -52,12 +46,6 @@
-
-
-
-
-
-
@@ -71,6 +59,7 @@
+
@@ -144,6 +133,7 @@
+
@@ -180,6 +170,7 @@
+
@@ -267,7 +258,11 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/feature/Timer_triggered_messages
@@ -278,6 +273,7 @@
+
@@ -319,6 +315,7 @@
+
@@ -365,6 +362,7 @@
+
diff --git a/test/codeblocks/ETL.depend b/test/codeblocks/ETL.depend
new file mode 100644
index 00000000..707aee8a
--- /dev/null
+++ b/test/codeblocks/ETL.depend
@@ -0,0 +1,12063 @@
+# depslib dependency file v1.0
+1424729709 source:u:\users\john\documents\programming\github\etl\crc16.cpp
+
+
+1507907758
+
+1424729709 source:u:\users\john\documents\programming\github\etl\crc16_ccitt.cpp
+
+
+1424729709 source:u:\users\john\documents\programming\github\etl\crc32.cpp
+
+
+1424729709 source:u:\users\john\documents\programming\github\etl\crc64_ecma.cpp
+
+
+1424729709 source:u:\users\john\documents\programming\github\etl\crc8_ccitt.cpp
+
+
+1424729709 source:u:\users\john\documents\programming\github\etl\test\main.cpp
+
+
+1452692153 +/UnitTest++.h>
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\unittest++.h
+ "UnitTestPP.h"
+
+1494161659 P.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\unittestpp.h
+ "Config.h"
+ "TestMacros.h"
+ "CheckMacros.h"
+ "TestRunner.h"
+ "TimeConstraint.h"
+ "ReportAssert.h"
+
+1494161659 ert.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\config.h
+
+1416833504 u:\users\john\documents\programming\github\unittest-cpp\unittest++\testmacros.h
+ "Config.h"
+ "TestSuite.h"
+ "ExceptionMacros.h"
+ "ExecuteTest.h"
+ "AssertException.h"
+ "TestDetails.h"
+ "MemoryOutStream.h"
+ "Posix/SignalTranslator.h"
+
+1494165259 nalTranslator.h"
+
+1416833496 u:\users\john\documents\programming\github\unittest-cpp\unittest++\testsuite.h
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\exceptionmacros.h
+ "Config.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\executetest.h
+ "Config.h"
+ "ExceptionMacros.h"
+ "TestDetails.h"
+ "TestResults.h"
+ "MemoryOutStream.h"
+ "AssertException.h"
+ "CurrentTest.h"
+ "ReportAssertImpl.h"
+ "Posix/SignalTranslator.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\testdetails.h
+ "HelperMacros.h"
+
+1494165259 ros.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\helpermacros.h
+ "Config.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\testresults.h
+ "HelperMacros.h"
+
+1417973669 u:\users\john\documents\programming\github\unittest-cpp\unittest++\memoryoutstream.h
+ "Config.h"
+ "HelperMacros.h"
+
+
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\assertexception.h
+ "Config.h"
+ "HelperMacros.h"
+
+
+1507807483 >
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\currenttest.h
+ "HelperMacros.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\reportassertimpl.h
+ "Config.h"
+ "HelperMacros.h"
+
+
+1417875049 u:\users\john\documents\programming\github\unittest-cpp\unittest++\posix\signaltranslator.h
+
+
+
+1414931290 u:\users\john\documents\programming\github\unittest-cpp\unittest++\checkmacros.h
+ "HelperMacros.h"
+ "ExceptionMacros.h"
+ "Checks.h"
+ "AssertException.h"
+ "MemoryOutStream.h"
+ "TestDetails.h"
+ "CurrentTest.h"
+ "ReportAssertImpl.h"
+
+1494165259 ertImpl.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\checks.h
+ "Config.h"
+ "TestResults.h"
+ "MemoryOutStream.h"
+
+1494161659 Stream.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\testrunner.h
+ "Test.h"
+ "TestList.h"
+ "CurrentTest.h"
+
+1494165259 st.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\test.h
+ "TestDetails.h"
+
+1494165259 ls.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\testlist.h
+ "HelperMacros.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\timeconstraint.h
+ "TimeHelpers.h"
+ "HelperMacros.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\timehelpers.h
+ "Config.h"
+ "Posix/TimeHelpers.h"
+ "Win32/TimeHelpers.h"
+
+1494165259 eHelpers.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\posix\timehelpers.h
+
+
+1494165259 h>
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\win32\timehelpers.h
+ "../Config.h"
+ "../HelperMacros.h"
+
+1494165259 Macros.h"
+
+1414849210 u:\users\john\documents\programming\github\unittest-cpp\unittest++\reportassert.h
+ "HelperMacros.h"
+
+1428227985 source:u:\users\john\documents\programming\github\etl\test\test_array.cpp
+
+ "../array.h"
+
+
+
+ "../integral_limits.h"
+
+1452516033 al_limits.h"
+
+1424729709 u:\users\john\documents\programming\github\etl\array.h
+
+
+
+
+ "exception.h"
+ "type_traits.h"
+ "parameter_type.h"
+ "static_assert.h"
+ "error_handler.h"
+
+1494277861 dler.h"
+
+1507728173 .h"
+
+1424729709 u:\users\john\documents\programming\github\etl\exception.h
+
+1424729709 source:u:\users\john\documents\programming\github\etl\test\test_container.cpp
+
+ "../container.h"
+
+
+1452516033 ner.h"
+
+1424729709 u:\users\john\documents\programming\github\etl\container.h
+
+
+
+1424729709 source:u:\users\john\documents\programming\github\etl\test\test_crc.cpp
+
+
+
+