Shared ISR code moved in icu.h.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2860 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2011-04-01 09:31:28 +00:00
parent be4c72c7a3
commit 875a7d8f41
2 changed files with 30 additions and 10 deletions

View File

@ -119,6 +119,32 @@ typedef void (*icucallback_t)(ICUDriver *icup);
*/ */
#define icuGetPeriodI(icup) icu_lld_get_period(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. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -93,16 +93,10 @@ static void icu_lld_serve_interrupt(ICUDriver *icup) {
sr = icup->tim->SR & icup->tim->DIER; sr = icup->tim->SR & icup->tim->DIER;
icup->tim->SR = 0; icup->tim->SR = 0;
if ((sr & TIM_SR_CC1IF) != 0) { if ((sr & TIM_SR_CC1IF) != 0)
icustate_t previous_state = icup->state; _icu_isr_invoke_period_cb(icup);
icup->state = ICU_ACTIVE; if ((sr & TIM_SR_CC2IF) != 0)
if (previous_state != ICU_WAITING) _icu_isr_invoke_width_cb(icup);
icup->config->period_cb(icup);
}
if ((sr & TIM_SR_CC2IF) != 0) {
icup->state = ICU_IDLE;
icup->config->width_cb(icup);
}
} }
/*===========================================================================*/ /*===========================================================================*/