//----------------------------------------------------------------------------- void irq_handler_tc1(void) { if (TC1->COUNT16.INTFLAG.reg & TC_INTFLAG_MC(1)) { HAL_GPIO_LED_toggle(); TC1->COUNT16.INTFLAG.reg = TC_INTFLAG_MC(1); } }
/*************************************************************************//** *****************************************************************************/ void SYSTIMER_OVF_Vect(void) { if(SYSTIMER.INTFLAG.reg & TC_INTFLAG_MC(0)) { halTimerIrqCount++; SYSTIMER.INTFLAG.reg = TC_INTFLAG_MC(0); } else { halTimerDelayInt = 1; SYSTIMER.INTFLAG.reg = TC_INTFLAG_MC(1); } }
static inline void tc_clear_interrupt( struct tc_module *const module, const enum tc_callback callback_type) { /* Sanity check arguments */ MBED_ASSERT(module); /* Clear interrupt flags */ if (callback_type == TC_CALLBACK_CC_CHANNEL0) { module->hw->COUNT8.INTENCLR.reg = TC_INTFLAG_MC(1); } else if (callback_type == TC_CALLBACK_CC_CHANNEL1) { module->hw->COUNT8.INTENCLR.reg = TC_INTFLAG_MC(2); } else { module->hw->COUNT8.INTENCLR.reg = (1 << callback_type); } }
/** * \internal Interrupt Handler for TC module * * Handles interrupts as they occur, it will run the callback functions * that are registered and enabled. * * \param[in] instance ID of the TC instance calling the interrupt * handler */ void _tc_interrupt_handler( uint8_t instance) { /* Temporary variable */ uint8_t interrupt_and_callback_status_mask; /* Get device instance from the look-up table */ struct tc_module *module = (struct tc_module *)_tc_instances[instance]; /* Read and mask interrupt flag register */ interrupt_and_callback_status_mask = module->hw->COUNT8.INTFLAG.reg & module->register_callback_mask & module->enable_callback_mask; /* Check if an Overflow interrupt has occurred */ if (interrupt_and_callback_status_mask & TC_INTFLAG_OVF) { /* Invoke registered and enabled callback function */ (module->callback[TC_CALLBACK_OVERFLOW])(module); /* Clear interrupt flag */ module->hw->COUNT8.INTFLAG.reg = TC_INTFLAG_OVF; } /* Check if an Error interrupt has occurred */ if (interrupt_and_callback_status_mask & TC_INTFLAG_ERR) { /* Invoke registered and enabled callback function */ (module->callback[TC_CALLBACK_ERROR])(module); /* Clear interrupt flag */ module->hw->COUNT8.INTFLAG.reg = TC_INTFLAG_ERR; } /* Check if an Match/Capture Channel 0 interrupt has occurred */ if (interrupt_and_callback_status_mask & TC_INTFLAG_MC(1)) { /* Invoke registered and enabled callback function */ (module->callback[TC_CALLBACK_CC_CHANNEL0])(module); /* Clear interrupt flag */ module->hw->COUNT8.INTFLAG.reg = TC_INTFLAG_MC(1); } /* Check if an Match/Capture Channel 1 interrupt has occurred */ if (interrupt_and_callback_status_mask & TC_INTFLAG_MC(2)) { /* Invoke registered and enabled callback function */ (module->callback[TC_CALLBACK_CC_CHANNEL1])(module); /* Clear interrupt flag */ module->hw->COUNT8.INTFLAG.reg = TC_INTFLAG_MC(2); } }
/** * \brief Registers a callback. * * Registers a callback function which is implemented by the user. * * \note The callback must be enabled by \ref tc_enable_callback, * in order for the interrupt handler to call it when the conditions for the * callback type is met. * * \param[in] module Pointer to TC software instance struct * \param[in] callback_func Pointer to callback function * \param[in] callback_type Callback type given by an enum */ enum status_code tc_register_callback( struct tc_module *const module, tc_callback_t callback_func, const enum tc_callback callback_type) { /* Sanity check arguments */ Assert(module); Assert(callback_func); /* Register callback function */ module->callback[callback_type] = callback_func; /* Set the bit corresponding to the callback_type */ if (callback_type == TC_CALLBACK_CC_CHANNEL0) { module->register_callback_mask |= TC_INTFLAG_MC(1); } else if (callback_type == TC_CALLBACK_CC_CHANNEL1) { module->register_callback_mask |= TC_INTFLAG_MC(2); } else { module->register_callback_mask |= (1 << callback_type); } return STATUS_OK; }