-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
86 lines (59 loc) · 1.97 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
/******************************************************************************
* File Name: main.c
*******************************************************************************/
#include "cy_pdl.h"
#include "cyhal.h"
#include "cybsp.h"
#include "cy_retarget_io.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "global.h"
#include "pirTask.h"
#include "thermistorTask.h"
#include "capsenseTask.h"
#include "uartTask.h"
#include "servoTask.h"
/* Global variable for Semaphore handle creation */
SemaphoreHandle_t switchSemaphore;
/* Global variable for queue handle creation */
QueueHandle_t servoQueue;
void handle_error(void)
{
/* Disable all interrupts. */
__disable_irq();
CY_ASSERT(0);
}
int main(void)
{
cy_rslt_t result;
/* Set up the device based on configurator selections */
result = cybsp_init();
if (result != CY_RSLT_SUCCESS)
{
handle_error();
}
result = cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX,CY_RETARGET_IO_BAUDRATE);
if (result != CY_RSLT_SUCCESS)
{
handle_error();
}
/* \x1b[2J\x1b[;H - ANSI ESC sequence for clear screen */
printf("\x1b[2J\x1b[;H");
printf("************************************************************\r\n");
printf(" Smart gate\r\n");
printf("************************************************************\r\n\n");
__enable_irq();
/* Queue handle creation */
servoQueue = xQueueCreate( 1, sizeof(unsigned int));
/* Semaphore handle creation */
switchSemaphore = xSemaphoreCreateBinary();
xTaskCreate(pirTask, "PIR" , configMINIMAL_STACK_SIZE*1 ,0 /* args */ ,2 /* priority */, 0 /* handle */);
xTaskCreate(thermistorTask, "thermistor" ,configMINIMAL_STACK_SIZE*4 , NULL, 1, 0);
xTaskCreate(uartTask, "UART" ,configMINIMAL_STACK_SIZE*8 , NULL, 1, 0);
xTaskCreate(capsenseTask, "capsense" ,configMINIMAL_STACK_SIZE*8 , NULL, 1, 0);
xTaskCreate(servoTask, "servo" ,configMINIMAL_STACK_SIZE*8 , NULL, 1, 0);
vTaskStartScheduler();
while(1);
}
/* [] END OF FILE */