-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
68 lines (50 loc) · 1.96 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
/*
* main.c
*
* Created: 24.8.2014 15:10:04
* Author: Tomas Baca
*/
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "system.h"
#include "mainTask.h"
#include "cspTask.h"
// Blinking RTOS task, just for debugging
void blink(void *p) {
while (1) {
led_yellow_toggle();
vTaskDelay(1000);
}
}
int main(void) {
// initialize the xMega peripherals
boardInit();
// Initialize the CSP buffers
csp_buffer_init(CSP_BUFFER_COUNT, CSP_BUFFER_SIZE);
// Initialize the CSP
csp_init(CSP_MY_ADDRESS);
// Initialize the CSP I2C interface
csp_i2c_init(CSP_I2C_SLAVE_ADDRESS, 0, CSP_I2C_BAUDSETTING);
// Add route to OBC via i2c
csp_route_set(CSP_OBC_ADDRESS, &csp_if_i2c, CSP_I2C_OBC_ADDRESS);
// Start router task
csp_route_start_task(CSP_ROUTER_STACK, CSP_ROUTER_PRIORITY);
/* -------------------------------------------------------------------- */
/* Starts blinking task - only for debug */
/* -------------------------------------------------------------------- */
xTaskCreate(blink, (signed char*) "blink", 64, NULL, configNORMAL_PRIORITY, NULL);
/* -------------------------------------------------------------------- */
/* Starts task that handles incoming communication */
/* -------------------------------------------------------------------- */
xTaskCreate(cspTask, (signed char*) "cspTask", 256, NULL, configNORMAL_PRIORITY, NULL);
/* -------------------------------------------------------------------- */
/* Starts task that handles outgoing communication */
/* -------------------------------------------------------------------- */
xTaskCreate(mainTask, (signed char*) "mainTask", 512, NULL, configNORMAL_PRIORITY, NULL);
/* -------------------------------------------------------------------- */
/* Starts the scheduler and all previously created tasks */
/* -------------------------------------------------------------------- */
vTaskStartScheduler();
return 0;
}