Commit 16eb16b8 authored by 耨义强's avatar 耨义强

feat(12):

parent 1d428143
/Test_Bench/bin
/Test_Bench/General_HY64_Data
{
"files.encoding": "gbk",
"files.associations": {
"includes.h": "c",
"globals_var.h": "c"
}
}
\ No newline at end of file
# CS08___test_bench
小康CS08检测台
\ No newline at end of file
{
"files.associations": {
"includes.h": "c",
"var_type.h": "c"
},
"files.encoding": "gbk"
}
\ No newline at end of file
#define GLOBALS_API_ATD
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : ATD_INIT
* Description : AD转化初始化
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void API_ATD_init(void)
{
///*
ATDCTL0 = null;
ATDCTL1_ETRIGSEL = Disable;
ATDCTL1_SRES = True; //10位精度
ATDCTL1_SMP_DIS = Disable; //
ATDCTL1_ETRIGCH = 0; //转化通道初始化
ATDCTL2_AFFC = Disable; //分别清除每一个 CCFX标志位用写1的方式
ATDCTL2_ICLKSTP = Enable; //使能停止模式
ATDCTL2_ETRIGE = Disable; //外部触发禁止
ATDCTL2_ASCIE = Disable; //禁止转化中断
ATDCTL2_ACMPIE = Disable; //禁止比较中断
ATDCTL3_DJM = Enable; //右对齐
ATDCTL3_S1C = 1; //转化长度1
ATDCTL3_S2C = 0;
ATDCTL3_S4C = 0;
ATDCTL3_S8C = 0;
ATDCTL3_FIFO = Disable; //不是FIFO模式 并且各自的结果放在各自的寄存器 ATDDRx
ATDCTL3_FRZ = Disable; //禁止冻结模式
ATDCTL4_SMP = SMP_TIME; //采样时间 4 CYCLE
ATDCTL4_PRS = SMP_PRE; //
ATDCTL5_SC = Disable;
ATDCTL5_CA = 0;
ATDCTL5_CB = 0;
ATDCTL5_CC = 0;
ATDCTL5_CD = 0;
ATDDIEN=0xfe;
ATDCTL5_SCAN = Enable; //连续转化
ATDCTL5_MULT = 0; //只有一个通道
//*/
}
/*-------------------------------------------------------------------------
* Function Name : API_GetSensorAD
* Description : 提取AD值
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void API_GetSensorAD(void)
{
static INT16U ad_data[10];
static INT8U p = null;
INT8U AD_STATUS;
AD_STATUS = ATDSTAT0;
if((AD_STATUS & 0x80) == 0x80)
{
ad_data[p] = ATDDR0;
p++;
if(p >2)
{
p = null;
}
APP_SortNByte(ad_data,3);
if(ad_data[1] > 200) //2V = 7.7V
{
Curkeyinput = KeyON;
}
else
{
Curkeyinput = KeyOFF;
}
ATDSTAT0_SCF = ClearFlag;
}
}
\ No newline at end of file
#define GLOBALS_API_CAN
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : Api_CAN_Init
* Description : CAN初始化
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_CAN_Init(void)
{
INT16U b = null;
CANCTL0_INITRQ = Enable; //准备初始化
while(!CANCTL1_INITAK); //等待进入初始化模式
CANCTL1 = CANCTL1_CANE_MASK | CANCTL1_BORM_MASK;
CANCTL1_WUPM = Disable; //所有显性唤醒
/*
SYNC_SEG + (PROP_SEG + PHASE_SEG1) + (PHASE_SEG2)
1 Tq 4--16 Tq 2--8 Tq
*/
CANBTR1_TSEG_10 = Seg1_5Tq; //351page 75% 75<= sp<=83
CANBTR1_TSEG_20 = Seg2_2Tq;
CANBTR0_SJW = SJW_1Tq; //重新同步
CANBTR1_SAMP = SAMP_1;
CANBTR0_BRP = 0x00; //0 500K 1 250K
CANIDAC_IDAM = IDAM_2_32Bit;
CANIDAC_IDHIT = IDHIT0; //滤波器 0 有效
CANIDAR0 = null; //
CANIDAR1 = null;
CANIDAR2 = null;
CANIDAR3 = null;
CANIDAR4 = null;
CANIDAR5 = null;
CANIDAR6 = null;
CANIDAR7 = null;
CANIDMR0 = 0xFF;
CANIDMR1 = 0xFF;
CANIDMR2 = 0xFF;
CANIDMR3 = 0xFF;
CANIDMR4 = 0xFF;
CANIDMR5 = 0xFF;
CANIDMR6 = 0xFF;
CANIDMR7 = 0xFF;
//
CANTIER = null;
CANCTL0_INITRQ = Disable; //完成初始化
while(CANCTL1_INITAK); //等待确认
CANRFLG_RXF = ClearFlag;
CANRIER_RXFIE = Enable; //使能接收中断
CANTIER_TXEIE = Disable; //禁止发送中断
CANCTL0_TIME = Enable; //使能时间戳
CANCTL0_CSWAI = WaitRun; //等待模式下可以运行
CANCTL0_WUPE = Enable;
}
/*-------------------------------------------------------------------------
* Function Name : GET_STAND_ID
* Description : 提取标准ID
* Input : IDR0_Add -> 对应的IDR0的地址
* Output : None
* Return : dwPGN
* onther :
--------------------------------------------------------------------------*/
INT16U Api_GET_STAND_ID(INT8U *IDR0_Add)
{
INT16U dwPGN;
INT8U *bp;
bp = (INT8U*)&dwPGN;
*(bp ) = *(IDR0_Add );
*(bp + 1) = *(IDR0_Add + 1);
dwPGN = dwPGN>>5;
return(dwPGN);
}
INT32U bsp_GET_EXTEND_ID(INT8U *IDR0_Add)
{
INT32U dwPGN = 0;
INT8U *bp;
bp = (INT8U*)&dwPGN;
*(bp ) = *(IDR0_Add );
*(bp + 1) = *(IDR0_Add + 1);
*(bp + 2) = *(IDR0_Add + 2);
*(bp + 3) = *(IDR0_Add + 3);
dwPGN = ((dwPGN & 0x7FFFF) >> 1) | ((dwPGN & 0xFFE00000) >> 3);
return(dwPGN);
}
/*-------------------------------------------------------------------------
* Function Name : Api_CANSendFrame
* Description :
* Input :
* Output : None
* Return : dwPGN
* onther :
--------------------------------------------------------------------------*/
INT8U Api_CANSendFrame(CAN_message * CanMessage)
{
INT8U txbuffer,index;
INT16U cn = null;
INT8U priority = 0;
INT8U length = CanMessage->Length;
INT32U id = CanMessage->ID;
if (!CANTFLG) //Is Transmit Buffer full ? Full ( TXEx=0;)
{
return failt;
}
if(id == null)
{
return failt;
}
if(!CanMessage->ID_EN){
return failt;
}
CANTBSEL = CANTFLG; /* Select lowest empty buffer */
txbuffer = CANTBSEL; // Backup selected buffer
/* Load Id to IDR Register */
//*((unsigned long *) ((unsigned long)(&CANTXIDR0))) = id; // I appreciate this , easy and good.
if (id < 0x00000800)
{
CANTXIDR0 = (INT8U)(id>>3);
CANTXIDR1 = id<<5;
CANTXIDR2 = 0;
CANTXIDR3 = 0;
}
else
{
CANTXIDR0 = (INT8U)((id & 0x1fe00000)>>21);
CANTXIDR1 = (INT8U)((id & 0x001c0000)>>13);
CANTXIDR1 |= (INT8U)((id & 0x00038000)>>15);
CANTXIDR1 |= 0x18;
CANTXIDR2 = (INT8U)((id & 0x00007f80)>>7);
CANTXIDR3 = (INT8U)((id & 0x0000007f)<<1);
}
if(length>8)
length=8;
for ( index=0; index < length; index++) {
*(&CANTXDSR0 + index) = CanMessage->Msg[index]; //Load data to Tx buffer Data Segment Registers
}
CANTXDLR = length; /* Set Data Length Code */
CANTXTBPR = priority; /* Set Priority */
CANTFLG = txbuffer; /* Start transmission */
while ((CANTFLG & txbuffer) != txbuffer)
{
//; // Wait for Transmission completion
cn++;
if(cn>WaitOverTime)
break;
}
return success;
}
/*-------------------------------------------------------------------------
* Function Name : Api_CAN_Rev_isr
* Description : 提取标准ID
* Input : IDR0_Add -> 对应的IDR0的地址
* Output : None
* Return : dwPGN
* onther :
--------------------------------------------------------------------------*/
interrupt void Api_CAN_Rev_isr(void)
{
INT32U stand_id;
INT8U m_dlc;
stand_id = bsp_GET_EXTEND_ID((INT8U*)&CANRXIDR0);
m_dlc = CANRXDLR_DLC;
switch(stand_id)
{
case 0x18DAF917: //车速
if(m_dlc == 8)
{
UDS_Receive_Main(&CANRXDSR0);
}
break;
default:
;
}
CANRFLG_RXF = ClearFlag;
}
\ No newline at end of file
#define GLOBALS_API_DFLASH
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : Api_Flash_Init
* Description : FLASH初始化
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_Flash_Init(void)
{
FCNFG = Disable; //禁止完成中断
FERCNFG = Disable; //禁止错误中断
if(false != FERSTAT)
{
FERSTAT = 0x03;
}
if(false == FCLKDIV_FDIVLD)
{
if(True == FCLKDIV_FDIVLCK)
{
FCLKDIV_FDIVLCK = Disable; //开启改写时钟Flash时钟分频
}
FCLKDIV_FDIV = 32; //10
FCLKDIV_FDIVLCK = Enable; //禁止改写时钟Flash时钟分频
}
}
/*-------------------------------------------------------------------------
* Function Name : Api_Flash_byte_read
* Description : 读取字节
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
INT8U Api_Flash_byte_read(INT16U _addr)
{
return *(INT8U *)_addr;
}
/*-------------------------------------------------------------------------
* Function Name : Api_DFlashCommSequence
* Description : DFlash命令序列
* Input : bCommandCounter
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
INT8U Api_DFlashCommSequence(INT8U bCommandCounter)
{
INT8U bCounter;
INT32U dwDelay;
if(MaxDFlashCommandCounter <= bCommandCounter)
{
return RunParameterErr;
}
//检测命令完成
dwDelay = null;
while(!FSTAT_CCIF)
{
dwDelay++;
if(dwDelay > MaxDelayTime)
{
bReturn = RunOverTimeErr;
break;
}
}
//命令正常完成
if(dwDelay < MaxDelayTime)
{
//清零ACCERR和FPVIOL标志
if((True == FSTAT_FPVIOL) ||
(True == FSTAT_ACCERR))
{
FSTAT = (FSTAT_FPVIOL_MASK | FSTAT_ACCERR_MASK);
}
//装载命令
for(bCounter = 0; bCounter <= bCommandCounter; bCounter++)
{
FCCOBIX = bCounter;
FCCOB = FlashCommandArray[bCounter];
}
FSTAT_CCIF = True; //启动命令
//检测命令完成
dwDelay = 0;
while(!FSTAT_CCIF)
{
dwDelay++;
if(dwDelay > MaxDelayTime)
{
bReturn = RunOverTimeErr;
break;
}
}
if(dwDelay < MaxDelayTime)
{
if(false != FSTAT_ACCERR)
{
bReturn = RunErrACCERR;
}
else
{
if(false != FSTAT_FPVIOL)
{
bReturn = RunErrFPVIOL;
}
else
{
if(false != FSTAT_MGSTAT1)
{
bReturn = RunErrMGSTAT1;
}
else
{
if(false != FSTAT_MGSTAT0)
{
bReturn = RunErrMGSTAT0;
}
}
}
}
}
}
return(bReturn);
}
/*-------------------------------------------------------------------------
* Function Name : Api_DFlashEraseSector
* Description : DFlash扇区擦除
* Input : wDestination
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
INT8U Api_DFlashEraseSector(INT16U wDestination)
{
INT16U wCommand;
if((wDestination & (INT16U)(DFLASH_SECTOR_SIZE -1)) != 0)
{
bReturn = RunParameterErr;
}
else
{
bReturn = RunComplete;
if((wDestination < DFLASH_BLOCK_START_ADDR) || \
(wDestination >= DFLASH_BLOCK_END_ADDR) || \
((wDestination + DFLASH_SECTOR_SIZE) > DFLASH_BLOCK_END_ADDR))
{
bReturn = RunParameterErr;
}
else
{
wDestination = wDestination & (INT16U)~(DFLASH_SECTOR_SIZE -1);
//命令准备
wCommand = ((INT16U)(DFLASH_ERASE_SECTOR) << 8);
FlashCommandArray[0] = (wCommand|GLOBAL_ADDRESS_DFLASH);
FlashCommandArray[1] = wDestination;
bReturn = Api_DFlashCommSequence(DFLASH_ERASE_COM_LENGTH);
}
}
return(bReturn);
}
/*-------------------------------------------------------------------------
* Function Name : Api_DFlashEraseVerify
* Description : DFlash扇区擦除
* Input : wDestination
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
INT8U Api_DFlashEraseVerify(INT16U wDestination, INT16U wSize)
{
INT16U wWordCounter;
INT16U wCommand;
bReturn = RunComplete;
if((0 != (wSize % WordSize)) ||
(wSize > DFLASH_SECTOR_SIZE))
{
bReturn = RunParameterErr;
}
else
{
if(0 != wSize)
{
wWordCounter = (INT16U)(wSize / WordSize);
wCommand = (((INT16U)(DFLASH_ERASE_VERIFY)) << 8);
FlashCommandArray[0] = (wCommand | GLOBAL_ADDRESS_DFLASH);
FlashCommandArray[1] = wDestination;
FlashCommandArray[2] = wWordCounter;
bReturn = Api_DFlashCommSequence(DFLASH_ERASE_VERIFY_COM_LENGTH);
}
}
return(bReturn);
}
/*-------------------------------------------------------------------------
* Function Name : Api_DFlashEraseVerify
* Description : DFlash扇区擦除
* Input : wDestination
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
INT8U Api_DFalshProgram(INT16U wDest,INT16U wByteNub,INT16U *wSource)
{
INT8U bLoopIndex;
INT8U bCounter;
INT8U bIndex;
INT16U wEndAdd;
INT16U wCommand;
//else
{
bReturn = RunComplete;
wEndAdd = wDest + wByteNub;
//检测参数正确性
if((0 != (wByteNub % WordSize)) ||
(DFLASH_BLOCK_END_ADDR < wEndAdd))
{
bReturn = RunParameterErr;
}
else
{
wCommand = (((INT16U)(DFLASH_PROGRAM)) << 8);
while(wDest < wEndAdd)
{
FlashCommandArray[0] = (wCommand | GLOBAL_ADDRESS_DFLASH);
FlashCommandArray[1] = wDest;
if(MaxProgramByteNumber < wByteNub)
{
bLoopIndex = DFLASH_PROGRAM_COM_LENGTH;
}
else
{
bLoopIndex = (INT8U)(wByteNub / WordSize);
}
for(bCounter = 0;bCounter < bLoopIndex;bCounter++)
{
FlashCommandArray[bCounter + 2] = *wSource;
wDest += WordSize;
wSource++;
wByteNub -= WordSize;
}
bIndex = bLoopIndex + 1;
if(RunComplete != Api_DFlashCommSequence(bIndex))
{
break;
}
}
}
}
return(bReturn);
}
\ No newline at end of file
#define GLOBALS_API_DEV
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : Api_Sys_Init
* Description : 系统初始化
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_Sys_Init(void)
{
DisableInterrupts;
Api_Clock_Init();
Api_Flash_Init();
Api_IO_init();
Api_CAN_Init();
Api_Timer0_Init(TPM_DIV1);
Api_SCI_Init();
Api_LCD_Init();
Api_Motor_Init();
EnableInterrupts;
}
/*-------------------------------------------------------------------------
* Function Name : Api_Clock_Init
* Description : 系统时钟初始化
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_Clock_Init(void)
{
INT32U dwTime = null;
MODE = NormalChip;
DIRECT = InitDIRECT; //初始化直接页寄存器
IVBR = InitIVBR; //初始化中断向量基地址
CPMUOSC_OSCE = Enable; //使能外部振荡器
while(!CPMUFLG_UPOSC) //等待振荡稳定
{
dwTime++;
if(dwTime > 10000)
{
dwTime = null;
break;
}
}
ECLKCTL_NECLK = Enable; //禁止ECLK输出
CPMUPROT = InitCPMUPROT; //禁止时钟保护
CPMUREFDIV = InitCPMUREFDIV; //设置分频系数
CPMUSYNR = InitCPMUSYNR; //设置乘系数
CPMUPOSTDIV = InitCPMUPOSTDIV; //设置分频参数
CPMUPLL = InitCPMUPLL; //PLL频率调节
//CPMUCOP = InitCPMUCOP; //开启看门狗
CPMUCLKS = InitCPMUCLKS; //在停止模式下振荡运行 选择PLL时钟
CPMUCLKS_PLLSEL = Enable;
CPMUOSC_OSCE = Enable; //使能外部振荡器
while(!CPMUFLG_UPOSC) //等待振荡稳定
{
dwTime++;
_FEED_COP();
if(dwTime > 10000)
{
dwTime = null;
break;
}
}
CPMUCLKS_PSTP = Enable; //伪停止模式
CPMUCLKS_RTIOSCSEL = Enable; //RTI STOP MODE 继续运行
CPMUCLKS_PRE = Enable;
CPMUCLKS_COPOSCSEL = !Enable; //COP STOP MODE 运行
CPMUCLKS_PCE = !Enable;
CPMUPROT = Enable; //使能时钟保护
CPMUHTCTL = Disable; //温度保护禁止
//中断
CPMUINT_OSCIE = Disable; //Osc
CPMUINT_LOCKIE = Disable; //Lock
//RTI
CPMURTI_RTDEC = True; //十进制
CPMURTI_RTR = 0x03; //400*10^3
CPMUINT_RTIE = Enable; //RTI
CPMULVCTL_LVIE = Disable; //LV
IRQCR = Disable; //IRQ
}
/*-------------------------------------------------------------------------
* Function Name : Api_IO_init
* Description :
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_IO_init(void)
{
/*PUCR = 0x40; //上拉驱动使能 禁止下拉
DDR1AD = 0x00;
PER1AD = 0xD0;
DDRA = 0xff;
DDRB = 0xff;
DDRU = 0xf0;
PERU = 0x0F;
PPSU = 0x00;
DDRR = 0x70;
PERR = 0x00;
PPSR = 0x00;
DDRV = 0xff;
PERV = 0x00;
PPSV = 0x00;
DDRH = 0xff;
PERH = 0x00;
PPSH = 0x00;
DDRS = 0x00;
PERS = 0x00;
PPSS = 0x00; //选择上拉 还是下拉
RDRS = 0x00; //驱动能力选择
PTSRR = 0x10; //控制IIC OR SPI
WOMS = 0x00;
PIES = 0x00;
PIFS = 0x00;
SPICR1 = 0x00;
SPICR2 = 0x01;
PTPRR = 0x06;
DDRP = 0xf2;
PERP = 0x00;
PPSP = 0x00;
DDRT = 0xff;
PERT = 0x00;
PPST = 0x00;
PT1AD = 0x00;
PORTA = 0x00;
PORTB = 0x00;
PTT = 0x00;
PTH = 0x00;
PTU = 0x00;
PTP = 0x00;
PTR = 0x00;
PTS = 0x00;
PTV = 0x00;
ATDDIEN = 0xff;*/
PUCR = 0x40; //上拉驱动使能 禁止下拉
DDR1AD = 0x70;
PER1AD = 0x0e;
DDRA = 0xff;
DDRB = 0xff;
DDRU = 0xff;
PERU = 0x00;
PPSU = 0x00;
DDRR = 0x70;
PERR = 0x00;
PPSR = 0x00;
DDRV = 0xff;
PERV = 0x00;
PPSV = 0x00;
DDRH = 0xff;
PERH = 0x00;
PPSH = 0x00;
DDRS = 0x00;
PERS = 0x00;
PPSS = 0x00; //选择上拉 还是下拉
RDRS = 0x00; //驱动能力选择
PTSRR = 0x10; //控制IIC OR SPI
WOMS = 0x00;
PIES = 0x00;
PIFS = 0x00;
SPICR1 = 0x00;
SPICR2 = 0x01;
PTPRR = 0x06;
DDRP = 0xf2;
PERP = 0x00;
PPSP = 0x00;
DDRT = 0xff;
PERT = 0x00;
PPST = 0x00;
PT1AD = 0x00;
PORTA = 0x00;
PORTB = 0x00;
PTT = 0x00;
PTH = 0x00;
PTU = 0x00;
PTP = 0x00;
PTR = 0x00;
PTS = 0x00;
PTV = 0x00;
ATDDIEN = 0xff;
}
#define GLOBALS_API_LCD
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : Api_LCD_Init
* Description :
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_LCD_Init(void)
{
INT8U b;
INT8U *bp;
LCDCR1_LCDSWAI = Disable; //在停止模式下运行
LCDCR0_DUTY = Duty4; // 1/4 Duty
LCDCR0_LCLK = IRCCLK_1M; // IRCCLK 1M
bp = &LCDRAM0;
for(b = 0; b < 20;b++)
{
*bp = 0; //清零LCDRAM
}
FPENR0 = 0xf0; //初始化各段
FPENR1 = 0xff; //初始化各段
FPENR2 = 0x7f; //初始化各段
FPENR3 = 0x00; //初始化各段
FPENR4 = 0x00; //初始化各段
LCDCR0_LCDEN = Enable; //使能LCD
}
/*-------------------------------------------------------------------------
* Function Name : Api_LCD_Display
* Description : LCD显示
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_LCD_Display(void)
{
LCDFP11BP = Matrix1[(Key.CAN_Step / 10) %10]>>4;
LCDFP12BP = Matrix1[(Key.CAN_Step / 10) %10];
LCDFP13BP = Matrix1[(Key.CAN_Step % 10)]>>4;
LCDFP14BP = Matrix1[(Key.CAN_Step % 10)];
if(RunStep > 23)
{
LCDFP19BP = Matrix1[((Key.CAN_Step -24) / 10) %10]>>4;
LCDFP20BP = Matrix1[((Key.CAN_Step -24) / 10) %10];
LCDFP21BP = Matrix1[((Key.CAN_Step -24) % 10)]>>4;
LCDFP22BP = Matrix1[((Key.CAN_Step -24) % 10)];
}
else
{
LCDFP19BP = Matrix1[0]>>4;
LCDFP20BP = Matrix1[0];
LCDFP21BP = Matrix1[0]>>4;
LCDFP22BP = Matrix1[0];
}
//L
LCDFP18BP |= 0x08;
LCDFP20BP |= 0x08;
LCDFP22BP |= 0x08;
//E
LCDFP5BP |= 0x0f;
LCDFP6BP |= 0x01;
//D
LCDFP7BP |= 0x0d;
LCDFP8BP |= 0x07;
//-
LCDFP9BP |= 0x02;
//Z
LCDFP15BP |= Matrix1[2]>>4;
LCDFP16BP |= Matrix1[2];
//H
LCDFP17BP |= 0x07;
LCDFP18BP |= 0x0e;
LCDRAM2_FP4BP = LCDFP4BP;
LCDRAM2_FP5BP = LCDFP5BP;
LCDRAM3_FP6BP = LCDFP6BP;
LCDRAM3_FP7BP = LCDFP7BP;
LCDRAM4_FP8BP = LCDFP8BP;
LCDRAM4_FP9BP = LCDFP9BP;
LCDRAM5_FP10BP = LCDFP10BP;
LCDRAM5_FP11BP = LCDFP11BP;
LCDRAM6_FP12BP = LCDFP12BP;
LCDRAM6_FP13BP = LCDFP13BP;
LCDRAM7_FP14BP = LCDFP14BP;
LCDRAM7_FP15BP = LCDFP15BP;
LCDRAM8_FP16BP = LCDFP16BP;
LCDRAM8_FP17BP = LCDFP17BP;
LCDRAM9_FP18BP = LCDFP18BP;
LCDRAM9_FP19BP = LCDFP19BP;
LCDRAM10_FP20BP = LCDFP20BP;
LCDRAM10_FP21BP = LCDFP21BP;
LCDRAM11_FP22BP = LCDFP22BP;
}
\ No newline at end of file
This diff is collapsed.
#define GLOBALS_API_SCI
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : Api_SCI_Init
* Description : SCI模块初始化
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_SCI_Init(void)
{
SCICR1_LOOPS = Disable; //串口正常模式
SCICR1_SCISWAI = Enable; //禁止等待模式
SCICR1_M = Disable; //8 byte 模式
SCICR1_WAKE = Enable; //Adrress Wake
SCICR1_PE = Disable; //禁止校验
SCISR1_RDRF = Disable;
SCIACR1_RXEDGIE = Disable; //
SCIACR1_BERRIE = Disable;
SCIACR1_BKDIE = Disable;
SCIACR2 = Disable;
SCIBDH_TNP = div4;
/*
When IREN = 0 then,
SCI baud rate = SCI bus clock / (16 x SBR[12:0])
When IREN = 1 then,
SCI baud rate = SCI bus clock / (32 x SBR[12:1])
*/
SCIBDH_IREN = Disable; //禁止红外线
SCIBD_SBR = 20;//baud_38400;
SCICR2_TIE = Disable;
SCICR2_TCIE = Disable;
SCICR2_ILIE = Disable;
SCICR2_RE = Enable; //使能接收
SCICR2_TE = Enable; //使能发送
SCICR2_RWU = Disable;
SCICR2_SBK = Disable; //使能发送
SCICR2_RIE = Enable; //使能接收中断
}
/*-------------------------------------------------------------------------
* Function Name : Api_SCI_Trans_Bytes
* Description : 串口发送
* Input : INT8U *str,INT16U len
* Output : None
* Return : None
* onther : str:发送字符串 len:发送数据长度
--------------------------------------------------------------------------*/
void Api_SCI_Trans_Bytes(INT8U *str,INT8U len)
{
INT8U i;
for(i=0;i<len;i++)
{
Api_SCI_Trans_Byte((*str));
str++;
}
}
/*-------------------------------------------------------------------------
* Function Name : Api_SCI_Trans_Byte
* Description : 串口发送
* Input : INT8U data
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_SCI_Trans_Byte(INT8U data)
{
while(SCISR1_TDRE == null);
SCIDRL = data;
while(!SCISR1_TC);
}
/*-------------------------------------------------------------------------
* Function Name : Api_SCI_Rev_isr
* Description : 串口接收中断
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
interrupt void Api_SCI_Rev_isr(void)
{
if(SCISR1_RDRF == one)
{
SCIRV[rvcnt] = SCIDRL;
rvcnt ++;
if((SCIRV[0]==0xEB)&&(SCIRV[1]==0x90))
{
if(SCIRV[rvcnt-1]==0xAA)
{
if((SCIRV[rvcnt-2]==0x55)&&(rvcnt >=126))
{
rvcnt = null;
CarFlag.FlagBits.RS232RV_Full = Enable;
}
}
}
}
if(SCIRV[0] !=0xEB)
{
rvcnt = null;
}
if(rvcnt >= SCI_LEN)
{
rvcnt = null;
}
SCISR1_RDRF = ClearFlag;
}
\ No newline at end of file
#define GLOBALS_API_TPM
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : Api_Timer0_Init
* Description : 定时器0初始化
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_Timer0_Init(INT8U TPM_DIV)
{
TIM0_TSCR1_TSWAI = Enable; //timer 0 在MCU等待模式下不能运行
TIM0_TSCR1_TSWAI = WaitRun;
TIM0_TSCR1_TSFRZ = Enable; //timer 0 计数器在冻结模式下禁止运行
TIM0_TSCR1_TFFCA = Disable; //正常清除标志位
TIM0_TSCR1_PRNT = Disable; //
TIM0_TSCR2_PR = TPM_DIV; //Bus Clock / 4
TIM0_TSCR2_TCRE = Disable;
TIM0_TTOV = Disable;
TIM0_TCTL1 = Disable; //禁止输出比较功能
TIM0_TCTL2 = Disable;
TIM0_TCTL3 = Disable; //禁止输出比较功能
TIM0_TCTL4 = Disable;
TIM0_TFLG2_TOF = Enable;
TIM0_TSCR1_TEN = Enable; //使能timer 0 正常功能
TIM0_TSCR2_TOI = Enable; //溢出中断使能
}
/*-------------------------------------------------------------------------
* Function Name : Api_Timer1_Init
* Description : 定时器1初始化
* Input :
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Api_Timer1_Init(INT8U TPM_DIV)
{
TIM1_TSCR1_TSWAI = Enable; //timer 0 在MCU等待模式下不能运行
TIM1_TSCR1_TSFRZ = Enable; //timer 0 计数器在冻结模式下禁止运行
TIM1_TSCR1_TFFCA = Disable; //正常清除标志位
TIM1_TSCR1_PRNT = Disable; //
TIM1_TSCR2_PR = TPM_DIV; //Bus Clock / 4
TIM1_TSCR2_TCRE = Disable;
TIM1_TTOV = Disable;
TIM1_TCTL1 = Disable; //禁止输出比较功能
TIM1_TCTL2 = Disable;
TIM1_TCTL3 = Disable; //禁止输出比较功能
TIM1_TCTL4 = Disable;
TIM1_TFLG2_TOF = Enable;
TIM1_TSCR1_TEN = Enable; //使能timer 0 正常功能
TIM1_TSCR2_TOI = Enable; //溢出中断使能
}
//-----------------------------------------------------------------------------
// 函数名称 : Api_Motor_Init
// 函数功能 : 初始化电机驱动
// 输入 :
// *Motor -> 电机结构指针
// 输出 : 无
// 返回值 : 运行状态
// 其他 : 无
//-----------------------------------------------------------------------------
void Api_Motor_Init(void)
{
INT16U *w;
INT8U Nub;
MCCTL0_MCPRE = 0; //时钟为总线的8分频
MCCTL0_MCSWAI = Enable; //停止模式停止工作
MCCTL0_FAST = Disable; //11bit分辨率
MCCTL0_DITH = Disable; //PER-> P10-P0 0:包含P0
MCCTL0_MCTOIF = ClearFlag; //清零中断标志
MCCTL1_RECIRC = True; //低续流
MCCTL1_MCTOIE = Enable; //使能中断
MCPER = 1454; //PWM周期 中断频率 22000
//
MCCC0_MCOM = clear; //双全H桥模式
MCCC0_MCAM = clear; //左对齐
MCCC0_CD = clear; //禁止延时
MCCC1_MCOM = clear; //全H桥模式
MCCC1_MCAM = clear; //左对齐
MCCC1_CD = clear; //禁止延时
//
MCCC2_MCOM = clear; //双全H桥模式
MCCC2_MCAM = clear; //左对齐
MCCC2_CD = clear; //禁止延时
MCCC3_MCOM = clear; //全H桥模式
MCCC3_MCAM = clear; //左对齐
MCCC3_CD = clear; //禁止延时
MCCC4_MCOM = clear;
MCCC4_MCAM = clear;
MCCC4_CD = clear;
MCCC5_MCOM = clear;
MCCC5_MCAM = clear;
MCCC5_CD = clear;
MCCC6_MCOM = clear; //双全H桥模式
MCCC6_MCAM = clear; //左对齐
MCCC6_CD = clear; //禁止延时
MCCC7_MCOM = clear; //全H桥模式
MCCC7_MCAM = clear; //左对齐
MCCC7_CD = clear; //禁止延时
w = &MCDC0; //初始化MCOC 0-7
for(Nub = 0;Nub < 8 ;Nub++)
{
*(w + Nub) = 0;
}
}
//-----------------------------------------------------------------------------
// 函数名称 : Api_Motor_isr
// 函数功能 : PWM溢出中断
// 输入 : 无
// 输出 : 无
// 返回值 : 无
// 其他 : 无
//-----------------------------------------------------------------------------
interrupt void Api_Motor_isr(void)
{
MCCTL0_MCTOIF = ClearFlag; //清零中断标志
}
/*-------------------------------------------------------------------------
* Function Name : Api_Timer0_isr
* Description : 定时器中断
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
interrupt void Api_Timer0_isr(void)
{
if((CANRFLG_RSTAT == 0x03)||(CANRFLG_TSTAT == 0x03))
{
if(BusOffTime == null)
{
BusOffTime = TT_200ms;
CANMISC_BOHOLD = ClearFlag;
}
if(BusOffTime > null)
{
BusOffTime--;
}
}
TIM0_TFLG2_TOF = ClearFlag; //清除中断标志位
}
/*-------------------------------------------------------------------------
* Function Name : API_Timer1_isr
* Description : 定时器中断
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
interrupt void API_Timer1_isr(void)
{
TIM1_TFLG2_TOF = ClearFlag; //清除中断标志位
}
#define GLOBALS_APP_CAN
#include "../App_Headers/includes.h"
#include "../Library/TimeCtrl.h"
#include "../Library/FT_VehSpeedCalc.h"
#define LED_P_NUMBER 0 //正控灯数量
#define LED_N_NUMBER 0 //负控灯数量
#define CAN_MAGS_NUMBER 10 //can报文数量
#define OIL_MUMBER 0 //水油检测点数
INT8U led_P = 0,
led_N = 0,
can_num = 0,
oil_num = 0;
void flash_1Hz_process(void)//500ms call blink/flash
{
Flash_1Hz = !(Flash_1Hz);
}
/*-------------------------------------------------------------------------
* Function Name : App_Msg_Copy
* Description :
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_Msg_Copy(CAN_message * CanMessage,INT16U* data)
{
CanMessage->Msg[0] = data[0];
CanMessage->Msg[0] = data[1];
CanMessage->Msg[0] = data[2];
CanMessage->Msg[0] = data[3];
CanMessage->Msg[0] = data[4];
CanMessage->Msg[0] = data[5];
CanMessage->Msg[0] = data[6];
CanMessage->Msg[0] = data[7];
//bReturn = Api_CANSendFrame(pMsg->id,0,pMsg->Len,pMsg->Data);
}
/*-------------------------------------------------------------------------
* Function Name : Write_CAN_Msg
* Description :
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void Write_CAN_Msg(CAN_message * CanMessage,INT8U i,INT8U data)
{
CanMessage->Msg[i] = data;
}
void Clear_CAN_Msg(CAN_message * CanMessage)
{
INT8U i = 0;
for (i; i <= (CanMessage->Length - 1); i++)
{
CanMessage->Msg[i] = 0x00;
}
CanMessage->ID_EN = 1;
}
void Set_CAN_Msg(CAN_message * CanMessage)
{
INT8U i = 0;
for (i; i <= (CanMessage->Length - 1); i++)
{
CanMessage->Msg[i] = 0xFF;
}
}
void Set_CAN_CRC(CAN_message * CanMessage){
INT8U i;
for(i = 1; i < CanMessage->Length; i++){
CanMessage->Msg[0] ^= CanMessage->Msg[i];
}
}
/*zh:
0CFF7902
0CFF7C02
18FFDC01
18FEDCD5
18FEDED5
*/
void Format_CAN_Msg()
{
CanMsg_330.ID = 0x330;
CanMsg_360.ID = 0x360;
CanMsg_385.ID = 0x385;
CanMsg_330.Length = 8;
CanMsg_360.Length = 8;
CanMsg_385.Length = 8;
CanMsg_330.ID_EN = 1;
CanMsg_360.ID_EN = 1;
CanMsg_385.ID_EN = 1;
}
void Disable_CAN_Tx(void){
CanMsg_330.ID_EN = 0;
CanMsg_360.ID_EN = 0;
CanMsg_385.ID_EN = 0;
}
void Set_Pin(INT16U pin)
{
}
/*-------------------------------------------------------------------------
* Function Name : App_Can_Proc
* Description :
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_Can_Proc(void)
{
unsigned char i;
unsigned int gMsg;
for(i = 0; i < CAN_List_Num; i++){
Message_Value_Calculate(CAN_List[i]);
}
if(GetCtrlTime(CANMsgSend_10ms) >= 10){
ClearCtrlTime(CANMsgSend_10ms);
//bReturn = Api_CANSendFrame((CAN_message *)&CanMessageID18FEDCD5);
//bReturn = Api_CANSendFrame((CAN_message *)&CanMessageID18FEDED5);
//Clear_CAN_Msg((CAN_message *)&CanMessageID18FEDCD5);
//Clear_CAN_Msg((CAN_message *)&CanMessageID18FEDED5);
}
if(GetCtrlTime(CANMsgSend_20ms) >= 20){
ClearCtrlTime(CANMsgSend_20ms);
}
if(GetCtrlTime(CANMsgSend_50ms) >= 50){
ClearCtrlTime(CANMsgSend_50ms);
bReturn = Api_CANSendFrame((CAN_message *)&CanMsg_330);
Clear_CAN_Msg((CAN_message *)&CanMsg_330);
bReturn = Api_CANSendFrame((CAN_message *)&CanMsg_360);
Clear_CAN_Msg((CAN_message *)&CanMsg_360);
bReturn = Api_CANSendFrame((CAN_message *)&CanMsg_385);
Clear_CAN_Msg((CAN_message *)&CanMsg_385);
}
if(GetCtrlTime(CANMsgSend_100ms) >= 100){
ClearCtrlTime(CANMsgSend_100ms);
}
if(GetCtrlTime(CANMsgSend_200ms) >= 200){
ClearCtrlTime(CANMsgSend_200ms);
}
if(GetCtrlTime(CANMsgSend_500ms) >= 500){
flash_1Hz_process();
ClearCtrlTime(CANMsgSend_500ms);
}
if(GetCtrlTime(CANMsgSend_1s) >= 1000){
ClearCtrlTime(CANMsgSend_1s);
}
if(GetCtrlTime(CANMsgSend_10s) >= 10000){
ClearCtrlTime(CANMsgSend_10s);
}
//REV 0
/*CanMessageID0CF80AF0.Msg[0] = 0x98;
CanMessageID0CF80AF0.Msg[1] = 0x3A;
CanMessageID18F816F3.Msg[3] |= 0x10; */
CurValueStr[ENUM_VSpeed ].val = 0;
CurValueStr[ENUM_Water ].val = 0;
CurValueStr[ENUM_VSpeed ].fval = Value_Plus;
CurValueStr[ENUM_Water ].fval = Value_Plus;
// CurVehSpeed = 0;
//LDW Open
//CanMessageID18FE5BE8.Msg[0] |= 0x40;
//FCW Open
// CanMessageID0CF02FA0.Msg[0] |= 0x03;
//AutoLwBm Open
// CanMessageID18FF0B21.Msg[5] |= 0x10;
}
#define GLOBALS_APP_DFLASH
#include "../App_Headers/includes.h"
//-----------------------------------------------------------------------------
// 函数名称 : App_CopyRam(INT8U *Dp,INT8U *Sp,INT8U Nub)
// 函数功能 : RAM 复制
// 输入 : *Dp -> 目的地址
// *Sp -> 原地址
// Nub -> 复制字节数量
// 输出 : 无
// 返回值 : 无
// 其他 : 无
//-----------------------------------------------------------------------------
void App_CopyRam(INT8U *Dp,INT8U *Sp,INT8U Nub)
{
INT8U b;
for(b = 0;b < Nub;b++)
{
*Dp++ = *Sp++;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_Read_EE_Memory
* Description : 读取EEPROM中数据
* Input : INT32U addr,INT8U *DestStr,INT16U len
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_Read_EE_Memory(INT16U ReadAddr,INT8U *DestStr,INT16U len)
{
INT16U i;
for(i= 0;i<len;i++)
{
*(DestStr + i) = Api_Flash_byte_read(ReadAddr + i);
}
}
\ No newline at end of file
/*
* APP_Data_Process.c
*
* Created on: 2012-6-17
* Author: qitiancun
*/
#define GLOBALS_APP_PROCESS
#include "../App_Headers/includes.h"
//CAN_message CanMsg_385;
//CAN_message CanMsg_155;
//CAN_message CanMsg_101;
//CAN_message CanMsg_205;
//CAN_message CanMsg_212;
//CAN_message CanMsg_323;
//CAN_message CanMsg_109;
//CAN_message CanMsg_26D;
/*-------------------------------------------------------------------------
* Function Name : App_State_Init
* Description : 加载数据
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_State_Init(void)
{
}
/*-------------------------------------------------------------------------
* Function Name : App_Load_Data
* Description : 加载数据
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_Load_Data(void)
{
App_Read_EE_Memory(DFLASH_RADIO_ADDR- DFLASH_PROGRAM_OFFSET,(INT8U *)&Radio,8);
check = App_CreateCheckSun((INT8U*)&Radio.VehRadio,Radio.bFlag,6);
if((Radio.bFlag != 0x55)||(check != Radio.bCheckSun))
{
Radio.RevRadio = 40;
Radio.VehRadio = 568;
Radio.VehNum = 4;
}
}
/*-------------------------------------------------------------------------
* Function Name : App_SCI_Proc
* Description : 串口数据处理
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
INT8U App_CreateCheckSun(INT8U *pData,INT8U checkbyte,INT8U len)
{
INT8U Check=0,i;
Check = 0xff ^ checkbyte;
for(i=0;i<len;i++)
{
Check = Check ^ pData[i];
}
return Check;
}
void App_Uds_Calc_Key(INT32U seed)
{
aaaa = 0xb5;//00000000 00000000 00000000 10110101
bbbb = 0xa3;//00000000 00000000 00000000 10100011
cccc = 0xf1;//00000000 00000000 00000000 11110001
dddd = 0x36;//00000000 00000000 00000000 00110110
dwSeed4 = (INT8U)( seed & 0x000000ff); //00000000 00000000 00000000 000000ff
dwSeed3 = (INT8U)((seed & 0x0000ff00) >> 8); //00000000 00000000 0000ff00 00000000
dwSeed2 = (INT8U)((seed & 0x00ff0000) >> 16); //00000000 00ff0000 00000000 00000000
dwSeed1 = (INT8U)((seed & 0xff000000) >> 24); //ff000000 00000000 00000000 00000000
dwKey1 = (INT8U)((aaaa * (dwSeed1 * dwSeed1)) + (bbbb * (dwSeed2 * dwSeed2)) + (cccc * (dwSeed1 * dwSeed2)));
dwKey2 = (INT8U)((aaaa * dwSeed1) + (bbbb * dwSeed2) + (dddd * (dwSeed1 * dwSeed2)));
dwKey3 = (INT8U)((aaaa * (dwSeed3 * dwSeed4)) + (bbbb * (dwSeed4 * dwSeed4)) + (cccc * (dwSeed3 * dwSeed4)));
dwKey4 = (INT8U)((aaaa * (dwSeed3 * dwSeed4)) + (bbbb * dwSeed4) + (dddd * (dwSeed3 * dwSeed4)));
CalcKey = (dwKey1 << 24UL) | (dwKey2 << 16UL) | (dwKey3 << 8UL) | dwKey4;
}
void UDS_Receive_Main(unsigned char *buf)
{
switch(EOLStep)
{
case 0:
{
if((buf[1] == 0x62) && (buf[2] == 0x02) && (buf[3] == 0x1F) && (buf[4] != EOLMode))
{
EOLStep = 1;
}
else
{
EOLStep = 0;
EOLError = 0;
}
}
break;
case 1:
{
if((buf[1] == 0x50) && (buf[2] == 0x03))
{
EOLStep = 2;
EOLError = 0;
}
else
{
EOLError++;
}
}
break;
case 2:
{
if((buf[1] == 0x67) && (buf[2] == 0x01))
{
GetSeed = buf[3];
GetSeed = GetSeed << 8;
GetSeed |= buf[4];
GetSeed = GetSeed << 8;
GetSeed |= buf[5];
GetSeed = GetSeed << 8;
GetSeed |= buf[6];
EOLStep = 3;
EOLError = 0;
}
else
{
EOLError++;
}
}
break;
case 3:
{
if((buf[1] == 0x67) && (buf[2] == 0x02))
{
EOLStep = 4;
EOLError = 0;
}
else
{
EOLError++;
}
}
break;
case 4:
{
if((buf[1] == 0x6E) && (buf[2] == 0x02) && (buf[3] == 0x1F))
{
EOLStep = 5;
EOLError = 0;
}
else
{
EOLError++;
}
}
break;
case 5:
{
if((buf[1] == 0x51) && (buf[2] == 0x01))
{
EOLStep = 0;
EOLError = 0;
}
else
{
EOLError++;
}
}
break;
default:
{
EOLStep = 0;
EOLError = 0;
}
}
if(EOLError >= 5)
{
EOLStep = 0;
EOLError = 0;
}
}
void Service_10_03_Proc(void)
{
/*
CanMessageID18DA17F9.ID = 0x18DA17F9;
CanMessageID18DA17F9.ID_EN = 1;
CanMessageID18DA17F9.Length = 8;
CanMessageID18DA17F9.Msg[0] = 0x02;
CanMessageID18DA17F9.Msg[1] = 0x10;
CanMessageID18DA17F9.Msg[2] = 0x03;
*/
}
void Service_11_01_Proc(void)
{
/*
CanMessageID18DA17F9.ID = 0x18DA17F9;
CanMessageID18DA17F9.ID_EN = 1;
CanMessageID18DA17F9.Length = 8;
CanMessageID18DA17F9.Msg[0] = 0x02;
CanMessageID18DA17F9.Msg[1] = 0x11;
CanMessageID18DA17F9.Msg[2] = 0x01;
*/
}
void Service_22_Proc(void)
{
/*
CanMessageID18DA17F9.ID = 0x18DA17F9;
CanMessageID18DA17F9.ID_EN = 1;
CanMessageID18DA17F9.Length = 8;
CanMessageID18DA17F9.Msg[0] = 0x03;
CanMessageID18DA17F9.Msg[1] = 0x22;
CanMessageID18DA17F9.Msg[2] = 0x02;
CanMessageID18DA17F9.Msg[3] = 0x1F;
*/
}
void Service_27_01_Proc(void)
{
/*
CanMessageID18DA17F9.ID = 0x18DA17F9;
CanMessageID18DA17F9.ID_EN = 1;
CanMessageID18DA17F9.Length = 8;
CanMessageID18DA17F9.Msg[0] = 0x02;
CanMessageID18DA17F9.Msg[1] = 0x27;
CanMessageID18DA17F9.Msg[2] = 0x01;
*/
}
void Service_27_02_Proc(void)
{
/*
CanMessageID18DA17F9.ID = 0x18DA17F9;
CanMessageID18DA17F9.ID_EN = 1;
CanMessageID18DA17F9.Length = 8;
App_Uds_Calc_Key(GetSeed);
CanMessageID18DA17F9.Msg[0] = 0x06;
CanMessageID18DA17F9.Msg[1] = 0x27;
CanMessageID18DA17F9.Msg[2] = 0x02;
CanMessageID18DA17F9.Msg[3] = (unsigned char)(CalcKey >> 24);
CanMessageID18DA17F9.Msg[4] = (unsigned char)(CalcKey >> 16);
CanMessageID18DA17F9.Msg[5] = (unsigned char)(CalcKey >> 8);
CanMessageID18DA17F9.Msg[6] = (unsigned char)(CalcKey);
*/
}
void Service_2E_Proc(void)
{
/*
CanMessageID18DA17F9.ID = 0x18DA17F9;
CanMessageID18DA17F9.ID_EN = 1;
CanMessageID18DA17F9.Length = 8;
CanMessageID18DA17F9.Msg[0] = 0x04;
CanMessageID18DA17F9.Msg[1] = 0x2E;
CanMessageID18DA17F9.Msg[2] = 0x02;
CanMessageID18DA17F9.Msg[3] = 0x1F;
CanMessageID18DA17F9.Msg[4] = EOLMode;
*/
}
void UDS_Service_Main(void)
{
switch(EOLStep)
{
case 0:
{
Service_22_Proc();
}
break;
case 1:
{
Service_10_03_Proc();
}
break;
case 2:
{
Service_27_01_Proc();
}
break;
case 3:
{
Service_27_02_Proc();
}
break;
case 4:
{
Service_2E_Proc();
}
break;
case 5:
{
Service_11_01_Proc();
}
break;
default:
{
EOLStep = 0;
EOLError = 0;
}
}
}
\ No newline at end of file
#define GLOBALS_APP_SCI
#include "../App_Headers/includes.h"
/*-------------------------------------------------------------------------
* Function Name : App_SCI_Proc
* Description : 串口数据处理
* Input : None
* Output : None
* Return : None
* onther :
--------------------------------------------------------------------------*/
void App_SCI_Proc(void)
{
if(CarFlag.FlagBits.RS232RV_Full == Enable)
{
CarFlag.FlagBits.RS232RV_Full = Disable;
App_CopyRam((INT8U *)&SciFrame,(INT8U *)SCIRV,SCI_LEN);
if(SCIRV[2] == 1) //车速
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x55;
SCIRV[3] = 0x01;
SCIRV[4] = 0x02;//上传
SCIRV[5] = 0x00;
SCIRV[6] = 0x21;
SCIRV[40] = App_CreateCheckSun((INT8U*)&SCIRV[7],SCIRV[2],33);
SCIRV[41] = 0x55;
SCIRV[42] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,43);
}
if(SCIRV[2] == 2) //转速
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x55;
SCIRV[3] = 0x02;
SCIRV[4] = 0x02;//上传
SCIRV[5] = 0x00;
SCIRV[6] = 0x21;
SCIRV[40] = App_CreateCheckSun((INT8U*)&SCIRV[7],SCIRV[2],33);
SCIRV[41] = 0x55;
SCIRV[42] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,43);
}
if(SCIRV[2] == 3) //水温
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x55;
SCIRV[3] = 0x03;
SCIRV[4] = 0x02;//上传
SCIRV[5] = 0x00;
SCIRV[6] = 0x21;
SCIRV[40] = App_CreateCheckSun((INT8U*)&SCIRV[7],SCIRV[2],33);
SCIRV[41] = 0x55;
SCIRV[42] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,43);
}
if(SCIRV[2] == 4) //燃油
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x55;
SCIRV[3] = 0x04;
SCIRV[4] = 0x02;//上传
SCIRV[5] = 0x00;
SCIRV[6] = 0x21;
SCIRV[40] = App_CreateCheckSun((INT8U*)&SCIRV[7],SCIRV[2],33);
SCIRV[41] = 0x55;
SCIRV[42] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,43);
}
if(SCIRV[2] == 11) //速比
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x55;
SCIRV[3] = 0x0b;
SCIRV[4] = 0x02;//上传
SCIRV[5] = 0x00;
SCIRV[6] = 0x21;
App_CopyRam((INT8U *)&SCIRV[7],(INT8U *)&Radio.VehRadio,6);
SCIRV[40] = App_CreateCheckSun((INT8U*)&SCIRV[7],SCIRV[2],33);
SCIRV[41] = 0x55;
SCIRV[42] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,43);
}
if(SCIRV[2] == 12) //电压
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x55;
SCIRV[3] = 0x0c;
SCIRV[4] = 0x02;//上传
SCIRV[5] = 0x00;
SCIRV[6] = 0x21;
//Veh
SCIRV[7] = 0;//ADEveArry.TmpEven
SCIRV[8] = 0;
//Rev
SCIRV[9] = 0;
SCIRV[10] = 0;
//tmp
SCIRV[11] = 0;
SCIRV[12] = 0;
//fuel
SCIRV[13] = 0;
SCIRV[14] = 0;
SCIRV[40] = App_CreateCheckSun((INT8U*)&SCIRV[7],SCIRV[2],33);
SCIRV[41] = 0x55;
SCIRV[42] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,43);
}
if(SciFrame.Dir == DownLoad)
{
switch(SciFrame.Frame_Type)
{
case VehType:
check = App_CreateCheckSun((INT8U*)SciFrame.Frame_Data,SciFrame.Frame_Check,33);
if(check == SciFrame.Frame_CheckSun)
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x01;
SCIRV[3] = 0x55;
SCIRV[4] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,5);
}
break;
case RevType:
check = App_CreateCheckSun((INT8U*)SciFrame.Frame_Data,SciFrame.Frame_Check,33);
if(check == SciFrame.Frame_CheckSun)
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x02;
SCIRV[3] = 0x55;
SCIRV[4] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,5);
}
break;
case TmpType:
check = App_CreateCheckSun((INT8U*)SciFrame.Frame_Data,SciFrame.Frame_Check,33);
if(check == SciFrame.Frame_CheckSun)
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x03;
SCIRV[3] = 0x55;
SCIRV[4] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,5);
}
break;
case FueType:
check = App_CreateCheckSun((INT8U*)SciFrame.Frame_Data,SciFrame.Frame_Check,33);
if(check == SciFrame.Frame_CheckSun)
{
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x04;
SCIRV[3] = 0x55;
SCIRV[4] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,5);
}
break;
case RadioType:
check = App_CreateCheckSun((INT8U*)SciFrame.Frame_Data,SciFrame.Frame_Check,33);
if(check == SciFrame.Frame_CheckSun)
{
Radio.bFlag = SciFrame.Frame_Check;
App_CopyRam((INT8U *)&Radio.VehRadio,(INT8U *)&SciFrame.Frame_Data[0],2);
App_CopyRam((INT8U *)&Radio.VehNum,(INT8U *)&SciFrame.Frame_Data[2],2);
App_CopyRam((INT8U *)&Radio.RevRadio,(INT8U *)&SciFrame.Frame_Data[4],2);
Radio.bCheckSun = App_CreateCheckSun((INT8U*)&Radio.VehRadio,Radio.bFlag,6);
SCIRV[0] = 0xeb;
SCIRV[1] = 0x90;
SCIRV[2] = 0x0b;
SCIRV[3] = 0x55;
SCIRV[4] = 0xaa;
Api_SCI_Trans_Bytes((INT8U *)SCIRV,5);
_FEED_COP();
bReturn = Api_DFlashEraseSector(DFLASH_RADIO_ADDR);
bReturn = Api_DFalshProgram(DFLASH_RADIO_ADDR,PAGE_LEN,(INT16U*)&Radio);
}
break;
case AccType:
check = App_CreateCheckSun((INT8U*)SciFrame.Frame_Data,SciFrame.Frame_Check,33);
if(check == SciFrame.Frame_CheckSun)
{
}
break;
default:
;
}
}
SciFrame.Frame_Head[0] = null;
SciFrame.Frame_Data[0] = null;
SciFrame.Frame_Data[1] = null;
SciFrame.Frame_Type = null;
SciFrame.Dir = null;
SCIRV[4] = null;
}
}
\ No newline at end of file
#define GLOBALS_APP_TEST
#include "../App_Headers/includes.h"
#include "../Library/TimeCtrl.h"
#define STEP_MAX 34//
void All_Lamp_TurnOn(void);
void APP_Test_Init(void){
Key.StepAuto = null;
Key.CAN_Step = null;
Key.CAN_Step = null;
// CurValueStr[ENUM_BatteryCurrent].val = 0;
//CurValueStr[CoolTemp].val = 0;
//CurValueStr[VehSpeed].val = 0;
//CurValueStr[AD_Blue].val = 0;
// CurValueStr[ENUM_BatteryCurrent].fval = Value_Plus;
//CurValueStr[CoolTemp].fval = Value_Plus;
//CurValueStr[VehSpeed].fval = Value_Plus;
//CurValueStr[AD_Blue].fval = Value_Plus;
//CanMessageID18F00029.Msg[1] = 0x7D;
//LDW Open
//CanMessageID18FE5BE8.Msg[0] |= 0x40;
//FCW Open
// CanMessageID0CF02FA0.Msg[0] |= 0x03;
//AutoLwBm Open
// CanMessageID18FF0B21.Msg[5] |= 0x10;
EOLMode = 1;
EOLStep = 0;
EOLError = 0;
}
void APP_Button_Proc(void){
/*if(Key.PushTime_1 > T_3s){
Key.StepAuto = 1;
}
if(Key.PushTime_2 > T_3s){
Key.StepAuto = 2;
}*/
if((Key.PushTime_2 > T_2s) || (Key.PushTime_1 > T_2s)){
Key.StepAuto = 1;
}
if(pSB1 == 1){
if((Key.PushTime_1 > T_50ms) && (!Key.StepAuto)){
Key.CAN_Step++;
if(Key.CAN_Step > STEP_MAX){
Key.CAN_Step = 0;
}
}
Key.PushTime_1 = null;
}
if(pSB2 == 1){
if((Key.PushTime_2 > T_50ms) && (!Key.StepAuto)){
if(Key.CAN_Step > 0){
Key.CAN_Step--;
}else{
Key.CAN_Step = STEP_MAX;
}
}
Key.PushTime_2 = null;
}
}
#define TirePressure(value) CurValueStr[ENUM_TirePressure_LF].val = value; CurValueStr[ENUM_TirePressure_RF].val = value; CurValueStr[ENUM_TirePressure_LR].val = value; CurValueStr[ENUM_TirePressure_RR].val = value;
#define TireTemp(value) CurValueStr[ENUM_TireTemp_LF ].val = value; CurValueStr[ENUM_TireTemp_RF ].val = value; CurValueStr[ENUM_TireTemp_LR ].val = value; CurValueStr[ENUM_TireTemp_RR ].val = value;
void APP_ICM_Proc(void) /*zh321*/ /*FS04*/
{
switch(Key.CAN_Step)
{
case 1:
{
CurValueStr[ENUM_VSpeed ].val = 52;//
CurValueStr[ENUM_Water ].val = 58;
}break;
case 2:
{
CurValueStr[ENUM_VSpeed ].val = 108;//
CurValueStr[ENUM_Water ].val = 68;
}break;
case 3:
{
CurValueStr[ENUM_VSpeed ].val = 165;//
CurValueStr[ENUM_Water ].val = 85;
}break;
case 4:
{
CurValueStr[ENUM_VSpeed ].val = 222;//
CurValueStr[ENUM_Water ].val = 102;
}break;
case 5:
{
CurValueStr[ENUM_VSpeed ].val = 279;//
CurValueStr[ENUM_Water ].val = 115;
}break;
case 6:
{
CurValueStr[ENUM_VSpeed ].val = 335;//
CurValueStr[ENUM_Water ].val = 120;
}break;
case 7:
{
CurValueStr[ENUM_VSpeed ].val = 388;//
CurValueStr[ENUM_Water ].val = 140;
Bits_Operation(&CanMsg_385, 0, 6, 2, 1); //EDR
}break;
case 8:
{
CurValueStr[ENUM_VSpeed ].val = 440;//
Bits_Operation(&CanMsg_360, 0, 4, 2, 1); //GPFƵ
}break;
case 9:
{
CurValueStr[ENUM_VSpeed ].val = 500;//
Bits_Operation(&CanMsg_360, 0, 4, 2, 2);//GPF
}break;
default:
Key.CAN_Step = null;
break;
}
}
void Message_ClearDatas(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char len, unsigned char Format){
unsigned char pBit, pByte, i;
pBit = StartBit;
pByte = StartByte;
switch(Format){
case Motorola:{
for(i = 0; i < len; i++){
__RESET_WATCHDOG();
Message->Msg[pByte] &= ~(1 << pBit);
pBit++;
if(pBit >= 8){
pBit = 0;
if(pByte > 0){
pByte--;
}else{
break;
}
}
}
}break;
case Intel:{
for(i = 0; i < len; i++){
__RESET_WATCHDOG();
Message->Msg[pByte] &= ~(1 << pBit);
pBit++;
if(pBit >= 8){
pBit = 0;
if(pByte < 7){
pByte++;
}else{
break;
}
}
}
}break;
default:{
;
}
}
}
void Message_FillDatas(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char len, unsigned char Format, unsigned long MessageValue){
unsigned char pBit, pByte, i;
pBit = StartBit;
pByte = StartByte;
MessageValue = MessageValue << pBit;
switch(Format){
case Motorola:{
for(i = 0; i < len; i++){
__RESET_WATCHDOG();
Message->Msg[pByte] |= MessageValue & (1 << pBit);
pBit++;
if(pBit >= 8){
pBit = 0;
if(pByte > 0){
pByte--;
MessageValue = MessageValue >> 8;
}else{
break;
}
}
}
}break;
case Intel:{
for(i = 0; i < len; i++){
__RESET_WATCHDOG();
Message->Msg[pByte] |= MessageValue & (1 << pBit);
pBit++;
if(pBit >= 8){
pBit = 0;
if(pByte < 7){
pByte++;
MessageValue = MessageValue >> 8;
}else{
break;
}
}
}
}break;
default:{
;
}
}
}
void Message_Value_Calculate(s_CAN_List list)
{
CAN_message *CanMessage;
INT8U Start_Byte, Start_Bit, len, Offset_Flag, Format_Flag;
INT16U Offset, Factor_1, Factor_2, CurValue, Value_Flag;
INT32U temp;
INT32U Message_Clear;
INT8U Byte_Count;
INT8U i;
CanMessage = list.canMsg;
Start_Byte = list.StartByte;
Start_Bit = list.StartBit;
len = list.SignalLen;
Offset_Flag = list.fOffset;
Format_Flag = list.fFormat;
Offset = list.Offset;
Factor_1 = list.Factor_1;
Factor_2 = list.Factor_2;
CurValue = list.CurValue->val;
Value_Flag = list.CurValue->fval;
temp = CurValue;
//计算偏移??
if(Offset != 0){
if(Offset_Flag == Offset_Minus){
if(Value_Flag == Value_Minus){
if(temp > Offset){
temp = 0; //错误,所要实现的值小于物理最小�?
}else{
temp = Offset - temp;
}
}else if(Value_Flag == Value_Plus){
temp += Offset;
}else{;}
}else if(Offset_Flag == Offset_Plus){
if(temp < Offset){
temp = 0; //错误,所要实现的值小于物理最小�?
}else{
temp -= Offset;
}
}
}
temp = temp * Factor_1 / Factor_2;
//temp = temp << Start_Bit;
Byte_Count = len / 8;
if((len % 8) != 0){
Byte_Count += 1;
}
//清脏数据
Message_ClearDatas(CanMessage, Start_Byte, Start_Bit, len, Format_Flag);
Message_FillDatas(CanMessage, Start_Byte, Start_Bit, len, Format_Flag, temp);
}
void FT_VehSpeedCalc(unsigned char spd){
unsigned long wTemp;
wTemp = spd;
}
/*zh:*/
/*------------------------------------------------------------------------------------------------
* function name : Bits_Operation
* parameter value range : StartByte(0~7) StartBit(0~7) Length(1~8) Value(0~255)
* notice : Do not span bytes.
* author : zhouhang
* date :2022.01.18
--------------------------------------------------------------------------------------------------*/
void Bits_Operation(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char Length, unsigned char Value) /*Do not span bytes*/
{
unsigned char i;
for (i = 0; i < Length; i++)
{
Message->Msg[StartByte] &= (~(1 << (i + StartBit)));
}
Message->Msg[StartByte] |= (Value << StartBit);
}
/*:zh*/
void All_Lamp_TurnOn(void)
{
;
}
\ No newline at end of file
#define GLOBALS_GUI_DISP
#include "../App_Headers/includes.h"
#include "../App_Headers/includes.h"
extern void _Startup(void); //ں
#ifndef VECTF
#define VECTF ( void ( *const near )( ) )
#endif
static interrupt void DummyISR(void)
{
for(;;);
}
#ifndef VECTF
#define VECTF ( void ( *const near )( ) )
#endif
//INTERRUPT VECTORS TABLE
#pragma CONST_SEG VECTORS_DATA
void near ( * const near _vectab[] )( ) =
{
VECTF DummyISR, //Spurious interrupt
VECTF DummyISR, //Reserved
VECTF DummyISR, //ATD Compare Interrupt
VECTF DummyISR, //High Temperature Interrupt
VECTF DummyISR, //Autonomous periodical interrupt (API)
VECTF DummyISR, //Low-voltage interrupt (LVI)
VECTF DummyISR, //PWM emergency shutdown
VECTF DummyISR, //Port T
VECTF DummyISR, //Reserved
VECTF DummyISR, //Reserved
VECTF DummyISR, //Reserved
VECTF Api_Motor_isr, //Motor Control Timer Overflow
VECTF DummyISR, //Reserved
VECTF DummyISR, //TIM1 Pulse accumulator input edge
VECTF DummyISR, //TIM1 Pulse accumulator A overflow
VECTF DummyISR, //TIM1 timer overflow
VECTF DummyISR, //TIM1 timer channel 7
VECTF DummyISR, //TIM1 timer channel 6
VECTF DummyISR, //TIM1 timer channel 5
VECTF DummyISR, //TIM1 timer channel 4
VECTF DummyISR, //TIM1 timer channel 3
VECTF DummyISR, //TIM1 timer channel 2
VECTF DummyISR, //TIM1 timer channel 1
VECTF DummyISR, //TIM1 timer channel 0
VECTF DummyISR, //CAN transmit
VECTF Api_CAN_Rev_isr, //CAN receive
VECTF DummyISR, //CAN errors
VECTF DummyISR, //CAN wake-up
VECTF DummyISR, //FLASH
VECTF DummyISR, //FLASH Fault Detect
VECTF DummyISR, //Reserved
VECTF DummyISR, //Reserved
VECTF DummyISR, //IIC bus
VECTF DummyISR, //Reserved
VECTF DummyISR, //Reserved
VECTF DummyISR, //CPMU PLL lock
VECTF DummyISR, //CPMU Oscillator Noise
VECTF DummyISR, //Port S
VECTF DummyISR, //Port R
VECTF DummyISR, //Port AD
VECTF DummyISR, //Reserved
VECTF DummyISR, //ATD
VECTF DummyISR, //Reserved
VECTF Api_SCI_Rev_isr,//SCI
VECTF DummyISR, //SPI
VECTF DummyISR, //TIM0 Pulse accumulator input edge
VECTF DummyISR, //TIM0 Pulse accumulator A overflow
VECTF Api_Timer0_isr, //TIM0 timer overflow Api_Timer0_isr
VECTF DummyISR, //TIM0 timer channel 7
VECTF DummyISR, //TIM0 timer channel 6
VECTF DummyISR, //TIM0 timer channel 5
VECTF DummyISR, //TIM0 timer channel 4
VECTF DummyISR, //TIM0 timer channel 3
VECTF DummyISR, //TIM0 timer channel 2
VECTF DummyISR, //TIM0 timer channel 1
VECTF DummyISR, //TIM0 timer channel 0
VECTF Api_RTC_isr, //Real time interrupt
VECTF DummyISR, //IRQ
VECTF DummyISR, //XIRQ
VECTF DummyISR, //SWI
VECTF DummyISR, //Unimplemented instruction trap
VECTF DummyISR, //COP watchdog reset
VECTF DummyISR, //Clock monitor reset
VECTF _Startup, // 0xFFFE: Reset
};
#pragma CONST_SEG DEFAULT
#ifdef GLOBALS_API_ATD
#define EXTERN_API_ATD
#else
#define EXTERN_API_ATD extern
#endif
#ifndef API_ATD_H_
#define API_ATD_H_
#define CHNAL1 1
#define CHNAL2 2
#define CHNAL3 3
#define SMP_TIME 0
#define SMP_PRE 16
EXTERN_API_ATD INT8U ADCH_SEL;
EXTERN_API_ATD INT16U ATD_Time;
EXTERN_API_ATD INT16U ATD_T3s;
EXTERN_API_ATD void API_ATD_init(void);
EXTERN_API_ATD void API_GetSensorAD(void);
#endif /* API_ATD_H_ */
#ifdef GLOBALS_API_CAN
#define EXTERN_API_CAN
#else
#define EXTERN_API_CAN extern
#endif
#ifndef API_CAN_H_
#define API_CAN_H_
#define SJW_1Tq 0
#define SJW_2Tq 1
#define SJW_3Tq 2
#define SAMP_1 0
#define Seg1_11Tq 10
#define Seg1_12Tq 11
#define Seg1_8Tq 7
#define Seg2_7Tq 6
#define Seg2_8Tq 7
#define Seg1_4Tq 3
#define Seg1_5Tq 4
#define Seg1_6Tq 5
#define Seg2_1Tq 0
#define Seg2_2Tq 1
#define Seg2_3Tq 2
#define Seg2_4Tq 3
#define IDAM_2_32Bit 0
#define IDAM_4_16Bit 1
#define IDHIT0 0
#define empoty 0
#define msg_full 1
#define bit0_mask 1
#define bit1_mask 2
#define bit2_mask 4
#define bit3_mask 8
#define bit4_mask 16
#define bit5_mask 32
#define bit6_mask 64
#define bit7_mask 128
//ºê¶¨Òå
#define GET_EXTPGN(id) (((((((INT32U)id&0xFF0000)>>16) >= 0xF0)?((INT32U)id & 0x00FF00):0)|((INT32U)id & 0x2FF0000)) >> 8)
#define ID138 0x138
#define success 1
#define failt 0
EXTERN_API_CAN void Api_CAN_Init(void);
EXTERN_API_CAN INT16U Api_GET_STAND_ID(INT8U *IDR0_Add);
EXTERN_API_CAN interrupt void Api_CAN_Rev_isr(void);
EXTERN_API_CAN INT8U Api_CANSendFrame(CAN_message * CanMessage);
#endif /* API_CAN_H_ */
#ifdef GLOBALS_API_DFLASH
#define EXTERN_API_DFLASH
#else
#define EXTERN_API_DFLASH extern
#endif
#ifndef API_DFLASH_H_
#define API_DFLASH_H_
#define MaxDFlashCommandCounter 0x06
#define MaxDelayTime BusClock
#define RunComplete 0
#define RunErr 1
#define RunParameterErr 2
#define RunOverTimeErr 3
#define RunErrACCERR 4
#define RunErrFPVIOL 5
#define RunErrMGSTAT1 6
#define RunErrMGSTAT0 7
#define RunErr 1
#define WordSize 0x02
//字大小
#define GLOBAL_ADDRESS_DFLASH 0x0000
//D Flash全局地址[17:16]
#define DFLASH_BLOCK_START_ADDR 0x004400
// D Flash 起始地址
#define DFLASH_VEH_ADDR DFLASH_BLOCK_START_ADDR
#define DFLASH_REV_ADDR DFLASH_VEH_ADDR + 256
#define DFLASH_TMP_ADDR DFLASH_REV_ADDR + 256
#define DFLASH_FUEL_ADDR DFLASH_TMP_ADDR + 256
#define DFLASH_RADIO_ADDR DFLASH_FUEL_ADDR + 256
#define DFLASH_SERKM_ADDR DFLASH_RADIO_ADDR + 256
#define DFLASH_POWER_ADDR DFLASH_SERKM_ADDR + 256
#define DFLASH_BLOCK_END_ADDR 0x0053FF
// D Flash 结束地址
#define DFLASH_SECTOR_SIZE 0x0100
// 256 字节数
#define DFLASH_ACC_START_ADD 0x004C00
//D-Falsh里程累计起始地址
#define DFLASH_ACC_END_ADD 0x004FFF
//D-Flash里程累计结束地址
#define DFLASH_MAXIMUM_SIZE 0x00001000
//D Flash 最大尺寸 4 KB
#define DFLASH_ERASE_VERIFY 0x10
//D Flash 擦除验证命令
#define DFLASH_PROGRAM 0x11
//D Falsh 编程命令
#define DFLASH_ERASE_SECTOR 0x12
//D Flash 擦除命令
#define DFLASH_ERASE_COM_LENGTH 0x01
//D Flash 擦除命令长度
#define DFLASH_ERASE_VERIFY_COM_LENGTH 0x02
//D Flash 擦除检验命令长度
#define DFLASH_PROGRAM_COM_LENGTH 0x04
//D Flash 最大编程字节长度
#define MaxProgramByteNumber 0x08
//最大编程字节数
#define DFlashAccSectorEndAdd 0x004F00
#define DflashAccSectorStartAdd 0x004C00
#define DFLASH_PROGRAM_OFFSET 0x4000
#define DFlashAccReadStartAdd (DFLASH_ACC_START_ADD - DFLASH_PROGRAM_OFFSET)
#define DFlashAccReadEndAdd (DFLASH_ACC_END_ADD - DFLASH_PROGRAM_OFFSET)
#define DFlashAccBlockNumber ((DFLASH_ACC_END_ADD - DFLASH_ACC_START_ADD + 1) / DFlashAccBlockLength)
EXTERN_API_DFLASH void Api_Flash_Init(void);
EXTERN_API_DFLASH INT8U Api_Flash_byte_read(INT16U _addr);
EXTERN_API_DFLASH INT8U Api_DFlashCommSequence(INT8U bCommandCounter);
EXTERN_API_DFLASH INT8U Api_DFlashEraseSector(INT16U wDestination);
EXTERN_API_DFLASH INT8U Api_DFalshProgram(INT16U wDest,INT16U wByteNub,INT16U *wSource);
EXTERN_API_DFLASH INT8U Api_DFlashEraseVerify(INT16U wDestination, INT16U wSize);
#endif /* API_DFLASH_H_ */
/*
* API_Device_Init.h
*
* Created on: 2012-3-27
* Author: arno.qi
*/
#ifdef GLOBALS_API_DEV
#define EXTERN_API_DEV
#else
#define EXTERN_API_DEV extern
#endif
#ifndef API_DEVICE_INIT_H_
#define API_DEVICE_INIT_H_
#define NormalChip 0x80
#define SpecialChip 0x00
#define InitDIRECT 0
#define InitIVBR 0xFF
#define InitCPMUPROT 0x26
#define InitCPMUCLKS 0x87
#define InitCPMUREFDIV 0x40
#define InitCPMUSYNR 0x47 //0X47 4M; 8M 0X43
#define InitCPMUPOSTDIV 0x00
#define InitCPMUPLL 0
#define InitPUCR 0x40
#define InitCPMUCOP 0x07
#define Enable 1
#define Disable 0
#define WaitRun 0
#define null 0
#define one 1
#define ClearFlag 1
#define clear 0
#define True 1
#define false 0
#define PushDown 0
#define UpSpring 1
#define BusClock 32000000 //16777216
#define SafetyVeh 10 *64
#define Prio1 1
#define Prio2 2
#define Prio3 3
#define Prio4 4
#define Prio5 5
#define Prio6 6
#define Prio7 7
#define PushDown 0
#define UpSpring 1
#define Auto 1
#define pSTB PTP_PTP1
/*#define pSBRInput PT1AD_PT1AD2 //Êó±ê-
#define pSBLInput PT1AD_PT1AD1 //Êó±ê+
#define P22_V7_BY1 PTV_PTV7
#define P21_V6_BY2 PTV_PTV6
#define P20_V5_OMID PTV_PTV5
#define P19_V4_OFUll PTV_PTV4
#define P16_V3_OPOW PTV_PTV3
#define P15_V2_OP1 PTV_PTV2
#define P14_V1_OP2 PTV_PTV1
#define P13_V0_OP3 PTV_PTV0
#define P12_U7_OP4 PTU_PTU7
#define P11_U6_OP5 PTU_PTU6
#define P10_U5_OP6 PTU_PTU5
#define P9_U4_ON1 PTU_PTU4
#define P6_U3_ON2 PTU_PTU3
#define P5_U2_ON3 PTU_PTU2
#define P99_AD6_ON4 PT1AD_PT1AD6
#define P98_AD5_ON5 PT1AD_PT1AD5
#define P97_AD4_ON6 PT1AD_PT1AD4
#define P96_AD3_IPOW PT1AD_PT1AD3*/
/*******************************************************
* INPUT
*******************************************************/
#define pSB1 PT1AD_PT1AD1
#define pSB2 PT1AD_PT1AD2
#define LED_P1 1
#define LED_P2 2
#define LED_P3 3
#define LED_P4 4
#define LED_P5 5
#define LED_P6 6
#define Full 7
#define Mid 8
#define LED_N1 11
#define LED_N2 12
#define LED_N3 13
#define LED_N4 14
#define LED_N5 15
#define LED_N6 16
#define LED_all 20
EXTERN_API_DEV void Api_Sys_Init(void);
EXTERN_API_DEV void Api_Clock_Init(void);
EXTERN_API_DEV void Api_IO_init(void);
#endif /* API_DEVICE_INIT_H_ */
#ifdef GLOBALS_API_LCD
#define EXTERN_API_LCD
const INT8U Matrix1[]=
{
//0 1 2 3 4 5 6 7 8 9
0xd7,0x06,0xe3,0xa7,0x36,0xb5,0xf5,0x07,0xf7,0xb7
};
const INT8U Matrix2[]=
{
//0 1 2 3 4 5 6 7 8 9
0xeb,0x0a,0xc7,0x8f,0x2e,0xad,0xed,0x0b,0xef,0xaf
};
const INT8U Matrix3[]=
{
//0 1 2 3 4 5 6 7 8 9
0x5f,0x06,0x6b,0x2f,0x36,0x3d,0x7d,0x07,0x7f,0x3f
};
#else
#define EXTERN_API_LCD extern
#endif
#ifndef API_LCD_H_
#define API_LCD_H_
#define Duty4 0 // 1/2 Duty
#define IRCCLK_1M 1 // IRCCLK 1M
EXTERN_API_LCD void Api_LCD_Init(void);
EXTERN_API_LCD void Api_LCD_Display(void);
#endif /* API_LCD_H_ */
#ifdef GLOBALS_API_RTC
#define EXTERN_API_RTC
#else
#define EXTERN_API_RTC extern
#endif
#ifndef API_RTC_H_
#define API_RTC_H_
#define T_1ms 1
#define T_10ms 10*T_1ms
#define T_20ms 20*T_1ms
#define T_25ms 25*T_1ms
#define T_50ms 50
#define T_100ms 100
#define T_1s 10*T_100ms
#define T_200ms 2*T_100ms
#define T_300ms 3*T_100ms
#define T_400ms 4*T_100ms
#define T_500ms 5*T_100ms
#define T_600ms 6*T_100ms
#define T_700ms 7*T_100ms
#define T_800ms 8*T_100ms
#define T_2s 2*T_1s
#define T_3s 3*T_1s
#define T_3_5s 3*T_1s
#define T_4s 4*T_1s
#define T_5s 5*T_1s
#define T_6s 6*T_1s
#define T_2_5s 2*T_1s
#define T_8s 8*T_1s
#define T_9s 9*T_1s
#define T_10s 10*T_1s
EXTERN_API_RTC interrupt void Api_RTC_isr(void);
EXTERN_API_RTC void Api_SetTimer7(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver7(ClockType *T);
EXTERN_API_RTC void Api_SetTimer6(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver6(ClockType *T);
EXTERN_API_RTC void Api_SetTimer5(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver5(ClockType *T);
EXTERN_API_RTC void Api_SetTimer4(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver4(ClockType *T);
EXTERN_API_RTC void Api_SetTimer3(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver3(ClockType *T);
EXTERN_API_RTC void Api_SetTimer2(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver2(ClockType *T);
EXTERN_API_RTC void Api_SetTimer1(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver1(ClockType *T);
EXTERN_API_RTC void Api_SetTimer0(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_TimerOver0(ClockType *T);
EXTERN_API_RTC void Api_SetAutoTimer(INT16U Second,ClockType *T);
EXTERN_API_RTC INT8U Api_AutoTimerOver(ClockType *T);
#endif /* API_RTC_H_ */
\ No newline at end of file
#ifdef GLOBALS_API_SCI
#define EXTERN_API_SCI
#else
#define EXTERN_API_SCI extern
#endif
#ifndef API_SCI_H_
#define API_SCI_H_
#define CH1 1
#define CH2 2
#define baud_9600 208
#define baud_19200 104
#define baud_38400 52
#define baud_115200 17
#define div4 3
EXTERN_API_SCI void Api_SCI_Init(void);
EXTERN_API_SCI void Api_SCI_Trans_Byte(INT8U data);
EXTERN_API_SCI void Api_SCI_Trans_Bytes(INT8U *pStr, INT8U length);
EXTERN_API_SCI interrupt void Api_SCI_Rev_isr(void);
#endif /* API_SCI_H_ */
\ No newline at end of file
#ifdef GLOBALS_API_TPM
#define EXTERN_API_TPM
#else
#define EXTERN_API_TPM extern
#endif
#ifndef API_TPM_H_
#define API_TPM_H_
#define TPM_DIV4 2
#define TPM_DIV2 1
#define TPM_DIV1 0
#define TPM_DIV128 7
#define TT_10ms 5
#define TT_15ms 7
#define TT_30ms TT_15ms *2
#define TT_100ms 49
#define TT_200ms 96
#define TT_120ms 58
#define TT_180ms 87
#define TT_240ms 117
#define TT_250ms 122
#define TT_340ms 165
#define TT_500ms TT_100ms *5
#define TT_750ms 367
#define TT_1s 490
#define TT_1_5s 735
#define TT_2s 980
#define TT_2_5s 1225
#define TT_3s 1465
#define TT_6s 2930
#define TT_8s 3186
EXTERN_API_TPM void Api_Timer0_Init(INT8U TPM_DIV);
EXTERN_API_TPM void Api_Timer1_Init(INT8U TPM_DIV);
EXTERN_API_TPM void Api_Motor_Init(void);
EXTERN_API_TPM interrupt void Api_Timer0_isr(void);
EXTERN_API_TPM interrupt void API_Timer1_isr(void);
EXTERN_API_TPM interrupt void Api_Motor_isr(void);
#endif /* API_TPM_H_ */
#ifdef GLOBALS_APP_CAN
#define EXTERN_APP_CAN
#else
#define EXTERN_APP_CAN extern
#endif
#ifndef APP_CAN_H_
#define APP_CAN_H_
EXTERN_APP_CAN void Format_CAN_Msg();
EXTERN_APP_CAN void App_Msg_Copy(CAN_message * CanMessage,INT16U* data);
EXTERN_APP_CAN void App_Can_Proc(void);
EXTERN_APP_CAN void Set_CAN_CRC(CAN_message * CanMessage);
EXTERN_APP_CAN void Disable_CAN_Tx(void);
#endif /* APP_CAN_H_ */
\ No newline at end of file
#ifdef GLOBALS_APP_DFLASH
#define EXTERN_APP_DFLASH
#else
#define EXTERN_APP_DFLASH extern
#endif
#ifndef APP_DFLASH_H_
#define APP_DFLASH_H_
#define AccDataFlag 0x55
#define PAGE_LEN 256
#define WaitOverTime 50000
EXTERN_APP_DFLASH void App_CopyRam(INT8U *Dp,INT8U *Sp,INT8U Nub);
EXTERN_APP_DFLASH void App_Read_EE_Memory(INT16U ReadAddr,INT8U *DestStr,INT16U len);
#endif /* APP_DFLASH_H_ */
\ No newline at end of file
/*
* APP_Data_Process.h
*
* Created on: 2012-3-27
* Author: qitiancun
*/
#ifdef GLOBALS_APP_PROCESS
#define EXTERN_APP_PROCESS
#else
#define EXTERN_APP_PROCESS extern
#endif
#ifndef APP_DATA_PROCESS_H_
#define APP_DATA_PROCESS_H_
#define CheckFlag 0x55
EXTERN_APP_PROCESS void App_Load_Data(void);
EXTERN_APP_PROCESS void App_State_Init(void);
EXTERN_APP_PROCESS INT8U App_CreateCheckSun(INT8U *pData,INT8U checkbyte,INT8U len);
EXTERN_APP_PROCESS void UDS_Receive_Main(unsigned char *buf);
EXTERN_APP_PROCESS void UDS_Service_Main(void);
#endif /* APP_DATA_PROCESS_H_ */
#ifdef GLOBALS_APP_SCI
#define EXTERN_APP_SCI
#else
#define EXTERN_APP_SCI extern
#endif
#ifndef APP_SCI_H_
#define APP_SCI_H_
#define VehType 1
#define RevType 2
#define TmpType 3
#define FueType 4
#define VehStepType 5
#define RevStepType 6
#define TmpStepType 7
#define FuelStepType 8
#define RadioType 11
#define AccType 13
#define PowerType 14
#define SerType 15
#define DownLoad 1
#define UpLoad 2
#define SCI_LEN 43
EXTERN_APP_SCI void App_SCI_Proc(void);
#endif /* APP_SCI_H_ */
\ No newline at end of file
#ifdef GLOBALS_APP_TEST
#define EXTERN_APP_TEST
#else
#define EXTERN_APP_TEST extern
#endif
#ifndef APP_TEDT_H_
#define APP_TEDT_H_
#define Motorola 0
#define Intel 1
#define Offset_Minus 0
#define Offset_Plus 1
#define Value_Minus 0
#define Value_Plus 1
typedef struct{
unsigned int val;
unsigned char fval;
}s_CurValue;
typedef struct{
CAN_message *canMsg;
unsigned char StartByte;
unsigned char StartBit;
unsigned char SignalLen;
unsigned int Offset;
unsigned char fOffset;
unsigned int Factor_1;/*Denominator of Resolution*/ /*精度的分母*/
unsigned int Factor_2;/*Numerator of Resolution*/ /*精度的分子*/
s_CurValue *CurValue;
unsigned char fFormat;
}s_CAN_List;
enum
{
ENUM_VSpeed = 0,//车速
ENUM_Water ,
CAN_List_Num ,
};
EXTERN_APP_TEST volatile s_CurValue CurValueStr[CAN_List_Num];
static const s_CAN_List CAN_List[] =
{
{&CanMsg_330, 1, 0, 13, 0, Offset_Plus , 100000, 5625, &CurValueStr[ENUM_VSpeed ], Motorola},
{&CanMsg_360, 1, 0, 8, 48, Offset_Minus, 100, 75, &CurValueStr[ENUM_Water ], Motorola},
};
EXTERN_APP_TEST void APP_Button_Proc(void);
EXTERN_APP_TEST void Message_Value_Calculate(s_CAN_List list);
void Bits_Operation(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char Length, unsigned char Value); /*Do not span bytes*/
#endif /* API_CAN_H_ */
/*
* GUI_Display.h
*
* Created on: 2012-3-27
* Author: arno.qi
*/
#ifdef GLOBALS_GUI_DISP
#define EXTERN_GUI_DISP
#else
#define EXTERN_GUI_DISP extern
#endif
#ifndef GUI_DISP_H_
#define GUI_DISP_H_
#endif /* GUI_DISP_H_ */
\ No newline at end of file
#ifdef GLOBALS_VARIABLE
#define EXTERN_VAR
#else
#define EXTERN_VAR extern
#endif
#ifndef GLOBALS_VAR_H_
#define GLOBALS_VAR_H_
EXTERN_VAR INT8U Flash_1Hz;
EXTERN_VAR volatile INT8U SCIRV[43];
EXTERN_VAR volatile INT8U bReturn;
EXTERN_VAR volatile INT16U FlashCommandArray[MaxDFlashCommandCounter];
EXTERN_VAR volatile ClockType Clock;
EXTERN_VAR volatile INT8U rvcnt;
EXTERN_VAR volatile CarFlagType CarFlag;
EXTERN_VAR volatile INT16U BusOffTime;
/*EXTERN_VAR volatile CanMsg Msg;
EXTERN_VAR volatile CanMsg Msg1;
EXTERN_VAR volatile CanMsg Msg2;*/
EXTERN_VAR volatile TwoINT8U TwoByte;
EXTERN_VAR volatile EcuType Ecu;
EXTERN_VAR volatile SciFrameType SciFrame;
EXTERN_VAR volatile RadioMeter Radio;
EXTERN_VAR volatile INT32U wTemp;
EXTERN_VAR volatile INT8U check;
EXTERN_VAR volatile INT16U VehFre;
EXTERN_VAR volatile INT8U RunStep;
EXTERN_VAR volatile KeyType Key;
EXTERN_VAR volatile INT8U step_cycle;
EXTERN_VAR volatile INT8U LCDFP4BP;
EXTERN_VAR volatile INT8U LCDFP5BP;
EXTERN_VAR volatile INT8U LCDFP6BP;
EXTERN_VAR volatile INT8U LCDFP7BP;
EXTERN_VAR volatile INT8U LCDFP8BP;
EXTERN_VAR volatile INT8U LCDFP9BP;
EXTERN_VAR volatile INT8U LCDFP10BP;
EXTERN_VAR volatile INT8U LCDFP11BP;
EXTERN_VAR volatile INT8U LCDFP12BP;
EXTERN_VAR volatile INT8U LCDFP13BP;
EXTERN_VAR volatile INT8U LCDFP14BP;
EXTERN_VAR volatile INT8U LCDFP15BP;
EXTERN_VAR volatile INT8U LCDFP16BP;
EXTERN_VAR volatile INT8U LCDFP17BP;
EXTERN_VAR volatile INT8U LCDFP18BP;
EXTERN_VAR volatile INT8U LCDFP19BP;
EXTERN_VAR volatile INT8U LCDFP20BP;
EXTERN_VAR volatile INT8U LCDFP21BP;
EXTERN_VAR volatile INT8U LCDFP22BP;
EXTERN_VAR volatile INT32U TEST;
/*EXTERN_VAR CAN_message CanMessageID092; //10
EXTERN_VAR CAN_message CanMessageID0A0; //50
EXTERN_VAR CAN_message CanMessageID0A1; //10
EXTERN_VAR CAN_message CanMessageID0A4; //20
EXTERN_VAR CAN_message CanMessageID100; //100
EXTERN_VAR CAN_message CanMessageID102; //100
EXTERN_VAR CAN_message CanMessageID104; //25
EXTERN_VAR CAN_message CanMessageID108; //100
EXTERN_VAR CAN_message CanMessageID10A; //100
EXTERN_VAR CAN_message CanMessageID112; //100
EXTERN_VAR CAN_message CanMessageID116; //100
EXTERN_VAR CAN_message CanMessageID139; //10
EXTERN_VAR CAN_message CanMessageID141; //10
EXTERN_VAR CAN_message CanMessageID144; //10
EXTERN_VAR CAN_message CanMessageID2F1; //50
EXTERN_VAR CAN_message CanMessageID150; //event
EXTERN_VAR CAN_message CanMessageID200; //100
EXTERN_VAR CAN_message CanMessageID290; //60
EXTERN_VAR CAN_message CanMessageID294; //event
EXTERN_VAR CAN_message CanMessageID2F0; //1000
EXTERN_VAR CAN_message CanMessageID316; //50
EXTERN_VAR CAN_message CanMessageID3EF; //1000
EXTERN_VAR CAN_message CanMessageID0B2; //10
EXTERN_VAR CAN_message CanMessageID10E; //100
EXTERN_VAR CAN_message CanMessageID071; //event
EXTERN_VAR CAN_message CanMessageID220; //100
EXTERN_VAR CAN_message CanMessageID20A; //100
EXTERN_VAR CAN_message CanMessageID387; //100
EXTERN_VAR CAN_message CanMessageID206; //100*/
/*EXTERN_VAR CAN_message CanMessageID0CF80AF0;
EXTERN_VAR CAN_message CanMessageID0CF80BF0;
EXTERN_VAR CAN_message CanMessageID0CF814F3;
EXTERN_VAR CAN_message CanMessageID18F815F3;
EXTERN_VAR CAN_message CanMessageID18F816F3;
EXTERN_VAR CAN_message CanMessageID0CF81EA7;
EXTERN_VAR CAN_message CanMessageID0CF81FA7;
EXTERN_VAR CAN_message CanMessageID18F820A7;
EXTERN_VAR CAN_message CanMessageID18F8058F;
EXTERN_VAR CAN_message CanMessageID18F8068F;*/
/*zh:*/
/*CS08 test*/
EXTERN_VAR CAN_message CanMessageID0CFF7F03;
EXTERN_VAR CAN_message CanMsg_330;
EXTERN_VAR CAN_message CanMsg_360;
EXTERN_VAR CAN_message CanMsg_385;
extern CAN_message CanMsg_330;
extern CAN_message CanMsg_360;
extern CAN_message CanMsg_385;
/**/
/*:zh*/
EXTERN_VAR Max_Page MaxPage;
EXTERN_VAR INT8U Auto_First;
EXTERN_VAR INT8U RT_10ms_En;
EXTERN_VAR INT8U RT_20ms_En;
EXTERN_VAR INT8U RT_25ms_En;
EXTERN_VAR INT8U RT_50ms_En;
EXTERN_VAR INT8U RT_60ms_En;
EXTERN_VAR INT8U RT_100ms_En;
EXTERN_VAR INT8U RT_200ms_En;
EXTERN_VAR INT8U RT_500ms_En;
EXTERN_VAR INT8U RT_1s_En;
EXTERN_VAR INT8U CurVehSpeed;
EXTERN_VAR volatile INT32U seed1;
EXTERN_VAR volatile INT32U seed2;
EXTERN_VAR volatile INT32U seed3;
EXTERN_VAR volatile INT32U seed4;
EXTERN_VAR volatile INT32U dwSeed1;
EXTERN_VAR volatile INT32U dwSeed2;
EXTERN_VAR volatile INT32U dwSeed3;
EXTERN_VAR volatile INT32U dwSeed4;
EXTERN_VAR volatile INT32U dwKey1;
EXTERN_VAR volatile INT32U dwKey2;
EXTERN_VAR volatile INT32U dwKey3;
EXTERN_VAR volatile INT32U dwKey4;
EXTERN_VAR volatile INT32U aaaa;
EXTERN_VAR volatile INT32U bbbb;
EXTERN_VAR volatile INT32U cccc;
EXTERN_VAR volatile INT32U dddd;
EXTERN_VAR volatile INT32U CalcKey;
EXTERN_VAR volatile INT32U GetSeed;
EXTERN_VAR volatile INT8U EOLMode;
EXTERN_VAR volatile INT8U EOLStep;
EXTERN_VAR volatile INT8U EOLError;
#endif /* GLOBALS_VAR_H_ */
/*
* Var_Type.h
*
* Created on: 2012-3-23
* Author: qitiancun
*/
#ifndef VAR_TYPE_H_
#define VAR_TYPE_H_
#define ADEveLen 10
typedef unsigned char INT8U;
typedef volatile unsigned char VINT8U;
typedef unsigned int INT16U;
typedef volatile unsigned int VINT16U;
typedef unsigned long INT32U;
typedef struct
{
INT8U ProceF; //处理标志位
INT32U id;
INT8U Len;
INT8U Data[8];
}CanMsg;
typedef union
{
struct
{
//1 word
INT32U EngRunAtv :1;
INT32U EngSpdStat:2;
INT32U EngCltTmpV:1;
INT32U EngCltTmp :1;
INT32U FlLvlPctV :1;
INT32U VehSpdAvgDrvnV :1;
INT32U ABSAtv :1;
INT32U ABSMlfIO :1;
INT32U EBDMlfIO :1;
INT32U IgnKyInstAtv :1;
INT32U IgnKyPstn :2;
INT32U HhBmIO :1;
INT32U LwBmIO :1;
INT32U FtFgLtIO :1;
//2 word
INT32U PnLgtAtv :1;
INT32U RrFgLtIO :1;
INT32U RtTrnLmpAtv :1;
INT32U LftTrnLmpAtv :1;
INT32U TDLckSwAtv :1;
INT32U RSDOpnSwAtv :1;
INT32U PDOpnSwAtv :1;
INT32U DDOpnSwAtv :1;
INT32U EPSIO :1;
INT32U NetCtlKeep :1;
INT32U NetDataKeep :1;
INT32U CanDataSend:1;
INT32U Reserved2:1;
INT32U Reserved3:1;
INT32U Reserved4:1;
INT32U Reserved5:1;
//3 word
INT32U MotorReset:1;
INT32U MotorInit:1;
INT32U Safety:1;
INT32U RunStar :1;
INT32U TmpFlash:1;
INT32U CanState:1;
INT32U Led:1;
INT32U DoorOpen:1;
INT32U KeyEn:1;
INT32U LampEn:1;
INT32U AccKmValid:1;
INT32U Perilous:1; //危险信号
INT32U RS232RV_Full:1;
INT32U ClearAcc:1;
INT32U Reserved20:1;
INT32U Reserved21:1;
//4 word
INT32U Reserved22:1;
INT32U Reserved23:1;
INT32U Reserved24:1;
INT32U Reserved25:1;
INT32U Reserved26:1;
INT32U Reserved27:1;
INT32U Reserved28:1;
INT32U Reserved29:1;
INT32U Reserved30:1;
INT32U Reserved31:1;
INT32U Reserved32:1;
INT32U Reserved33:1;
INT32U Reserved34:1;
INT32U Reserved35:1;
INT32U Reserved36:1;
INT32U Reserved37:1;
}FlagBits;
INT32U FlagArry[3];
}CarFlagType;
typedef union
{
struct
{
INT8U bit0:1;
INT8U bit1:1;
INT8U bit2:1;
INT8U bit3:1;
INT8U bit4:1;
INT8U bit5:1;
INT8U bit6:1;
INT8U bit7:1;
INT8U bit8:1;
INT8U bit9:1;
INT8U bit10:1;
INT8U bit11:1;
INT8U bit12:1;
INT8U bit13:1;
INT8U bit14:1;
INT8U bit15:1;
}bits;
INT16U w;
}WordBit;
typedef union
{
struct
{
INT16U d16H;
INT16U d16L;
}dw;
INT32U dw32;
}ULONG;
typedef union
{
struct
{
INT8U d8H;
INT8U d8L;
}bytes;
INT16U int16u;
}TwoINT8U;
typedef struct
{
INT8U bDat[256];
INT16U wSectorStartAdd;
INT16U wBlockAdd;
}tDFlashBuff;
typedef struct
{
INT8U Col;
INT16U isFlash; //是否闪烁
INT8U FlashEn; //闪烁使能
INT8U TEnable7;
INT16U OverTime7; //定时极限
INT16U Time7;
INT8U TEnable6;
INT16U OverTime6; //定时极限
INT16U Time6;
INT8U TEnable5;
INT16U OverTime5; //定时极限
INT16U Time5;
INT8U TEnable4;
INT16U OverTime4; //定时极限
INT16U Time4;
INT8U TEnable3;
INT16U OverTime3; //定时极限
INT16U Time3;
INT8U TEnable2;
INT16U OverTime2; //定时极限
INT16U Time2;
INT8U TEnable1;
INT16U OverTime1; //定时极限
INT16U Time1;
INT8U TEnable0;
INT16U OverTime0; //定时极限
INT16U Time0;
INT8U AutoEnable;
INT16U OverAutoTime; //定时极限
INT16U AutoTime;
INT8U HalfSeconds; //1/10秒
INT8U Seconds;
INT8U Minutes;
INT8U Hours;
}ClockType;
typedef union
{
INT16U duty;
INT16U cycle;
INT16U time;
}EcuType;
typedef struct
{
INT8U Frame_Head[2]; //数据帧头
INT8U Frame_Check; //校验字
INT8U Frame_Type; //数据帧类型
INT8U Dir;
INT8U Bak2;
INT8U Frame_Len;
INT8U Frame_Data[33];
INT8U Frame_CheckSun;
INT8U Frame_END[2];
}SciFrameType;
typedef struct //
{
INT8U bFlag;
INT16U VehRadio; //
INT16U VehNum; //
INT16U RevRadio; //
INT8U bCheckSun;
}RadioMeter;
typedef struct
{
INT16U PushTime_1;
INT16U PushTime_2;
INT8U CAN_Step;
INT8U StepAuto;
INT8U CheckDispOk;
}KeyType;
typedef struct
{
INT32U ID;
INT8U Length;
INT8U ID_EN;
INT8U Msg[8];
}CAN_message;
typedef struct{
INT8U Led;
INT8U Trip;
INT8U WF;
INT8U Radar;
}Max_Page;
#endif /* VAR_TYPE_H_ */
/*
* includes.h
*
* Created on: 2012-3-21
* Author: qitiancun
*/
#ifndef _INCLUDES_H_
#define _INCLUDES_H_
#include "hidef.h" /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "mc9s12hy64.h"
#include "../App_Headers/Var_Type.h"
//
#include "../App_Headers/API_Device_Init.h"
#include "../App_Headers/API_DFlash.h"
#include "../App_Headers/API_CAN.h"
#include "../App_Headers/API_TPM.h"
#include "../App_Headers/API_SCI.h"
#include "../App_Headers/API_RTC.h"
#include "../App_Headers/API_LCD.h"
//Ӧò
#include "../App_Headers/Globals_Var.h"
#include "../App_Headers/APP_CAN.h"
#include "../App_Headers/APP_DFlash.h"
#include "../App_Headers/APP_Data_Process.h"
#include "../App_Headers/APP_SCI.h"
#include "../App_Headers/APP_Test.h"
//GUI
#include "../App_Headers/GUI_Display.h"
#endif /* _INCLUDES_H_ */
OPEN source 0 0 60 39
Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off
OPEN assembly 60 0 40 31
Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xC054
OPEN procedure 0 39 60 17
Procedure < attributes VALUES on,TYPES off
OPEN register 60 31 40 25
Register < attributes FORMAT AUTO,COMPLEMENT None
OPEN memory 60 56 40 22
Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80
OPEN data 0 56 60 22
Data:1 < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16
OPEN data 0 32 60 68
Data:2 < attributes SCOPE local,COMPLEMENT None,FORMAT Symb,MODE periodical,SORT NotSort,UPDATERATE 1,NAMEWIDTH 16
OPEN command 60 78 40 22
Command < attributes CACHESIZE 1000
bckcolor 50331647
font 'Courier New' 9 BLACK
AUTOSIZE on
ACTIVATE "Command" "Procedure" "Data:1" "Register" "Assembly" "Memory" "Data:2" "Source"
[STARTUP]
CPUTARGETTYPE=0
USE_CYCLONEPRO_RELAYS=1
CyclonePro_poweroffonexit=0
CyclonePro_currentvoltage=255
CyclonePro_PowerDownDelay=250
CyclonePro_PowerUpDelay=250
RESET_DELAY=0
PORT=101
interface_selection=4
SHOWDIALOG=0
IO_DELAY_SET=0
frequency_has_changed_old_io_delay_cnt=0
IO_DELAY_CNT=0
PCI_DELAY=0
[Environment Variables]
GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib
LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include
OBJPATH={Project}bin
TEXTPATH={Project}bin
ABSPATH={Project}bin
[HI-WAVE]
Target=icd12
Layout=C_layout.hwl
LoadDialogOptions=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
CPU=HC12
MainFrame=0,1,-1,-1,-1,-1,25,25,1050,551
TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806
[HC12MultilinkCyclonePro_GDI_SETTINGS]
CMDFILE0=CMDFILE STARTUP ON ".\cmd\CyclonePro_USB_startup.cmd"
CMDFILE1=CMDFILE RESET ON ".\cmd\CyclonePro_USB_reset.cmd"
CMDFILE2=CMDFILE PRELOAD ON ".\cmd\CyclonePro_USB_preload.cmd"
CMDFILE3=CMDFILE POSTLOAD ON ".\cmd\CyclonePro_USB_postload.cmd"
CMDFILE4=CMDFILE VPPON ON ".\cmd\CyclonePro_USB_vppon.cmd"
CMDFILE5=CMDFILE VPPOFF ON ".\cmd\CyclonePro_USB_vppoff.cmd"
CMDFILE6=CMDFILE UNSECURE ON ".\cmd\CyclonePro_USB_erase_unsecure_hcs12p.cmd"
MCUID=0x02F2
NV_PARAMETER_FILE=
NV_SAVE_WSP=0
NV_AUTO_ID=1
[ICD12]
COMSETTINGS=SETCOMM DRIVER NOPROTOCOL NOPERIODICAL
SETCLKSW=0
HOTPLUGGING=0
DETECTRUNNING=0
RESYNCONCOPRESET=0
BDMAutoSpeed=1
BDMClockSpeed=0
HIGHIODELAYCONSTFORPLL=40
[PORT]
IP=
CAN_FILE [文件标识不可改动]
TBEGAIN [开始标识不可改动]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
T=1000ms [组标识]
20 288 81 00 00 00 [水温60]
T=1000ms [组标识]
20 288 A1 00 00 00 [水温84]
T=1000ms [组标识]
20 288 CA 00 00 00 [水温115]
T=1000ms [组标识]
20 288 D1 00 00 00 [水温120]
T=1000ms [组标识]
20 094 00 00 07 D0 [转速500]
20 088 14 00 00 00 [车速20]
T=1000ms [组标识]
20 094 00 00 0F A0 [转速1000]
20 088 28 00 00 00 [车速40]
T=1000ms [组标识]
20 094 00 00 1F 40 [转速2000]
20 088 3C 00 00 00 [车速60]
T=1000ms [组标识]
20 094 00 00 2E E0 [转速3000]
20 088 50 00 00 00 [车速80]
T=1000ms [组标识]
20 094 00 00 3E 80 [转速4000]
20 088 64 00 00 00 [车速100]
T=1000ms [组标识]
20 094 00 00 4E 20 [转速5000]
20 088 78 00 00 00 [车速120]
T=1000ms [组标识]
20 094 00 00 5D C0 [转速6000]
20 088 8C 00 00 00 [车速140]
T=1000ms [组标识]
20 094 00 00 6D 60 [转速7000]
20 088 A0 00 00 00 [车速160]
T=1000ms [组标识]
20 094 00 00 7D 00 [转速8000]
20 088 B4 00 00 00 [车速180]
T=1000ms [组标识]
20 094 00 00 7D 00 [转速8000]
20 088 C8 00 00 00 [车速200]
T=1000ms [组标识]
20 094 00 00 7D 00 [转速8000]
20 088 DC 00 00 00 [车速220]
T=1000ms [组标识]
20 094 00 00 7D 00 [转速8000]
20 088 F0 00 00 00 [车速240]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 118 00 00 00 00 00 00 00 00 [P档]
150 116 00 80 00 00 00 00 00 00 [P档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 118 00 00 00 00 00 00 00 00 [R档]
150 116 00 70 00 00 00 00 00 00 [R档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 118 00 00 00 00 00 00 00 00 [N档]
150 116 00 60 00 00 00 00 00 00 [N档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 118 00 00 00 00 00 00 00 00 [D档]
150 116 00 50 00 00 00 00 00 00 [D档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
150 118 00 02 06 00 00 00 00 00 [6档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
150 118 00 02 05 00 00 00 00 00 [5档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
150 118 00 02 04 00 00 00 00 00 [4档]
T=1000ms [组标识]
150 068 08 00 00 00 00 00 00 00 [ABS]
150 268 00 00 00 00 00 00 00 00
150 118 00 02 03 00 00 00 00 00 [3档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00 [空 机油压力]
150 268 00 00 00 00 00 00 00 00
150 118 00 02 02 00 00 00 00 00 [2档]
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00 [空 车门]
150 268 00 00 00 00 00 00 00 00
150 118 00 02 01 00 00 00 00 00 [1档]
T=1000ms [组标识]
150 288 00 04 00 00 00 00 00 00 [发动故障]
150 068 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00 [空 充电灯]
150 268 00 00 00 00 00 00 00 00
150 288 00 00 00 00 00 00 00 00
T=1000ms [组标识]
150 268 20 00 00 00 00 00 00 00 [安全气囊]
150 068 00 00 00 00 00 00 00 00
150 288 00 00 00 00 00 00 00 00
T=1000ms [组标识]
150 068 00 00 00 00 00 00 00 00 [空 制动器]
150 268 00 00 00 00 00 00 00 00
T=1000ms [组标识]
100 082 00 00 00 00 00 00 00 80 [CRUISE]
150 068 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
T=1000ms [组标识]
150 288 00 02 00 00 00 00 00 00 [SVS]
150 068 00 00 00 00 00 00 00 00
100 082 00 00 00 00 00 00 00 00
150 268 00 00 00 00 00 00 00 00
T=1000ms [组标识]
150 068 04 00 00 00 00 00 00 00 [EBD]
150 268 00 00 00 00 00 00 00 00
150 288 00 00 00 00 00 00 00 00
T=1000ms [组标识]
20 268 00 00 00 00 00
20 094 00 00 7D 00 [转速8000]
20 088 F0 00 00 00 [车速240]
TEND [结束标识不可改动]
\ No newline at end of file
This diff is collapsed.
#include "FT_VehSpeedCalc.h"
typedef struct{
unsigned int N;
unsigned int VehSpd;
}s_VehSpeedInfo_Buffer;
s_VehSpeedInfo_Buffer MsgToSpd;
s_VehSpeedInfo_Buffer SpdToMsg;
unsigned int FT_WheelRadius = 309;
unsigned int FT_WheelTeeth = 68;
unsigned int FT_WheelRatio = 5135;
void SetWheelInfo(unsigned int Radius, unsigned int Teeth){
unsigned long wTemp;
wTemp = Radius;
wTemp = 2 * 314 * wTemp / Teeth;
wTemp = wTemp * 36 * 50;
wTemp = wTemp / 1000;
FT_WheelRatio = wTemp;
}
unsigned int TestMsg;
void FT_VehSpeedCalc_Main(unsigned int Data, unsigned int *DestData, unsigned char Dir){
unsigned long wTemp;
switch(Dir){
case CANMESSAGE_TO_SPEED:{
}break;
case SPEED_TO_CANMESSAGE:{
SpdToMsg.VehSpd = Data;
wTemp = SpdToMsg.VehSpd;
wTemp = wTemp * 1000 * 2;
wTemp = wTemp / FT_WheelRatio;
TestMsg = wTemp;
SpdToMsg.N += wTemp;
if(SpdToMsg.N > 64255){
SpdToMsg.N -= 64255;
}
*DestData = SpdToMsg.N;
}break;
default:
;
}
}
void FT_Fill_VehSpeedCANMessage(unsigned int val, unsigned char *Data){
Data[0] = val;
Data[1] = val >> 8;
Data[2] = val;
Data[3] = val >> 8;
Data[4] = val;
Data[5] = val >> 8;
Data[6] = val;
Data[7] = val >> 8;
}
\ No newline at end of file
#ifndef __FT_VEHSPEEDCALC_H_
#define __FT_VEHSPEEDCALC_H_
#define SPEED_TO_CANMESSAGE 1
#define CANMESSAGE_TO_SPEED 0
void SetWheelInfo(unsigned int Radius, unsigned int Teeth);
void FT_VehSpeedCalc_Main(unsigned int Data, unsigned int *DestData, unsigned char Dir);
void FT_Fill_VehSpeedCANMessage(unsigned int val, unsigned char *Data);
#endif
\ No newline at end of file
#include "TimeCtrl.h"
typedef struct{
unsigned int Time;
unsigned char En;
}s_TimeCtrl;
s_TimeCtrl TimeCtrl[TimeSNMax];
typedef struct{
unsigned int Timer_2ms;
unsigned int Timer_10ms;
}s_BaseTimer;
s_BaseTimer BaseTimer;
/*************************************************************************
* Timer Control
*************************************************************************/
void InitTimeCtrl(void){
unsigned char i;
for(i = 0; i < TimeSNMax; i++){
TimeCtrl[i].Time = 0;
TimeCtrl[i].En = 0;
}
BaseTimer.Timer_2ms = 0;
BaseTimer.Timer_10ms = 0;
}
void TimerCtrlms(unsigned int time){
unsigned char i;
for(i = 0; i < TimeSNMax; i++){
if(TimeCtrl[i].En){
if(TimeCtrl[i].Time < MAX_CTRL_TIME){
TimeCtrl[i].Time += time;
}
}else{
TimeCtrl[i].Time = 0;
}
}
}
void EnableTimeCtrl(e_TimeSN sn){
if(!TimeCtrl[sn].En){
TimeCtrl[sn].En = 1;
TimeCtrl[sn].Time = 0;
}
}
void DisableTimeCtrl(e_TimeSN sn){
if(TimeCtrl[sn].En){
TimeCtrl[sn].En = 0;
TimeCtrl[sn].Time = 0;
}
}
void ClearCtrlTime(e_TimeSN sn){
TimeCtrl[sn].Time = 0;
}
unsigned int GetCtrlTime(e_TimeSN sn){
return TimeCtrl[sn].Time;
}
/*************************************************************************
* Timer Task
* 2ms / 10ms
*************************************************************************/
void Timer_1ms_Base(void){
if(BaseTimer.Timer_10ms <= 5000){
BaseTimer.Timer_10ms += 1;
}
if(BaseTimer.Timer_2ms <= 5000){
BaseTimer.Timer_2ms += 1;
}
}
void Timer_2ms_Task(void){
unsigned int n;
unsigned char i;
if(BaseTimer.Timer_2ms >= 2){
n = BaseTimer.Timer_2ms / 2;
BaseTimer.Timer_2ms = BaseTimer.Timer_2ms - (n * 2);
TimerCtrlms(2 * n);
}
}
void Timer_10ms_Task(void){
unsigned int n;
unsigned char i;
if(BaseTimer.Timer_10ms >= 10){
n = BaseTimer.Timer_10ms / 10;
BaseTimer.Timer_10ms = BaseTimer.Timer_10ms - (n * 10);
}
}
\ No newline at end of file
#ifndef __TIMECTRL_H_
#define __TIMECTRL_H_
#define MAX_CTRL_TIME 15000 //ms
typedef enum{
CANMsgSend_10ms = 0,
CANMsgSend_20ms,
CANMsgSend_50ms,
CANMsgSend_100ms,
CANMsgSend_200ms,
CANMsgSend_500ms,
CANMsgSend_1s,
CANMsgSend_10s,
TwoLamp_Ctrl,
TimeSNMax,
}e_TimeSN;
void InitTimeCtrl(void);
void TimerCtrlms(unsigned int time);
void EnableTimeCtrl(e_TimeSN sn);
void DisableTimeCtrl(e_TimeSN sn);
void ClearCtrlTime(e_TimeSN sn);
unsigned int GetCtrlTime(e_TimeSN sn);
void Timer_1ms_Base(void);
void Timer_2ms_Task(void);
void Timer_10ms_Task(void);
#endif
\ No newline at end of file
[STARTUP]
CPUTARGETTYPE=0
USE_CYCLONEPRO_RELAYS=0
PORT=1
interface_selection=0
SHOWDIALOG=0
IO_DELAY_SET=1
frequency_has_changed_old_io_delay_cnt=14
CyclonePro_poweroffonexit=0
CyclonePro_currentvoltage=255
CyclonePro_PowerDownDelay=250
CyclonePro_PowerUpDelay=250
IO_DELAY_CNT=14
PCI_DELAY=0
RESET_DELAY=0
[Environment Variables]
GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib
LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include
OBJPATH={Project}bin
TEXTPATH={Project}bin
ABSPATH={Project}bin
[HI-WAVE]
Target=TBDML
Layout=C_layout.hwl
LoadDialogOptions=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
CPU=HC12
AEFWarningDialog=FALSE
MainFrame=2,3,-32000,-32000,-1,-1,108,-2,1133,531
TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806
Configuration=P&E_Multilink_USB.hwc
Statusbar=1
ShowToolbar=1
Smallborder=0
Hideheadline=0
Hidetitle=0
[HC12MultilinkCyclonePro_GDI_SETTINGS]
CMDFILE0=CMDFILE STARTUP ON ".\cmd\P&E_Multilink_USB_startup.cmd"
CMDFILE1=CMDFILE RESET ON ".\cmd\P&E_Multilink_USB_reset.cmd"
CMDFILE2=CMDFILE PRELOAD ON ".\cmd\P&E_Multilink_USB_preload.cmd"
CMDFILE3=CMDFILE POSTLOAD ON ".\cmd\P&E_Multilink_USB_postload.cmd"
CMDFILE4=CMDFILE VPPON ON ".\cmd\P&E_Multilink_USB_vppon.cmd"
CMDFILE5=CMDFILE VPPOFF ON ".\cmd\P&E_Multilink_USB_vppoff.cmd"
CMDFILE6=CMDFILE UNSECURE ON ".\cmd\P&E_Multilink_USB_erase_unsecure_hcs12p.cmd"
MCUId=0x2F2
CHIPSECURE=CHIPSECURE SETUP 0xFF0F 0x3 0x2
DBG0=DBG GENERAL DISARM_ON PROTECT_OFF ANALYZE_ON STEPATRUN_ON
DBG1=DBG PREDEFINED SELECT 0
DBG2=DBG PREDEFINED DBGENGINE TRACE ENABLE RECORDAFTER PUREPC
NV_PARAMETER_FILE=
NV_SAVE_WSP=0
NV_AUTO_ID=1
[ICD12]
COMSETTINGS=SETCOMM DRIVER NOPROTOCOL NOPERIODICAL
SETCLKSW=0
HOTPLUGGING=0
DETECTRUNNING=0
RESYNCONCOPRESET=0
BDMAutoSpeed=0
BDMClockSpeed=14
HIGHIODELAYCONSTFORPLL=40
[PORT]
IP=
[Recent Applications File List]
File0=D:\李亭龙工作\天有为工作\我的程序\Freescale\CAN检测软件\CAN FC-3跑表架\bin\Project.abs
File1=D:\李亭龙工作\天有为工作\我的程序\Freescale\CAN检测软件\CAN NL-1跑表架\bin\Project.abs
File2=D:\李亭龙工作\天有为工作\我的程序\Freescale\CAN检测软件\CAN 扩展帧\bin\Project.abs
File3=F:\21--505CAN检测程序\CAN检测软件\bin\Project.abs
LoadFlags0=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags1=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags2=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags3=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
[Recent Layout File List]
File0=C_layout.hwl
File1=
File2=
File3=
[TBDML]
COMSETTINGS=SETCOMM DRIVER NOPROTOCOL NOPERIODICAL
[TBDML HCS12_GDI_SETTINGS]
CMDFILE0=CMDFILE STARTUP ON "startup.cmd"
CMDFILE1=CMDFILE RESET ON "reset.cmd"
CMDFILE2=CMDFILE PRELOAD ON "preload.cmd"
CMDFILE3=CMDFILE POSTLOAD ON "postload.cmd"
MCUId=0x2F2
CMDFILE4=CMDFILE VPPON ON "vppon.cmd"
CMDFILE5=CMDFILE VPPOFF ON "vppoff.cmd"
CMDFILE6=CMDFILE UNSECURE ON "unsecure.cmd"
CHIPSECURE=CHIPSECURE SETUP 0xFF0F 0x3 0x2
DBG0=DBG GENERAL DISARM_ON PROTECT_OFF ANALYZE_ON STEPATRUN_ON
DBG1=DBG PREDEFINED SELECT 0
DBG2=DBG PREDEFINED DBGENGINE TRACE ENABLE RECORDAFTER PUREPC
NV_PARAMETER_FILE=C:\Program Files (x86)\Freescale\CWS12v5.1\prog\FPP\mcu02F2.fpp
NV_SAVE_WSP=0
NV_AUTO_ID=1
This diff is collapsed.
This diff is collapsed.
/*
* Note: This file is recreated by the project wizard whenever the MCU is
* changed and should not be edited by hand
*/
/* Include the derivative-specific header file */
#include <mc9s12hy64.h>
#pragma LINK_INFO DERIVATIVE "mc9s12hy64"
#define GLOBALS_VARIABLE
#include "../App_Headers/includes.h"
#include "../Library/TimeCtrl.h"
#include "../Library/FT_VehSpeedCalc.h"
void main(void) {
unsigned char i;
step_cycle = 0;
Api_Sys_Init();
App_State_Init();
App_Load_Data();
Format_CAN_Msg();
APP_Test_Init();
InitTimeCtrl();
//SetWheelInfo(309,68);
//CurVehSpeed = 0;
for(i = 0; i < TimeSNMax; i++){
EnableTimeCtrl(i);
}
//Api_SetTimer0(100,(ClockType *)&Clock);
for(;;) {
pSTB = 0;
__RESET_WATCHDOG();
Timer_2ms_Task();
APP_Button_Proc();
APP_ICM_Proc();
App_Can_Proc();
Api_LCD_Display();
}
}
[Environment Variables]
GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib
LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include
OBJPATH={Project}bin
TEXTPATH={Project}bin
ABSPATH={Project}bin
[HI-WAVE]
Target=TBDML
Layout=C_layout.hwl
LoadDialogOptions=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
CPU=HC12
MainFrame=2,3,-1,-1,-1,-1,437,191,1367,927
TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806
AEFWarningDialog=FALSE
Configuration=TBDML.hwc
Statusbar=1
ShowToolbar=1
Smallborder=0
Hideheadline=0
Hidetitle=0
[TBDML HCS12_GDI_SETTINGS]
CMDFILE0=CMDFILE STARTUP ON ".\cmd\TBDML_startup.cmd"
CMDFILE1=CMDFILE RESET ON ".\cmd\TBDML_reset.cmd"
CMDFILE2=CMDFILE PRELOAD ON ".\cmd\TBDML_preload.cmd"
CMDFILE3=CMDFILE POSTLOAD ON ".\cmd\TBDML_postload.cmd"
CMDFILE4=CMDFILE VPPON ON ".\cmd\TBDML_vppon.cmd"
CMDFILE5=CMDFILE VPPOFF ON ".\cmd\TBDML_vppoff.cmd"
CMDFILE6=CMDFILE UNSECURE ON ".\cmd\TBDML_erase_unsecure_hcs12p.cmd"
MCUID=0x02F2
CHIPSECURE=CHIPSECURE SETUP 0xFF0F 0x3 0x2
DBG0=DBG GENERAL DISARM_ON PROTECT_OFF ANALYZE_ON STEPATRUN_ON
DBG1=DBG PREDEFINED SELECT 0
DBG2=DBG PREDEFINED DBGENGINE TRACE ENABLE RECORDAFTER PUREPC
NV_PARAMETER_FILE=D:\New Folder\prog\FPP\mcu02F2.fpp
NV_SAVE_WSP=0
NV_AUTO_ID=1
COMDEVICE=SETCOMM COMPORT LPT "TBDML #1"
ISRDISABLEDSTEP=0
[TBDML]
COMSETTINGS=SETCOMM DRIVER NOPROTOCOL NOPERIODICAL
NV_PARAMETER_FILE=
NV_SAVE_WSP=0
NV_AUTO_ID=1
[Recent Applications File List]
File0=D:\TYW1̨\Test_Bench\bin\Project.abs
File1=C:\Users\ǿ\Desktop\TYW̨\Test_Bench\bin\Project.abs
File2=C:\Users\ǿ\Desktop\fs04___test_bench___little_can\Test_Bench\bin\Project.abs
File3=D:\LD01_02-ƿ3ϵ\̨\20210705\bin\Project.abs
LoadFlags0=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags1=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags2=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags3=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
[Recent Layout File List]
File0=C_layout.hwl
File1=
File2=
File3=
[Recent HI-WAVE FindProcedure Search]
Search0=main
Search1=App_Can_Proc
Search2=APP_ICM_Proc
This diff is collapsed.
#ifndef __UDS_SERVICE_H_
#define __UDS_SERVICE_H_
/*
#define ServiceID_DiagnosticSessionControl 0x10
#define ServiceID_ECUReset 0x11
#define ServiceID_SecurityAccess 0x27
#define ServiceID_ReadDataByIdentifier 0x22
#define ServiceID_WriteDataByIdentifier 0x2E
#define ServiceID_TesterPresent 0x3E
typedef enum
{
TransferEnd = 0,
TransferStart,
} e_TransferStatus;
typedef enum
{
Tx_NoAct = 0,
Tx_SF,
Tx_FF,
Tx_CF,
Tx_End,
} e_TxType;
typedef struct
{
unsigned char ServiceID;
e_TransferStatus TransferStatus;
unsigned int DataLen;
unsigned char Data[64];
} s_UDS_ServiceBuffer;
void SetRxTransferStatus(e_TransferStatus sts, unsigned int UDS_Len);
unsigned char GetRxTransferDataNumber(void);
void TransferServiceRxInfo(unsigned char *Data, unsigned char len);
void UDS_ServiceMain(void);
void SetServiceProc(unsigned char ServiceID, unsigned int ServiceDID);
e_TxType TransferServiceTxInfo(s_UDS_Msg_Buffer *buffer);
*/
#endif
This diff is collapsed.
#ifndef __UDS_TP_H_
#define __UDS_TP_H_
/*
#define N_PCITYPE_SF 0
#define N_PCITYPE_FF 1
#define N_PCITYPE_CF 2
#define N_PCITYPE_FC 3
typedef enum
{
COMM_Free = 0,
COMM_Send_FC,
COMM_Wait_FC,
COMM_Wait_CF,
COMM_Send_Frame,
COMM_WaitServiceHandle,
} e_CommunicateStatus;
typedef union
{
struct
{
unsigned char SF_DL : 4;
unsigned char N_PCItype : 4;
unsigned char Data1 : 8;
unsigned char Data2 : 8;
unsigned char Data3 : 8;
unsigned char Data4 : 8;
unsigned char Data5 : 8;
unsigned char Data6 : 8;
unsigned char Data7 : 8;
} SF_Format;
struct
{
unsigned char FF_DL_H : 4;
unsigned char N_PCItype : 4;
unsigned char FF_DL_L : 8;
unsigned char Data2 : 8;
unsigned char Data3 : 8;
unsigned char Data4 : 8;
unsigned char Data5 : 8;
unsigned char Data6 : 8;
unsigned char Data7 : 8;
} FF_Format;
struct
{
unsigned char SN : 4;
unsigned char N_PCItype : 4;
unsigned char Data1 : 8;
unsigned char Data2 : 8;
unsigned char Data3 : 8;
unsigned char Data4 : 8;
unsigned char Data5 : 8;
unsigned char Data6 : 8;
unsigned char Data7 : 8;
} CF_Format;
struct
{
unsigned char FS : 4;
unsigned char N_PCItype : 4;
unsigned char BS : 8;
unsigned char STmin : 8;
unsigned char Data3 : 8;
unsigned char Data4 : 8;
unsigned char Data5 : 8;
unsigned char Data6 : 8;
unsigned char Data7 : 8;
} FC_Format;
unsigned char Data[8];
} u_UDS_Message_Format;
typedef struct
{
u_UDS_Message_Format DataMsg;
unsigned char AnalysisStatus;
} s_UDS_Msg_Buffer;
extern s_UDS_Msg_Buffer UDS_Tx_Buffer;
extern e_CommunicateStatus CommunicateStatus;
void GetUDSMessage(unsigned char *CAN_BufAddr, unsigned char len);
unsigned char FillTxBuffer(unsigned char *Data, unsigned char len);
void ClearUDS_Msg_Buffer(s_UDS_Msg_Buffer *buffer);
void AnalysisUDSMessage(void);
void TP_SendFC(void);
void EnableUDSSend(void);
void TP_SendServiceMsg(void);
*/
#endif
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment