#include "sys.h"
#include "delay.h"
#include "can.h"
#include "led.h"
#include "nvic.h"
#include "stdio.h"
#include "usart.h"
#include "hmi_driver.h"
#include "subfunction.h"
u8 can1_rec_flag = 0;
u8 can1_buf[100];
u8 can1_num;
u16 CAN1_ID;
u8 CAN1_DATA[8];//={0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x01};
u8 CAN2_DATA[8]= {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x02};
u8 CAN3_DATA[8]= {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x03};
u8 CAN4_DATA[8]= {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x04};
u8 CAN5_DATA[8]= {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x05};
u8 CAN6_DATA[8]= {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x06};
int main(void)
{
u8 j;
u8 t=0;
u8 i=0;
NVIC_Configuration();
delay_init(168); //延时初始化
uart_init(); //串口初始化
CAN_Mode_Init();
////用于wq125
// if(W25QXX_ReadID()!=W25Q128) SetTextValue(0,9,"119");//检测不到W25Q128
// else SetTextValue(0,10,"110");
// W25QXX_Write((u8*)TEXT_Buffer,FLASH_SIZE-200,6); //从倒数第100个地址处开始,写入SIZE长度的数据
// W25QXX_Read(datatemp,FLASH_SIZE-200,6); //从倒数第100个地址处开始,读出SIZE个字节
// SetTextValue(0,13,&datatemp[0]);
//
while(1)
{
CAN1_Send_Msg(CAN2_DATA,8,0x0111);//扫描从机CAN1
delay_ms(10);
if(can1_num>0)
{
printf("%d",can1_num);//从串口1打印从can1接受了6帧数据
RS232_1_Send_Data(can1_buf,48);
can1_num=0;
}
delay_ms(1);//两次扫描之间要加延时,要不然会出错
CAN1_Send_Msg(CAN3_DATA,8,0x0112);//扫描从机CAN2
delay_ms(1);
if(can1_num>0)
{
printf("%d",can1_num);//从串口1打印从can1接受了3帧数据
RS232_1_Send_Data(can1_buf,24);
can1_num=0;
}
//指示系统正在运行
t++;
delay_ms(100);
if(t==2)
{
LED0=!LED0;
t=0;
}
//指示系统正在运行
}
}
|