bsp_can.h 1.66 KB
/*
*********************************************************************************************************
*	                                  
*	模块名称 : 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