Fixed bug #477.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6794 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
c322035d6b
commit
c90c328606
|
@ -119,6 +119,21 @@ void ext_lld_stop(EXTDriver *extp) {
|
|||
*/
|
||||
void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel) {
|
||||
|
||||
/* Setting the associated GPIO for external channels.*/
|
||||
if (channel < 16) {
|
||||
uint32_t n = channel >> 2;
|
||||
uint32_t mask = ~(0xF << ((channel & 3) * 4));
|
||||
uint32_t port = ((extp->config->channels[channel].mode &
|
||||
EXT_MODE_GPIO_MASK) >>
|
||||
EXT_MODE_GPIO_OFF) << ((channel & 3) * 4);
|
||||
|
||||
#if defined(STM32F1XX)
|
||||
AFIO->EXTICR[n] = (AFIO->EXTICR[n] & mask) | port;
|
||||
#else /* !defined(STM32F1XX) */
|
||||
SYSCFG->EXTICR[n] = (SYSCFG->EXTICR[n] & mask) | port;
|
||||
#endif /* !defined(STM32F1XX) */
|
||||
}
|
||||
|
||||
#if STM32_EXTI_NUM_CHANNELS > 32
|
||||
if (channel < 32) {
|
||||
#endif
|
||||
|
@ -165,22 +180,6 @@ void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel) {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Setting the associated GPIO for external channels.*/
|
||||
if (channel < 16) {
|
||||
uint32_t n = channel >> 2;
|
||||
uint32_t mask = ~(0xF << ((channel & 3) * 4));
|
||||
uint32_t port = ((extp->config->channels[channel].mode &
|
||||
EXT_MODE_GPIO_MASK) >>
|
||||
EXT_MODE_GPIO_OFF) << ((channel & 3) * 4);
|
||||
|
||||
#if defined(STM32L1XX_MD) || defined(STM32F0XX) || defined(STM32F2XX) || \
|
||||
defined(STM32F30X) || defined(STM32F37X) || defined(STM32F4XX)
|
||||
SYSCFG->EXTICR[n] = (SYSCFG->EXTICR[n] & mask) | port;
|
||||
#else /* STM32F1XX */
|
||||
AFIO->EXTICR[n] = (AFIO->EXTICR[n] & mask) | port;
|
||||
#endif /* STM32F1XX */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue