diff options
author | Stefan Agner <stefan@agner.ch> | 2016-05-02 19:13:19 -0700 |
---|---|---|
committer | Stefan Agner <stefan@agner.ch> | 2016-05-09 17:17:05 -0700 |
commit | 21d6d84123de8e6e2ebdf5543b530403951b3059 (patch) | |
tree | 046a7fa39e1c7cff49792ac67f1ae899271a56b7 /examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c | |
parent | 2fb8ccd4adf6433033a402e2fa07c2f11c489518 (diff) |
resync with FreeRTOS_BSP_1.0.1_iMX7D
Diffstat (limited to 'examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c')
-rw-r--r-- | examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c b/examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c index 4b035cb..d092c45 100644 --- a/examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c +++ b/examples/imx7_colibri_m4/demo_apps/blinking_imx_demo/gpt_timer.c @@ -37,15 +37,15 @@ #include "FreeRTOS.h" #include "semphr.h" -#include "gpt.h" -#include "gpt_timer.h" #include "board.h" +#include "gpt.h" +#include "hw_timer.h" static SemaphoreHandle_t xSemaphore; -void GPT_Timer_Init() +void Hw_Timer_Init(void) { - gpt_mode_config_t config = { + gpt_init_config_t config = { .freeRun = false, .waitEnable = true, .stopEnable = true, @@ -54,8 +54,6 @@ void GPT_Timer_Init() .enableMode = true }; - xSemaphore = xSemaphoreCreateBinary(); - /* Initialize GPT module */ GPT_Init(BOARD_GPTA_BASEADDR, &config); @@ -67,11 +65,13 @@ void GPT_Timer_Init() /* Enable NVIC interrupt */ NVIC_EnableIRQ(BOARD_GPTA_IRQ_NUM); + + xSemaphore = xSemaphoreCreateBinary(); } -void GPT_Timer_Delay(uint32_t ms) +void Hw_Timer_Delay(uint32_t ms) { - uint64_t counter = 24000 * ms; /* First get the counter needed by delay time */ + uint64_t counter = 24000ULL * ms; /* First get the counter needed by delay time */ uint32_t high; uint32_t div24m, div; @@ -100,16 +100,20 @@ void GPT_Timer_Delay(uint32_t ms) xSemaphoreTake(xSemaphore, portMAX_DELAY); } -void BOARD_GPTA_HANDLER() +void BOARD_GPTA_HANDLER(void) { - BaseType_t xHigherPriorityTaskWoken; + BaseType_t xHigherPriorityTaskWoken = pdFALSE; - /* When GPT timeout, we disable GPT to make sure this is a oneshot event */ + /* When GPT time-out, we disable GPT to make sure this is a one-shot event. */ GPT_Disable(BOARD_GPTA_BASEADDR); GPT_SetIntCmd(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1, false); GPT_ClearStatusFlag(BOARD_GPTA_BASEADDR, gptStatusFlagOutputCompare1); + /* Unlock the task to process the event. */ xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken); + + /* Perform a context switch to wake the higher priority task. */ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } /******************************************************************************* |