forked from ROMEO/obsw
added freeRTOS on linux build
This commit is contained in:
102
mission/mission.c
Normal file
102
mission/mission.c
Normal file
@ -0,0 +1,102 @@
|
||||
/* Standard includes. */
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
#include "task.h"
|
||||
|
||||
void rust_main();
|
||||
|
||||
// called to stop execution (either a panic or program ended)
|
||||
// to be implemented by bsp (do not return from it!)
|
||||
void done();
|
||||
|
||||
void init_task(void *) {
|
||||
// printf("Starting Mission\n");
|
||||
|
||||
rust_main();
|
||||
|
||||
// printf("Started Tasks, deleting init task\n");
|
||||
|
||||
done();
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void mission(void) {
|
||||
|
||||
int taskParameters = 0;
|
||||
|
||||
static const size_t stackSizeWords = 102400;
|
||||
StaticTask_t xTaskBuffer;
|
||||
StackType_t xStack[stackSizeWords];
|
||||
|
||||
xTaskCreate(init_task, /* The function that implements the task. */
|
||||
"init", /* The text name assigned to the task - for debug only as
|
||||
it is not used by the kernel. */
|
||||
10240, /* The size of the stack to allocate to the task. */
|
||||
&taskParameters, /* The parameter passed to the task - not used in
|
||||
this simple case. */
|
||||
4, /* The priority assigned to the task. */
|
||||
NULL);
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following
|
||||
line will never be reached. If the following line does execute, then
|
||||
there was either insufficient FreeRTOS heap memory available for the idle
|
||||
and/or timer tasks to be created, or vTaskStartScheduler() was called from
|
||||
User mode. See the memory management section on the FreeRTOS web site for
|
||||
more details on the FreeRTOS heap http://www.freertos.org/a00111.html. The
|
||||
mode from which main() is called is set in the C start up code and must be
|
||||
a privileged mode (not user mode). */
|
||||
|
||||
done();
|
||||
|
||||
for (;;)
|
||||
;
|
||||
/* Don't expect to reach here. */
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) {
|
||||
(void)pcTaskName;
|
||||
(void)pxTask;
|
||||
|
||||
/* Run time stack overflow checking is performed if
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
|
||||
function is called if a stack overflow is detected. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
// TODO panic
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
void rust_alloc_failed();
|
||||
|
||||
void vApplicationMallocFailedHook(void) {
|
||||
/* Called if a call to pvPortMalloc() fails because there is insufficient
|
||||
free memory available in the FreeRTOS heap. pvPortMalloc() is called
|
||||
internally by FreeRTOS API functions that create tasks, queues, software
|
||||
timers, and semaphores. The size of the FreeRTOS heap is set by the
|
||||
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
rust_alloc_failed();
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
void rust_assert_called(const char *pcFile, unsigned long ulLine);
|
||||
|
||||
void vAssertCalled(const char *pcFile, unsigned long ulLine) {
|
||||
taskDISABLE_INTERRUPTS();
|
||||
rust_assert_called(pcFile, ulLine);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*-----------------------------------------------------------*/
|
Reference in New Issue
Block a user