Skip to content

Commit e57a039

Browse files
committed
suspend callback task when reszing, still there is chance to run into issue.
1 parent e400dc8 commit e57a039

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cores/nRF5/utility/AdaCallback.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
static QueueHandle_t _cb_queue = NULL;
4242
static uint32_t _cb_qdepth;
43+
static TaskHandle_t _cb_task;
4344

4445
void adafruit_callback_task(void* arg)
4546
{
@@ -140,8 +141,7 @@ void ada_callback_init(uint32_t stack_sz)
140141
_cb_qdepth = INITIAL_QUEUE_DEPTH;
141142
_cb_queue = xQueueCreate(_cb_qdepth, sizeof(void*));
142143

143-
TaskHandle_t callback_task_hdl;
144-
xTaskCreate( adafruit_callback_task, "Callback", stack_sz, NULL, TASK_PRIO_NORMAL, &callback_task_hdl);
144+
xTaskCreate( adafruit_callback_task, "Callback", stack_sz, NULL, TASK_PRIO_NORMAL, &_cb_task);
145145
}
146146

147147
bool ada_callback_queue_resize(uint32_t new_depth)
@@ -152,6 +152,7 @@ bool ada_callback_queue_resize(uint32_t new_depth)
152152

153153
LOG_LV1("MEMORY", "AdaCallback increase queue depth to %d", new_depth);
154154

155+
vTaskSuspend(_cb_task);
155156
taskENTER_CRITICAL();
156157

157158
// move item from old queue
@@ -168,6 +169,7 @@ bool ada_callback_queue_resize(uint32_t new_depth)
168169
_cb_queue = new_queue;
169170

170171
taskEXIT_CRITICAL();
172+
vTaskResume(_cb_task);
171173

172174
return true;
173175
}

0 commit comments

Comments
 (0)