diff --git a/arduino/Embedded_Template_Library.h b/arduino/Embedded_Template_Library.h
index 5959207e..aed4c865 100644
--- a/arduino/Embedded_Template_Library.h
+++ b/arduino/Embedded_Template_Library.h
@@ -2,79 +2,79 @@
#ifndef ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
#define ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
-#if defined(TEENSYDUINO)
+#if defined(TEENSYDUINO)
- #if defined(__AVR_ATmega32U4__)
- #define ARDUINO_BOARD "Teensy 2.0"
- #elif defined(__AVR_AT90USB1286__)
- #define ARDUINO_BOARD "Teensy++ 2.0"
- #elif defined(__MK20DX128__)
- #define ARDUINO_BOARD "Teensy 3.0"
- #elif defined(__MK20DX256__)
- #define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
- #elif defined(__MKL26Z64__)
- #define ARDUINO_BOARD "Teensy LC"
- #elif defined(__MK64FX512__)
- #define ARDUINO_BOARD "Teensy 3.5"
- #elif defined(__MK66FX1M0__)
- #define ARDUINO_BOARD "Teensy 3.6"
- #else
- #define ARDUINO_BOARD "Unknown"
- #endif
+ #if defined(__AVR_ATmega32U4__)
+ #define ARDUINO_BOARD "Teensy 2.0"
+ #elif defined(__AVR_AT90USB1286__)
+ #define ARDUINO_BOARD "Teensy++ 2.0"
+ #elif defined(__MK20DX128__)
+ #define ARDUINO_BOARD "Teensy 3.0"
+ #elif defined(__MK20DX256__)
+ #define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
+ #elif defined(__MKL26Z64__)
+ #define ARDUINO_BOARD "Teensy LC"
+ #elif defined(__MK64FX512__)
+ #define ARDUINO_BOARD "Teensy 3.5"
+ #elif defined(__MK66FX1M0__)
+ #define ARDUINO_BOARD "Teensy 3.6"
+ #else
+ #define ARDUINO_BOARD "Unknown"
+ #endif
#else // --------------- Arduino ------------------
- #if defined(ARDUINO_AVR_ADK)
- #define ARDUINO_BOARD "Mega Adk"
- #elif defined(ARDUINO_AVR_BT)
- #define ARDUINO_BOARD "Bt"
- #elif defined(ARDUINO_AVR_DUEMILANOVE)
- #define ARDUINO_BOARD "Duemilanove"
- #elif defined(ARDUINO_AVR_ESPLORA)
- #define ARDUINO_BOARD "Esplora"
- #elif defined(ARDUINO_AVR_ETHERNET)
- #define ARDUINO_BOARD "Ethernet"
- #elif defined(ARDUINO_AVR_FIO)
- #define ARDUINO_BOARD "Fio"
- #elif defined(ARDUINO_AVR_GEMMA)
- #define ARDUINO_BOARD "Gemma"
- #elif defined(ARDUINO_AVR_LEONARDO)
- #define ARDUINO_BOARD "Leonardo"
- #elif defined(ARDUINO_AVR_LILYPAD)
- #define ARDUINO_BOARD "Lilypad"
- #elif defined(ARDUINO_AVR_LILYPAD_USB)
- #define ARDUINO_BOARD "Lilypad Usb"
- #elif defined(ARDUINO_AVR_MEGA)
- #define ARDUINO_BOARD "Mega"
- #elif defined(ARDUINO_AVR_MEGA2560)
- #define ARDUINO_BOARD "Mega 2560"
- #elif defined(ARDUINO_AVR_MICRO)
- #define ARDUINO_BOARD "Micro"
- #elif defined(ARDUINO_AVR_MINI)
- #define ARDUINO_BOARD "Mini"
- #elif defined(ARDUINO_AVR_NANO)
- #define ARDUINO_BOARD "Nano"
- #elif defined(ARDUINO_AVR_NG)
- #define ARDUINO_BOARD "NG"
- #elif defined(ARDUINO_AVR_PRO)
- #define ARDUINO_BOARD "Pro"
- #elif defined(ARDUINO_AVR_ROBOT_CONTROL)
- #define ARDUINO_BOARD "Robot Ctrl"
- #elif defined(ARDUINO_AVR_ROBOT_MOTOR)
- #define ARDUINO_BOARD "Robot Motor"
- #elif defined(ARDUINO_AVR_UNO)
- #define ARDUINO_BOARD "Uno"
- #elif defined(ARDUINO_AVR_YUN)
- #define ARDUINO_BOARD "Yun"
- #elif defined(ARDUINO_SAM_DUE)
- #define ARDUINO_BOARD "Due"
- #elif defined(ARDUINO_SAMD_ZERO)
- #define ARDUINO_BOARD "Zero"
- #elif defined(ARDUINO_ARC32_TOOLS)
- #define ARDUINO_BOARD "101"
- #else
- #define ARDUINO_BOARD "Unknown"
- #endif
+ #if defined(ARDUINO_AVR_ADK)
+ #define ARDUINO_BOARD "Mega Adk"
+ #elif defined(ARDUINO_AVR_BT)
+ #define ARDUINO_BOARD "Bt"
+ #elif defined(ARDUINO_AVR_DUEMILANOVE)
+ #define ARDUINO_BOARD "Duemilanove"
+ #elif defined(ARDUINO_AVR_ESPLORA)
+ #define ARDUINO_BOARD "Esplora"
+ #elif defined(ARDUINO_AVR_ETHERNET)
+ #define ARDUINO_BOARD "Ethernet"
+ #elif defined(ARDUINO_AVR_FIO)
+ #define ARDUINO_BOARD "Fio"
+ #elif defined(ARDUINO_AVR_GEMMA)
+ #define ARDUINO_BOARD "Gemma"
+ #elif defined(ARDUINO_AVR_LEONARDO)
+ #define ARDUINO_BOARD "Leonardo"
+ #elif defined(ARDUINO_AVR_LILYPAD)
+ #define ARDUINO_BOARD "Lilypad"
+ #elif defined(ARDUINO_AVR_LILYPAD_USB)
+ #define ARDUINO_BOARD "Lilypad Usb"
+ #elif defined(ARDUINO_AVR_MEGA)
+ #define ARDUINO_BOARD "Mega"
+ #elif defined(ARDUINO_AVR_MEGA2560)
+ #define ARDUINO_BOARD "Mega 2560"
+ #elif defined(ARDUINO_AVR_MICRO)
+ #define ARDUINO_BOARD "Micro"
+ #elif defined(ARDUINO_AVR_MINI)
+ #define ARDUINO_BOARD "Mini"
+ #elif defined(ARDUINO_AVR_NANO)
+ #define ARDUINO_BOARD "Nano"
+ #elif defined(ARDUINO_AVR_NG)
+ #define ARDUINO_BOARD "NG"
+ #elif defined(ARDUINO_AVR_PRO)
+ #define ARDUINO_BOARD "Pro"
+ #elif defined(ARDUINO_AVR_ROBOT_CONTROL)
+ #define ARDUINO_BOARD "Robot Ctrl"
+ #elif defined(ARDUINO_AVR_ROBOT_MOTOR)
+ #define ARDUINO_BOARD "Robot Motor"
+ #elif defined(ARDUINO_AVR_UNO)
+ #define ARDUINO_BOARD "Uno"
+ #elif defined(ARDUINO_AVR_YUN)
+ #define ARDUINO_BOARD "Yun"
+ #elif defined(ARDUINO_SAM_DUE)
+ #define ARDUINO_BOARD "Due"
+ #elif defined(ARDUINO_SAMD_ZERO)
+ #define ARDUINO_BOARD "Zero"
+ #elif defined(ARDUINO_ARC32_TOOLS)
+ #define ARDUINO_BOARD "101"
+ #else
+ #define ARDUINO_BOARD "Unknown"
+ #endif
#endif
#endif
diff --git a/examples/ArmTimerCallbacks - C++/RTE/Device/STM32F401RETx/system_stm32f4xx.c b/examples/ArmTimerCallbacks - C++/RTE/Device/STM32F401RETx/system_stm32f4xx.c
index bca0633d..62183db5 100644
--- a/examples/ArmTimerCallbacks - C++/RTE/Device/STM32F401RETx/system_stm32f4xx.c
+++ b/examples/ArmTimerCallbacks - C++/RTE/Device/STM32F401RETx/system_stm32f4xx.c
@@ -1,176 +1,179 @@
/**
- ******************************************************************************
- * @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.
- *
- ******************************************************************************
- */
+ ******************************************************************************
+ * @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
- * @{
- */
+ * @{
+ */
+/** @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(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 */
+#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)
+/*!< 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)
+#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 */
+#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. */
+#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;
+ * @{
+ */
+/* 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);
+#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
- */
+ * @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
+/* 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;
@@ -190,8 +193,8 @@ void SystemInit(void)
/* Disable all interrupts */
RCC->CIR = 0x00000000;
-#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
- SystemInit_ExtMemCtl();
+#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 ------------------*/
@@ -203,64 +206,62 @@ void SystemInit(void)
}
/**
- * @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
- */
+ * @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 */
+ 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;
-
+ pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
+
if (pllsource != 0)
{
/* HSE used as PLL clock source */
@@ -272,12 +273,10 @@ void SystemCoreClockUpdate(void)
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;
+ pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >> 16) + 1) * 2;
+ SystemCoreClock = pllvco / pllp;
break;
+ default: SystemCoreClock = HSI_VALUE; break;
}
/* Compute HCLK frequency --------------------------------------------------*/
/* Get HCLK prescaler */
@@ -286,478 +285,486 @@ void SystemCoreClockUpdate(void)
SystemCoreClock >>= tmp;
}
-#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
-#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
- || defined(STM32F469xx) || defined(STM32F479xx)
+#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
- */
+ * @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 uint32_t tmpreg = 0, timeout = 0xFFFF;
register __IO uint32_t index;
- /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
+ /* 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->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;
+ /* 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->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;
-
+ /* 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->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;
+ /* 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->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;
-
+ /* 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->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;
-
+ /* 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->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 -------------------------------------------------------*/
+ /* 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;
-
+ 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))
+ FMC_Bank5_6->SDCMR = 0x00000011;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Delay */
- for (index = 0; index<1000; index++);
-
+ for (index = 0; index < 1000; index++);
+
/* PALL command */
- FMC_Bank5_6->SDCMR = 0x00000012;
- timeout = 0xFFFF;
- while((tmpreg != 0) && (timeout-- > 0))
+ FMC_Bank5_6->SDCMR = 0x00000012;
+ timeout = 0xFFFF;
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
-
+
/* Auto refresh command */
FMC_Bank5_6->SDCMR = 0x00000073;
- timeout = 0xFFFF;
- while((tmpreg != 0) && (timeout-- > 0))
+ timeout = 0xFFFF;
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
-
+
/* MRD register program */
FMC_Bank5_6->SDCMR = 0x00046014;
- timeout = 0xFFFF;
- while((tmpreg != 0) && (timeout-- > 0))
+ timeout = 0xFFFF;
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
- }
-
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
/* Set refresh count */
- tmpreg = FMC_Bank5_6->SDRTR;
- FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
-
+ tmpreg = FMC_Bank5_6->SDRTR;
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C << 1));
+
/* Disable write protection */
- tmpreg = FMC_Bank5_6->SDCR[0];
+ tmpreg = FMC_Bank5_6->SDCR[0];
FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
-#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
+ #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)
+ #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 */
+ #endif /* STM32F469xx || STM32F479xx */
- (void)(tmp);
+ (void)(tmp);
}
-#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
-#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+ #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
- */
+ * @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;
+ #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)
+ #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
+ #else
+ /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
clock */
RCC->AHB1ENR |= 0x000001F8;
-#endif /* STM32F446xx */
+ #endif /* STM32F446xx */
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
-
-#if defined(STM32F446xx)
+
+ #if defined(STM32F446xx)
/* Connect PAx pins to FMC Alternate function */
- GPIOA->AFR[0] |= 0xC0000000;
- GPIOA->AFR[1] |= 0x00000000;
+ GPIOA->AFR[0] |= 0xC0000000;
+ GPIOA->AFR[1] |= 0x00000000;
/* Configure PDx pins in Alternate function mode */
- GPIOA->MODER |= 0x00008000;
+ GPIOA->MODER |= 0x00008000;
/* Configure PDx pins speed to 50 MHz */
GPIOA->OSPEEDR |= 0x00008000;
/* Configure PDx pins Output type to push-pull */
- GPIOA->OTYPER |= 0x00000000;
+ GPIOA->OTYPER |= 0x00000000;
/* No pull-up, pull-down for PDx pins */
- GPIOA->PUPDR |= 0x00000000;
+ GPIOA->PUPDR |= 0x00000000;
/* Connect PCx pins to FMC Alternate function */
- GPIOC->AFR[0] |= 0x00CC0000;
- GPIOC->AFR[1] |= 0x00000000;
+ GPIOC->AFR[0] |= 0x00CC0000;
+ GPIOC->AFR[1] |= 0x00000000;
/* Configure PDx pins in Alternate function mode */
- GPIOC->MODER |= 0x00000A00;
+ GPIOC->MODER |= 0x00000A00;
/* Configure PDx pins speed to 50 MHz */
GPIOC->OSPEEDR |= 0x00000A00;
/* Configure PDx pins Output type to push-pull */
- GPIOC->OTYPER |= 0x00000000;
+ GPIOC->OTYPER |= 0x00000000;
/* No pull-up, pull-down for PDx pins */
- GPIOC->PUPDR |= 0x00000000;
-#endif /* STM32F446xx */
+ 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->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;
+ /* 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->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;
+ /* 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->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;
+ /* 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->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;
+ /* 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)
+ #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->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;
-
+ /* 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->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 -------------------------------------------------------*/
+ /* 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)
+ /* Configure and enable SDRAM bank1 */
+ #if defined(STM32F446xx)
FMC_Bank5_6->SDCR[0] = 0x00001954;
-#else
+ #else
FMC_Bank5_6->SDCR[0] = 0x000019E4;
-#endif /* STM32F446xx */
- FMC_Bank5_6->SDTR[0] = 0x01115351;
-
+ #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))
+ FMC_Bank5_6->SDCMR = 0x00000011;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Delay */
- for (index = 0; index<1000; index++);
-
+ for (index = 0; index < 1000; index++);
+
/* PALL command */
- FMC_Bank5_6->SDCMR = 0x00000012;
- timeout = 0xFFFF;
- while((tmpreg != 0) && (timeout-- > 0))
+ FMC_Bank5_6->SDCMR = 0x00000012;
+ timeout = 0xFFFF;
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
-
- /* Auto refresh command */
-#if defined(STM32F446xx)
+
+ /* Auto refresh command */
+ #if defined(STM32F446xx)
FMC_Bank5_6->SDCMR = 0x000000F3;
-#else
+ #else
FMC_Bank5_6->SDCMR = 0x00000073;
-#endif /* STM32F446xx */
+ #endif /* STM32F446xx */
timeout = 0xFFFF;
- while((tmpreg != 0) && (timeout-- > 0))
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
-
- /* MRD register program */
-#if defined(STM32F446xx)
+
+ /* MRD register program */
+ #if defined(STM32F446xx)
FMC_Bank5_6->SDCMR = 0x00044014;
-#else
+ #else
FMC_Bank5_6->SDCMR = 0x00046014;
-#endif /* STM32F446xx */
+ #endif /* STM32F446xx */
timeout = 0xFFFF;
- while((tmpreg != 0) && (timeout-- > 0))
+ while ((tmpreg != 0) && (timeout-- > 0))
{
- tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
- }
-
+ 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 */
-
+ #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];
+ 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 */
+ #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(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;
+ #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->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;
+ /* 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->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;
+ /* 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->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;
+ /* 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->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;
+ /* 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)
+ /*-- 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)
+ #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)
+ #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 /* 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 */
+ #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || \
+ STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || \
+ STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
+ (void)(tmp);
}
-#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
+#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
/**
- * @}
- */
+ * @}
+ */
/**
- * @}
- */
+ * @}
+ */
/**
- * @}
- */
+ * @}
+ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/examples/ArmTimerCallbacks - C++/etl_profile.h b/examples/ArmTimerCallbacks - C++/etl_profile.h
index 84bbd550..d6eda2a5 100644
--- a/examples/ArmTimerCallbacks - C++/etl_profile.h
+++ b/examples/ArmTimerCallbacks - C++/etl_profile.h
@@ -10,6 +10,6 @@
#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
#define ETL_NO_STL
-//#include "etl/profiles/auto.h"
+// #include "etl/profiles/auto.h"
#endif
diff --git a/examples/ArmTimerCallbacks - C++/main.cpp b/examples/ArmTimerCallbacks - C++/main.cpp
index 72692618..4a2ccb28 100644
--- a/examples/ArmTimerCallbacks - C++/main.cpp
+++ b/examples/ArmTimerCallbacks - C++/main.cpp
@@ -1,23 +1,23 @@
#include
-//#if (__cplusplus < 201103L)
+// #if (__cplusplus < 201103L)
extern "C"
{
-//#endif
-#include "Board_LED.h" // ::Board Support:LED
+// #endif
#include "Board_Buttons.h" // ::Board Support:Buttons
-//#if (__cplusplus < 201103L)
+#include "Board_LED.h" // ::Board Support:LED
+ // #if (__cplusplus < 201103L)
}
-//#endif
+// #endif
-#include "stm32f4xx.h" // Device header
+#include "stm32f4xx.h" // Device header
-#include "etl/function.h"
-#include "etl/callback_timer.h"
-#include "etl/vector.h"
-#include "etl/iterator.h"
#include "etl/binary.h"
+#include "etl/callback_timer.h"
+#include "etl/function.h"
+#include "etl/iterator.h"
+#include "etl/vector.h"
struct FP
{
@@ -28,7 +28,7 @@ static etl::vector power_callbacks;
void register_poweroff_callback(void (*function)())
{
- FP fp = { function };
+ FP fp = {function};
power_callbacks.push_back(fp);
}
@@ -45,38 +45,38 @@ etl::timer::id::type swap_timers;
* SystemCoreClockConfigure: configure SystemCoreClock using HSI
(HSE is not populated on Nucleo board)
*----------------------------------------------------------------------------*/
-void SystemCoreClockConfigure(void) {
+void SystemCoreClockConfigure(void)
+{
+ RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
+ while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
- 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
- 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
- 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->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
+ RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
// PLL configuration: VCO = HSI/M * N, Sysclk = VCO/P
- RCC->PLLCFGR = ( 16ul | // PLL_M = 16
- (384ul << 6U) | // PLL_N = 384
- ( 3ul << 16U) | // PLL_P = 8
- (RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
- ( 8ul << 24U) ); // PLL_Q = 8
+ RCC->PLLCFGR = (16ul | // PLL_M = 16
+ (384ul << 6U) | // PLL_N = 384
+ (3ul << 16U) | // PLL_P = 8
+ (RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
+ (8ul << 24U)); // PLL_Q = 8
- RCC->CR |= RCC_CR_PLLON; // Enable PLL
- while((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
+ 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
+ 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()
@@ -123,7 +123,7 @@ void LedToggle()
int main()
{
- SystemCoreClockConfigure(); // configure HSI as System Clock
+ SystemCoreClockConfigure(); // configure HSI as System Clock
SystemCoreClockUpdate();
LED_Initialize();
@@ -131,10 +131,10 @@ int main()
// 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);
+ 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);
+ swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
SysTick_Config(SystemCoreClock / 1000);
@@ -152,7 +152,7 @@ extern "C"
{
void SysTick_Handler()
{
- const uint32_t TICK = 1U;
+ const uint32_t TICK = 1U;
static uint32_t nticks = TICK;
if (callback_timer.tick(nticks))
diff --git a/examples/FunctionInterruptSimulation-Delegates/FunctionInterruptSimulation.cpp b/examples/FunctionInterruptSimulation-Delegates/FunctionInterruptSimulation.cpp
index bbf6debf..859b92c8 100644
--- a/examples/FunctionInterruptSimulation-Delegates/FunctionInterruptSimulation.cpp
+++ b/examples/FunctionInterruptSimulation-Delegates/FunctionInterruptSimulation.cpp
@@ -11,8 +11,8 @@ enum VectorId
USART1_IRQ_HANDLER = 52,
USART2_IRQ_HANDLER = 53,
VECTOR_ID_END,
- VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
- VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
+ VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
+ VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
};
typedef etl::delegate_service InterruptVectors;
@@ -91,8 +91,8 @@ public:
// Constructor.
Uart(int port_id, size_t interruptId)
- : port_id(port_id),
- callback(etl::delegate::create(*this))
+ : port_id(port_id)
+ , callback(etl::delegate::create(*this))
{
GetInterruptVectorsInstance().register_delegate(interruptId, callback);
}
@@ -119,7 +119,8 @@ Uart uart1(0, USART1_IRQ_HANDLER);
Uart uart2(1, USART2_IRQ_HANDLER);
// Declare a global callback for the timer.
-// Uses the most efficient callback type for a class, as everything is known at compile time.
+// Uses the most efficient callback type for a class, as everything is known at
+// compile time.
etl::delegate timer_member_callback = etl::delegate::create();
// Declare the callbacks for the free functions.
diff --git a/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp b/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp
index 9eb6cb98..8e680e3d 100644
--- a/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp
+++ b/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp
@@ -1,7 +1,7 @@
#include
-#include "etl/function.h"
#include "etl/callback_service.h"
+#include "etl/function.h"
enum VectorId
{
@@ -11,8 +11,8 @@ enum VectorId
USART1_IRQ_HANDLER = 52,
USART2_IRQ_HANDLER = 53,
VECTOR_ID_END,
- VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
- VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
+ VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
+ VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
};
typedef etl::callback_service InterruptVectors;
@@ -91,8 +91,8 @@ public:
// Constructor.
Uart(int port_id, int interruptId)
- : port_id(port_id),
- callback(*this)
+ : port_id(port_id)
+ , callback(*this)
{
GetInterruptVectorsInstance().register_callback(interruptId, callback);
}
@@ -119,7 +119,8 @@ Uart uart1(0, USART1_IRQ_HANDLER);
Uart uart2(1, USART2_IRQ_HANDLER);
// Declare a global callback for the timer.
-// Uses the most efficient callback type for a class, as everything is known at compile time.
+// Uses the most efficient callback type for a class, as everything is known at
+// compile time.
etl::function_imp timer_member_callback;
// Declare the callbacks for the free functions.
diff --git a/examples/MutexMessageRouter/MutexMessageRouter.cpp b/examples/MutexMessageRouter/MutexMessageRouter.cpp
index 1d612673..b04a61f4 100644
--- a/examples/MutexMessageRouter/MutexMessageRouter.cpp
+++ b/examples/MutexMessageRouter/MutexMessageRouter.cpp
@@ -1,13 +1,13 @@
-#include
-#include
#include
-#include
#include
+#include
+#include
+#include
-#include "etl/mutex.h"
#include "etl/message.h"
#include "etl/message_router.h"
+#include "etl/mutex.h"
//*************************************
struct Message1 : public etl::message<1>
@@ -48,9 +48,7 @@ public:
}
//*****************
- void on_receive_unknown(const etl::imessage&)
- {
- }
+ void on_receive_unknown(const etl::imessage&) {}
std::string result;
@@ -61,7 +59,7 @@ private:
//*************************************
etl::atomic start = false;
-Router router;
+Router router;
//*************************************
void thread1()
@@ -106,5 +104,3 @@ int main()
return 0;
}
-
-
diff --git a/examples/QueuedFSM/QueuedFSM.cpp b/examples/QueuedFSM/QueuedFSM.cpp
index a0cbd029..5bda8913 100644
--- a/examples/QueuedFSM/QueuedFSM.cpp
+++ b/examples/QueuedFSM/QueuedFSM.cpp
@@ -31,9 +31,9 @@ SOFTWARE.
// derived class.
//*****************************************************************************
-#include "etl/queue.h"
#include "etl/fsm.h"
#include "etl/message_packet.h"
+#include "etl/queue.h"
#include
#include
@@ -122,7 +122,7 @@ public:
while (!queue.empty())
{
message_packet& packet = queue.front();
- etl::imessage& msg = packet.get();
+ etl::imessage& msg = packet.get();
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
// Call the base class's receive function.
@@ -258,7 +258,7 @@ int main()
State2 state2;
// The list of states.
- etl::ifsm_state* state_list[] = { &state1, &state2 };
+ etl::ifsm_state* state_list[] = {&state1, &state2};
// Define some messages.
Message1 m1(1);
@@ -285,4 +285,3 @@ int main()
return 0;
}
-
diff --git a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp
index f4348e5e..e9d815d2 100644
--- a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp
+++ b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp
@@ -1,6 +1,6 @@
-#include "etl/queue.h"
#include "etl/message_router.h"
+#include "etl/queue.h"
#include
#include
@@ -81,7 +81,7 @@ public:
while (!queue.empty())
{
message_packet& packet = queue.front();
- etl::imessage& msg = packet.get();
+ etl::imessage& msg = packet.get();
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
// Call the base class's receive function.
@@ -146,4 +146,3 @@ int main()
return 0;
}
-
diff --git a/examples/Scheduler/Scheduler.cpp b/examples/Scheduler/Scheduler.cpp
index 015822ae..3ea957be 100644
--- a/examples/Scheduler/Scheduler.cpp
+++ b/examples/Scheduler/Scheduler.cpp
@@ -31,9 +31,9 @@ SOFTWARE.
// Experiment with the different scheduling policies.
//*****************************************************************************
+#include "etl/function.h"
#include "etl/scheduler.h"
#include "etl/task.h"
-#include "etl/function.h"
#include
#include
@@ -50,13 +50,13 @@ public:
: task(1)
, work(3)
{
-
}
//*************************************
uint32_t task_request_work() const
{
- return work; // How much work do we still have to do? This could be a message queue length.
+ return work; // How much work do we still have to do? This could be a
+ // message queue length.
}
//*************************************
@@ -83,13 +83,13 @@ public:
: task(2)
, work(4)
{
-
}
//*************************************
uint32_t task_request_work() const
{
- return work; // How much work do we still have to do? This could be a message queue length.
+ return work; // How much work do we still have to do? This could be a
+ // message queue length.
}
//*************************************
@@ -115,7 +115,6 @@ public:
Idle(etl::ischeduler& scheduler_)
: scheduler(scheduler_)
{
-
}
//*************************************
@@ -181,4 +180,3 @@ int main()
return 0;
}
-
diff --git a/examples/SharedMessage/SharedMessage.cpp b/examples/SharedMessage/SharedMessage.cpp
index caaf4a0b..7bcbc27f 100644
--- a/examples/SharedMessage/SharedMessage.cpp
+++ b/examples/SharedMessage/SharedMessage.cpp
@@ -2,18 +2,18 @@
// Shared message example
//*****************************************************************************
-#include "etl/shared_message.h"
-#include "etl/message.h"
-#include "etl/reference_counted_message_pool.h"
-#include "etl/message_router.h"
-#include "etl/message_bus.h"
#include "etl/fixed_sized_memory_block_allocator.h"
+#include "etl/message.h"
+#include "etl/message_bus.h"
+#include "etl/message_router.h"
#include "etl/queue.h"
+#include "etl/reference_counted_message_pool.h"
+#include "etl/shared_message.h"
-#include
#include
-#include
+#include
#include
+#include
constexpr etl::message_router_id_t RouterId1 = 1U;
constexpr etl::message_router_id_t RouterId2 = 2U;
@@ -26,9 +26,8 @@ struct Message1 : public etl::message<1>
Message1(std::string s_)
: s(s_)
{
-
}
-
+
std::string s;
};
@@ -40,10 +39,10 @@ struct Message2 : public etl::message<2>
Message2(std::string s_)
: s(s_)
{
-
}
-
+
std::string s;
+
char data[100];
};
@@ -55,7 +54,6 @@ struct Message3 : public etl::message<3>
Message3(std::string s_)
: s(s_)
{
-
}
std::string s;
@@ -199,7 +197,7 @@ struct Bus : public etl::message_bus<2U>
//*****************************************************************************
MessageRouter1 router1;
MessageRouter2 router2;
-Bus bus;
+Bus bus;
//*****************************************************************************
// The thread safe message pool. Uses atomic uint32_t for counting.
@@ -230,8 +228,8 @@ private:
};
//*****************************************************************************
-// The memory block allocator that supplies the pool with memory
-// to store reference counted messages in.
+// The memory block allocator that supplies the pool with memory
+// to store reference counted messages in.
// The reference counted message parameters type for the messages we will use.
using message_parameters_small = MessagePool::pool_message_parameters;
@@ -243,10 +241,12 @@ constexpr size_t max_alignment_small = message_parameters_small::max_alignment;
constexpr size_t max_size_large = message_parameters_large::max_size;
constexpr size_t max_alignment_large = message_parameters_large::max_alignment;
-// A fixed memory block allocator for 4 items, using the parameters from the smaller messages.
+// A fixed memory block allocator for 4 items, using the parameters from the
+// smaller messages.
etl::fixed_sized_memory_block_allocator memory_allocator;
-// A fixed memory block allocator for 4 items, using the parameters from the larger message.
+// A fixed memory block allocator for 4 items, using the parameters from the
+// larger message.
etl::fixed_sized_memory_block_allocator memory_allocator_successor;
//*****************************************************************************
@@ -256,8 +256,8 @@ etl::fixed_sized_memory_block_allocator
MessagePool message_pool(memory_allocator);
//*****************************************************************************
-// A statically allocated reference counted message that is never allocated or released by a pool.
-// Contains a copy of Message3("Three").
+// A statically allocated reference counted message that is never allocated or
+// released by a pool. Contains a copy of Message3("Three").
//*****************************************************************************
etl::persistent_message pm3(Message3("Three"));
@@ -269,10 +269,15 @@ int main()
Message1 m1("One");
Message2 m2("Two");
-
- etl::shared_message sm1(message_pool, m1); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m1.
- etl::shared_message sm2(message_pool, m2); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m2.
- etl::shared_message sm3(pm3); // Created a shared message from a statically allocated persistent message.
+
+ etl::shared_message sm1(message_pool,
+ m1); // Created a shared message by allocating a reference counted message
+ // from message_pool containing a copy of m1.
+ etl::shared_message sm2(message_pool,
+ m2); // Created a shared message by allocating a reference counted message
+ // from message_pool containing a copy of m2.
+ etl::shared_message sm3(pm3); // Created a shared message from a statically
+ // allocated persistent message.
bus.subscribe(router1); // Subscribe router1 to the bus.
bus.subscribe(router2); // Subscribe router2 to the bus.
diff --git a/examples/UniquePtrWithPool/Main.cpp b/examples/UniquePtrWithPool/Main.cpp
index c3172ff9..30347951 100644
--- a/examples/UniquePtrWithPool/Main.cpp
+++ b/examples/UniquePtrWithPool/Main.cpp
@@ -6,7 +6,8 @@
struct S
{
S(int a_, double b_)
- : a(a_), b(b_)
+ : a(a_)
+ , b(b_)
{
}
@@ -17,11 +18,11 @@ struct S
int main()
{
etl::pool pool;
- auto pool_deleter = [&pool](auto ptr)
- {
- std::cout << "Releasing S(" << ptr->a << ", " << ptr->b << ") back to pool." << std::endl;
- pool.destroy(ptr);
- };
+ auto pool_deleter = [&pool](auto ptr)
+ {
+ std::cout << "Releasing S(" << ptr->a << ", " << ptr->b << ") back to pool." << std::endl;
+ pool.destroy(ptr);
+ };
using Unique = etl::unique_ptr;
Unique us1(pool.create(1, 2), pool_deleter);
diff --git a/examples/platformio/src/main.cpp b/examples/platformio/src/main.cpp
index 66295c17..0686ba82 100644
--- a/examples/platformio/src/main.cpp
+++ b/examples/platformio/src/main.cpp
@@ -88,35 +88,35 @@ public:
// Notify observers about a position event.
void Position_Event()
{
- Position position = { 100, 200 };
+ Position position = {100, 200};
notify_observers(position);
}
// Notify observers about a button up event.
void Button_Event_Up()
{
- Button button = { Button::Up };
+ Button button = {Button::Up};
notify_observers(button);
}
// Notify observers about a button down event.
void Button_Event_Down()
{
- Button button = { Button::Down };
+ Button button = {Button::Down};
notify_observers(button);
}
// Notify observers about a wheel up event.
void Wheel_Event_Up()
{
- Wheel wheel = { 50 };
+ Wheel wheel = {50};
notify_observers(wheel);
}
// Notify observers about a wheel down event.
void Wheel_Event_Down()
{
- Wheel wheel = { -25 };
+ Wheel wheel = {-25};
notify_observers(wheel);
}
};
@@ -137,6 +137,6 @@ int main()
mouse_driver.Position_Event();
mouse_driver.Wheel_Event_Down();
mouse_driver.Wheel_Event_Up();
-
+
return 0;
}
diff --git a/include/etl/absolute.h b/include/etl/absolute.h
index fc43717f..bfa68642 100644
--- a/include/etl/absolute.h
+++ b/include/etl/absolute.h
@@ -32,9 +32,9 @@ SOFTWARE.
#define ETL_ABSOLUTE_INCLUDED
#include "platform.h"
-#include "type_traits.h"
-#include "integral_limits.h"
#include "error_handler.h"
+#include "integral_limits.h"
+#include "type_traits.h"
namespace etl
{
@@ -52,26 +52,20 @@ namespace etl
ETL_ASSERT_FAIL(ETL_ERROR_GENERIC("absolute value of minimum signed integer is undefined"));
return T(0);
}
- }
+ } // namespace private_absolute
//***************************************************************************
// For signed types.
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- typename etl::enable_if::value && etl::is_integral::value, T>::type
- absolute(T value)
+ ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if< etl::is_signed::value && etl::is_integral::value, T>::type absolute(T value)
{
- return (value == etl::integral_limits::min) ? etl::private_absolute::signed_min_error()
- : static_cast((value < T(0)) ? -value : value);
+ return (value == etl::integral_limits::min) ? etl::private_absolute::signed_min_error() : static_cast((value < T(0)) ? -value : value);
}
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- typename etl::enable_if::value && !etl::is_integral::value, T>::type
- absolute(T value) ETL_NOEXCEPT
+ ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if< etl::is_signed::value && !etl::is_integral::value, T>::type absolute(T value)
+ ETL_NOEXCEPT
{
return (value < T(0)) ? -value : value;
}
@@ -80,10 +74,7 @@ namespace etl
// For unsigned types.
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- typename etl::enable_if::value, T>::type
- absolute(T value) ETL_NOEXCEPT
+ ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if::value, T>::type absolute(T value) ETL_NOEXCEPT
{
return value;
}
@@ -93,15 +84,14 @@ namespace etl
// Returns the result as the unsigned type.
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- typename etl::enable_if::value, typename etl::make_unsigned::type>::type
- absolute_unsigned(T value) ETL_NOEXCEPT
+ ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if::value, typename etl::make_unsigned::type>::type absolute_unsigned(T value)
+ ETL_NOEXCEPT
{
typedef typename etl::make_unsigned::type TReturn;
return (value == etl::integral_limits::min) ? (etl::integral_limits::max / 2U) + 1U
- : (value < T(0)) ? TReturn(-value) : TReturn(value);
+ : (value < T(0)) ? TReturn(-value)
+ : TReturn(value);
}
//***************************************************************************
@@ -109,14 +99,10 @@ namespace etl
// Returns the result as the unsigned type.
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- typename etl::enable_if::value, T>::type
- absolute_unsigned(T value) ETL_NOEXCEPT
+ ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if::value, T>::type absolute_unsigned(T value) ETL_NOEXCEPT
{
return etl::absolute(value);
}
-}
+} // namespace etl
#endif
-
diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h
index 3843ea9b..0a4348a2 100644
--- a/include/etl/algorithm.h
+++ b/include/etl/algorithm.h
@@ -39,16 +39,16 @@ SOFTWARE.
///\ingroup utilities
#include "platform.h"
-#include "type_traits.h"
-#include "iterator.h"
-#include "functional.h"
-#include "utility.h"
-#include "largest.h"
-#include "gcd.h"
#include "error_handler.h"
#include "exception.h"
-#include "ranges.h"
+#include "functional.h"
+#include "gcd.h"
#include "invoke.h"
+#include "iterator.h"
+#include "largest.h"
+#include "ranges.h"
+#include "type_traits.h"
+#include "utility.h"
#include
#include
@@ -57,10 +57,10 @@ SOFTWARE.
#if ETL_USING_STL
#include
- #include
- #include
#include
+ #include
#include
+ #include
#endif
namespace etl
@@ -68,11 +68,12 @@ namespace etl
// Declare prototypes of the ETL's sort functions
template
#if ETL_USING_STD_NAMESPACE
- ETL_CONSTEXPR20
+ ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
- void shell_sort(TIterator first, TIterator last);
+ void
+ shell_sort(TIterator first, TIterator last);
template
#if ETL_USING_STD_NAMESPACE
@@ -80,7 +81,8 @@ namespace etl
#else
ETL_CONSTEXPR14
#endif
- void shell_sort(TIterator first, TIterator last, TCompare compare);
+ void
+ shell_sort(TIterator first, TIterator last, TCompare compare);
template
ETL_CONSTEXPR14 void insertion_sort(TIterator first, TIterator last);
@@ -108,7 +110,7 @@ namespace etl
}
};
-}
+} // namespace etl
//*****************************************************************************
// Algorithms defined by the ETL
@@ -128,8 +130,8 @@ namespace etl
static void do_swap(TIterator1 a, TIterator2 b)
{
typename etl::iterator_traits::value_type tmp = *a;
- *a = *b;
- *b = tmp;
+ *a = *b;
+ *b = tmp;
}
};
@@ -144,7 +146,7 @@ namespace etl
swap(*a, *b);
}
};
- }
+ } // namespace private_algorithm
//***************************************************************************
// iter_swap
@@ -155,7 +157,8 @@ namespace etl
#else
ETL_CONSTEXPR14
#endif
- void iter_swap(TIterator1 a, TIterator2 b)
+ void
+ iter_swap(TIterator1 a, TIterator2 b)
{
typedef etl::iterator_traits traits1;
typedef etl::iterator_traits traits2;
@@ -166,9 +169,7 @@ namespace etl
typedef typename traits1::reference r1;
typedef typename traits2::reference r2;
- const bool use_swap = etl::is_same::value &&
- etl::is_reference::value &&
- etl::is_reference::value;
+ const bool use_swap = etl::is_same::value && etl::is_reference::value && etl::is_reference::value;
private_algorithm::swap_impl::do_swap(a, b);
}
@@ -182,9 +183,8 @@ namespace etl
#else
ETL_CONSTEXPR14
#endif
- TIterator2 swap_ranges(TIterator1 first1,
- TIterator1 last1,
- TIterator2 first2)
+ TIterator2
+ swap_ranges(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{
while (first1 != last1)
{
@@ -199,8 +199,7 @@ namespace etl
//***************************************************************************
// generate
template
- ETL_CONSTEXPR14
- void generate(TIterator db, TIterator de, TFunction funct)
+ ETL_CONSTEXPR14 void generate(TIterator db, TIterator de, TFunction funct)
{
while (db != de)
{
@@ -210,7 +209,7 @@ namespace etl
//***************************************************************************
// copy
-#if ETL_USING_STL && ETL_USING_CPP20
+#if ETL_USING_STL && ETL_USING_CPP20
// Use the STL constexpr implementation.
template
constexpr TIterator2 copy(TIterator1 sb, TIterator1 se, TIterator2 db)
@@ -243,8 +242,7 @@ namespace etl
}
#else
template
- ETL_CONSTEXPR14
- TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
+ ETL_CONSTEXPR14 TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
while (sb != se)
{
@@ -340,9 +338,9 @@ namespace etl
template
ETL_CONSTEXPR20 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
-#include "etl/private/diagnostic_array_bounds_push.h"
+ #include "etl/private/diagnostic_array_bounds_push.h"
return std::move_backward(sb, se, de);
-#include "etl/private/diagnostic_pop.h"
+ #include "etl/private/diagnostic_pop.h"
}
#elif ETL_USING_CPP11
// For C++11
@@ -370,9 +368,7 @@ namespace etl
//***************************************************************************
// Pointers
template
- ETL_CONSTEXPR14
- typename etl::enable_if::value, void>::type
- reverse(TIterator b, TIterator e)
+ ETL_CONSTEXPR14 typename etl::enable_if::value, void>::type reverse(TIterator b, TIterator e)
{
if (b != e)
{
@@ -386,9 +382,7 @@ namespace etl
// Non-pointers
template
- ETL_CONSTEXPR14
- typename etl::enable_if::value, void>::type
- reverse(TIterator b, TIterator e)
+ ETL_CONSTEXPR14 typename etl::enable_if::value, void>::type reverse(TIterator b, TIterator e)
{
while ((b != e) && (b != --e))
{
@@ -399,10 +393,8 @@ namespace etl
//***************************************************************************
// lower_bound
//***************************************************************************
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
{
typedef typename etl::iterator_traits::difference_type difference_t;
@@ -410,7 +402,7 @@ namespace etl
while (count > 0)
{
- TIterator itr = first;
+ TIterator itr = first;
difference_t step = count / 2;
etl::advance(itr, step);
@@ -429,10 +421,8 @@ namespace etl
return first;
}
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator lower_bound(TIterator first, TIterator last, const TValue& value)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator lower_bound(TIterator first, TIterator last, const TValue& value)
{
typedef etl::less::value_type> compare;
@@ -442,10 +432,8 @@ namespace etl
//***************************************************************************
// upper_bound
//***************************************************************************
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
{
typedef typename etl::iterator_traits::difference_type difference_t;
@@ -453,7 +441,7 @@ namespace etl
while (count > 0)
{
- TIterator itr = first;
+ TIterator itr = first;
difference_t step = count / 2;
etl::advance(itr, step);
@@ -472,10 +460,8 @@ namespace etl
return first;
}
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator upper_bound(TIterator first, TIterator last, const TValue& value)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator upper_bound(TIterator first, TIterator last, const TValue& value)
{
typedef etl::less::value_type> compare;
@@ -485,32 +471,26 @@ namespace etl
//***************************************************************************
// equal_range
//***************************************************************************
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- ETL_OR_STD::pair equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 ETL_OR_STD::pair equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare)
{
- return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare),
- etl::upper_bound(first, last, value, compare));
+ return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare), etl::upper_bound(first, last, value, compare));
}
- template
+ template
ETL_NODISCARD
ETL_OR_STD::pair equal_range(TIterator first, TIterator last, const TValue& value)
{
typedef etl::less::value_type> compare;
- return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare()),
- etl::upper_bound(first, last, value, compare()));
+ return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare()), etl::upper_bound(first, last, value, compare()));
}
//***************************************************************************
// binary_search
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool binary_search(TIterator first, TIterator last, const T& value, Compare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool binary_search(TIterator first, TIterator last, const T& value, Compare compare)
{
first = etl::lower_bound(first, last, value, compare);
@@ -518,9 +498,7 @@ namespace etl
}
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool binary_search(TIterator first, TIterator last, const T& value)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool binary_search(TIterator first, TIterator last, const T& value)
{
typedef etl::less::value_type> compare;
@@ -531,9 +509,7 @@ namespace etl
// find_if
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
while (first != last)
{
@@ -552,9 +528,7 @@ namespace etl
// find
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator find(TIterator first, TIterator last, const T& value)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator find(TIterator first, TIterator last, const T& value)
{
while (first != last)
{
@@ -572,13 +546,13 @@ namespace etl
//***************************************************************************
// fill
#if ETL_USING_STL && ETL_USING_CPP20
- template
+ template
constexpr void fill(TIterator first, TIterator last, const TValue& value)
{
std::fill(first, last, value);
}
#else
- template
+ template
ETL_CONSTEXPR14 void fill(TIterator first, TIterator last, const TValue& value)
{
while (first != last)
@@ -592,13 +566,13 @@ namespace etl
//***************************************************************************
// fill_n
#if ETL_USING_STL && ETL_USING_CPP20
- template
+ template
constexpr TIterator fill_n(TIterator first, TSize count, const TValue& value)
{
return std::fill_n(first, count, value);
}
#else
- template
+ template
ETL_CONSTEXPR14 TIterator fill_n(TIterator first, TSize count, const TValue& value)
{
while (count != 0)
@@ -615,9 +589,7 @@ namespace etl
// count
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- typename etl::iterator_traits::difference_type count(TIterator first, TIterator last, const T& value)
+ ETL_NODISCARD ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type count(TIterator first, TIterator last, const T& value)
{
typename iterator_traits::difference_type n = 0;
@@ -638,10 +610,7 @@ namespace etl
// count_if
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- typename etl::iterator_traits::difference_type
- count_if(TIterator first, TIterator last, TUnaryPredicate predicate)
+ ETL_NODISCARD ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type count_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
typename iterator_traits::difference_type n = 0;
@@ -664,8 +633,7 @@ namespace etl
// Three parameter
template
[[nodiscard]]
- constexpr
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
+ constexpr bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{
return std::equal(first1, last1, first2);
}
@@ -673,8 +641,7 @@ namespace etl
// Three parameter + predicate
template
[[nodiscard]]
- constexpr
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
+ constexpr bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
{
return std::equal(first1, last1, first2, predicate);
}
@@ -682,8 +649,7 @@ namespace etl
// Four parameter
template
[[nodiscard]]
- constexpr
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
+ constexpr bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
{
return std::equal(first1, last1, first2, last2);
}
@@ -691,8 +657,7 @@ namespace etl
// Four parameter + Predicate
template
[[nodiscard]]
- constexpr
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
+ constexpr bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
{
return std::equal(first1, last1, first2, last2, predicate);
}
@@ -700,9 +665,7 @@ namespace etl
#else
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{
while (first1 != last1)
{
@@ -720,9 +683,7 @@ namespace etl
// Predicate
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
{
while (first1 != last1)
{
@@ -740,9 +701,7 @@ namespace etl
// Four parameter
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
{
while ((first1 != last1) && (first2 != last2))
{
@@ -760,13 +719,11 @@ namespace etl
// Four parameter, Predicate
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
{
while ((first1 != last1) && (first2 != last2))
{
- if (!predicate(*first1 , *first2))
+ if (!predicate(*first1, *first2))
{
return false;
}
@@ -783,11 +740,7 @@ namespace etl
// lexicographical_compare
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
- TIterator2 first2, TIterator2 last2,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool lexicographical_compare(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TCompare compare)
{
while ((first1 != last1) && (first2 != last2))
{
@@ -810,10 +763,7 @@ namespace etl
// lexicographical_compare
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
- TIterator2 first2, TIterator2 last2)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool lexicographical_compare(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
{
typedef etl::less::value_type> compare;
@@ -824,17 +774,13 @@ namespace etl
// min
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- const T& min(const T& a, const T& b, TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR const T& min(const T& a, const T& b, TCompare compare)
{
return (compare(a, b)) ? a : b;
}
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- const T& min(const T& a, const T& b)
+ ETL_NODISCARD ETL_CONSTEXPR const T& min(const T& a, const T& b)
{
typedef etl::less compare;
@@ -845,17 +791,13 @@ namespace etl
// max
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- const T& max(const T& a, const T& b, TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR const T& max(const T& a, const T& b, TCompare compare)
{
return (compare(a, b)) ? b : a;
}
template
- ETL_NODISCARD
- ETL_CONSTEXPR
- const T& max(const T& a, const T& b)
+ ETL_NODISCARD ETL_CONSTEXPR const T& max(const T& a, const T& b)
{
typedef etl::less compare;
@@ -866,8 +808,7 @@ namespace etl
// for_each
//***************************************************************************
template
- ETL_CONSTEXPR14
- TUnaryOperation for_each(TIterator first, TIterator last, TUnaryOperation unary_operation)
+ ETL_CONSTEXPR14 TUnaryOperation for_each(TIterator first, TIterator last, TUnaryOperation unary_operation)
{
while (first != last)
{
@@ -882,8 +823,7 @@ namespace etl
// transform
//***************************************************************************
template
- ETL_CONSTEXPR14
- TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation)
+ ETL_CONSTEXPR14 TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation)
{
while (first1 != last1)
{
@@ -897,8 +837,8 @@ namespace etl
}
template
- ETL_CONSTEXPR14
- TIteratorOut transform(TIteratorIn1 first1, TIteratorIn1 last1, TIteratorIn2 first2, TIteratorOut d_first, TBinaryOperation binary_operation)
+ ETL_CONSTEXPR14 TIteratorOut transform(TIteratorIn1 first1, TIteratorIn1 last1, TIteratorIn2 first2, TIteratorOut d_first,
+ TBinaryOperation binary_operation)
{
while (first1 != last1)
{
@@ -960,8 +900,8 @@ namespace etl
while ((value_index > top_index) && compare(first[parent], value))
{
first[value_index] = ETL_MOVE(first[parent]);
- value_index = parent;
- parent = (value_index - 1) / 2;
+ value_index = parent;
+ parent = (value_index - 1) / 2;
}
first[value_index] = ETL_MOVE(value);
@@ -972,7 +912,7 @@ namespace etl
ETL_CONSTEXPR14 void adjust_heap(TIterator first, TDistance value_index, TDistance length, TValue value, TCompare compare)
{
TDistance top_index = value_index;
- TDistance child2nd = (2 * value_index) + 2;
+ TDistance child2nd = (2 * value_index) + 2;
while (child2nd < length)
{
@@ -982,14 +922,14 @@ namespace etl
}
first[value_index] = ETL_MOVE(first[child2nd]);
- value_index = child2nd;
- child2nd = 2 * (child2nd + 1);
+ value_index = child2nd;
+ child2nd = 2 * (child2nd + 1);
}
if (child2nd == length)
{
first[value_index] = ETL_MOVE(first[child2nd - 1]);
- value_index = child2nd - 1;
+ value_index = child2nd - 1;
}
push_heap(first, value_index, top_index, ETL_MOVE(value), compare);
@@ -1016,26 +956,24 @@ namespace etl
return true;
}
- }
+ } // namespace private_heap
// Pop Heap
template
- ETL_CONSTEXPR14
- void pop_heap(TIterator first, TIterator last, TCompare compare)
+ ETL_CONSTEXPR14 void pop_heap(TIterator first, TIterator last, TCompare compare)
{
- typedef typename etl::iterator_traits::value_type value_t;
+ typedef typename etl::iterator_traits::value_type value_t;
typedef typename etl::iterator_traits::difference_type distance_t;
value_t value = ETL_MOVE(last[-1]);
- last[-1] = ETL_MOVE(first[0]);
+ last[-1] = ETL_MOVE(first[0]);
private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), ETL_MOVE(value), compare);
}
// Pop Heap
template
- ETL_CONSTEXPR14
- void pop_heap(TIterator first, TIterator last)
+ ETL_CONSTEXPR14 void pop_heap(TIterator first, TIterator last)
{
typedef etl::less::value_type> compare;
@@ -1044,8 +982,7 @@ namespace etl
// Push Heap
template
- ETL_CONSTEXPR14
- void push_heap(TIterator first, TIterator last, TCompare compare)
+ ETL_CONSTEXPR14 void push_heap(TIterator first, TIterator last, TCompare compare)
{
typedef typename etl::iterator_traits::difference_type difference_t;
typedef typename etl::iterator_traits::value_type value_t;
@@ -1055,8 +992,7 @@ namespace etl
// Push Heap
template
- ETL_CONSTEXPR14
- void push_heap(TIterator first, TIterator last)
+ ETL_CONSTEXPR14 void push_heap(TIterator first, TIterator last)
{
typedef etl::less::value_type> compare;
@@ -1065,8 +1001,7 @@ namespace etl
// Make Heap
template
- ETL_CONSTEXPR14
- void make_heap(TIterator first, TIterator last, TCompare compare)
+ ETL_CONSTEXPR14 void make_heap(TIterator first, TIterator last, TCompare compare)
{
typedef typename etl::iterator_traits::difference_type difference_t;
@@ -1093,8 +1028,7 @@ namespace etl
// Make Heap
template
- ETL_CONSTEXPR14
- void make_heap(TIterator first, TIterator last)
+ ETL_CONSTEXPR14 void make_heap(TIterator first, TIterator last)
{
typedef etl::less::value_type> compare;
@@ -1103,9 +1037,7 @@ namespace etl
// Is Heap
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool is_heap(TIterator first, TIterator last)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool is_heap(TIterator first, TIterator last)
{
typedef etl::less::value_type> compare;
@@ -1114,17 +1046,14 @@ namespace etl
// Is Heap
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool is_heap(TIterator first, TIterator last, TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 bool is_heap(TIterator first, TIterator last, TCompare compare)
{
return private_heap::is_heap(first, last - first, compare);
}
// Sort Heap
template
- ETL_CONSTEXPR14
- void sort_heap(TIterator first, TIterator last)
+ ETL_CONSTEXPR14 void sort_heap(TIterator first, TIterator last)
{
while (first != last)
{
@@ -1135,8 +1064,7 @@ namespace etl
// Sort Heap
template
- ETL_CONSTEXPR14
- void sort_heap(TIterator first, TIterator last, TCompare compare)
+ ETL_CONSTEXPR14 void sort_heap(TIterator first, TIterator last, TCompare compare)
{
while (first != last)
{
@@ -1148,11 +1076,10 @@ namespace etl
//***************************************************************************
/// partial_sort
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/partial_sort">
//***************************************************************************
template
- ETL_CONSTEXPR14
- void partial_sort(TIterator first, TIterator middle, TIterator last, TCompare compare)
+ ETL_CONSTEXPR14 void partial_sort(TIterator first, TIterator middle, TIterator last, TCompare compare)
{
if (first == middle)
{
@@ -1160,7 +1087,7 @@ namespace etl
}
typedef typename etl::iterator_traits::value_type value_t;
- typedef typename etl::iterator_traits::difference_type difference_t;
+ typedef typename etl::iterator_traits::difference_type difference_t;
etl::make_heap(first, middle, compare);
@@ -1169,7 +1096,7 @@ namespace etl
if (compare(*i, *first))
{
value_t value = ETL_MOVE(*i);
- *i = ETL_MOVE(*first);
+ *i = ETL_MOVE(*first);
private_heap::adjust_heap(first, difference_t(0), difference_t(middle - first), ETL_MOVE(value), compare);
}
@@ -1181,11 +1108,10 @@ namespace etl
//***************************************************************************
/// partial_sort
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/partial_sort">
//***************************************************************************
template
- ETL_CONSTEXPR14
- void partial_sort(TIterator first, TIterator middle, TIterator last)
+ ETL_CONSTEXPR14 void partial_sort(TIterator first, TIterator middle, TIterator last)
{
typedef etl::less::value_type> compare;
@@ -1195,18 +1121,15 @@ namespace etl
//***************************************************************************
/// partial_sort_copy
///\ingroup algorithm
- ///
+ ///< a
+ ///< href="http://en.cppreference.com/w/cpp/algorithm/partial_sort_copy">
//***************************************************************************
template
- ETL_CONSTEXPR14
- TRandomAccessIterator partial_sort_copy(TInputIterator first,
- TInputIterator last,
- TRandomAccessIterator d_first,
- TRandomAccessIterator d_last,
- TCompare compare)
+ ETL_CONSTEXPR14 TRandomAccessIterator partial_sort_copy(TInputIterator first, TInputIterator last, TRandomAccessIterator d_first,
+ TRandomAccessIterator d_last, TCompare compare)
{
typedef typename etl::iterator_traits::value_type value_t;
- typedef typename etl::iterator_traits::difference_type difference_t;
+ typedef typename etl::iterator_traits::difference_type difference_t;
TRandomAccessIterator result = d_first;
@@ -1244,16 +1167,14 @@ namespace etl
//***************************************************************************
/// partial_sort_copy
///\ingroup algorithm
- ///
+ ///< a
+ ///< href="http://en.cppreference.com/w/cpp/algorithm/partial_sort_copy">
//***************************************************************************
template
- ETL_CONSTEXPR14
- TRandomAccessIterator partial_sort_copy(TInputIterator first,
- TInputIterator last,
- TRandomAccessIterator d_first,
- TRandomAccessIterator d_last)
+ ETL_CONSTEXPR14 TRandomAccessIterator partial_sort_copy(TInputIterator first, TInputIterator last, TRandomAccessIterator d_first,
+ TRandomAccessIterator d_last)
{
- typedef etl::less::value_type> compare;
+ typedef etl::less< typename etl::iterator_traits::value_type> compare;
return etl::partial_sort_copy(first, last, d_first, d_last, compare());
}
@@ -1261,14 +1182,12 @@ namespace etl
//***************************************************************************
// Search
//***************************************************************************
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare)
{
while (true)
{
- TIterator1 itr = first;
+ TIterator1 itr = first;
TIterator2 search_itr = search_first;
while (true)
@@ -1297,10 +1216,8 @@ namespace etl
}
// Search
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last)
{
typedef etl::equal_to::value_type> compare;
@@ -1315,9 +1232,8 @@ namespace etl
//*********************************
// For random access iterators
template
- ETL_CONSTEXPR14
- typename etl::enable_if::value, TIterator>::type
- rotate_general(TIterator first, TIterator middle, TIterator last)
+ ETL_CONSTEXPR14 typename etl::enable_if::value, TIterator>::type
+ rotate_general(TIterator first, TIterator middle, TIterator last)
{
if (first == middle)
{
@@ -1329,35 +1245,35 @@ namespace etl
return first;
}
- typedef typename etl::iterator_traits::value_type value_type;
+ typedef typename etl::iterator_traits::value_type value_type;
typedef typename etl::iterator_traits::difference_type difference_type;
- difference_type n = last - first;
- difference_type m = middle - first;
+ difference_type n = last - first;
+ difference_type m = middle - first;
difference_type gcd_nm = (n == 0 || m == 0) ? n + m : etl::gcd(n, m);
- TIterator result = first + (last - middle);
+ TIterator result = first + (last - middle);
for (difference_type i = 0; i < gcd_nm; i++)
{
- value_type temp = ETL_MOVE(*(first + i));
- difference_type j = i;
-
- while (true)
+ value_type temp = ETL_MOVE(*(first + i));
+ difference_type j = i;
+
+ while (true)
{
difference_type k = j + m;
-
+
if (k >= n)
{
k = k - n;
}
-
+
if (k == i)
{
break;
}
*(first + j) = ETL_MOVE(*(first + k));
- j = k;
+ j = k;
}
*(first + j) = ETL_MOVE(temp);
@@ -1369,8 +1285,7 @@ namespace etl
//*********************************
// For bidirectional iterators
template
- ETL_CONSTEXPR14
- typename etl::enable_if::value, TIterator>::type
+ ETL_CONSTEXPR14 typename etl::enable_if::value, TIterator>::type
rotate_general(TIterator first, TIterator middle, TIterator last)
{
if (first == middle)
@@ -1396,9 +1311,8 @@ namespace etl
//*********************************
// For forward iterators
template
- ETL_CONSTEXPR14
- typename etl::enable_if::value, TIterator>::type
- rotate_general(TIterator first, TIterator middle, TIterator last)
+ ETL_CONSTEXPR14 typename etl::enable_if::value, TIterator>::type rotate_general(TIterator first, TIterator middle,
+ TIterator last)
{
if (first == middle)
{
@@ -1410,7 +1324,7 @@ namespace etl
return first;
}
- TIterator next = middle;
+ TIterator next = middle;
TIterator result = first;
etl::advance(result, etl::distance(middle, last));
@@ -1435,8 +1349,7 @@ namespace etl
//*********************************
// Simplified algorithm for rotate left by one
template
- ETL_CONSTEXPR14
- TIterator rotate_left_by_one(TIterator first, TIterator last)
+ ETL_CONSTEXPR14 TIterator rotate_left_by_one(TIterator first, TIterator last)
{
typedef typename etl::iterator_traits::value_type value_type;
@@ -1456,13 +1369,12 @@ namespace etl
//*********************************
// Simplified for algorithm rotate right by one
template
- ETL_CONSTEXPR14
- TIterator rotate_right_by_one(TIterator first, TIterator last)
+ ETL_CONSTEXPR14 TIterator rotate_right_by_one(TIterator first, TIterator last)
{
typedef typename etl::iterator_traits::value_type value_type;
// Save the last item.
- TIterator previous = etl::prev(last);
+ TIterator previous = etl::prev(last);
value_type temp(ETL_MOVE(*previous));
// Move the rest.
@@ -1474,12 +1386,11 @@ namespace etl
// The new position of the first item.
return result;
}
- }
+ } // namespace private_algorithm
//*********************************
- template
- ETL_CONSTEXPR14
- TIterator rotate(TIterator first, TIterator middle, TIterator last)
+ template
+ ETL_CONSTEXPR14 TIterator rotate(TIterator first, TIterator middle, TIterator last)
{
if (first == middle)
{
@@ -1498,7 +1409,7 @@ namespace etl
#if ETL_USING_CPP20
if (etl::next(middle) == last)
{
- if ETL_IF_CONSTEXPR(etl::is_bidirectional_iterator_concept::value)
+ if ETL_IF_CONSTEXPR (etl::is_bidirectional_iterator_concept< TIterator>::value)
{
return private_algorithm::rotate_right_by_one(first, last);
}
@@ -1513,11 +1424,7 @@ namespace etl
//***************************************************************************
// Predicate
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator1 find_end(TIterator1 b, TIterator1 e,
- TIterator2 sb, TIterator2 se,
- TPredicate predicate)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator1 find_end(TIterator1 b, TIterator1 e, TIterator2 sb, TIterator2 se, TPredicate predicate)
{
if (sb == se)
{
@@ -1537,7 +1444,7 @@ namespace etl
else
{
result = new_result;
- b = result;
+ b = result;
++b;
}
}
@@ -1546,10 +1453,7 @@ namespace etl
// Default
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator1 find_end(TIterator1 b, TIterator1 e,
- TIterator2 sb, TIterator2 se)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator1 find_end(TIterator1 b, TIterator1 e, TIterator2 sb, TIterator2 se)
{
typedef etl::equal_to::value_type> predicate;
@@ -1558,15 +1462,11 @@ namespace etl
//***************************************************************************
/// Finds the iterator to the smallest element in the range (begin, end).
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/min_element">
///\ingroup algorithm
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator min_element(TIterator begin,
- TIterator end,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator min_element(TIterator begin, TIterator end, TCompare compare)
{
TIterator minimum = begin;
@@ -1591,13 +1491,10 @@ namespace etl
//***************************************************************************
/// min_element
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/min_element">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator min_element(TIterator begin,
- TIterator end)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator min_element(TIterator begin, TIterator end)
{
typedef typename etl::iterator_traits::value_type value_t;
@@ -1606,15 +1503,11 @@ namespace etl
//***************************************************************************
/// Finds the iterator to the largest element in the range (begin, end).
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/max_element">
///\ingroup algorithm
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator max_element(TIterator begin,
- TIterator end,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator max_element(TIterator begin, TIterator end, TCompare compare)
{
TIterator maximum = begin;
@@ -1639,13 +1532,10 @@ namespace etl
//***************************************************************************
/// max_element
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/max_element">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator max_element(TIterator begin,
- TIterator end)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator max_element(TIterator begin, TIterator end)
{
typedef typename etl::iterator_traits::value_type value_t;
@@ -1654,15 +1544,11 @@ namespace etl
//***************************************************************************
/// Finds the greatest and the smallest element in the range (begin, end).
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element">
///\ingroup algorithm
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- ETL_OR_STD::pair minmax_element(TIterator begin,
- TIterator end,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 ETL_OR_STD::pair minmax_element(TIterator begin, TIterator end, TCompare compare)
{
TIterator minimum = begin;
TIterator maximum = begin;
@@ -1693,13 +1579,10 @@ namespace etl
//***************************************************************************
/// minmax_element
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- ETL_OR_STD::pair minmax_element(TIterator begin,
- TIterator end)
+ ETL_NODISCARD ETL_CONSTEXPR14 ETL_OR_STD::pair minmax_element(TIterator begin, TIterator end)
{
typedef typename etl::iterator_traits::value_type value_t;
@@ -1709,13 +1592,10 @@ namespace etl
//***************************************************************************
/// minmax
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/minmax">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- ETL_OR_STD::pair minmax(const T& a,
- const T& b)
+ ETL_NODISCARD ETL_CONSTEXPR14 ETL_OR_STD::pair minmax(const T& a, const T& b)
{
return (b < a) ? ETL_OR_STD::pair(b, a) : ETL_OR_STD::pair(a, b);
}
@@ -1723,14 +1603,10 @@ namespace etl
//***************************************************************************
/// minmax
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/minmax">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- ETL_OR_STD::pair minmax(const T& a,
- const T& b,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 ETL_OR_STD::pair minmax(const T& a, const T& b, TCompare compare)
{
return compare(b, a) ? ETL_OR_STD::pair(b, a) : ETL_OR_STD::pair(a, b);
}
@@ -1738,14 +1614,10 @@ namespace etl
//***************************************************************************
/// is_sorted_until
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted_until">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator is_sorted_until(TIterator begin,
- TIterator end,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator is_sorted_until(TIterator begin, TIterator end, TCompare compare)
{
if (begin != end)
{
@@ -1768,13 +1640,10 @@ namespace etl
//***************************************************************************
/// is_sorted_until
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted_until">
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator is_sorted_until(TIterator begin,
- TIterator end)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator is_sorted_until(TIterator begin, TIterator end)
{
typedef etl::less::value_type> compare;
@@ -1784,13 +1653,10 @@ namespace etl
//***************************************************************************
/// is_sorted
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted">
//***************************************************************************
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool is_sorted(TIterator begin,
- TIterator end)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 bool is_sorted(TIterator begin, TIterator end)
{
return etl::is_sorted_until(begin, end) == end;
}
@@ -1798,14 +1664,10 @@ namespace etl
//***************************************************************************
/// is_sorted
///\ingroup algorithm
- ///
+ ///< a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted">
//***************************************************************************
- template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- bool is_sorted(TIterator begin,
- TIterator end,
- TCompare compare)
+ template
+ ETL_NODISCARD ETL_CONSTEXPR14 bool is_sorted(TIterator begin, TIterator end, TCompare compare)
{
return etl::is_sorted_until(begin, end, compare) == end;
}
@@ -1815,11 +1677,7 @@ namespace etl
///\ingroup algorithm
//***************************************************************************
template
- ETL_NODISCARD
- ETL_CONSTEXPR14
- TIterator is_unique_sorted_until(TIterator begin,
- TIterator end,
- TCompare compare)
+ ETL_NODISCARD ETL_CONSTEXPR14 TIterator is_unique_sorted_until(TIterator begin, TIterator end, TCompare compare)
{
if (begin != end)
{
@@ -1844,10 +1702,7 @@ namespace etl
///\ingroup algorithm
//***************************************************************************
template