From 6b9d1341109e01d45edc17f91abbd1c71b3d8b57 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 2 Sep 2017 12:40:56 +0000 Subject: PAL synchronous API. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10528 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c | 10 ++-------- os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h | 21 +++++++++++++++++++++ os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c | 10 ++-------- os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h | 21 +++++++++++++++++++++ os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c | 10 ++-------- os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h | 21 +++++++++++++++++++++ 6 files changed, 69 insertions(+), 24 deletions(-) (limited to 'os/hal/ports/STM32/LLD') 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 b432fa6ee..be8f7e829 100644 --- a/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c +++ b/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.c @@ -235,14 +235,8 @@ void _pal_lld_enablepadevent(ioportid_t port, EXTI->FTSR &= ~padmask; /* Programming interrupt and event registers.*/ - if (callback != NULL) { - EXTI->IMR |= padmask; - EXTI->EMR &= ~padmask; - } - else { - EXTI->EMR |= padmask; - EXTI->IMR &= ~padmask; - } + EXTI->IMR |= padmask; + EXTI->EMR &= ~padmask; /* Setting up callback and argument for this event.*/ _pal_set_event(pad, callback, arg); 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 a80597d64..a20cea930 100644 --- a/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv1/hal_pal_lld.h @@ -394,6 +394,27 @@ typedef uint32_t iopadid_t; #define pal_lld_disablepadevent(port, pad) \ _pal_lld_disablepadevent(port, pad) +/** + * @brief Returns a PAL event structure associated to a pad. + * + * @param[in] port port identifier + * @param[in] pad pad number within the port + * + * @notapi + */ +#define pal_lld_get_pad_event(port, pad) \ + &_pal_events[pad]; (void)(port) + +/** + * @brief Returns a PAL event structure associated to a line. + * + * @param[in] line line identifier + * + * @notapi + */ +#define pal_lld_get_line_event(line) \ + &_pal_events[PAL_PAD(line)] + #if !defined(__DOXYGEN__) extern const PALConfig pal_default_config; extern palevent_t _pal_events[16]; 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 6a23eff29..70f769f02 100644 --- a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c +++ b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c @@ -264,14 +264,8 @@ void _pal_lld_enablepadevent(ioportid_t port, EXTI->FTSR &= ~padmask; /* Programming interrupt and event registers.*/ - if (callback != NULL) { - EXTI->IMR |= padmask; - EXTI->EMR &= ~padmask; - } - else { - EXTI->EMR |= padmask; - EXTI->IMR &= ~padmask; - } + EXTI->IMR |= padmask; + EXTI->EMR &= ~padmask; /* Setting up callback and argument for this event.*/ _pal_set_event(pad, callback, arg); 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 ba90ccafd..4a30a61a5 100644 --- a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h @@ -577,6 +577,27 @@ typedef uint32_t iopadid_t; #define pal_lld_disablepadevent(port, pad) \ _pal_lld_disablepadevent(port, pad) +/** + * @brief Returns a PAL event structure associated to a pad. + * + * @param[in] port port identifier + * @param[in] pad pad number within the port + * + * @notapi + */ +#define pal_lld_get_pad_event(port, pad) \ + &_pal_events[pad]; (void)(port) + +/** + * @brief Returns a PAL event structure associated to a line. + * + * @param[in] line line identifier + * + * @notapi + */ +#define pal_lld_get_line_event(line) \ + &_pal_events[PAL_PAD(line)] + #if !defined(__DOXYGEN__) extern const PALConfig pal_default_config; extern palevent_t _pal_events[16]; 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 a20e39c9a..6c8a1ec2e 100644 --- a/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c +++ b/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.c @@ -260,14 +260,8 @@ void _pal_lld_enablepadevent(ioportid_t port, EXTI->FTSR &= ~padmask; /* Programming interrupt and event registers.*/ - if (callback != NULL) { - EXTI->IMR |= padmask; - EXTI->EMR &= ~padmask; - } - else { - EXTI->EMR |= padmask; - EXTI->IMR &= ~padmask; - } + EXTI->IMR |= padmask; + EXTI->EMR &= ~padmask; /* Setting up callback and argument for this event.*/ _pal_set_event(pad, callback, arg); 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 b1f5694b6..7b423807e 100644 --- a/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h +++ b/os/hal/ports/STM32/LLD/GPIOv3/hal_pal_lld.h @@ -589,6 +589,27 @@ typedef uint32_t iopadid_t; #define pal_lld_disablepadevent(port, pad) \ _pal_lld_disablepadevent(port, pad) +/** + * @brief Returns a PAL event structure associated to a pad. + * + * @param[in] port port identifier + * @param[in] pad pad number within the port + * + * @notapi + */ +#define pal_lld_get_pad_event(port, pad) \ + &_pal_events[pad]; (void)(port) + +/** + * @brief Returns a PAL event structure associated to a line. + * + * @param[in] line line identifier + * + * @notapi + */ +#define pal_lld_get_line_event(line) \ + &_pal_events[PAL_PAD(line)] + #if !defined(__DOXYGEN__) extern const PALConfig pal_default_config; extern palevent_t _pal_events[16]; -- cgit v1.2.3