Fixes to task reimplementation to make UART work.

This commit is contained in:
Johny Mattsson 2016-05-31 13:56:47 +10:00
parent 56789592fa
commit 75dbc59ba9
2 changed files with 13 additions and 13 deletions

View File

@ -54,12 +54,13 @@ bool task_init_handler(task_prio_t priority, uint8 qlen) {
task_handle_t task_get_id(task_callback_t t) {
int p = TASK_PRIORITY_COUNT;
/* Initialise and uninitialised Qs with the default Q len */
while(p--)
/* Initialise any uninitialised Qs with the default Q len */
for (task_prio_t p = TASK_PRIORITY_LOW; p != TASK_PRIORITY_COUNT; ++p)
{
if (!task_Q[p]) {
CHECK(task_init_handler( p, TASK_DEFAULT_QUEUE_LEN ), 0, "Task initialisation failed");
}
}
if ( (task_count & (TASK_HANDLE_ALLOCATION_BRICK - 1)) == 0 ) {
/* With a brick size of 4 this branch is taken at 0, 4, 8 ... and the new size is +4 */
@ -71,8 +72,8 @@ task_handle_t task_get_id(task_callback_t t) {
memset (task_func+task_count, 0, sizeof(task_callback_t)*TASK_HANDLE_ALLOCATION_BRICK);
}
task_func[task_count++] = t;
return TASK_HANDLE_MONIKER + (task_count-1);
task_func[task_count] = t;
return TASK_HANDLE_MONIKER | task_count++;
}
@ -80,7 +81,7 @@ bool task_post (task_prio_t priority, task_handle_t handle, task_param_t param)
{
if (priority >= TASK_PRIORITY_COUNT ||
!task_Q[priority] ||
(handle & TASK_HANDLE_MASK != TASK_HANDLE_MONIKER))
(handle & TASK_HANDLE_MASK) != TASK_HANDLE_MONIKER)
return false;
task_event_t ev = { handle, param };
@ -95,11 +96,12 @@ bool task_post (task_prio_t priority, task_handle_t handle, task_param_t param)
static bool next_event (task_event_t *ev, task_prio_t *prio)
{
for (task_prio_t p = TASK_PRIORITY_COUNT; p != TASK_PRIORITY_LOW; --p)
for (task_prio_t pr = TASK_PRIORITY_COUNT; pr != TASK_PRIORITY_LOW; --pr)
{
if (task_Q[p-1] && xQueueReceive (task_Q[p-1], ev, 0) == pdTRUE)
task_prio_t p = pr -1;
if (task_Q[p] && xQueueReceive (task_Q[p], ev, 0) == pdTRUE)
{
*prio = p-1;
*prio = p;
return true;
}
}

View File

@ -54,6 +54,7 @@ void TEXT_SECTION_ATTR user_start_trampoline (void)
// +================== New task interface ==================+
static void start_lua(task_param_t param, task_prio_t prio) {
(void)param;
(void)prio;
char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
NODE_DBG("Task task_lua started.\n");
@ -115,7 +116,7 @@ void nodemcu_init(void)
// test_spiffs();
#endif
task_post_low(task_get_id(start_lua),'s');
task_post_low(task_get_id(start_lua), 0);
}
@ -142,13 +143,10 @@ void user_init(void)
rtctime_late_startup ();
#endif
#if 0
// TODO: fix uart driver to work with RTOS SDK
UartBautRate br = BIT_RATE_DEFAULT;
input_sig = task_get_id(handle_input);
uart_init (br, br, input_sig);
#endif
#ifndef NODE_DEBUG
system_set_os_print(0);