Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS1620_improved TextLCD_improved mbed-rtos mbed
tsk_main.cpp
- Committer:
- dzoni
- Date:
- 2015-12-14
- Revision:
- 15:a627638edd9c
- Parent:
- 13:f62b10a6e1c5
- Child:
- 17:94c385ff2641
File content as of revision 15:a627638edd9c:
#include "mbed.h"
#include "rtos.h"
#include "tsk_button.h"
#include "tsk_display.h"
#include "tsk_dist.h"
#include "tsk_led.h"
#include "tsk_temp.h"
#define TASKS_NUMBER (sizeof(taskList)/sizeof(taskList[0]))
uint32_t uiCnt = 0;
struct task_definition_struct {
void(*task)(void const *args);
uint32_t(*init)(void const *args); // Result: 1 = OK, 0 = FAIL
void *task_args; // NULL For DEFAULT (NULL)
void *init_args; // NULL For DEFAULT (NULL)
osPriority priority;
// uint32_t stack_size; // 0 for DEFAULT (DEFAULT_STACK_SIZE)
// unsigned char *stack_pointer; // NULL for DEFAULT (NULL)
uint32_t delay; // Delay on start from previous task
Thread *thread; // To be filled in during runtime
uint32_t retVal; // Return Value - to be filled in during runtime
};
static struct task_definition_struct taskList[] = {
{ dist_thread, NULL, NULL, NULL, osPriorityNormal, 0, NULL, 0 },
{ temp_thread, &initDS1620Temp, NULL, NULL, osPriorityLow, 0, NULL, 0 },
{ button_thread, NULL, NULL, NULL, osPriorityNormal, 0, NULL, 0 },
{ led_thread, NULL, NULL, NULL, osPriorityNormal, 0, NULL, 0 },
{ disp_thread, &initDisplay, NULL, NULL, osPriorityNormal, 0, NULL, 0 },
};
static uint32_t initTasks(void) {
uint32_t i;
uint32_t retval = 1;
for (i = 0; i < TASKS_NUMBER; i++) {
if (taskList[i].init != NULL) {
if ((taskList[i].retVal = ((*taskList[i].init)(taskList[i].init_args))) == 0)
retval = 0;
} else {
taskList[i].retVal = 1;
}
}
for (i = 0; i < TASKS_NUMBER; i++) {
Thread::wait(taskList[i].delay);
if (taskList[i].retVal == 1) {
taskList[i].thread = new Thread(taskList[i].task, taskList[i].task_args, taskList[i].priority );
}
}
return retval;
}
int main() {
Thread::wait(1000);
initTasks();
Thread::wait(osWaitForever);
disposeDisplay(NULL);
}