diff options
author | Stephane D'Alu <sdalu@sdalu.com> | 2016-07-10 19:15:46 +0200 |
---|---|---|
committer | Stephane D'Alu <sdalu@sdalu.com> | 2016-07-10 19:15:46 +0200 |
commit | 321ec844af3b1e7a23c94bce65bc8aa13ef1e09e (patch) | |
tree | 1eea159a7f4fd9e8cb27d41405fbd1f719c74441 | |
parent | 5d1b4d1d776f4e32b5f238a977172800417727bf (diff) | |
download | ChibiOS-Contrib-321ec844af3b1e7a23c94bce65bc8aa13ef1e09e.tar.gz ChibiOS-Contrib-321ec844af3b1e7a23c94bce65bc8aa13ef1e09e.tar.bz2 ChibiOS-Contrib-321ec844af3b1e7a23c94bce65bc8aa13ef1e09e.zip |
moved GPT to LLD
-rw-r--r-- | demos/NRF52/Classic/halconf.h | 2 | ||||
-rw-r--r-- | demos/NRF52/Classic/main.c | 33 | ||||
-rw-r--r-- | demos/NRF52/Classic/mcuconf.h | 4 | ||||
-rw-r--r-- | os/hal/ports/NRF5/LLD/hal_gpt_lld.c (renamed from os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c) | 5 | ||||
-rw-r--r-- | os/hal/ports/NRF5/LLD/hal_gpt_lld.h (renamed from os/hal/ports/NRF5/NRF51822/hal_gpt_lld.h) | 4 | ||||
-rw-r--r-- | os/hal/ports/NRF5/LLD/hal_st_lld.h | 1 | ||||
-rw-r--r-- | os/hal/ports/NRF5/NRF51822/platform.mk | 4 | ||||
-rw-r--r-- | os/hal/ports/NRF5/NRF52832/platform.mk | 4 |
8 files changed, 40 insertions, 17 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
diff --git a/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c b/os/hal/ports/NRF5/LLD/hal_gpt_lld.c index 3fb14dd..e850e31 100644 --- a/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c +++ b/os/hal/ports/NRF5/LLD/hal_gpt_lld.c @@ -15,8 +15,8 @@ */
/**
- * @file NRF51x22/gpt_lld.c
- * @brief NRF51x22 GPT subsystem low level driver source.
+ * @file NRF5/LLD/hal_gpt_lld.c
+ * @brief NRF5 GPT subsystem low level driver source.
*
* @addtogroup GPT
* @{
@@ -102,6 +102,7 @@ static uint8_t prescaler(uint16_t freq) static void gpt_lld_serve_interrupt(GPTDriver *gptp) {
gptp->tim->EVENTS_COMPARE[gptp->cc_int] = 0;
+ (void)gptp->tim->EVENTS_COMPARE[gptp->cc_int];
if (gptp->state == GPT_ONESHOT)
gptp->state = GPT_READY; /* Back in GPT_READY state. */
gptp->config->callback(gptp);
diff --git a/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.h b/os/hal/ports/NRF5/LLD/hal_gpt_lld.h index 5ce7a95..4173a3a 100644 --- a/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.h +++ b/os/hal/ports/NRF5/LLD/hal_gpt_lld.h @@ -15,8 +15,8 @@ */
/**
- * @file NRF51x22/gpt_lld.h
- * @brief NRF51x22 GPT subsystem low level driver header.
+ * @file NRF5/LLD/gpt_lld.h
+ * @brief NRF5 GPT subsystem low level driver header.
*
* @addtogroup GPT
* @{
diff --git a/os/hal/ports/NRF5/LLD/hal_st_lld.h b/os/hal/ports/NRF5/LLD/hal_st_lld.h index 9d67ce9..7073e12 100644 --- a/os/hal/ports/NRF5/LLD/hal_st_lld.h +++ b/os/hal/ports/NRF5/LLD/hal_st_lld.h @@ -124,6 +124,7 @@ #error "Invalid IRQ priority assigned to ST driver"
#endif
+
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
diff --git a/os/hal/ports/NRF5/NRF51822/platform.mk b/os/hal/ports/NRF5/NRF51822/platform.mk index 9ddbeee..8631487 100644 --- a/os/hal/ports/NRF5/NRF51822/platform.mk +++ b/os/hal/ports/NRF5/NRF51822/platform.mk @@ -26,7 +26,7 @@ ifneq ($(findstring HAL_USE_ADC TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_adc_lld.c endif ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),) -PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c +PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c endif ifneq ($(findstring HAL_USE_WDG TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c @@ -51,7 +51,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_ext_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_adc_lld.c \ - ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c \ + ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_pwm_lld.c \ diff --git a/os/hal/ports/NRF5/NRF52832/platform.mk b/os/hal/ports/NRF5/NRF52832/platform.mk index fd3912c..57ae88d 100644 --- a/os/hal/ports/NRF5/NRF52832/platform.mk +++ b/os/hal/ports/NRF5/NRF52832/platform.mk @@ -12,6 +12,9 @@ endif ifneq ($(findstring HAL_USE_SERIAL TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c endif +ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),) +PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c +endif ifneq ($(findstring HAL_USE_WDG TRUE,$(HALCONF)),) PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c endif @@ -24,6 +27,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_pal_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_st_lld.c \ + ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_gpt_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c endif |