aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin K. Oblaukhov <oblaukhov@sl.iae.nsk.su>2019-04-09 13:40:54 +0700
committerKonstantin K. Oblaukhov <oblaukhov@sl.iae.nsk.su>2019-04-09 15:16:36 +0700
commit6dc1071c9f5f470dc4956ce78d59040499b76e07 (patch)
tree8a1cb5537963be04056e3292898d3291e73d3459
parenta9b84aa0361442234a9c664dd06c97b6587e9d8c (diff)
downloadChibiOS-Contrib-6dc1071c9f5f470dc4956ce78d59040499b76e07.tar.gz
ChibiOS-Contrib-6dc1071c9f5f470dc4956ce78d59040499b76e07.tar.bz2
ChibiOS-Contrib-6dc1071c9f5f470dc4956ce78d59040499b76e07.zip
EXT test rewritten.
Add default value for NRF5_PAL_PAD_TO_EVENT macro.
-rw-r--r--os/hal/ports/NRF5/LLD/GPIOv1/hal_pal_lld.h8
-rw-r--r--testhal/NRF51/NRF51822/PAL/Makefile (renamed from testhal/NRF51/NRF51822/EXT/Makefile)0
-rw-r--r--testhal/NRF51/NRF51822/PAL/chconf.h (renamed from testhal/NRF51/NRF51822/EXT/chconf.h)0
-rw-r--r--testhal/NRF51/NRF51822/PAL/halconf.h (renamed from testhal/NRF51/NRF51822/EXT/halconf.h)2
-rw-r--r--testhal/NRF51/NRF51822/PAL/halconf_community.h (renamed from testhal/NRF51/NRF51822/EXT/halconf_community.h)0
-rw-r--r--testhal/NRF51/NRF51822/PAL/main.c (renamed from testhal/NRF51/NRF51822/EXT/main.c)33
-rw-r--r--testhal/NRF51/NRF51822/PAL/mcuconf.h (renamed from testhal/NRF51/NRF51822/EXT/mcuconf.h)0
7 files changed, 20 insertions, 23 deletions
diff --git a/os/hal/ports/NRF5/LLD/GPIOv1/hal_pal_lld.h b/os/hal/ports/NRF5/LLD/GPIOv1/hal_pal_lld.h
index 2df3fd3..e9021eb 100644
--- a/os/hal/ports/NRF5/LLD/GPIOv1/hal_pal_lld.h
+++ b/os/hal/ports/NRF5/LLD/GPIOv1/hal_pal_lld.h
@@ -155,6 +155,14 @@ typedef uint32_t iopadid_t;
#define NRF5_GPIOTE_NUM_CHANNELS (8)
#endif
+/**
+ * @brief Pad to event number
+ * @details Converts pad to GPIOTE peripheral pad event number
+ */
+#if !defined(NRF5_PAL_PAD_TO_EVENT) || defined(__DOXYGEN__)
+#define NRF5_PAL_PAD_TO_EVENT(pad) ((pad) % NRF5_GPIOTE_NUM_CHANNELS)
+#endif
+
/*===========================================================================*/
/* Implementation, some of the following macros could be implemented as */
/* functions, if so please put them in pal_lld.c. */
diff --git a/testhal/NRF51/NRF51822/EXT/Makefile b/testhal/NRF51/NRF51822/PAL/Makefile
index 79e226d..79e226d 100644
--- a/testhal/NRF51/NRF51822/EXT/Makefile
+++ b/testhal/NRF51/NRF51822/PAL/Makefile
diff --git a/testhal/NRF51/NRF51822/EXT/chconf.h b/testhal/NRF51/NRF51822/PAL/chconf.h
index 0ac7be8..0ac7be8 100644
--- a/testhal/NRF51/NRF51822/EXT/chconf.h
+++ b/testhal/NRF51/NRF51822/PAL/chconf.h
diff --git a/testhal/NRF51/NRF51822/EXT/halconf.h b/testhal/NRF51/NRF51822/PAL/halconf.h
index 407dd2f..c8c556a 100644
--- a/testhal/NRF51/NRF51822/EXT/halconf.h
+++ b/testhal/NRF51/NRF51822/PAL/halconf.h
@@ -55,7 +55,7 @@
* @brief Enables the EXT subsystem.
*/
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
-#define HAL_USE_EXT TRUE
+#define HAL_USE_EXT FALSE
#endif
/**
diff --git a/testhal/NRF51/NRF51822/EXT/halconf_community.h b/testhal/NRF51/NRF51822/PAL/halconf_community.h
index 43fdbf8..43fdbf8 100644
--- a/testhal/NRF51/NRF51822/EXT/halconf_community.h
+++ b/testhal/NRF51/NRF51822/PAL/halconf_community.h
diff --git a/testhal/NRF51/NRF51822/EXT/main.c b/testhal/NRF51/NRF51822/PAL/main.c
index f24eb5d..313291c 100644
--- a/testhal/NRF51/NRF51822/EXT/main.c
+++ b/testhal/NRF51/NRF51822/PAL/main.c
@@ -42,11 +42,9 @@ static void led2toggle(void *arg) {
debouncing2 = false;
}
-static void extcb1(EXTDriver *extp, expchannel_t channel)
+static void extcb1(void *arg)
{
- (void)extp;
- (void)channel;
-
+ (void)arg;
uint8_t pad1 = palReadPad(IOPORT1, KEY1);
if (!debouncing1 && (pad1 == PAL_LOW)) {
@@ -63,11 +61,9 @@ static void extcb1(EXTDriver *extp, expchannel_t channel)
}
}
-static void extcb2(EXTDriver *extp, expchannel_t channel)
+static void extcb2(void *arg)
{
- (void)extp;
- (void)channel;
-
+ (void)arg;
uint8_t pad2 = palReadPad(IOPORT1, KEY2);
if (!debouncing2 && (pad2 == PAL_LOW)) {
@@ -84,14 +80,6 @@ static void extcb2(EXTDriver *extp, expchannel_t channel)
}
}
-static const EXTConfig extcfg =
-{
- {
- {EXT_CH_MODE_FALLING_EDGE | EXT_CH_MODE_AUTOSTART | (KEY1 << EXT_MODE_GPIO_OFFSET), extcb1},
- {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | (KEY2 << EXT_MODE_GPIO_OFFSET), extcb2},
- }
-};
-
/*
* Application entry point.
*/
@@ -106,8 +94,9 @@ int main(void)
*/
halInit();
chSysInit();
-
- extStart(&EXTD1, &extcfg);
+
+ palSetPadCallback(IOPORT1, KEY1, extcb1, NULL);
+ palSetPadCallback(IOPORT1, KEY2, extcb2, NULL);
/*
* Normal main() thread activity, in this demo it enables and disables the
@@ -116,12 +105,12 @@ int main(void)
while (TRUE) {
palSetPad(IOPORT1, LED0);
chThdSleepMilliseconds(5000);
- extChannelDisable(&EXTD1, 0);
- extChannelDisable(&EXTD1, 1);
+ palDisablePadEvent(IOPORT1, KEY1);
+ palDisablePadEvent(IOPORT1, KEY2);
palClearPad(IOPORT1, LED0);
chThdSleepMilliseconds(5000);
- extChannelEnable(&EXTD1, 0);
- extChannelEnable(&EXTD1, 1);
+ palEnablePadEvent(IOPORT1, KEY1, PAL_EVENT_MODE_FALLING_EDGE);
+ palEnablePadEvent(IOPORT1, KEY2, PAL_EVENT_MODE_RISING_EDGE);
}
return 0;
diff --git a/testhal/NRF51/NRF51822/EXT/mcuconf.h b/testhal/NRF51/NRF51822/PAL/mcuconf.h
index f3a0d85..f3a0d85 100644
--- a/testhal/NRF51/NRF51822/EXT/mcuconf.h
+++ b/testhal/NRF51/NRF51822/PAL/mcuconf.h