AVR单片机实现了232到CAN转换
SMPL_1X
#define PHSEG1_8TQ
#define PHSEG1_7TQ
#define PHSEG1_6TQ
#define PHSEG1_5TQ
#define PHSEG1_4TQ
#define PHSEG1_3TQ
#define PHSEG1_2TQ
#define PHSEG1_1TQ
#define PRSEG_8TQ
#define PRSEG_7TQ
#define PRSEG_6TQ
#define PRSEG_5TQ
#define PRSEG_4TQ
#define PRSEG_3TQ
#define PRSEG_2TQ
#define PRSEG_1TQ
#define PHSEG2_8TQ
#define PHSEG2_7TQ
#define PHSEG2_6TQ
#define PHSEG2_5TQ
#define PHSEG2_4TQ
#define PHSEG2_3TQ
#define PHSEG2_2TQ
#define PHSEG2_1TQ
#define SOF_ENABLED
#define WAKFIL_ENABLED
#define WAKFIL_DISABLED 0x00
#define RX0IE_ENABLED
#define RX0IE_DISABLED
#define RX1IE_ENABLED
#define RX1IE_DISABLED
#define G_RXIE_ENABLED
#define G_RXIE_DISABLED 0x00
#define TX0IE_ENABLED
#define TX0IE_DISABLED
#define TX1IE_ENABLED
#define TX2IE_DISABLED
#define TX2IE_ENABLED
#define TX2IE_DISABLED
#define G_TXIE_ENABLED
#define G_TXIE_DISABLED 0x00
#define ERRIE_ENABLED
#define ERRIE_DISABLED
#define WAKIE_ENABLED
#define WAKIE_DISABLED
#define IVRE_ENABLED
#define IVRE_DISABLED
#define RX0IF_SET
#define RX0IF_RESET
#define RX1IF_SET
#define RX1IF_RESET
#define TX0IF_SET
#define TX0IF_RESET
#define TX1IF_SET
#define TX2IF_RESET
#define TX2IF_SET
#define TX2IF_RESET
#define ERRIF_SET
#define ERRIF_RESET
#define WAKIF_SET
#define WAKIF_RESET
#define IVRF_SET
#define IVRF_RESET
#define REQOP_CONFIG
#define REQOP_LISTEN
#define REQOP_LOOPBACK
#define REQOP_SLEEP
#define REQOP_NORMAL
#define ABORT
#define OSM_ENABLED
#define CLKOUT_ENABLED
#define CLKOUT_DISABLED 0x00
#define CLKOUT_PRE_8
#define CLKOUT_PRE_4
#define CLKOUT_PRE_2
#define CLKOUT_PRE_1
#define OPMODE_CONFIG
#define OPMODE_LISTEN
#define OPMODE_LOOPBACK 0x40
#define OPMODE_SLEEP
#define OPMODE_NORMAL
#define RXM_RCV_ALL
#define RXM_VALID_EXT
#define RXM_VALID_STD
#define RXM_VALID_ALL
#define RXRTR_REMOTE
#define RXRTR_NO_REMOTE 0x00
#define BUKT_ROLLOVER
#define BUKT_NO_ROLLOVER 0x00
#define FILHIT0_FLTR_1
#define FILHIT0_FLTR_0
#define FILHIT1_FLTR_5
#define FILHIT1_FLTR_4
#define FILHIT1_FLTR_3
#define FILHIT1_FLTR_2
#define FILHIT1_FLTR_1
#define FILHIT1_FLTR_0
#define TXREQ_SET
#define TXREQ_CLEAR
#define TXP_HIGHEST
#define TXP_INTER_HIGH
#define TXP_INTER_LOW
#define TXP_LOWEST
#define CAN_RESET
#define CAN_READ
#define CAN_WRITE
#define CAN_RTS
#define CAN_RTS_TXB0
#define CAN_RTS_TXB1
#define CAN_RTS_TXB2
#define CAN_RD_STATUS
#define CAN_BIT_MODIFY
#define CAN_RX_STATUS
#define CAN_RD_RX_BUFF
#define CAN_LOAD_TX
#define DUMMY_BYTE
#define TXB0
#define TXB1
#define TXB2
#define RXB0
#define RXB1
#define EXIDE_SET
#define EXIDE_RESET
uchar can_boud=0x07;//MCP2515在16M晶振情况,can_boud=0x00总线波特率为1M,0x01=500K,0x03=250K,0x07=125K;公式:16M/(16*(1+X))
uint bps=38400;//定义avr单片机串口波特率
uchar eflag=0;//是不是扩展帧,为1则表示接收到的是扩展帧,0表示标准帧
uchar Tdate[10]={0};//存放要发送标准帧的数据,最大10位,前2位是ID号,后8位是数据位
uchar TID[2]={0,0};//存放要发送标准帧的ID号
uchar Rdate[8]={0};//存放接收到的数据
uchar RESID[4];//存放接收到
AVR单片机232CAN转 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)