-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.c
105 lines (87 loc) · 3.67 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
101
102
103
104
105
#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"
#include "cJSON.h"
#ifdef LPC177x_8x // LPC1788 DB504
#pragma message("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
#pragma message("Cpu lpc1768 DB275")
HeapRegion_t xHeapRegions[] = {
{ (uint8_t *) 0x10001000UL, 0x7000 }, // 28kB
{ (uint8_t *) 0x2007C000UL, 0x4000 }, // 16kB
{ (uint8_t *) 0x20080000UL, 0x4000 }, // 16kB
{ NULL, 0 } // Tot: 60kB
};
#endif
/*
static void task_DigitalTest(void *pvParameters) {
for (;;) {
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay500);
GPIO_CLR_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay500);
}
}
*/
int main(void) {
vPortDefineHeapRegions(xHeapRegions);
//SystemInit();
SystemCoreClockUpdate();
// https://www.keil.com/pack/doc/CMSIS/Core/html/group__NVIC__gr.html
NVIC_SetPriorityGrouping( 2 );
//NVIC_SetPriority(TIMER1_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY);
cJSON_Hooks hooks;
hooks.malloc_fn = pvPortMalloc;
hooks.free_fn = vPortFree;
cJSON_InitHooks(&hooks);
hardware_Init();
powerMgmt_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));
SPI0TxMessageBuffer = xMessageBufferCreate( 250 * 5 );
SPI0RxMessageBuffer = xMessageBufferCreate( 1000 );
//TxMessageBuffer = xMessageBufferCreate( 250 * 5 );
RosTxQueue = xQueueCreate(15, 250);
memset(&sensorMsg, 0, sizeof(SensorType));
//xTaskCreate(task_DigitalTest, "Digital", 128, NULL, 4, (TaskHandle_t *)&xHandle[taskcounter++]);
// Prio
xTaskCreate(powerMgmt_Task, "PowerMgmt", 300, NULL, 7, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(ROSCommsRx_Task, "RosCommsRx", 3000, NULL, 6, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(ROSCommsTx_Task, "RosCommsTx", 4000, NULL, 5, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(SPI0TxQueue_Task, "SPI0TxQueue", 1500, NULL, 7, (TaskHandle_t *)&xHandle[taskcounter++]);
//xTaskCreate(ROSCommsTest_Task, "RosCommsTest", 500, NULL, 5, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(motorCtrl_Task, "MotorCtrl", 300, NULL, 5, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(sensor_Task, "Sensor", 500, NULL, 4, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(boundary_Task, "Boundary", 500, NULL, 3, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(LCD_Task, "LCD", 400, NULL, 2, (TaskHandle_t *)&xHandle[taskcounter++]);
xTaskCreate(keypad_Task, "Keypad", 200, NULL, 2, (TaskHandle_t *)&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);
}
}