Microchip® Advanced Software Framework

tcc_callback.c File Reference

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,
 
)
Value:
void TCC##n##_Handler(void) \
{ \
}
void _tcc_interrupt_handler(uint8_t module_index)
Definition: tcc_callback.c:212

ISR handler for TCC

Auto-generate a set of interrupt handlers for each TCC in the device.

#define _TCC_INTERRUPT_VECT_NUM (   n,
  unused 
)    SYSTEM_INTERRUPT_MODULE_TCC##n,
#define _TCC_INTFLAG_MC (   n,
  dummy 
)    TCC_INTFLAG_MC##n,

static enum system_interrupt_vector _tcc_interrupt_get_interrupt_vector ( uint32_t  inst_num)
static

Get the interrupt vector for the given device instance

Parameters
[in]TheTCC module instance number
Returns
Interrupt vector for of the given TCC module instance.

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.

Parameters
[in]module_indexID 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.

Parameters
[in]modulePointer to TCC software instance struct
[in]callback_typeCallback 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 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.

Parameters
[in]modulePointer to TCC software instance struct
[in]callback_typeCallback 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(), run_callback_test(), and run_capture_and_compare_test().

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.

Note
The callback must be enabled by tcc_enable_callback, in order for the interrupt handler to call it when the conditions for the callback type is met.
Parameters
[in]modulePointer to TCC software instance struct
[in]callback_funcPointer to callback function
[in]callback_typeCallback type given by an enum

References _tcc_intflag, Assert, tcc_module::callback, tcc_module::register_callback_mask, and STATUS_OK.

Referenced by configure_tcc_callbacks(), run_callback_test(), and run_capture_and_compare_test().

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.

Parameters
[in]modulePointer to TCC software instance struct
[in]callback_typeCallback 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]
Initial value:
= {
TCC_INTFLAG_OVF,
TCC_INTFLAG_TRG,
TCC_INTFLAG_CNT,
TCC_INTFLAG_ERR,
TCC_INTFLAG_FAULTA,
TCC_INTFLAG_FAULTB,
TCC_INTFLAG_FAULT0,
TCC_INTFLAG_FAULT1,
#define _TCC_INTFLAG_MC(n,dummy)
}

Referenced by _tcc_interrupt_handler(), tcc_disable_callback(), tcc_enable_callback(), tcc_register_callback(), and tcc_unregister_callback().