|
Core
|
Core timeout library. More...
#include "timeout.h"#include "core_config.h"#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include <stm32g4xx_hal.h>Functions | |
| bool | core_timeout_insert (core_timeout_t *timeout) |
| Add a timeout to the internal list of timeouts to be monitored. | |
| void | core_timeout_start_all () |
| Enable all timeouts currently in the internal timeout list. | |
| void | core_timeout_reset_by_module_ref (void *module, uint32_t ref) |
| Reset a timeout given the module and the refernce number. | |
| void | core_timeout_reset (core_timeout_t *timeout) |
| Reset a timeout given a pointer to the timeout struct. | |
| void | core_timeout_check_all () |
| Check all timeouts currently stored in the internal timeout list. | |
| void | core_timeout_suspend (core_timeout_t *timeout) |
| Suspend timeout. | |
| void | core_timeout_resume (core_timeout_t *timeout) |
| Resume suspended timeout. | |
| void | core_timeout_hard_reset (core_timeout_t *timeout) |
| Force reset a timeout. | |
Core timeout library.
This core library component can be used to set timeouts for both software events and core library events. Timeouts are specified by a core_timeout_t struct.
timeout member to the desired timeout length in millisecondscallback member to the timeout's callback function. When the function is called, a pointer to the struct defining the timeout that called the callback function is passed to it.module and ref members. See below.core_timeout_check_all at regular intervals. If a timeout has elapsed, the handler is called. Timeouts are checked in the order they are added.The module and ref members of the core_timeout_t struct can be used to define timeouts that are automatically reset by other core library components. To reset these timeouts, the core_timeout_reset_by_module_ref() function is used. The module member is set to a register struct defined by the HAL (e.g. FDCAN1, SPI1, USART3, etc.). The meaning of ref depends on the selected module. Currently, the modules that support this feature are:
FDCAN1, FDCAN2, and FDCAN3: The timeout is reset when a frame with an ID equal to the value of ref is receivedTimeouts with a module not in the above list will never be reset by the core library. Thus, the user can define timeouts where module is NULL or equal to a custom value and reset them using the core_timeout_reset_by_module_ref() function.
The 'check' member can be implemented to have the timeout library automatically check whether or not a timeout should be reset. The 'check' member should point to a function returning a bool value, true if the timeout should be reset, false if not. This is checked inside the core_timeout_check_all function.
Set this member to 1 to not allow it to be reset by a normal reset function. A timeout with this parameter set can only be reset through the core_timeout_hard_reset function.
Set this member to 1 to only have callback trigger once, the first time the timeout has hit its limit.
| void core_timeout_hard_reset | ( | core_timeout_t * | timeout | ) |
Force reset a timeout.
| timeout | Pointer to timeout being reset |
| bool core_timeout_insert | ( | core_timeout_t * | timeout | ) |
Add a timeout to the internal list of timeouts to be monitored.
| timeout | Pointer to the timeout |
| 1 | if there is enough space |
| 0 | otherwise |
| void core_timeout_reset | ( | core_timeout_t * | timeout | ) |
Reset a timeout given a pointer to the timeout struct.
| timeout | Pointer to the timeout being reset |
| void core_timeout_reset_by_module_ref | ( | void * | module, |
| uint32_t | ref ) |
Reset a timeout given the module and the refernce number.
| module | Module that is calling this function |
| ref | Reference number |
| void core_timeout_resume | ( | core_timeout_t * | timeout | ) |
Resume suspended timeout.
| timeout | Pointer to the timeout being resumed |
| void core_timeout_suspend | ( | core_timeout_t * | timeout | ) |
Suspend timeout.
| timeout | Pointer to the timeout being suspended |