first commit
This commit is contained in:
545
.staticdata/K2DCU/fs/fa7923e9870aeba29fc81ef6ccc608ef
Normal file
545
.staticdata/K2DCU/fs/fa7923e9870aeba29fc81ef6ccc608ef
Normal file
@@ -0,0 +1,545 @@
|
||||
#include "main.h"
|
||||
|
||||
CPowerOnCheckValue PowerOnCheckValue;
|
||||
CGeneralOperValue GeneralOperValue;
|
||||
|
||||
CSoftTimer SoftTimer[TIMER_MAX];
|
||||
CWaitTimer WaitTimer[SOFTTIMER_WAIT_MAX];
|
||||
Uint32 ulSoftClock;
|
||||
|
||||
void CInitSystem(void);
|
||||
void CInitGeneralOperValue(void);
|
||||
void CInitGpio(void);
|
||||
void CSystemConfigure(void);
|
||||
void CMappingInterrupt(void);
|
||||
void CProcessSoftTimer(void);
|
||||
Uint16 CPowerOnCheck(void);
|
||||
void CSoftTimerWorkProcess(void);
|
||||
Uint16 CIsStatusSoftTimer(Uint16 ucTimerIndex);
|
||||
void CReloadSoftTimer(Uint16 ucTimerIndex);
|
||||
void CInitSoftTimers(void);
|
||||
void CInitSoftTimer(void);
|
||||
void CConfigSoftTimer(Uint16 ucTimerIndex, Uint32 ulDelay);
|
||||
void CStartSoftTimer(Uint16 ucTimerIndex);
|
||||
Uint16 CSoftClockTimeOut(Uint32 ulStartClock, Uint32 ulTimeOutClock);
|
||||
Uint32 CGetSoftClock(void);
|
||||
void CSOftWaitCountCancel(Uint16 Index);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CSetApuOperIndex(APU_OPER_IDX_BOOT);
|
||||
|
||||
CInitSystem();
|
||||
|
||||
CInitOled();
|
||||
|
||||
CSetApuOperIndex(APU_OPER_IDX_INITIAL);
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
CSoftTimerWorkProcess();
|
||||
|
||||
if (CGetApuOperIndex() == APU_OPER_IDX_INITIAL)
|
||||
{
|
||||
if (OledOperValue.uiProgressDone == 1U)
|
||||
{
|
||||
if (CSoftWaitCountProcedure(SOFTTIMER_WAIT_INIT, TIME_1SEC) == TIME_OVER)
|
||||
{
|
||||
COledBufferReset();
|
||||
CSetApuOperIndex(APU_OPER_IDX_POST); // Adc 보정완료 이 후 POST 시작
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CGetApuOperIndex() == APU_OPER_IDX_POST)
|
||||
{
|
||||
if (CPowerOnCheck() == 0U)
|
||||
{
|
||||
AdcOperValue.uiOffsetAdjustStart = 1U; // 센서 문제 없을 경우 offset 계산.
|
||||
|
||||
COledBufferReset();
|
||||
CSetApuOperIndex(APU_OPER_IDX_STANDBY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GeneralOperValue.uiMaintenence == 0U)
|
||||
{
|
||||
// 정비 모드가 꺼져있어야 시퀀스 동작.
|
||||
//CApuOperProcedure();
|
||||
|
||||
CLedControlProcedure();
|
||||
|
||||
GPIO_ENGINE_HEATER_CS(GPIO_USER_MODE_1());
|
||||
GPIO_GLOW_PLUG_CS(GPIO_USER_MODE_1());
|
||||
GPIO_SOLENOID_CS(GPIO_USER_MODE_1());
|
||||
GPIO_FUEL_PUMP_CS(GPIO_USER_MODE_1());
|
||||
GPIO_COOLANT_PUMP_CS(GPIO_USER_MODE_1());
|
||||
GPIO_FAN1_CS(GPIO_USER_MODE_1());
|
||||
GPIO_FAN2_CS(GPIO_USER_MODE_1());
|
||||
}
|
||||
else
|
||||
{
|
||||
CDebugModeProcedure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSoftTimerWorkProcess(void)
|
||||
{
|
||||
static Uint16 RefeshDelay = 0U;
|
||||
|
||||
if (CIsStatusSoftTimer(TIMER_01MS) == SOFTTIMER_TIME_OVER) // Excute Per 1msec
|
||||
{
|
||||
CReloadSoftTimer(TIMER_01MS);
|
||||
|
||||
if (GeneralOperValue.uiApuState > APU_OPER_IDX_POST) // ADC 오프셋 보정 완료 후 감지
|
||||
{
|
||||
CAlarmProcedure();
|
||||
CDisplayAlarmPopup();
|
||||
}
|
||||
|
||||
if (GeneralOperValue.Maintenence.KeyTest == 0U)
|
||||
{
|
||||
// (정비모드:키테스트)가 아니면 키 입력 시작 함.
|
||||
CKeyCheckProcedure();
|
||||
CKeyWaitCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (CIsStatusSoftTimer(TIMER_10MS) == SOFTTIMER_TIME_OVER) // Excute Per 10msec
|
||||
{
|
||||
CReloadSoftTimer(TIMER_10MS);
|
||||
|
||||
CSendECanDataA();
|
||||
CSendECanDataB();
|
||||
|
||||
COledReflash(0, 0, OLED_WIDTH, OLED_HEIGHT);
|
||||
|
||||
if (CGetApuOperIndex() == APU_OPER_IDX_INITIAL)
|
||||
{
|
||||
CInitializePage();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RefeshDelay == 0U)
|
||||
{
|
||||
if (CGetApuOperIndex() == APU_OPER_IDX_POST)
|
||||
{
|
||||
CDisplayPostFail();
|
||||
}
|
||||
else
|
||||
{
|
||||
CSetPage(OledOperValue.uiPageNum);
|
||||
}
|
||||
}
|
||||
RefeshDelay = (RefeshDelay + 1U) % 10U;
|
||||
}
|
||||
}
|
||||
|
||||
if (CIsStatusSoftTimer(TIMER_100MS) == SOFTTIMER_TIME_OVER) // Excute Per 100msec
|
||||
{
|
||||
CReloadSoftTimer(TIMER_100MS);
|
||||
|
||||
// 차량제어컴퓨터의 통신 수신이 한번이라도 되었을 경우 통신 타임아웃 체크 시작
|
||||
if (CApuSystemAlarmCheck() == 0U)
|
||||
{
|
||||
// 고장발생시 타임아웃은 체크하지 않는다.
|
||||
CommCheck.CarComputer = ((GeneralOperValue.Conection.CarComputer == 1U) && (CommCheck.CarComputer < COMM_TIME_OUT_COUNT)) ? (CommCheck.CarComputer + 1U) : 0U;
|
||||
CommCheck.Gcu = ((GeneralOperValue.Conection.Gcu == 1U) && (CommCheck.Gcu < COMM_TIME_OUT_COUNT)) ? (CommCheck.Gcu + 1U) : 0U;
|
||||
CommCheck.Ecu = ((GeneralOperValue.Conection.Ecu == 1U) && (CommCheck.Ecu < COMM_TIME_OUT_COUNT)) ? (CommCheck.Ecu + 1U) : 0U;
|
||||
}
|
||||
}
|
||||
if (CIsStatusSoftTimer(TIMER_1SEC) == SOFTTIMER_TIME_OVER) // Excute Per 1s
|
||||
{
|
||||
CReloadSoftTimer(TIMER_1SEC);
|
||||
|
||||
if (OledOperValue.uiAlreadyAlarm == 1U) // 경고 고장 알람 발생 후 해제 되지 않으면 1분뒤 다시 팝업 하기 위함.
|
||||
{
|
||||
if (CSoftWaitCountProcedure(SOFTTIMER_WAIT_POPUP, (TIME_1SEC * 60UL)) == TIME_OVER)
|
||||
{
|
||||
OledOperValue.uiAlarmPopCheck = 0U;
|
||||
OledOperValue.uiAlreadyAlarm = 0U;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CSOftWaitCountCancel(SOFTTIMER_WAIT_POPUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSOftWaitCountCancel(Uint16 Index)
|
||||
{
|
||||
WaitTimer[Index].ulCountSoftClock = 0U;
|
||||
WaitTimer[Index].uiSoftCountTarget = 0U;
|
||||
}
|
||||
|
||||
Uint16 CIsStatusSoftTimer(Uint16 uiTimerIndex)
|
||||
{
|
||||
Uint16 isRunning = 1U;
|
||||
|
||||
if (SoftTimer[uiTimerIndex].iStart != -1)
|
||||
{
|
||||
if (SoftTimer[uiTimerIndex].iStart == 1)
|
||||
{
|
||||
if (SoftTimer[uiTimerIndex].ulDecreaseValue == 0U)
|
||||
{
|
||||
isRunning = SOFTTIMER_TIME_OVER; // Success
|
||||
}
|
||||
else
|
||||
{
|
||||
isRunning = SOFTTIMER_RUNNING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
void CReloadSoftTimer(Uint16 uiTimerIndex)
|
||||
{
|
||||
if (SoftTimer[uiTimerIndex].iTimer != -1)
|
||||
{
|
||||
SoftTimer[uiTimerIndex].ulDecreaseValue = SoftTimer[uiTimerIndex].ulSetValue;
|
||||
}
|
||||
}
|
||||
|
||||
Uint16 CSoftWaitCountProcedure(Uint16 uiIndex, Uint32 ulWaitTime)
|
||||
{
|
||||
Uint16 isCountOver = 0U;
|
||||
|
||||
switch (WaitTimer[uiIndex].uiSoftCountTarget)
|
||||
{
|
||||
case 0U:
|
||||
{
|
||||
WaitTimer[uiIndex].ulCountSoftClock = CGetSoftClock();
|
||||
WaitTimer[uiIndex].uiSoftCountTarget = 1U;
|
||||
break;
|
||||
}
|
||||
case 1U:
|
||||
{
|
||||
if (CSoftClockTimeOut(WaitTimer[uiIndex].ulCountSoftClock, ulWaitTime) == SOFTTIMER_TIME_OVER)
|
||||
{
|
||||
WaitTimer[uiIndex].uiSoftCountTarget = 2U;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
WaitTimer[uiIndex].ulCountSoftClock = 0U;
|
||||
WaitTimer[uiIndex].uiSoftCountTarget = 0U;
|
||||
isCountOver = 1U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isCountOver;
|
||||
}
|
||||
|
||||
Uint16 CSoftClockTimeOut(Uint32 ulStartClock, Uint32 ulTimeOutClock)
|
||||
{
|
||||
Uint16 isRunning = 1U;
|
||||
Uint32 ulCpuClock = CGetSoftClock();
|
||||
|
||||
if (((ulCpuClock + SYSTEM_10MIN_TIME - ulStartClock) % SYSTEM_10MIN_TIME) >= ulTimeOutClock)
|
||||
{
|
||||
isRunning = 0U;
|
||||
}
|
||||
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
Uint32 CGetSoftClock(void)
|
||||
{
|
||||
return ulSoftClock;
|
||||
}
|
||||
|
||||
void CInitSystem(void)
|
||||
{
|
||||
DINT;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
InitSysCtrl();
|
||||
|
||||
CInitGpio(); // GPIO Direction and mux
|
||||
|
||||
InitPieCtrl();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
InitPieVectTable();
|
||||
|
||||
InitCpuTimers();
|
||||
|
||||
ConfigCpuTimer(&CpuTimer0, 150.0f, 100.0f); // 100usec
|
||||
|
||||
CSystemConfigure();
|
||||
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
CpuTimer0Regs.TCR.all = 0x4001U; // Use write-only instruction to set TSS bit = 0
|
||||
}
|
||||
|
||||
void CInitGpio(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
// GPIO MUX Setting
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0x1U; // SCL
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0x1U; // SDA
|
||||
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0x0U; // Enable pull-up (SDAA)
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0x0U; // Enable pull-up (SCLA)
|
||||
|
||||
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 0x3U; // Asynch input (SDAA)
|
||||
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 0x3U; // Asynch input (SCLA)
|
||||
|
||||
// GPIO Direction Setting '1' Output, '0' Input
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO1 = 0U; // GPIO_COOLING_PUMP_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO2 = 0U; // GPIO_FUEL_PUMP_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO3 = 0U; // GPIO_COOLING_FAN1_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO4 = 0U; // GPIO_COOLING_FAN2_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO5 = 0U; // GPIO_GLOW_PLUG_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO6 = 0U; // GPIO_ENGINE_HEATER_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO7 = 0U; // GPIO_STOP_SOLENOID_FUSE
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO8 = 0U; // GPIO_ECU_ON_OFF
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO9 = 0U; // GPIO_FUEL_PUMP
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO10 = 0U; // GPIO_GLOW_PLUG
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO11 = 0U; // GPIO_STOP_SOLENOID
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO24 = 0U; // GPIO_ENGINE_HEATER
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO29 = 0U; // CPU_SW_MODE_RESET
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO30 = 0U; // CPU_SW_MODE_ENT
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO31 = 0U; // CPU_SW_DOWN
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO39 = 0U; // CPU_SW_UP
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO64 = 0U; // CPU_SW_EMERGENCY
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO66 = 0U; // CPU_SW_START
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO67 = 0U; // CPU_SW_PWR
|
||||
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO12 = 1U; // GPIO_CPU_LED_SWITCH3
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO13 = 1U; // GPIO_CPU_LED_SWITCH2
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO14 = 1U; // GPIO_CPU_LED_SWITCH1
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO26 = 1U; // GPIO_FUEL_PUMP_CS
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO27 = 1U; // GPIO_GLOW_PLUG_CS
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO28 = 1U; // GPIO_OLED_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO37 = 1U; // GPIO_OLED_RESET
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO48 = 1U; // GPIO_STOP_SOLENOID_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1U; // GPIO_ENGINE_HEATER_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO50 = 1U; // GPIO_COOLING_FAN1_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO51 = 1U; // GPIO_COOLING_FAN2_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO52 = 1U; // GPIO_COOLING_PUMP_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO55 = 1U; // GPIO_FAULT_CMD_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO56 = 1U; // GPIO_EMERGENCY_CMD_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO57 = 1U; // GPIO_STOP_CMD_CS
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO58 = 1U; // GPIO_START_CMD_CS
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO65 = 1U; // GPIO_POWER_HOLD
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO68 = 1U; // GPIO_CPU_LED_COM_FAULT
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO69 = 1U; // GPIO_CPU_LED_COM_RUN
|
||||
GpioCtrlRegs.GPCDIR.bit.GPIO70 = 1U; // GPIO_CPU_LED_COM_STA
|
||||
|
||||
// GPAQSEL : 0b00 - Synchronize to SYSCLKOUT, 0b01 - Qualification 3 sample, 0b10 - Qualification 6 sample, 0b11 - Asynchronous
|
||||
GpioCtrlRegs.GPAQSEL1.all = 0x0000U; // GPIO0-GPIO15 Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPAQSEL2.all = 0x0000U; // GPIO16-GPIO31 Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPBQSEL1.all = 0x0000U; // GPIO32-GPIO47 Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPBQSEL2.all = 0x0000U; // GPIO48-GPIO63 Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO1 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO2 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO3 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO4 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO5 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO6 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO8 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO10 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO11 = 1U; // 3 Clk Sampling
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 1U; // 3 Clk Sampling
|
||||
|
||||
// Gpio Default Value Initial
|
||||
GPIO_POWER_HOLD(1);
|
||||
|
||||
GPIO_CPU_LED_COM_FAULT_N(1);
|
||||
GPIO_CPU_LED_COM_RUN_N(1);
|
||||
GPIO_CPU_LED_COM_STA_N(1);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
void CActiveChipSelect(Uint16 Active)
|
||||
{
|
||||
if (Active == 0U)
|
||||
{
|
||||
// 비상정지 상황에서는 모든 CS를 OFF한다. (0 - CS OFF, 1 - CS ON)
|
||||
GPIO_ENGINE_HEATER_CS(0);
|
||||
GPIO_GLOW_PLUG_CS(0);
|
||||
GPIO_SOLENOID_CS(0);
|
||||
GPIO_FUEL_PUMP_CS(0);
|
||||
|
||||
GPIO_COOLANT_PUMP_CS(0);
|
||||
GPIO_FAN1_CS(0);
|
||||
GPIO_FAN2_CS(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 운영 상태에서는 EcuSignal의 상태를 확인하고 엔진히터, 글로우플러그, 솔레노이드, 연료펌프를 동작한다.
|
||||
// 0 - CS OFF, 1 - CS ON
|
||||
GPIO_ENGINE_HEATER_CS(GPIO_ENGINE_HEATER());
|
||||
GPIO_GLOW_PLUG_CS(GPIO_GLOW_PLUG());
|
||||
GPIO_SOLENOID_CS(GPIO_SOLENOID());
|
||||
GPIO_FUEL_PUMP_CS(GPIO_FUEL_PUMP());
|
||||
|
||||
GPIO_COOLANT_PUMP_CS(1);
|
||||
GPIO_FAN1_CS(1);
|
||||
GPIO_FAN2_CS(1);
|
||||
}
|
||||
}
|
||||
|
||||
static interrupt void CMainTimer0Interrupt(void)
|
||||
{
|
||||
// Per 100uSec
|
||||
|
||||
DINT;
|
||||
|
||||
ulSoftClock = (ulSoftClock + 1U) % SYSTEM_10MIN_TIME;
|
||||
|
||||
CProcessSoftTimer();
|
||||
// Do Something
|
||||
|
||||
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 0x01U; // Adc Read Start
|
||||
|
||||
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP1;
|
||||
EINT;
|
||||
}
|
||||
|
||||
void CSystemConfigure(void)
|
||||
{
|
||||
CMappingInterrupt();
|
||||
|
||||
CInitGeneralOperValue();
|
||||
|
||||
CInitAdc();
|
||||
CInitEcan();
|
||||
|
||||
CInitXintf();
|
||||
|
||||
CInitSoftTimers();
|
||||
|
||||
CInitKeyOperValue();
|
||||
}
|
||||
|
||||
void CInitGeneralOperValue(void)
|
||||
{
|
||||
(void) memset(&GeneralOperValue, 0, sizeof(CGeneralOperValue));
|
||||
(void) memset(&PowerOnCheckValue, 0x1FF, sizeof(CPowerOnCheckValue)); // Set All bit 1
|
||||
|
||||
GeneralOperValue.uiPassword[OLED_PASS_DIGIT_1] = 0;
|
||||
GeneralOperValue.uiPassword[OLED_PASS_DIGIT_2] = 0;
|
||||
GeneralOperValue.uiPassword[OLED_PASS_DIGIT_3] = 0;
|
||||
GeneralOperValue.uiPassword[OLED_PASS_DIGIT_4] = 0;
|
||||
}
|
||||
|
||||
void CMappingInterrupt(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
// Interrupt Vector Remapping
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 0x1U; // TINT0
|
||||
PieCtrlRegs.PIEIER1.bit.INTx6 = 0x1U; // ADC
|
||||
PieCtrlRegs.PIEIER9.bit.INTx5 = 0x1U; // ECAN0INTA
|
||||
PieCtrlRegs.PIEIER9.bit.INTx7 = 0x1U; // ECAN0INTB
|
||||
|
||||
PieVectTable.TINT0 = &CMainTimer0Interrupt;
|
||||
PieVectTable.ECAN0INTA = &CECanInterruptA;
|
||||
PieVectTable.ECAN0INTB = &CECanInterruptB;
|
||||
PieVectTable.ADCINT = &CAdcInterrupt;
|
||||
|
||||
IER = M_INT1 | M_INT9;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
void CProcessSoftTimer(void)
|
||||
{
|
||||
Uint16 i;
|
||||
|
||||
for (i = 0U; i < TIMER_MAX; i++)
|
||||
{
|
||||
if (SoftTimer[i].iTimer != -1)
|
||||
{
|
||||
if (SoftTimer[i].iStart == 1)
|
||||
{
|
||||
if (SoftTimer[i].ulDecreaseValue > 0UL)
|
||||
{
|
||||
SoftTimer[i].ulDecreaseValue--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CInitSoftTimers(void)
|
||||
{
|
||||
CInitSoftTimer();
|
||||
CConfigSoftTimer(TIMER_01MS, TIME_01MS);
|
||||
CConfigSoftTimer(TIMER_10MS, TIME_10MS);
|
||||
CConfigSoftTimer(TIMER_20MS, TIME_20MS);
|
||||
CConfigSoftTimer(TIMER_50MS, TIME_50MS);
|
||||
CConfigSoftTimer(TIMER_100MS, TIME_100MS);
|
||||
CConfigSoftTimer(TIMER_500MS, TIME_500MS);
|
||||
CConfigSoftTimer(TIMER_1SEC, TIME_1SEC);
|
||||
|
||||
CStartSoftTimer(TIMER_01MS);
|
||||
CStartSoftTimer(TIMER_10MS);
|
||||
CStartSoftTimer(TIMER_20MS);
|
||||
CStartSoftTimer(TIMER_50MS);
|
||||
CStartSoftTimer(TIMER_100MS);
|
||||
CStartSoftTimer(TIMER_500MS);
|
||||
CStartSoftTimer(TIMER_1SEC);
|
||||
}
|
||||
|
||||
void CStartSoftTimer(Uint16 ucTimerIndex)
|
||||
{
|
||||
if (SoftTimer[ucTimerIndex].iTimer != -1)
|
||||
{
|
||||
SoftTimer[ucTimerIndex].iStart = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CInitSoftTimer(void)
|
||||
{
|
||||
Uint16 i;
|
||||
|
||||
(void) memset(&SoftTimer, 0, sizeof(SoftTimer));
|
||||
(void) memset(&WaitTimer, 0, sizeof(WaitTimer));
|
||||
|
||||
for (i = 0; i < TIMER_MAX; i++)
|
||||
{
|
||||
SoftTimer[i].iTimer = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void CConfigSoftTimer(Uint16 TimerIndex, Uint32 Delay)
|
||||
{
|
||||
SoftTimer[TimerIndex].iTimer = (int16) TimerIndex;
|
||||
SoftTimer[TimerIndex].ulSetValue = Delay;
|
||||
SoftTimer[TimerIndex].ulDecreaseValue = Delay;
|
||||
SoftTimer[TimerIndex].iStart = 0;
|
||||
}
|
||||
|
||||
Uint16 CPowerOnCheck(void)
|
||||
{
|
||||
// 통신 수신 확인은 CAN 수신 인터럽트 발생 시, 체크
|
||||
Uint16 retValue = (*(Uint16*)&PowerOnCheckValue) & 0x7FU;
|
||||
|
||||
PowerOnCheckValue.EngineHeaterSensor = ((Adc_EngineHeater_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_EngineHeater_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
PowerOnCheckValue.GlowPlugSensor = ((Adc_GlowPlug_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_GlowPlug_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
PowerOnCheckValue.SolenoidSensor = ((Adc_Solenoid_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_Solenoid_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
PowerOnCheckValue.FuelPumpSensor = ((Adc_FuelPump_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_FuelPump_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
PowerOnCheckValue.CoolantPumpSensor = ((Adc_CoolantPump_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_CoolantPump_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
PowerOnCheckValue.Fan1Sensor = ((Adc_Fan1_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_Fan1_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
PowerOnCheckValue.Fan2Sensor = ((Adc_Fan2_I.iAdcValue > SENSOR_MIN_LIMIT) && (Adc_Fan2_I.iAdcValue < SENSOR_MAX_LIMIT)) ? 0U : 1U;
|
||||
|
||||
return retValue; // '0' 정상
|
||||
}
|
||||
Reference in New Issue
Block a user