forked from Damme/LandLord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·107 lines (88 loc) · 3.2 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
106
107
#include "define.h"
#include "keypad.h"
#include "sensor.h"
#include "powermgmt.h"
#include "motorctrl.h"
#if DEBUGCONSOLE
#include "console.h"
#else
#include "lcd.h"
#endif
#if debugPrintf
#include "redirect.h"
#endif
#include "FreeRTOS.h"
#include "task.h"
const TickType_t xDelay100 = 100 / portTICK_PERIOD_MS;
const TickType_t xDelay200 = 200 / portTICK_PERIOD_MS;
const TickType_t xDelay500 = 500 / portTICK_PERIOD_MS;
/* The CLI commands are defined in CLI-commands.c. */
void vRegisterCLICommands(void);
xQueueHandle xQueue = NULL;
void SystemSetupStuff(void)
{
LPC_SC->PCONP |= PCONP_PCGPIO; // power up GPIO
LPC_GPIO1->FIODIR |= PIN(25); // p1.25 Pwr on set output
LPC_GPIO1->FIOPIN |= PIN(25); // p1.25 Keep pwr on
// Configure Power button
LPC_PINCON->PINMODE3 |= (PINMODE_PULLDOWN << 24); // Pullup
}
HeapRegion_t xHeapRegions[] = {
{ (uint8_t *) 0x10001000UL, 0x7000 },
{ (uint8_t *) 0x2007C000UL, 0x4000 },
{ (uint8_t *) 0x20080000UL, 0x4000 },
{ NULL, 0 }
};
static void task_DigitalTest(void *pvParameters)
{
// int Counter1 = 0;
// Configure LCD backligt
LPC_GPIO1->FIODIR |= PIN(20); // P1.20 output mode.
LPC_GPIO1->FIOSET |= PIN(20); // p1.20 LCD backlight ON
/*
LPC_GPIO0->FIODIR |= PIN(18); // p0.20 output mode.
LPC_GPIO0->FIODIR |= PIN(19); // p0.20 output mode.
LPC_GPIO0->FIODIR |= PIN(20); // p0.20 output mode.
LPC_PINCON->PINSEL0 &= ~((uint32_t)3 << 30);
LPC_PINCON->PINSEL1 &= ~(3 << 0);
LPC_PINCON->PINSEL1 &= ~(3 << 4);
LPC_PINCON->PINSEL1 &= ~(3 << 6);
LPC_PINCON->PINSEL1 &= ~(3 << 8);
LPC_PINCON->PINMODE1 &= ~(3 << 4);
LPC_PINCON->PINMODE1 |= (2 << 4);
LPC_PINCON->PINMODE1 &= ~(3 << 6);
LPC_PINCON->PINMODE1 |= (2 << 6);
LPC_PINCON->PINMODE1 &= ~(3 << 8);
LPC_PINCON->PINMODE1 |= (2 << 8);
*/
for (;;) {
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay500);
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay500);
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay200);
GPIO_SET_PIN(LCD_BACKLIGHT);
vTaskDelay(xDelay200);
}
}
int main(void)
{
vPortDefineHeapRegions(xHeapRegions);
SystemCoreClockUpdate();
SystemSetupStuff();
xQueue = xQueueCreate(mainQUEUE_LENGTH, sizeof(unsigned long));
if (xQueue != NULL) {
//xTaskCreate(task_DigitalTest, "Digital", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
xTaskCreate(task_Keypad, "Keypad", configMINIMAL_STACK_SIZE, NULL, 6, NULL);
#if DEBUGCONSOLE
xTaskCreate(task_Console, "Console", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
#else
xTaskCreate(task_LCD, "LCD", 1024, NULL, 8, NULL);
#endif
xTaskCreate(task_Sensor, "Sensor", 256, NULL, 5, NULL);
xTaskCreate(task_PowerMgmt, "PowerMgmt", 160, NULL, 5, NULL);
xTaskCreate(task_MotorCtrl, "MotorCtrl", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
vTaskStartScheduler();
}
}