bsp_can.h
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
*********************************************************************************************************
*
* 模块名称 : CAN网络演示程序。
* 文件名称 : bsp_can.h
* 版 本 : V1.0
* 说 明 : 头文件
*
*********************************************************************************************************
*/
#ifndef _BSP_CAN_H
#define _BSP_CAN_H
#include "stm32f4xx_can.h"
#include "bsp.h"
#define CAN_BUF_LEN 0xf
typedef enum
{
BandRate_100kbps,
BandRate_125kbps,
BandRate_200kbps,
BandRate_250kbps,
BandRate_500kbps,
BandRate_1Mbps
}CanBaudRate;
typedef struct
{
CanTxMsg g_tCanTxMsg; /* 用于发送 */
CanRxMsg g_tCanRxMsg; /* 用于接收 */
unsigned char RxBuf[CAN_BUF_LEN+1];
unsigned char TxBuf[CAN_BUF_LEN+1];
volatile unsigned short RxBuf_In;
volatile unsigned short RxBuf_Out;
volatile unsigned short TxBuf_In;
volatile unsigned short TxBuf_Out;
}CANStruct;
extern CanRxMsg g_tCanRxMsg;
/* 供外部调用的函数声明 */
extern u8 CAN1_Mode_Init(CanBaudRate CanBaudValue,u8 mode);;
extern u8 CAN2_Mode_Init(CanBaudRate CanBaudValue,u8 mode);
extern void SendCanMsg(void);
extern void ProcessDataFormCAN(void);
extern u8 CAN1_Send_Msg(unsigned short int StdID,unsigned char *msg, unsigned char len,u16 time);
extern u8 CAN2_Send_Msg(unsigned short int StdID,unsigned char *msg, unsigned char len,u16 time);
extern u8 CAN1_Send_Msg_Extend(unsigned int StdID,unsigned char *msg, unsigned char len,u16 time);
extern u8 CAN2_Send_Msg_Extend(unsigned int StdID,unsigned char *msg, unsigned char len,u16 time);
extern u8 CAN_Send_Msg(unsigned short int StdID,unsigned char *msg, unsigned char len,u16 time,u8 CanSelect);
#endif