diff --git a/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.cpp b/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.cpp index 8a122a0efb0ac36ad719cd7de64568eabb427b79..692b352c4fec6146976af844e5aff0a8dfc3c904 100644 --- a/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.cpp +++ b/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.cpp @@ -75,3 +75,16 @@ void Scheduling::startAsynchronousTask(uint8_t task_number) } #endif // CONFIG_OWNTECH_SCHEDULING_ENABLE_ASYNCHRONOUS_TASKS + + +// Suspend asynchronous tasks + +void Scheduling::suspendCurrentTaskMs(uint32_t duration_ms) +{ + k_sleep(K_MSEC(duration_ms)); +} + +void Scheduling::suspendCurrentTaskUs(uint32_t duration_us) +{ + k_sleep(K_USEC(duration_us)); +} diff --git a/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.h b/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.h index eb3be2d78fae36d4799d85ea92c1e32a7fcbbadc..52a6e5f5524cc05c938a9ddedbe56b736500d2d6 100644 --- a/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.h +++ b/zephyr/modules/owntech_scheduling/zephyr/public_api/Scheduling.h @@ -91,6 +91,27 @@ public: #endif // CONFIG_OWNTECH_SCHEDULING_ENABLE_ASYNCHRONOUS_TASKS + /** + * @brief This function allows to suspend an asynchronous + * task for a specified duration expressed in milliseconds. + * For example, you can call this function at the end of an + * asynchronous task main function, when there is no need + * for the task to run permanently. + * + * DO NOT use this function in a synchronous task! + */ + void suspendCurrentTaskMs(uint32_t duration_ms); + + /** + * @brief This function allows to suspend an asynchronous + * task for a specified duration expressed in microseconds. + * For example, you can call this function at the end of an + * asynchronous task main function, when there is no need + * for the task to run permanently. + * + * DO NOT use this function in a synchronous task! + */ + void suspendCurrentTaskUs(uint32_t duration_us); private: static const int DEFAULT_PRIORITY;