diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-09-02 16:35:10 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-09-02 16:35:10 +0000 |
commit | 16e2a55bf42f532404cddd8ddbc7cbee38c39572 (patch) | |
tree | 31420acfcb28168ac876f45f0c51253090d8f547 /os/hal/ports/STM32/LLD | |
parent | a489fc365df4d1b4f407438c2efcee428e073e49 (diff) | |
download | ChibiOS-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')
-rw-r--r-- | os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c | 34 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h | 13 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c | 30 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h | 11 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c | 30 | ||||
-rw-r--r-- | os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h | 11 |
6 files changed, 64 insertions, 65 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 */
diff --git a/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h b/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h index a20cea930..f7f1c2e81 100644 --- a/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h @@ -368,19 +368,16 @@ typedef uint32_t iopadid_t; /**
* @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
*/
-#define pal_lld_enablepadevent(port, pad, mode, callback, arg) \
- _pal_lld_enablepadevent(port, pad, mode, callback, arg)
+#define pal_lld_enablepadevent(port, pad, mode) \
+ _pal_lld_enablepadevent(port, pad, mode)
/**
* @brief Pad event disable.
@@ -427,12 +424,12 @@ extern "C" { void _pal_lld_setgroupmode(ioportid_t port,
ioportmask_t mask,
iomode_t mode);
+#if PAL_USE_CALLBACKS || PAL_USE_WAIT
void _pal_lld_enablepadevent(ioportid_t port,
iopadid_t pad,
- ioeventmode_t mode,
- palcallback_t callback,
- void *arg);
+ ioeventmode_t mode);
void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad);
+#endif
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c index 70f769f02..ab6864474 100644 --- a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c +++ b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c @@ -92,6 +92,14 @@ static void initgpio(stm32_gpio_t *gpiop, const stm32_gpio_setup_t *config) { */
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.
*/
@@ -212,24 +220,20 @@ void _pal_lld_setgroupmode(ioportid_t port, }
}
+#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;
@@ -247,7 +251,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.*/
@@ -266,9 +270,6 @@ 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);
}
/**
@@ -298,7 +299,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 = (SYSCFG->EXTICR[cridx] >> croff) & 0xFU;
@@ -312,10 +313,13 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) { 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 */
diff --git a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h index 4a30a61a5..546c45045 100644 --- a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h @@ -551,19 +551,16 @@ typedef uint32_t iopadid_t; /**
* @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
*/
-#define pal_lld_enablepadevent(port, pad, mode, callback, arg) \
- _pal_lld_enablepadevent(port, pad, mode, callback, arg)
+#define pal_lld_enablepadevent(port, pad, mode) \
+ _pal_lld_enablepadevent(port, pad, mode)
/**
* @brief Pad event disable.
@@ -612,9 +609,7 @@ extern "C" { iomode_t mode);
void _pal_lld_enablepadevent(ioportid_t port,
iopadid_t pad,
- ioeventmode_t mode,
- palcallback_t callback,
- void *arg);
+ ioeventmode_t mode);
void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad);
#ifdef __cplusplus
}
diff --git a/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c b/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c index 6c8a1ec2e..65f76a609 100644 --- a/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c +++ b/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c @@ -95,6 +95,14 @@ static void initgpio(stm32_gpio_t *gpiop, const stm32_gpio_setup_t *config) { */
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.
*/
@@ -208,24 +216,20 @@ void _pal_lld_setgroupmode(ioportid_t port, }
}
+#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;
@@ -243,7 +247,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.*/
@@ -262,9 +266,6 @@ 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);
}
/**
@@ -294,7 +295,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 = (SYSCFG->EXTICR[cridx] >> croff) & 0xFU;
@@ -308,10 +309,13 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) { 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 */
diff --git a/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h b/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h index 7b423807e..c76fda1b0 100644 --- a/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h @@ -563,19 +563,16 @@ typedef uint32_t iopadid_t; /**
* @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
*/
-#define pal_lld_enablepadevent(port, pad, mode, callback, arg) \
- _pal_lld_enablepadevent(port, pad, mode, callback, arg)
+#define pal_lld_enablepadevent(port, pad, mode) \
+ _pal_lld_enablepadevent(port, pad, mode)
/**
* @brief Pad event disable.
@@ -624,9 +621,7 @@ extern "C" { iomode_t mode);
void _pal_lld_enablepadevent(ioportid_t port,
iopadid_t pad,
- ioeventmode_t mode,
- palcallback_t callback,
- void *arg);
+ ioeventmode_t mode);
void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad);
#ifdef __cplusplus
}
|