diff options
| -rw-r--r-- | os/hal/include/st.h | 11 | ||||
| -rw-r--r-- | os/hal/platforms/STM32/TIMv1/st_lld.h | 14 | ||||
| -rw-r--r-- | os/rt/include/chdebug.h | 4 | ||||
| -rw-r--r-- | os/rt/ports/ARMCMx/chcore_timer.h | 9 | 
4 files changed, 36 insertions, 2 deletions
diff --git a/os/hal/include/st.h b/os/hal/include/st.h index 05d382d93..b2cb00543 100644 --- a/os/hal/include/st.h +++ b/os/hal/include/st.h @@ -111,6 +111,17 @@   * @api
   */
  #define stGetAlarm() st_lld_get_alarm()
 +
 +/**
 + * @brief   Determines if the alarm is active.
 + *
 + * @return              The alarm status.
 + * @retval false        if the alarm is not active.
 + * @retval true         is the alarm is active
 + *
 + * @api
 + */
 +#define stIsAlarmActive() st_lld_is_alarm_active()
  /** @} */
  /*===========================================================================*/
 diff --git a/os/hal/platforms/STM32/TIMv1/st_lld.h b/os/hal/platforms/STM32/TIMv1/st_lld.h index 882472cb2..fb067f202 100644 --- a/os/hal/platforms/STM32/TIMv1/st_lld.h +++ b/os/hal/platforms/STM32/TIMv1/st_lld.h @@ -128,6 +128,20 @@ static inline systime_t st_lld_get_alarm(void) {    return (systime_t)STM32_TIM2->CCR[0];
  }
 +/**
 + * @brief   Determines if the alarm is active.
 + *
 + * @return              The alarm status.
 + * @retval false        if the alarm is not active.
 + * @retval true         is the alarm is active
 + *
 + * @notapi
 + */
 +static inline bool st_lld_is_alarm_active(void) {
 +
 +  return (bool)((STM32_TIM2->DIER & STM32_TIM_DIER_CC1IE) != 0);
 +}
 +
  #endif /* _ST_LLD_H_ */
  /** @} */
 diff --git a/os/rt/include/chdebug.h b/os/rt/include/chdebug.h index ee49eec00..0fdc865eb 100644 --- a/os/rt/include/chdebug.h +++ b/os/rt/include/chdebug.h @@ -175,7 +175,7 @@ typedef struct {  #endif /* !defined(chDbgCheck) */
  #else /* !CH_DBG_ENABLE_CHECKS */
 -#define chDbgCheck(c) {(void)(c);}
 +#define chDbgCheck(c) /*{(void)(c);}*/
  #endif /* !CH_DBG_ENABLE_CHECKS */
  #if CH_DBG_ENABLE_ASSERTS || defined(__DOXYGEN__)
 @@ -200,7 +200,7 @@ typedef struct {  }
  #endif /* !defined(chDbgAssert) */
  #else /* !CH_DBG_ENABLE_ASSERTS */
 -#define chDbgAssert(c, r) {(void)(c);}
 +#define chDbgAssert(c, r) /*{(void)(c);}*/
  #endif /* !CH_DBG_ENABLE_ASSERTS */
  /** @} */
 diff --git a/os/rt/ports/ARMCMx/chcore_timer.h b/os/rt/ports/ARMCMx/chcore_timer.h index 089ab2519..da3bd82de 100644 --- a/os/rt/ports/ARMCMx/chcore_timer.h +++ b/os/rt/ports/ARMCMx/chcore_timer.h @@ -37,6 +37,7 @@  #else /* !defined(CH_PORT_DO_NOT_USE_ST) */
 +/* This is the only header in the HAL designed to be include-able alone.*/
  #include "st.h"
  /*===========================================================================*/
 @@ -90,6 +91,8 @@ static inline systime_t port_timer_get_time(void) {   */
  static inline void port_timer_start_alarm(systime_t time) {
 +  chDbgAssert(stIsAlarmActive() == false, "already active");
 +
    stStartAlarm(time);
  }
 @@ -100,6 +103,8 @@ static inline void port_timer_start_alarm(systime_t time) {   */
  static inline void port_timer_stop_alarm(void) {
 +  chDbgAssert(stIsAlarmActive() != false, "not active");
 +
    stStopAlarm();
  }
 @@ -112,6 +117,8 @@ static inline void port_timer_stop_alarm(void) {   */
  static inline void port_timer_set_alarm(systime_t time) {
 +  chDbgAssert(stIsAlarmActive() != false, "not active");
 +
    stSetAlarm(time);
  }
 @@ -124,6 +131,8 @@ static inline void port_timer_set_alarm(systime_t time) {   */
  static inline systime_t port_timer_get_alarm(void) {
 +  chDbgAssert(stIsAlarmActive() != false, "not active");
 +
    return stGetAlarm();
  }
  | 
