Fixes to task reimplementation to make UART work.
This commit is contained in:
parent
56789592fa
commit
75dbc59ba9
|
@ -54,12 +54,13 @@ bool task_init_handler(task_prio_t priority, uint8 qlen) {
|
||||||
|
|
||||||
|
|
||||||
task_handle_t task_get_id(task_callback_t t) {
|
task_handle_t task_get_id(task_callback_t t) {
|
||||||
int p = TASK_PRIORITY_COUNT;
|
/* Initialise any uninitialised Qs with the default Q len */
|
||||||
/* Initialise and uninitialised Qs with the default Q len */
|
for (task_prio_t p = TASK_PRIORITY_LOW; p != TASK_PRIORITY_COUNT; ++p)
|
||||||
while(p--)
|
{
|
||||||
if (!task_Q[p]) {
|
if (!task_Q[p]) {
|
||||||
CHECK(task_init_handler( p, TASK_DEFAULT_QUEUE_LEN ), 0, "Task initialisation failed");
|
CHECK(task_init_handler( p, TASK_DEFAULT_QUEUE_LEN ), 0, "Task initialisation failed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( (task_count & (TASK_HANDLE_ALLOCATION_BRICK - 1)) == 0 ) {
|
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 */
|
/* 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);
|
memset (task_func+task_count, 0, sizeof(task_callback_t)*TASK_HANDLE_ALLOCATION_BRICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
task_func[task_count++] = t;
|
task_func[task_count] = t;
|
||||||
return TASK_HANDLE_MONIKER + (task_count-1);
|
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 ||
|
if (priority >= TASK_PRIORITY_COUNT ||
|
||||||
!task_Q[priority] ||
|
!task_Q[priority] ||
|
||||||
(handle & TASK_HANDLE_MASK != TASK_HANDLE_MONIKER))
|
(handle & TASK_HANDLE_MASK) != TASK_HANDLE_MONIKER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
task_event_t ev = { handle, param };
|
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)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ void TEXT_SECTION_ATTR user_start_trampoline (void)
|
||||||
|
|
||||||
// +================== New task interface ==================+
|
// +================== New task interface ==================+
|
||||||
static void start_lua(task_param_t param, task_prio_t prio) {
|
static void start_lua(task_param_t param, task_prio_t prio) {
|
||||||
|
(void)param;
|
||||||
(void)prio;
|
(void)prio;
|
||||||
char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
|
char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL };
|
||||||
NODE_DBG("Task task_lua started.\n");
|
NODE_DBG("Task task_lua started.\n");
|
||||||
|
@ -115,7 +116,7 @@ void nodemcu_init(void)
|
||||||
// test_spiffs();
|
// test_spiffs();
|
||||||
#endif
|
#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 ();
|
rtctime_late_startup ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO: fix uart driver to work with RTOS SDK
|
|
||||||
UartBautRate br = BIT_RATE_DEFAULT;
|
UartBautRate br = BIT_RATE_DEFAULT;
|
||||||
|
|
||||||
input_sig = task_get_id(handle_input);
|
input_sig = task_get_id(handle_input);
|
||||||
uart_init (br, br, input_sig);
|
uart_init (br, br, input_sig);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NODE_DEBUG
|
#ifndef NODE_DEBUG
|
||||||
system_set_os_print(0);
|
system_set_os_print(0);
|
||||||
|
|
Loading…
Reference in New Issue