diff --git a/os/sb/host/sbvrq.c b/os/sb/host/sbvrq.c index 480a2594a..eeb7f1410 100644 --- a/os/sb/host/sbvrq.c +++ b/os/sb/host/sbvrq.c @@ -246,9 +246,9 @@ void sbVRQTriggerFromISR(sb_class_t *sbp, sb_vrqmask_t vmask) { void sb_api_vrq_set_alarm(struct port_extctx *ectxp) { sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p; sysinterval_t interval = (sysinterval_t )ectxp->r0; - bool continuous = (bool)ectxp->r1; + bool reload = (bool)ectxp->r1; - if (continuous) { + if (reload) { chVTSetContinuous(&sbp->alarm_vt, interval, delay_cb, (void *)sbp); } else { diff --git a/os/sb/user/sbuser.h b/os/sb/user/sbuser.h index fa3887d89..54d5c6fb7 100644 --- a/os/sb/user/sbuser.h +++ b/os/sb/user/sbuser.h @@ -843,6 +843,31 @@ static inline void sbSleepMicroseconds(time_usecs_t usecs) { sbSleep(sbTimeUS2I(usecs)); } +/** + * @brief Sets an alarm. + * @note On alarm a VRQ is triggered, the VRQ number is hard-coded in the + * sandbox configuration, default is zero. + * + * @param[in] interval the interval in system ticks + * @param[in] reload specifies a periodic alarm + * + * @api + */ +static inline void sbSetAlarm(sysinterval_t interval, bool reload) { + + __syscall2r(245, (uint32_t)interval, (uint32_t)reload); +} + +/** + * @brief Resets an alarm. + * + * @api + */ +static inline void sbResetAlarm(void) { + + __syscall0(246); +} + /** * @brief VRQ @p wait pseudo-instruction. *