aboutsummaryrefslogtreecommitdiffstats
path: root/demos/NRF52
diff options
context:
space:
mode:
Diffstat (limited to 'demos/NRF52')
-rw-r--r--demos/NRF52/Classic/halconf.h2
-rw-r--r--demos/NRF52/Classic/main.c33
-rw-r--r--demos/NRF52/Classic/mcuconf.h4
3 files changed, 28 insertions, 11 deletions
diff --git a/demos/NRF52/Classic/halconf.h b/demos/NRF52/Classic/halconf.h
index e218263..3da2870 100644
--- a/demos/NRF52/Classic/halconf.h
+++ b/demos/NRF52/Classic/halconf.h
@@ -62,7 +62,7 @@
* @brief Enables the GPT subsystem.
*/
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT FALSE
+#define HAL_USE_GPT TRUE
#endif
/**
diff --git a/demos/NRF52/Classic/main.c b/demos/NRF52/Classic/main.c
index 1f92bdc..28e7505 100644
--- a/demos/NRF52/Classic/main.c
+++ b/demos/NRF52/Classic/main.c
@@ -26,6 +26,22 @@ WDGConfig WDG_config = {
};
+void gpt_callback(GPTDriver *gptp) {
+ palTogglePad(IOPORT1, LED2);
+}
+
+/*
+ * GPT configuration
+ * Frequency: 31250Hz (32us period)
+ * Resolution: 16 bits
+ */
+static const GPTConfig gpt_config = {
+ .frequency = 31250,
+ .callback = gpt_callback,
+ .resolution = 16,
+};
+
+
/*
* Command Random
*/
@@ -140,9 +156,7 @@ static THD_FUNCTION(Thread1, arg) {
while (1) {
- palSetPad(IOPORT1, led);
- chThdSleepMilliseconds(100);
- palClearPad(IOPORT1, led);
+ palTogglePad(IOPORT1, led);
chThdSleepMilliseconds(100);
}
}
@@ -166,12 +180,14 @@ int main(void)
sdStart(&SD1, &serial_config);
palSetPad(IOPORT1, LED1);
- palSetPad(IOPORT1, LED2);
- palSetPad(IOPORT1, LED3);
+ palClearPad(IOPORT1, LED2);
+ palClearPad(IOPORT1, LED3);
palSetPad(IOPORT1, LED4);
+ gptStart(&GPTD1, &gpt_config);
+ gptStartContinuous(&GPTD1, 31250);
-
+
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+1,
Thread1, NULL);
@@ -181,6 +197,7 @@ int main(void)
shellThread, (void *)&shell_cfg1);
+
printf(PORT_INFO "\r\n");
chThdSleep(2);
@@ -189,7 +206,9 @@ int main(void)
printf("Priority levels %d\r\n", CORTEX_PRIORITY_LEVELS);
- test_execute((BaseSequentialStream *)&SD1);
+ //test_execute((BaseSequentialStream *)&SD1);
+
+ NRF_P0->DETECTMODE = 0;
while (true) {
if (watchdog_started &&
diff --git a/demos/NRF52/Classic/mcuconf.h b/demos/NRF52/Classic/mcuconf.h
index c73c34e..f70f2cc 100644
--- a/demos/NRF52/Classic/mcuconf.h
+++ b/demos/NRF52/Classic/mcuconf.h
@@ -22,9 +22,6 @@
*/
-
-
-
#define NRF5_SOFTDEVICE_THREAD_WA_SIZE 128
#define SHELL_CMD_TEST_ENABLED FALSE
@@ -44,6 +41,7 @@
#define NRF5_SERIAL_USE_UART0 TRUE
#define NRF5_SERIAL_USE_HWFLOWCTRL TRUE
#define NRF5_RNG_USE_RNG0 TRUE
+#define NRF5_GPT_USE_TIMER0 TRUE
#define WDG_USE_TIMEOUT_CALLBACK TRUE