|
1 | 1 | #include "obc_logging.h" |
| 2 | +#include "obc_adc.h" |
2 | 3 | #include "obc_sci_io.h" |
3 | | -#include "obc_i2c_io.h" |
4 | | -#include "obc_spi_io.h" |
5 | | -#include "obc_reset.h" |
| 4 | +#include "obc_errors.h" |
| 5 | +#include "obc_print.h" |
6 | 6 | #include "obc_scheduler_config.h" |
7 | | -#include "state_mgr.h" |
| 7 | +#include "obc_metadata.h" |
8 | 8 |
|
9 | 9 | #include <FreeRTOS.h> |
10 | 10 | #include <os_task.h> |
| 11 | +#include <sci.h> |
| 12 | +#include <adc.h> |
| 13 | +#include <metadata_struct.h> |
11 | 14 |
|
12 | 15 | #include <sys_common.h> |
13 | 16 | #include <sys_core.h> |
14 | | -#include <gio.h> |
15 | | -#include <sci.h> |
16 | | -#include <i2c.h> |
17 | | -#include <spi.h> |
18 | | -#include <can.h> |
19 | | -#include <het.h> |
20 | 17 |
|
21 | | -// This is the stack canary. It should never be overwritten. |
22 | | -// Ideally, it would be a random value, but we don't have a good source of entropy |
23 | | -// that we can use. |
24 | | -void *__stack_chk_guard = (void *)0xDEADBEEF; |
| 18 | +static StaticTask_t taskBuffer; |
| 19 | +static StackType_t taskStack[1024]; |
25 | 20 |
|
26 | | -void __stack_chk_fail(void) { resetSystem(RESET_REASON_STACK_CHECK_FAIL); } |
| 21 | +extern uint32_t __metadata_start__; |
27 | 22 |
|
28 | | -int main(void) { |
29 | | - // Run hardware initialization code |
30 | | - gioInit(); |
31 | | - sciInit(); |
32 | | - i2cInit(); |
33 | | - spiInit(); |
34 | | - canInit(); |
35 | | - hetInit(); |
| 23 | +void vTask1(void *pvParameters) { |
| 24 | + while (1) { |
| 25 | + app_metadata_t metadata = {0}; |
| 26 | + obc_error_code_t errCode; |
36 | 27 |
|
37 | | - _enable_interrupt_(); |
| 28 | + errCode = readAppMetadata(&metadata); |
38 | 29 |
|
39 | | - // Initialize bus mutexes |
40 | | - initSciMutex(); |
41 | | - initI2CMutex(); |
42 | | - initSpiMutex(); |
| 30 | + if (errCode == OBC_ERR_CODE_NO_METADATA) { |
| 31 | + sciPrintf("\r\nNO METADATA, APP NOT SENT TO BL OVER SERIAL\r\n"); |
| 32 | + } else { |
| 33 | + sciPrintf("\r\nParsed values:\r\n"); |
| 34 | + sciPrintf("Version: 0x%x\r\n", metadata.vers); |
| 35 | + sciPrintf("Binary Size: 0x%x\r\n", metadata.binSize); |
| 36 | + sciPrintf("Board Type(0 = Launchpad, 1 = Rev1, 2 = Rev2): 0x%x\r\n", metadata.boardType); |
| 37 | + vTaskDelay(2000); |
| 38 | + } |
| 39 | + } |
| 40 | +} |
43 | 41 |
|
44 | | - // The state_mgr is the only task running initially. |
45 | | - obcSchedulerInitTask(OBC_SCHEDULER_CONFIG_ID_STATE_MGR); |
46 | | - obcSchedulerCreateTask(OBC_SCHEDULER_CONFIG_ID_STATE_MGR); |
| 42 | +int main(void) { |
| 43 | + sciInit(); |
| 44 | + initSciPrint(); |
| 45 | + |
| 46 | + xTaskCreateStatic(vTask1, "Demo", 1024, NULL, 1, taskStack, &taskBuffer); |
47 | 47 |
|
48 | 48 | vTaskStartScheduler(); |
| 49 | + |
| 50 | + while (1) |
| 51 | + ; |
49 | 52 | } |
0 commit comments