aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-09-02 16:35:10 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-09-02 16:35:10 +0000
commit16e2a55bf42f532404cddd8ddbc7cbee38c39572 (patch)
tree31420acfcb28168ac876f45f0c51253090d8f547 /os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c
parenta489fc365df4d1b4f407438c2efcee428e073e49 (diff)
downloadChibiOS-16e2a55bf42f532404cddd8ddbc7cbee38c39572.tar.gz
ChibiOS-16e2a55bf42f532404cddd8ddbc7cbee38c39572.tar.bz2
ChibiOS-16e2a55bf42f532404cddd8ddbc7cbee38c39572.zip
Made PAL callback and wait APIs independent from each other.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10543 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c')
-rw-r--r--os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c b/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c
index be8f7e829..84f0be664 100644
--- a/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c
+++ b/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c
@@ -80,6 +80,14 @@ palevent_t _pal_events[16];
*/
void _pal_lld_init(const PALConfig *config) {
+#if PAL_USE_CALLBACKS || PAL_USE_WAIT || defined(__DOXYGEN__)
+ unsigned i;
+
+ for (i = 0; i < 16; i++) {
+ _pal_init_event(i);
+ }
+#endif
+
/*
* Enables the GPIO related clocks.
*/
@@ -183,24 +191,20 @@ void _pal_lld_setgroupmode(ioportid_t port,
port->CRL = (port->CRL & ml) | crl;
}
+#if PAL_USE_CALLBACKS || PAL_USE_WAIT || defined(__DOXYGEN__)
/**
* @brief Pad event enable.
- * @details This function programs an event callback in the specified mode.
* @note Programming an unknown or unsupported mode is silently ignored.
*
* @param[in] port port identifier
* @param[in] pad pad number within the port
* @param[in] mode pad event mode
- * @param[in] callback event callback function
- * @param[in] arg callback argument
*
* @notapi
*/
void _pal_lld_enablepadevent(ioportid_t port,
iopadid_t pad,
- ioeventmode_t mode,
- palcallback_t callback,
- void *arg) {
+ ioeventmode_t mode) {
uint32_t padmask, cridx, crmask, portidx;
@@ -218,7 +222,7 @@ void _pal_lld_enablepadevent(ioportid_t port,
crmask = ~(0xFU << (((uint32_t)pad & 3U) * 4U));
/* Port index is obtained assuming that GPIO ports are placed at regular
- 0x400 intervalis in memory space. So far this is true for all devices.*/
+ 0x400 intervals in memory space. So far this is true for all devices.*/
portidx = (uint32_t)port >> 10U;
/* Port selection in SYSCFG.*/
@@ -237,14 +241,11 @@ void _pal_lld_enablepadevent(ioportid_t port,
/* Programming interrupt and event registers.*/
EXTI->IMR |= padmask;
EXTI->EMR &= ~padmask;
-
- /* Setting up callback and argument for this event.*/
- _pal_set_event(pad, callback, arg);
}
/**
* @brief Pad event disable.
- * @details This function disables previously programmed event callbacks.
+ * @details This function also disables previously programmed event callbacks.
*
* @param[in] port port identifier
* @param[in] pad pad number within the port
@@ -269,7 +270,7 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
croff = ((uint32_t)pad & 3U) * 4U;
/* Port index is obtained assuming that GPIO ports are placed at regular
- 0x400 intervalis in memory space. So far this is true for all devices.*/
+ 0x400 intervals in memory space. So far this is true for all devices.*/
portidx = (uint32_t)port >> 10U;
crport = (AFIO->EXTICR[cridx] >> croff) & 0xFU;
@@ -282,11 +283,14 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
EXTI->RTSR = rtsr1 & ~padmask;
EXTI->FTSR = ftsr1 & ~padmask;
EXTI->PR = padmask;
-
- /* Clearing callback and argument for this event.*/
- _pal_clear_event(pad);
}
+
+#if PAL_USE_CALLBACKS || PAL_USE_WAIT
+ /* Callback cleared and/or thread reset.*/
+ _pal_clear_event(pad);
+#endif
}
+#endif /* PAL_USE_CALLBACKS || PAL_USE_WAIT */
#endif /* HAL_USE_PAL */