From 1c60f17682e5ccfa2c330da98b17985422c35842 Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 4 Dec 2012 11:16:01 +0000 Subject: AT91SAM7A3. EXT ported. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4868 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/AT91SAM7/ext_lld.c | 13 ++++++++----- os/hal/platforms/AT91SAM7/ext_lld.h | 34 +++++++++++++++------------------- 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'os') diff --git a/os/hal/platforms/AT91SAM7/ext_lld.c b/os/hal/platforms/AT91SAM7/ext_lld.c index 98f08c9b8..00d874972 100644 --- a/os/hal/platforms/AT91SAM7/ext_lld.c +++ b/os/hal/platforms/AT91SAM7/ext_lld.c @@ -45,7 +45,7 @@ EXTDriver EXTDA; #if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \ - (SAM7_PLATFORM == SAM7X512) + (SAM7_PLATFORM == SAM7X512) || (SAM7_PLATFORM == SAM7A3) /** * @brief EXTDB driver identifier. */ @@ -75,7 +75,7 @@ static void ext_lld_serveInterrupt(EXTDriver *extp) { irqFlags = extp->pio->PIO_ISR; /* Call callback function for any pending interrupt.*/ - for(ch = 0; ch < 32; ch++) { + for(ch = 0; ch < EXT_MAX_CHANNELS; ch++) { /* Check if the channel is activated and if its IRQ flag is set.*/ if((extp->config->channels[ch].mode & @@ -109,7 +109,7 @@ CH_IRQ_HANDLER(EXTIA_IRQHandler) { } #if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \ - (SAM7_PLATFORM == SAM7X512) + (SAM7_PLATFORM == SAM7X512) || (SAM7_PLATFORM == SAM7A3) /** * @brief EXTI[1] interrupt handler. * @@ -145,7 +145,7 @@ void ext_lld_init(void) { EXTDA.pid = AT91C_ID_PIOA; #if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \ - (SAM7_PLATFORM == SAM7X512) + (SAM7_PLATFORM == SAM7X512) || (SAM7_PLATFORM == SAM7A3) /* Same for PIOB.*/ extObjectInit(&EXTDB); EXTDB.pio = AT91C_BASE_PIOB; @@ -172,7 +172,7 @@ void ext_lld_start(EXTDriver *extp) { EXTIA_IRQHandler); break; #if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \ - (SAM7_PLATFORM == SAM7X512) + (SAM7_PLATFORM == SAM7X512) || (SAM7_PLATFORM == SAM7A3) case AT91C_ID_PIOB: AIC_ConfigureIT(AT91C_ID_PIOB, SAM7_computeSMR(config->mode, config->priority), @@ -215,6 +215,9 @@ void ext_lld_stop(EXTDriver *extp) { */ void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel) { + chDbgCheck((extp->config->channels[channel].cb != NULL), + "Call back pointer can not be NULL"); + extp->pio->PIO_IER = (1 << channel); } diff --git a/os/hal/platforms/AT91SAM7/ext_lld.h b/os/hal/platforms/AT91SAM7/ext_lld.h index 8ec6fea5d..042a2fa1a 100644 --- a/os/hal/platforms/AT91SAM7/ext_lld.h +++ b/os/hal/platforms/AT91SAM7/ext_lld.h @@ -38,12 +38,12 @@ /** * @brief Pointer to the SAM7 AIC register block. */ -#define SAM7_EXT_AIC ((AT91PS_AIC *)AT91C_BASE_AIC) +#define SAM7_EXT_AIC ((AT91PS_AIC *)AT91C_BASE_AIC) /** * @brief Number of channels within one ext driver. */ -#define EXT_MAX_CHANNELS 32 +#define EXT_MAX_CHANNELS 32 /** * @brief Mask of priority bits in interrupt mode register. @@ -53,12 +53,12 @@ /** * @brief Shifter for priority bits in interrupt mode register. */ -#define SAM7_EXT_PRIORITY_SHIFTER 0 +#define SAM7_EXT_PRIORITY_SHIFTER 0 /** * @brief Shifter for mode bits in interrupt mode register. */ -#define SAM7_EXT_MODE_SHIFTER 5 +#define SAM7_EXT_MODE_SHIFTER 5 /* * On the SAM7 architecture, a single channel can only be enables or disabled @@ -80,7 +80,7 @@ * @name EXT channels mode * @{ */ -#define EXT_CH_MODE_ENABLED 1 /**< @brief Channel is enabled. */ +#define EXT_CH_MODE_ENABLED 1 /**< @brief Channel is enabled. */ /** @} */ /** @@ -98,15 +98,15 @@ /** * @brief Rising edge callback. */ -#define SAM7_EXT_MODE_RISING_EDGE AT91C_AIC_SRCTYPE_POSITIVE_EDGE +#define SAM7_EXT_MODE_RISING_EDGE AT91C_AIC_SRCTYPE_POSITIVE_EDGE /** * @brief High-level callback. */ -#define SAM7_EXT_MODE_HIGH_LEVEL AT91C_AIC_SRCTYPE_HIGH_LEVEL +#define SAM7_EXT_MODE_HIGH_LEVEL AT91C_AIC_SRCTYPE_HIGH_LEVEL /** * @brief Low-level callback. */ -#define SAM7_EXT_MODE_LOW_LEVEL AT91C_AIC_SRCTYPE_EXT_LOW_LEVEL +#define SAM7_EXT_MODE_LOW_LEVEL AT91C_AIC_SRCTYPE_EXT_LOW_LEVEL /** @} */ /** @@ -114,7 +114,7 @@ * @{ */ #define SAM7_EXT_PRIOR_HIGHEST AT91C_AIC_PRIOR_HIGHEST -#define SAM7_EXT_PRIOR_LOWEST AT91C_AIC_PRIOR_LOWEST +#define SAM7_EXT_PRIOR_LOWEST AT91C_AIC_PRIOR_LOWEST /** @} */ /*===========================================================================*/ @@ -152,9 +152,6 @@ typedef struct { uint32_t mode; /** * @brief Channel callback. - * @details In the STM32 implementation a @p NULL callback pointer is - * valid and configures the channel as an event sources instead - * of an interrupt source. */ extcallback_t cb; } EXTChannelConfig; @@ -169,12 +166,10 @@ typedef struct { */ EXTChannelConfig channels[EXT_MAX_CHANNELS]; /* End of the mandatory fields.*/ - /** * @brief interrupt mode. */ uint32_t mode; - /** * @brief interrupt priority. */ @@ -188,20 +183,21 @@ struct EXTDriver { /** * @brief Driver state. */ - extstate_t state; + extstate_t state; /** * @brief Current configuration data. */ - const EXTConfig *config; + const EXTConfig *config; /* End of the mandatory fields.*/ + /** * @brief Pointer to the corresponding PIO registers block. */ - AT91PS_PIO pio; + AT91PS_PIO pio; /** * @brief peripheral ID of the corresponding PIO block. */ - uint32_t pid; + uint32_t pid; }; /*===========================================================================*/ @@ -223,7 +219,7 @@ struct EXTDriver { #if !defined(__DOXYGEN__) extern EXTDriver EXTDA; #if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \ - (SAM7_PLATFORM == SAM7X512) + (SAM7_PLATFORM == SAM7X512) || (SAM7_PLATFORM == SAM7A3) extern EXTDriver EXTDB; #endif #endif -- cgit v1.2.3