Shared ISR code moved in icu.h.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2860 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
be4c72c7a3
commit
875a7d8f41
|
@ -119,6 +119,32 @@ typedef void (*icucallback_t)(ICUDriver *icup);
|
|||
*/
|
||||
#define icuGetPeriodI(icup) icu_lld_get_period(icup)
|
||||
|
||||
/**
|
||||
* @brief Common ISR code, ICU width event.
|
||||
*
|
||||
* @param[in] icup pointer to the @p ICUDriver object
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#define _icu_isr_invoke_width_cb(usbp) { \
|
||||
(icup)->state = ICU_IDLE; \
|
||||
(icup)->config->width_cb(icup); \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Common ISR code, ICU period event.
|
||||
*
|
||||
* @param[in] icup pointer to the @p ICUDriver object
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#define _icu_isr_invoke_period_cb(usbp) { \
|
||||
icustate_t previous_state = (icup)->state; \
|
||||
(icup)->state = ICU_ACTIVE; \
|
||||
if (previous_state != ICU_WAITING) \
|
||||
(icup)->config->period_cb(icup); \
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -93,16 +93,10 @@ static void icu_lld_serve_interrupt(ICUDriver *icup) {
|
|||
|
||||
sr = icup->tim->SR & icup->tim->DIER;
|
||||
icup->tim->SR = 0;
|
||||
if ((sr & TIM_SR_CC1IF) != 0) {
|
||||
icustate_t previous_state = icup->state;
|
||||
icup->state = ICU_ACTIVE;
|
||||
if (previous_state != ICU_WAITING)
|
||||
icup->config->period_cb(icup);
|
||||
}
|
||||
if ((sr & TIM_SR_CC2IF) != 0) {
|
||||
icup->state = ICU_IDLE;
|
||||
icup->config->width_cb(icup);
|
||||
}
|
||||
if ((sr & TIM_SR_CC1IF) != 0)
|
||||
_icu_isr_invoke_period_cb(icup);
|
||||
if ((sr & TIM_SR_CC2IF) != 0)
|
||||
_icu_isr_invoke_width_cb(icup);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
Loading…
Reference in New Issue