⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer4_manager.h

📁 reference about wireless design which is helpful to everyone
💻 H
字号:
#ifndef TIMER4_MANAGER_H
#define TIMER4_MANAGER_H
/** \addtogroup module_timer4_manager  Timer 4 Manager (t4mgr)
 * \brief Provides run-time individuably configurable, periodical callbacks.
 *
 * The module uses the 8-bit timer 4 to generate interrupts at an interval specified in the initial call
 * to \ref t4mgrInit. Each timer 4 interrupt is called a "tick".
 *
 * The information for each callback is stored in a structure called \ref T4MGR_CALLBACK_INFO, which
 * contains a period, a counter and a function pointer. The counter is incremented for each timer tick,
 * until it reaches the specified period. The counter is then reset (to 0), and the callback is made.
 *
 * Up to \ref T4MGR_SETUP_NUMBER_OF_CALLBACK_FUNCTIONS callbacks can be configured at a time, with a period
 * of 1 to 254 timer ticks. Note that there are two special values for the period number:
 *     \li An entry in the callback table is unused when the period is set to
 *         \ref T4MGR_UNUSED_CALLBACK = 0.
 *     \li An entry in the callback table is suspended (i.e. the tick counter is halted) as long as the
 *         period is set to \ref T4MGR_SUSPENDED_CALLBACK = 255.
 *
 * A callback is configured by calling \ref t4mgrSetupCallback. The counter and the period can later on be
 * changed by calling \ref t4mgrModifyCallback. The callback can be removed by calling
 * \ref t4mgrCancelCallback.
 *
 * @{
 */


/// All entries in the callback table are currently in use (returned by \c t4mgrSetupCallback)
#define T4MGR_INVALID_INDEX			0xFF
/// Special value for \c T4MGR_CALLBACK_INFO.period: The entry in the callback table is unused
#define T4MGR_UNUSED_CALLBACK		0x00
/// Special value for \c T4MGR_CALLBACK_INFO.period: The entry in the callback table is suspended
#define T4MGR_SUSPENDED_CALLBACK	0xFF


/// Special value for \c t4mgrModifyCallback: When the \c period parameter is T4MGR_KEEP_PERIOD,
/// the current value is kept
#define T4MGR_KEEP_PERIOD			0x00
/// Special value for \c t4mgrModifyCallback: When the \c counter parameter is T4MGR_KEEP_COUNTER,
/// the current value is kept
#define T4MGR_KEEP_COUNTER			0xFF


/// Callback table
typedef struct {
   UINT8 counter;		///< Incrementing counter
   UINT8 period;        ///< Number of timer ticks between each callback (counter = ++counter \% period)
   VFPTR CallbackFunc;  ///< Pointer to the callback function
} T4MGR_CALLBACK_INFO;


// Initializes the timer 4 manager for interrupts at the specified tick interval
void t4mgrInit(UINT16 tickInterval);
// Configures a callback to occur at the specified period
UINT8 t4mgrSetupCallback(UINT8 period, VFPTR CallbackFunc);
// Modifies the period and counter of a callback
void t4mgrModifyCallback(UINT8 index, UINT8 period, UINT8 counter);
// Cancels a callback
void t4mgrCancelCallback(UINT8 index);


/// @}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -