diff --git a/os/hal/osal/nil/osal.h b/os/hal/osal/nil/osal.h index 77afc18eb..37838cc88 100644 --- a/os/hal/osal/nil/osal.h +++ b/os/hal/osal/nil/osal.h @@ -731,6 +731,8 @@ static inline msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, */ static inline void osalEventObjectInit(event_source_t *esp) { + osalDbgCheck(esp != NULL); + esp->flags = 0; esp->cb = NULL; esp->param = NULL; @@ -747,6 +749,8 @@ static inline void osalEventObjectInit(event_source_t *esp) { static inline void osalEventBroadcastFlagsI(event_source_t *esp, eventflags_t flags) { + osalDbgCheck(esp != NULL); + esp->flags |= flags; if (esp->cb != NULL) esp->cb(esp); @@ -763,12 +767,37 @@ static inline void osalEventBroadcastFlagsI(event_source_t *esp, static inline void osalEventBroadcastFlags(event_source_t *esp, eventflags_t flags) { + osalDbgCheck(esp != NULL); + chSysLock(); osalEventBroadcastFlagsI(esp, flags); chSchRescheduleS(); chSysUnlock(); } +/** + * @brief Event callback setup. + * @note The callback is invoked from ISR context and can + * only invoke I-Class functions. The callback is meant + * to wakeup the task that will handle the event by + * calling @p osalEventGetAndClearFlagsI(). + * + * @param[in] esp pointer to the event flags object + * @param[in] cb pointer to the callback function + * @param[in] param parameter to be passed to the callback function + * + * @api + */ +static inline void osalEventSetCallback(event_source_t *esp, + eventcallback_t cb, + void *param) { + + osalDbgCheck(esp != NULL); + + esp->cb = cb; + esp->param = param; +} + /** * @brief Initializes s @p mutex_t object. * diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h index f815b2153..109f99533 100644 --- a/os/nil/include/nil.h +++ b/os/nil/include/nil.h @@ -391,8 +391,10 @@ typedef struct { * @brief Panic message. * @note This field is only present if some debug options have been * activated. + * @note Accesses to this pointer must never be optimized out so the + * field itself is declared volatile. */ - const char *dbg_panic_msg; + const char * volatile dbg_panic_msg; #endif } nil_system_t;