Skip to content

Commit 815269e

Browse files
committed
fix commit issues?
1 parent 850b220 commit 815269e

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

obc/app/app_main.c

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
11
#include "obc_logging.h"
2-
#include "obc_adc.h"
32
#include "obc_sci_io.h"
4-
#include "obc_errors.h"
5-
#include "obc_print.h"
3+
#include "obc_i2c_io.h"
4+
#include "obc_spi_io.h"
5+
#include "obc_reset.h"
66
#include "obc_scheduler_config.h"
7-
#include "obc_metadata.h"
7+
#include "state_mgr.h"
88

99
#include <FreeRTOS.h>
1010
#include <os_task.h>
11-
#include <sci.h>
12-
#include <adc.h>
13-
#include <metadata_struct.h>
1411

1512
#include <sys_common.h>
1613
#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>
1720

18-
static StaticTask_t taskBuffer;
19-
static StackType_t taskStack[1024];
20-
21-
extern uint32_t __metadata_start__;
22-
23-
void vTask1(void *pvParameters) {
24-
while (1) {
25-
app_metadata_t metadata = {0};
26-
obc_error_code_t errCode;
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;
2725

28-
errCode = readAppMetadata(&metadata);
29-
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-
}
26+
void __stack_chk_fail(void) { resetSystem(RESET_REASON_STACK_CHECK_FAIL); }
4127

4228
int main(void) {
29+
// Run hardware initialization code
30+
gioInit();
4331
sciInit();
44-
initSciPrint();
32+
i2cInit();
33+
spiInit();
34+
canInit();
35+
hetInit();
4536

46-
xTaskCreateStatic(vTask1, "Demo", 1024, NULL, 1, taskStack, &taskBuffer);
37+
_enable_interrupt_();
4738

48-
vTaskStartScheduler();
39+
// Initialize bus mutexes
40+
initSciMutex();
41+
initI2CMutex();
42+
initSpiMutex();
4943

50-
while (1)
51-
;
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);
47+
48+
vTaskStartScheduler();
5249
}

obc/app/sys/metadata/obc_metadata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <stddef.h>
66

7-
extern uint32_t __metadata_start__;
7+
extern uint32_t __metadata_start__[sizeof(app_metadata_t) / sizeof(uint32_t)];
88

99
obc_error_code_t readAppMetadata(app_metadata_t* metadata) {
1010
if (metadata == NULL) {

0 commit comments

Comments
 (0)