forked from Damme/LandLord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
101 lines (84 loc) · 3.61 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <stdio.h>
#include "common.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "global.h"
#include "ROSComms.h"
#include "lcd.h"
#include "sensor.h"
#include "powermgmt.h"
#include "keypad.h"
#include "motorctrl.h"
#include "boundary.h"
#ifdef LPC177x_8x // LPC1788 DB504
TODO("Cpu lpc1788 DB504")
HeapRegion_t xHeapRegions[] = {
{ (uint8_t *) 0x10001000UL, 0xF000 }, // 60kB
{ (uint8_t *) 0x20000000UL, 0x2000 }, // 8kB
{ (uint8_t *) 0x20002000UL, 0x2000 }, // 8kB
{ (uint8_t *) 0x20004000UL, 0x4000 }, // 16kB
{ NULL, 0 } // Tot: 92kB
};
#else // LPC1768 DB275
TODO("Cpu lpc1768 DB275")
#error "I fucked something up in LPC175x_6x_hal, check all pin setup, chkpin, pindir etc and also the special invert functions. \
(5x/6x does not have hw invert polarity!) \
Make a complete testsuite and test all those things. LCD does work and print though so it is probably something with reading a pin state. \
Something fishy going on.. :("
HeapRegion_t xHeapRegions[] = {
{ (uint8_t *) 0x10001000UL, 0x7000 }, // 28kB
{ (uint8_t *) 0x2007C000UL, 0x4000 }, // 16kB
{ (uint8_t *) 0x20080000UL, 0x4000 }, // 16kB
{ NULL, 0 } // Tot: 60kB
};
#endif
/*
https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source
arm-none-eabi-gdb main.elf
target extended-remote 10.42.43.164:3333
*/
static void task_DigitalTest(void *pvParameters) {
for (;;) {
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay500);
GPIO_CLR_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay500);
}
}
int main(void) {
setbuf(stdout, NULL);
vPortDefineHeapRegions(xHeapRegions);
SystemCoreClockUpdate(); //or call -> SystemInit(); ? Dont know why I dont do this
// https://www.keil.com/pack/doc/CMSIS/Core/html/group__NVIC__gr.html
NVIC_SetPriorityGrouping( 2 );
//NVIC_SetPriority(TIMER1_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY);
hardware_Init();
xScreenMsgQueue = xQueueCreate(6, sizeof(xScreenMsgType));
xSensorQueue = xQueueCreate(1, sizeof(xSensorMsgType));
xMotorMsgQueue = xQueueCreate(10, sizeof(xMotorMsgType));
xBoundaryMsgQueue = xQueueCreate(1, sizeof(xBoundaryMsgType));
xJSONMessageQueue = xQueueCreate(8, sizeof(xJSONMessageType));
SPI0TxQueue = xQueueCreate(250, sizeof(char));
TxMessageBuffer = xMessageBufferCreate( 1024 );
// xTaskCreate(task_DigitalTest, "Digital", 128, NULL, 4, &xHandle[taskcounter++]);
// Prio
xTaskCreate(powerMgmt_Task, "PowerMgmt", 300, NULL, 7, &xHandle[taskcounter++]);
xTaskCreate(ROSCommsTx_Task, "RosCommsTx", 1000, NULL, 5, &xHandle[taskcounter++]);
xTaskCreate(ROSCommsRx_Task, "RosCommsRx", 800, NULL, 6, &xHandle[taskcounter++]);
xTaskCreate(ROSCommsFillSPI0TxQueue_Task, "SPI0TxQueue_Task", 1500, NULL, 7, &xHandle[taskcounter++]);
xTaskCreate(motorCtrl_Task, "MotorCtrl", 300, NULL, 5, &xHandle[taskcounter++]);
xTaskCreate(sensor_Task, "Sensor", 500, NULL, 4, &xHandle[taskcounter++]);
xTaskCreate(boundary_Task, "Boundary", 500, NULL, 3, &xHandle[taskcounter++]);
xTaskCreate(LCD_Task, "LCD", 400, NULL, 2, &xHandle[taskcounter++]);
xTaskCreate(keypad_Task, "Keypad", 200, NULL, 2, &xHandle[taskcounter++]);
vTaskStartScheduler();
// Should never get here.
printf("Insufficient RAM!");
for (;;) {
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay100);
GPIO_CLR_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay100);
}
}