SAM TCC - Timer Counter for Control Applications Callback Driver.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include "tcc_callback.h"
Macros | |
#define | _TCC_INTERRUPT_HANDLER(n, m) |
#define | _TCC_INTERRUPT_VECT_NUM(n, unused) SYSTEM_INTERRUPT_MODULE_TCC##n, |
#define | _TCC_INTFLAG_MC(n, dummy) TCC_INTFLAG_MC##n, |
Functions | |
static enum system_interrupt_vector | _tcc_interrupt_get_interrupt_vector (uint32_t inst_num) |
void | _tcc_interrupt_handler (uint8_t module_index) |
void | tcc_disable_callback (struct tcc_module *const module, const enum tcc_callback callback_type) |
Disables callback. More... | |
void | tcc_enable_callback (struct tcc_module *const module, const enum tcc_callback callback_type) |
Enables callback. More... | |
enum status_code | tcc_register_callback (struct tcc_module *const module, tcc_callback_t callback_func, const enum tcc_callback callback_type) |
Registers a callback. More... | |
enum status_code | tcc_unregister_callback (struct tcc_module *const module, const enum tcc_callback callback_type) |
Unregisters a callback. More... | |
Variables | |
void * | _tcc_instances [TCC_INST_NUM] |
const uint32_t | _tcc_intflag [TCC_CALLBACK_N] |
#define _TCC_INTERRUPT_HANDLER | ( | n, | |
m | |||
) |
ISR handler for TCC
Auto-generate a set of interrupt handlers for each TCC in the device.
Referenced by _tcc_interrupt_get_interrupt_vector().
|
static |
Get the interrupt vector for the given device instance
[in] | The | TCC module instance number |
References _TCC_INTERRUPT_VECT_NUM, and MREPEAT.
Referenced by tcc_disable_callback(), and tcc_enable_callback().
void _tcc_interrupt_handler | ( | uint8_t | module_index | ) |
Interrupt handler for the TCC module
Handles interrupts as they occur, it will run the callback functions that are registered and enabled.
[in] | module_index | ID of the TCC instance calling the interrupt handler |
References _tcc_instances, _tcc_intflag, tcc_module::callback, tcc_module::enable_callback_mask, tcc_module::hw, i, and tcc_module::register_callback_mask.
void tcc_disable_callback | ( | struct tcc_module *const | module, |
const enum tcc_callback | callback_type | ||
) |
Disables callback.
Disables the callback function registered by the tcc_register_callback, and the callback will not be called from the interrupt routine. The function will also disable the appropriate interrupts.
[in] | module | Pointer to TCC software instance struct |
[in] | callback_type | Callback type given by an enum |
References _tcc_get_inst_index(), _tcc_interrupt_get_interrupt_vector(), _tcc_intflag, Assert, tcc_module::enable_callback_mask, tcc_module::hw, and system_interrupt_disable().
Referenced by nm_bsp_stop_configurable_timer(), and run_callback_test().
void tcc_enable_callback | ( | struct tcc_module *const | module, |
const enum tcc_callback | callback_type | ||
) |
Enables callback.
Enables the callback function registered by the tcc_register_callback. The callback function will be called from the interrupt handler when the conditions for the callback type are met. This function will also enable the appropriate interrupts.
[in] | module | Pointer to TCC software instance struct |
[in] | callback_type | Callback type given by an enum |
References _tcc_get_inst_index(), _tcc_interrupt_get_interrupt_vector(), _tcc_intflag, Assert, tcc_module::enable_callback_mask, tcc_module::hw, and system_interrupt_enable().
Referenced by configure_tcc_callbacks(), nm_bsp_start_configurable_timer(), run_callback_test(), run_capture_and_compare_test(), sw_timer_init(), timer0_init(), and wifi_cb().
enum status_code tcc_register_callback | ( | struct tcc_module *const | module, |
tcc_callback_t | callback_func, | ||
const enum tcc_callback | callback_type | ||
) |
Registers a callback.
Registers a callback function which is implemented by the user.
[in] | module | Pointer to TCC software instance struct |
[in] | callback_func | Pointer to callback function |
[in] | callback_type | Callback type given by an enum |
References _tcc_intflag, Assert, tcc_module::callback, tcc_module::register_callback_mask, and STATUS_OK.
Referenced by configurable_timer_init(), configure_tcc_callbacks(), configure_timer(), run_callback_test(), run_capture_and_compare_test(), sw_timer_init(), and timer0_init().
enum status_code tcc_unregister_callback | ( | struct tcc_module *const | module, |
const enum tcc_callback | callback_type | ||
) |
Unregisters a callback.
Unregisters a callback function implemented by the user. The callback should be disabled before it is unregistered.
[in] | module | Pointer to TCC software instance struct |
[in] | callback_type | Callback type given by an enum |
References _tcc_intflag, Assert, tcc_module::callback, NULL, tcc_module::register_callback_mask, and STATUS_OK.
void* _tcc_instances[TCC_INST_NUM] |
Referenced by _tcc_interrupt_handler(), and tcc_init().
const uint32_t _tcc_intflag[TCC_CALLBACK_N] |
Referenced by _tcc_interrupt_handler(), tcc_disable_callback(), tcc_enable_callback(), tcc_register_callback(), and tcc_unregister_callback().