-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCpu0_Main.c
More file actions
106 lines (87 loc) · 4.02 KB
/
Cpu0_Main.c
File metadata and controls
106 lines (87 loc) · 4.02 KB
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
/**********************************************************************************************************************
* \file Cpu0_Main.c
*********************************************************************************************************************/
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "IfxStm.h"
#include "Bsp.h"
#include "IfxPort.h"
#include "App_InputEcu.h"
#include "If_InputEcu.h"
IfxCpu_syncEvent cpuSyncEvent = 0;
/*********************************************************************************************************************/
/*------------------------------------------------------Macros-------------------------------------------------------*/
#define LED_PORT (&MODULE_P10)
#define LED_PIN (2U)
#define TASK_BASE_PERIOD_MS (10U)
/*********************************************************************************************************************/
/*********************************************************************************************************************/
/*-------------------------------------------------Global variables--------------------------------------------------*/
volatile uint16 g_task_10ms_cnt = 0U;
/* 디버그용 변수 */
volatile boolean g_led_on = FALSE;
volatile boolean g_button_pulse = FALSE;
/*********************************************************************************************************************/
/*********************************************************************************************************************/
/*------------------------------------------------Function Prototypes------------------------------------------------*/
static void init_led(void);
static void toggle_led(void);
/*********************************************************************************************************************/
/*********************************************************************************************************************/
/*---------------------------------------------Function Implementations----------------------------------------------*/
void core0_main(void)
{
const if_input_ecu_data_t* input_data;
IfxCpu_enableInterrupts();
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* CAN transceiver STB(P20.6) 강제 normal mode */
IfxPort_setPinModeOutput(&MODULE_P20,
6,
IfxPort_OutputMode_pushPull,
IfxPort_OutputIdx_general);
IfxPort_setPinLow(&MODULE_P20, 6);
IfxCpu_emitEvent(&cpuSyncEvent);
IfxCpu_waitEvent(&cpuSyncEvent, 1);
init_led();
app_input_ecu_init();
while (1)
{
app_input_ecu_task_10ms();
app_input_ecu_task_10ms_can_tx();
g_task_10ms_cnt++;
input_data = if_input_ecu_get_data();
g_button_pulse = (input_data->user_ack_button == true) ? TRUE : FALSE;
if (input_data->user_ack_button == true)
{
toggle_led();
}
waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, TASK_BASE_PERIOD_MS));
}
}
/*********************************************************************************************************************/
static void init_led(void)
{
IfxPort_setPinModeOutput(LED_PORT,
LED_PIN,
IfxPort_OutputMode_pushPull,
IfxPort_OutputIdx_general);
IfxPort_setPinLow(LED_PORT, LED_PIN);
g_led_on = FALSE;
}
/*********************************************************************************************************************/
static void toggle_led(void)
{
if (g_led_on == FALSE)
{
IfxPort_setPinHigh(LED_PORT, LED_PIN);
g_led_on = TRUE;
}
else
{
IfxPort_setPinLow(LED_PORT, LED_PIN);
g_led_on = FALSE;
}
}
/*********************************************************************************************************************/