From 2114bc97d1daebe4240ee670813ff3586e24bdf9 Mon Sep 17 00:00:00 2001 From: pcirillo Date: Wed, 10 Apr 2013 09:56:34 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5580 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/SPC5xx/FlexPWM_v1/pwm_lld.h | 19 +++++------ os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.c | 36 ++++++++------------ os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.h | 30 +++++++--------- testhal/SPC560Pxx/PWM-ICU/main.c | 3 +- 4 files changed, 35 insertions(+), 53 deletions(-) diff --git a/os/hal/platforms/SPC5xx/FlexPWM_v1/pwm_lld.h b/os/hal/platforms/SPC5xx/FlexPWM_v1/pwm_lld.h index cf1f267b8..5684bca37 100644 --- a/os/hal/platforms/SPC5xx/FlexPWM_v1/pwm_lld.h +++ b/os/hal/platforms/SPC5xx/FlexPWM_v1/pwm_lld.h @@ -111,7 +111,6 @@ * @name Configuration options * @{ */ -#if SPC5_HAS_FLEXPWM0 || defined(__DOXYGEN__) /** * @brief PWMD1 driver enable switch. * @details If set to @p TRUE the support for PWMD1 is included. @@ -197,9 +196,7 @@ #define SPC5_PWM_FLEXPWM0_STOP_PCTL (SPC5_ME_PCTL_RUN(0) | \ SPC5_ME_PCTL_LP(0)) #endif -#endif -#if SPC5_HAS_FLEXPWM1 || defined(__DOXYGEN__) /** * @brief PWMD5 driver enable switch. * @details If set to @p TRUE the support for PWMD5 is included. @@ -285,18 +282,10 @@ #define SPC5_PWM_FLEXPWM1_STOP_PCTL (SPC5_ME_PCTL_RUN(0) | \ SPC5_ME_PCTL_LP(0)) #endif -#endif /*===========================================================================*/ /* Configuration checks. */ /*===========================================================================*/ -#if !SPC5_HAS_FLEXPWM0 -#error "FlexPWM0 not present in the selected device" -#endif - -#if !SPC5_HAS_FLEXPWM1 -#error "FlexPWM1 not present in the selected device" -#endif #define SPC5_PWM_USE_FLEXPWM0 (SPC5_PWM_USE_SMOD0 || \ SPC5_PWM_USE_SMOD1 || \ @@ -308,6 +297,14 @@ SPC5_PWM_USE_SMOD6 || \ SPC5_PWM_USE_SMOD7) +#if !SPC5_HAS_FLEXPWM0 && SPC5_PWM_USE_FLEXPWM0 +#error "FlexPWM0 not present in the selected device" +#endif + +#if !SPC5_HAS_FLEXPWM1 && SPC5_PWM_USE_FLEXPWM1 +#error "FlexPWM1 not present in the selected device" +#endif + #if !SPC5_PWM_USE_FLEXPWM0 && !SPC5_PWM_USE_FLEXPWM1 #error "PWM driver activated but no PWM peripheral assigned" #endif diff --git a/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.c b/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.c index 06794be62..ff5d54deb 100644 --- a/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.c +++ b/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.c @@ -223,10 +223,10 @@ static void icu_lld_serve_interrupt(ICUDriver *icup) { else { icup->etimerp->CHANNEL[icup->smod_number].STS.B.ICF1 = 1U; if (icup->etimerp->CHANNEL[icup->smod_number].CTRL3.B.C1FCNT == 2) { - period = icup->etimer->CHANNEL[icup->smod_number].CAPT1.R; - period = icup->etimer->CHANNEL[icup->smod_number].CAPT1.R; + period = icup->etimerp->CHANNEL[icup->smod_number].CAPT1.R; + period = icup->etimerp->CHANNEL[icup->smod_number].CAPT1.R; } else { - period = icup->etimer->CHANNEL[icup->smod_number].CAPT1.R; + period = icup->etimerp->CHANNEL[icup->smod_number].CAPT1.R; } _icu_isr_invoke_period_cb(icup); } @@ -240,10 +240,10 @@ static void icu_lld_serve_interrupt(ICUDriver *icup) { else { icup->etimerp->CHANNEL[icup->smod_number].STS.B.ICF2 = 1U; if (icup->etimerp->CHANNEL[icup->smod_number].CTRL3.B.C2FCNT == 2) { - width = icup->etimer->CHANNEL[icup->smod_number].CAPT2.R; - width = icup->etimer->CHANNEL[icup->smod_number].CAPT2.R; + width = icup->etimerp->CHANNEL[icup->smod_number].CAPT2.R; + width = icup->etimerp->CHANNEL[icup->smod_number].CAPT2.R; } else { - width = icup->etimer->CHANNEL[icup->smod_number].CAPT2.R; + width = icup->etimerp->CHANNEL[icup->smod_number].CAPT2.R; } _icu_isr_invoke_width_cb(icup); } @@ -256,20 +256,20 @@ static void icu_lld_serve_interrupt(ICUDriver *icup) { if ((sr & 0x0040) != 0) { /* ICF1 */ icup->etimerp->CHANNEL[icup->smod_number].STS.B.ICF1 = 1U; if (icup->etimerp->CHANNEL[icup->smod_number].CTRL3.B.C1FCNT == 2) { - period = icup->etimer->CHANNEL[icup->smod_number].CAPT1.R; - period = icup->etimer->CHANNEL[icup->smod_number].CAPT1.R; + period = icup->etimerp->CHANNEL[icup->smod_number].CAPT1.R; + period = icup->etimerp->CHANNEL[icup->smod_number].CAPT1.R; } else { - period = icup->etimer->CHANNEL[icup->smod_number].CAPT1.R; + period = icup->etimerp->CHANNEL[icup->smod_number].CAPT1.R; } _icu_isr_invoke_period_cb(icup); } else if ((sr & 0x0080) != 0) { /* ICF2 */ icup->etimerp->CHANNEL[icup->smod_number].STS.B.ICF2 = 1U; if (icup->etimerp->CHANNEL[icup->smod_number].CTRL3.B.C2FCNT == 2) { - width = icup->etimer->CHANNEL[icup->smod_number].CAPT2.R; - width = icup->etimer->CHANNEL[icup->smod_number].CAPT2.R; + width = icup->etimerp->CHANNEL[icup->smod_number].CAPT2.R; + width = icup->etimerp->CHANNEL[icup->smod_number].CAPT2.R; } else { - width = icup->etimer->CHANNEL[icup->smod_number].CAPT2.R; + width = icup->etimerp->CHANNEL[icup->smod_number].CAPT2.R; } _icu_isr_invoke_width_cb(icup); } @@ -970,20 +970,12 @@ void icu_lld_init(void) { */ void icu_lld_start(ICUDriver *icup) { - chDbgAssert((icup->config->channel == ICU_CHANNEL_1) || - (icup->config->channel == ICU_CHANNEL_2) || - (icup->config->channel == ICU_CHANNEL_3) || - (icup->config->channel == ICU_CHANNEL_4) || - (icup->config->channel == ICU_CHANNEL_5) || - (icup->config->channel == ICU_CHANNEL_6), - "icu_lld_start(), #1", "invalid input"); - chDbgAssert(icu_active_submodules0 < 6, "icu_lld_start(), #1", "too many submodules"); chDbgAssert(icu_active_submodules1 < 6, "icu_lld_start(), #1", - "too many submodules"); + "too many submodules"); chDbgAssert(icu_active_submodules2 < 6, "icu_lld_start(), #1", - "too many submodules"); + "too many submodules"); if (icup->state == ICU_STOP) { #if SPC5_ICU_USE_SMOD0 diff --git a/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.h b/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.h index f8c4b13fd..3f445f84a 100644 --- a/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.h +++ b/os/hal/platforms/SPC5xx/eTimer_v1/icu_lld.h @@ -94,7 +94,6 @@ * @name Configuration options * @{ */ -#if SPC5_HAS_ETIMER0 || defined(__DOXYGEN__) /** * @brief ICUD1 driver enable switch. * @details If set to @p TRUE the support for ICUD1 is included. @@ -177,9 +176,7 @@ #define SPC5_ICU_ETIMER0_STOP_PCTL (SPC5_ME_PCTL_RUN(0) | \ SPC5_ME_PCTL_LP(0)) #endif -#endif -#if SPC5_HAS_ETIMER1 || defined(__DOXYGEN__) /** * @brief ICUD6 driver enable switch. * @details If set to @p TRUE the support for ICUD6 is included. @@ -262,9 +259,7 @@ #define SPC5_ICU_ETIMER1_STOP_PCTL (SPC5_ME_PCTL_RUN(0) | \ SPC5_ME_PCTL_LP(0)) #endif -#endif -#if SPC5_HAS_ETIMER2 || defined(__DOXYGEN__) /** * @brief ICUD13 driver enable switch. * @details If set to @p TRUE the support for ICUD13 is included. @@ -347,25 +342,12 @@ #define SPC5_ICU_ETIMER2_STOP_PCTL (SPC5_ME_PCTL_RUN(0) | \ SPC5_ME_PCTL_LP(0)) #endif -#endif /** @} */ /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ -#if !SPC5_HAS_ETIMER0 -#error "ETIMER0 not present in the selected device" -#endif - -#if !SPC5_HAS_ETIMER1 -#error "ETIMER1 not present in the selected device" -#endif - -#if !SPC5_HAS_ETIMER2 -#error "ETIMER2 not present in the selected device" -#endif - #define SPC5_ICU_USE_ETIMER0 (SPC5_ICU_USE_SMOD0 || \ SPC5_ICU_USE_SMOD1 || \ SPC5_ICU_USE_SMOD2 || \ @@ -387,6 +369,18 @@ SPC5_ICU_USE_SMOD16 || \ SPC5_ICU_USE_SMOD17) +#if !SPC5_HAS_ETIMER0 && SPC5_ICU_USE_ETIMER0 +#error "ETIMER0 not present in the selected device" +#endif + +#if !SPC5_HAS_ETIMER1 && SPC5_ICU_USE_ETIMER1 +#error "ETIMER1 not present in the selected device" +#endif + +#if !SPC5_HAS_ETIMER2 && SPC5_ICU_USE_ETIMER2 +#error "ETIMER2 not present in the selected device" +#endif + #if !SPC5_ICU_USE_ETIMER0 && !SPC5_ICU_USE_ETIMER1 && !SPC5_ICU_USE_ETIMER2 #error "ICU driver activated but no SMOD peripheral assigned" #endif diff --git a/testhal/SPC560Pxx/PWM-ICU/main.c b/testhal/SPC560Pxx/PWM-ICU/main.c index 4b7c91b8c..eb12cda0e 100644 --- a/testhal/SPC560Pxx/PWM-ICU/main.c +++ b/testhal/SPC560Pxx/PWM-ICU/main.c @@ -59,8 +59,7 @@ static ICUConfig icucfg = { 250000, /* 250kHz ICU clock frequency.*/ icuwidthcb, icuperiodcb, - NULL, - ICU_CHANNEL_1 + NULL }; /*