diff --git a/os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h b/os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h index 43277ee96..e742a7e66 100644 --- a/os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h +++ b/os/common/ports/ARMCMx/devices/STM32F4xx/cmparams.h @@ -57,7 +57,7 @@ * @note This number does not include the 16 system vectors and must be * rounded to a multiple of 8. */ -#define CORTEX_NUM_VECTORS 88 +#define CORTEX_NUM_VECTORS 96 /* The following code is not processed when the file is included from an asm module.*/ @@ -66,7 +66,8 @@ /* If the device type is not externally defined, for example from the Makefile, then a file named board.h is included. This file must contain a device definition compatible with the vendor include file.*/ -#if !defined(STM32F40XX) && !defined(STM32F427X) +#if !defined(STM32F40_41xxx) && !defined(STM32F427_437xx) && \ + !defined(STM32F429_439xx) && !defined(STM32F401xx) #include "board.h" #endif diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h index 9a74788ae..1b80bba65 100644 --- a/os/rt/include/chsys.h +++ b/os/rt/include/chsys.h @@ -145,35 +145,38 @@ /** * @brief Realtime counter cycles to seconds. * @details Converts from realtime counter cycles number to seconds. + * @note The result is rounded up to the next second boundary. * * @param[in] n number of cycles * @return The number of seconds. * * @api */ -#define RTC2S(n) (rtcnt_t)(CH_CFG_RTC_FREQUENCY / (freq)) +#define RTC2S(n) ((((n) - 1UL) / CH_CFG_RTC_FREQUENCY) + 1UL) /** * @brief Realtime counter cycles to milliseconds. * @details Converts from realtime counter cycles number to milliseconds. + * @note The result is rounded up to the next millisecond boundary. * * @param[in] n number of cycles * @return The number of milliseconds. * * @api */ -#define RTC2MS(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000UL)) +#define RTC2MS(n) ((((n) - 1UL) / (CH_CFG_RTC_FREQUENCY / 1000UL)) + 1UL) /** * @brief Realtime counter cycles to microseconds. * @details Converts from realtime counter cycles number to microseconds. + * @note The result is rounded up to the next microsecond boundary. * * @param[in] n number of cycles * @return The number of microseconds. * * @api */ -#define RTC2US(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000000UL)) +#define RTC2US(n) ((((n) - 1UL) / (CH_CFG_RTC_FREQUENCY / 1000000UL)) + 1UL) /** @} */ /** diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h index ea84df9fd..35d9986c0 100644 --- a/os/rt/include/chvt.h +++ b/os/rt/include/chvt.h @@ -160,6 +160,42 @@ struct virtual_timer { #define US2ST(usec) \ ((systime_t)(((((uint32_t)(usec)) * \ ((uint32_t)CH_CFG_ST_FREQUENCY) - 1UL) / 1000000UL) + 1UL)) + +/** + * @brief System ticks to seconds. + * @details Converts from system ticks number to seconds. + * @note The result is rounded up to the next second boundary. + * + * @param[in] n number of system ticks + * @return The number of seconds. + * + * @api + */ +#define ST2S(n) ((((n) - 1UL) / CH_CFG_ST_FREQUENCY) + 1UL) + +/** + * @brief System ticks to milliseconds. + * @details Converts from system ticks number to milliseconds. + * @note The result is rounded up to the next millisecond boundary. + * + * @param[in] n number of system ticks + * @return The number of milliseconds. + * + * @api + */ +#define ST2MS(n) ((((n) - 1UL) / (CH_CFG_ST_FREQUENCY / 1000UL)) + 1UL) + +/** + * @brief System ticks to microseconds. + * @details Converts from system ticks number to microseconds. + * @note The result is rounded up to the next microsecond boundary. + * + * @param[in] n number of system ticks + * @return The number of microseconds. + * + * @api + */ +#define ST2US(n) ((((n) - 1UL) / (CH_CFG_ST_FREQUENCY / 1000000UL)) + 1UL) /** @} */ /*===========================================================================*/