diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-09-13 12:40:42 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-09-13 12:40:42 +0000 |
commit | fbac4d253d67cc5b1ec39166ce1abb8124b1e3a8 (patch) | |
tree | 23300615d3484cef1515fba815a7218f1118d377 /os/hal/platforms | |
parent | b86e5efeeb17af6937319d0fd874fc64b0c1ccb4 (diff) | |
download | ChibiOS-fbac4d253d67cc5b1ec39166ce1abb8124b1e3a8.tar.gz ChibiOS-fbac4d253d67cc5b1ec39166ce1abb8124b1e3a8.tar.bz2 ChibiOS-fbac4d253d67cc5b1ec39166ce1abb8124b1e3a8.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3314 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r-- | os/hal/platforms/STM32/ext_lld.c | 51 | ||||
-rw-r--r-- | os/hal/platforms/STM32/ext_lld.h | 2 |
2 files changed, 47 insertions, 6 deletions
diff --git a/os/hal/platforms/STM32/ext_lld.c b/os/hal/platforms/STM32/ext_lld.c index fc203fa60..712ed5a39 100644 --- a/os/hal/platforms/STM32/ext_lld.c +++ b/os/hal/platforms/STM32/ext_lld.c @@ -328,7 +328,7 @@ void ext_lld_start(EXTDriver *extp) { /* Configuration.*/
imr = emr = rtsr = ftsr = 0;
for (i = 0; i < EXT_MAX_CHANNELS; i++) {
- if (extp->config->channels[i].mode != EXT_CH_MODE_DISABLED) {
+ if (extp->config->channels[i].mode & EXT_CH_MODE_AUTOSTART) {
if (extp->config->channels[i].cb != NULL)
imr |= (1 << i);
else
@@ -344,11 +344,11 @@ void ext_lld_start(EXTDriver *extp) { AFIO->EXTICR[2] = extp->config->exti[2];
AFIO->EXTICR[3] = extp->config->exti[3];
EXTI->SWIER = 0;
- EXTI->RTSR = rtsr;
- EXTI->FTSR = ftsr;
- EXTI->PR = EXT_CHANNELS_MASK;
- EXTI->EMR = emr;
- EXTI->IMR = imr;
+ EXTI->RTSR = rtsr;
+ EXTI->FTSR = ftsr;
+ EXTI->PR = EXT_CHANNELS_MASK;
+ EXTI->EMR = emr;
+ EXTI->IMR = imr;
}
/**
@@ -385,6 +385,45 @@ void ext_lld_stop(EXTDriver *extp) { EXTI->PR = EXT_CHANNELS_MASK;
}
+/**
+ * @brief Enables an EXT channel.
+ *
+ * @param[in] extp pointer to the @p EXTDriver object
+ * @param[in] channel channel to be enabled
+ *
+ * @notapi
+ */
+void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel) {
+
+ if (extp->config->channels[channel].cb != NULL)
+ EXTI->IMR |= (1 << channel);
+ else
+ EXTI->EMR |= (1 << channel);
+ if (extp->config->channels[channel].mode & EXT_CH_MODE_RISING_EDGE)
+ EXTI->RTSR |= (1 << channel);
+ if (extp->config->channels[channel].mode & EXT_CH_MODE_FALLING_EDGE)
+ EXTI->FTSR |= (1 << channel);
+}
+
+/**
+ * @brief Disables an EXT channel.
+ *
+ * @param[in] extp pointer to the @p EXTDriver object
+ * @param[in] channel channel to be disabled
+ *
+ * @notapi
+ */
+void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel) {
+
+ (void)extp;
+
+ EXTI->IMR &= ~(1 << channel);
+ EXTI->EMR &= ~(1 << channel);
+ EXTI->RTSR &= ~(1 << channel);
+ EXTI->FTSR &= ~(1 << channel);
+ EXTI->PR = (1 << channel);
+}
+
#endif /* HAL_USE_EXT */
/** @} */
diff --git a/os/hal/platforms/STM32/ext_lld.h b/os/hal/platforms/STM32/ext_lld.h index 45e863d9c..17ea09fb8 100644 --- a/os/hal/platforms/STM32/ext_lld.h +++ b/os/hal/platforms/STM32/ext_lld.h @@ -254,6 +254,8 @@ extern "C" { void ext_lld_init(void);
void ext_lld_start(EXTDriver *extp);
void ext_lld_stop(EXTDriver *extp);
+ void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel);
+ void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel);
#ifdef __cplusplus
}
#endif
|