aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/hal/osal/os-less/ARMCMx/osal.h8
-rw-r--r--os/nil/include/nil.h8
-rw-r--r--os/rt/include/chvt.h16
3 files changed, 17 insertions, 15 deletions
diff --git a/os/hal/osal/os-less/ARMCMx/osal.h b/os/hal/osal/os-less/ARMCMx/osal.h
index 66cb594a5..c54ed9327 100644
--- a/os/hal/osal/os-less/ARMCMx/osal.h
+++ b/os/hal/osal/os-less/ARMCMx/osal.h
@@ -425,8 +425,8 @@ typedef struct {
* @api
*/
#define OSAL_MS2ST(msec) \
- ((systime_t)((((((uint32_t)(msec)) * \
- ((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000UL) + 1UL))
+ ((systime_t)((((uint32_t)(msec)) * \
+ ((uint32_t)OSAL_ST_FREQUENCY) + 999UL) / 1000UL))
/**
* @brief Microseconds to system ticks.
@@ -439,8 +439,8 @@ typedef struct {
* @api
*/
#define OSAL_US2ST(usec) \
- ((systime_t)((((((uint32_t)(usec)) * \
- ((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000000UL) + 1UL))
+ ((systime_t)((((uint32_t)(usec)) * \
+ ((uint32_t)OSAL_ST_FREQUENCY) + 999999UL) / 1000000UL))
/** @} */
/**
diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h
index 3babb8da9..e17aeef99 100644
--- a/os/nil/include/nil.h
+++ b/os/nil/include/nil.h
@@ -596,8 +596,8 @@ struct nil_system {
* @api
*/
#define MS2ST(msec) \
- ((systime_t)((((((uint32_t)(msec)) * \
- ((uint32_t)NIL_CFG_ST_FREQUENCY)) - 1UL) / 1000UL) + 1UL))
+ ((systime_t)((((uint32_t)(msec)) * \
+ ((uint32_t)NIL_CFG_ST_FREQUENCY) + 999UL) / 1000UL))
/**
* @brief Microseconds to system ticks.
@@ -610,8 +610,8 @@ struct nil_system {
* @api
*/
#define US2ST(usec) \
- ((systime_t)((((((uint32_t)(usec)) * \
- ((uint32_t)NIL_CFG_ST_FREQUENCY)) - 1UL) / 1000000UL) + 1UL))
+ ((systime_t)((((uint32_t)(usec)) * \
+ ((uint32_t)NIL_CFG_ST_FREQUENCY) + 999999UL) / 1000000UL))
/** @} */
/**
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index 01dc38ac6..ae26beacf 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -118,8 +118,8 @@
* @api
*/
#define MS2ST(msec) \
- ((systime_t)((((((uint32_t)(msec)) * \
- ((uint32_t)CH_CFG_ST_FREQUENCY)) - 1UL) / 1000UL) + 1UL))
+ ((systime_t)((((uint32_t)(msec)) * \
+ ((uint32_t)CH_CFG_ST_FREQUENCY) + 999UL) / 1000UL))
/**
* @brief Microseconds to system ticks.
@@ -132,8 +132,8 @@
* @api
*/
#define US2ST(usec) \
- ((systime_t)((((((uint32_t)(usec)) * \
- ((uint32_t)CH_CFG_ST_FREQUENCY)) - 1UL) / 1000000UL) + 1UL))
+ ((systime_t)((((uint32_t)(usec)) * \
+ ((uint32_t)CH_CFG_ST_FREQUENCY) + 999999UL) / 1000000UL))
/**
* @brief System ticks to seconds.
@@ -145,7 +145,7 @@
*
* @api
*/
-#define ST2S(n) (((((n) - 1UL) * 1UL) / CH_CFG_ST_FREQUENCY) + 1UL)
+#define ST2S(n) (((n) + CH_CFG_ST_FREQUENCY - 1UL) / CH_CFG_ST_FREQUENCY)
/**
* @brief System ticks to milliseconds.
@@ -157,7 +157,8 @@
*
* @api
*/
-#define ST2MS(n) (((((n) - 1UL) * 1000UL) / CH_CFG_ST_FREQUENCY) + 1UL)
+#define ST2MS(n) (((n) * 1000UL + CH_CFG_ST_FREQUENCY - 1UL) / \
+ CH_CFG_ST_FREQUENCY)
/**
* @brief System ticks to microseconds.
@@ -169,7 +170,8 @@
*
* @api
*/
-#define ST2US(n) (((((n) - 1UL) * 1000000UL) / CH_CFG_ST_FREQUENCY) + 1UL)
+#define ST2US(n) (((n) * 1000000UL + CH_CFG_ST_FREQUENCY - 1UL) / \
+ CH_CFG_ST_FREQUENCY)
/** @} */
/*===========================================================================*/