From 4c9316d0b620a641a331da0cd5f57d24bae1e6d3 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Mar 2017 15:03:50 +0700 Subject: [PATCH] correct rtos priority lower number = lower prio --- cores/nRF5/rtos.h | 9 +++++++++ cores/nRF5/wiring_constants.h | 9 --------- libraries/Bluefruit52Lib/src/bluefruit.cpp | 16 +++++++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cores/nRF5/rtos.h b/cores/nRF5/rtos.h index 8d9d5364..df10c792 100644 --- a/cores/nRF5/rtos.h +++ b/cores/nRF5/rtos.h @@ -51,6 +51,15 @@ #include "queue.h" #include "semphr.h" +enum +{ + TASK_PRIO_LOWEST = 0, + TASK_PRIO_LOW = 1, + TASK_PRIO_NORMAL = 2, + TASK_PRIO_HIGH = 3, + TASK_PRIO_HIGHEST = 4, +}; + #if 0 #define rtos_malloc(_size) ({ cprintf("[malloc] %s:%d : %d bytes\r\n", __PRETTY_FUNCTION__, __LINE__, _size); pvPortMalloc(_size); }) #define rtos_free(ptr) ({ cprintf("[free] %s:%d\r\n" ,__PRETTY_FUNCTION__, __LINE__/*malloc_usable_size(ptr)*/); vPortFree(ptr); }) diff --git a/cores/nRF5/wiring_constants.h b/cores/nRF5/wiring_constants.h index 8669a25f..2cbda4ba 100644 --- a/cores/nRF5/wiring_constants.h +++ b/cores/nRF5/wiring_constants.h @@ -56,15 +56,6 @@ enum BitOrder { //#define DEFAULT 1 //#define EXTERNAL 0 -enum -{ - TASK_PRIO_HIGHEST = 0, - TASK_PRIO_HIGH = 1, - TASK_PRIO_NORMAL = 2, - TASK_PRIO_LOW = 3, - TASK_PRIO_LOWEST = 4 -}; - typedef uint32_t err_t; enum diff --git a/libraries/Bluefruit52Lib/src/bluefruit.cpp b/libraries/Bluefruit52Lib/src/bluefruit.cpp index 9c036695..dc51d866 100644 --- a/libraries/Bluefruit52Lib/src/bluefruit.cpp +++ b/libraries/Bluefruit52Lib/src/bluefruit.cpp @@ -54,7 +54,8 @@ #define CFG_DEFAULT_NAME "Bluefruit52" #define CFG_ADV_BLINKY_INTERVAL 500 -#define CFG_BLUEFRUIT_TASK_STACKSIZE (512*3) +#define CFG_BLE_TASK_STACKSIZE (512*3) +#define CFG_SOC_TASK_STACKSIZE (16*3) #define CFG_BOND_NFFS_DIR "/adafruit/bond" @@ -181,12 +182,17 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable) /*------------- DFU OTA as built-in service -------------*/ _dfu_svc.start(); - // Create RTOS Task for BLE Event - TaskHandle_t task_hdl; - xTaskCreate( adafruit_bluefruit_task, "BLE Evt", CFG_BLUEFRUIT_TASK_STACKSIZE, NULL, TASK_PRIO_HIGH, &task_hdl); - + // Create RTOS Semaphore & Task for BLE Event _ble_event_sem = xSemaphoreCreateBinary(); VERIFY(_ble_event_sem, NRF_ERROR_NO_MEM); + + TaskHandle_t ble_task_hdl; + xTaskCreate( adafruit_bluefruit_task, "SD BLE", CFG_BLE_TASK_STACKSIZE, NULL, TASK_PRIO_HIGH, &ble_task_hdl); + + // Create RTOS Semaphore & Task for SOC Event +// TaskHandle_t soc_task_hdl; +// xTaskCreate( adafruit_bluefruit_task, "SD SOC", CFG_SOC_TASK_STACKSIZE, NULL, TASK_PRIO_HIGH, &soc_task_hdl); + NVIC_EnableIRQ(SD_EVT_IRQn); // Create Timer for led advertising blinky