⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r591can.h

📁 基于p87c591的can通讯驱动程序源码
💻 H
字号:
/*======================================================================*/
/* NAME:    r591can.h                                                   */
/* INFO:    CAN module for the PHYTEC training board equipped with      */
/*          PHYTEC phyCORE 591 and Philips P8x591 Microcontroller       */
/* RIGHTS:  Embedded Systems Academy   www.esacademy.com                */
/*----------------------------------------------------------------------*/
/* To get BTRx timing values for other speeds, consult the              */
/* Microcontroller Peripheral Timing Calculators provided by the        */
/* Embedded Systems Academy at www.esacademy.com/faq/calc/philips.htm   */
/*----------------------------------------------------------------------*/
/*          BASED ON THE CAN EXAMPLE PROVIDED BY PHYTEC                 */
/* HISTORY: V1.0   Pf    21-FEB-2000                                    */
/*          V1.1   Pf    16-JUN-2000                                    */
/*======================================================================*/

#include "reg591ex.h"

/* Data structure for a CAN message */
typedef struct
{
   DWORD ID;      /* Message Identifier */
   BYTE  LEN;     /* Data length (0-8) */
   BYTE  BUF[8];  /* Data buffer */
} MSG_BUF;


/*======================================================================*/
/* FUNCTION:   init_can_125_12                                          */
/* DESCRIPTION:Initializes the CAN interface. Bus operates at 125kBit,  */
/*             if processor clock is 12MHz. Screeners are set to        */
/*             "one long filter for std messages.                       */
/* CAUTION:    Does not initialize filters - nothing will be received   */
/*             unless screeners are set using set_screener_std          */
/* INPUT:      none                                                     */
/* OUTPUT:     none                                                     */
/*======================================================================*/
void init_can_125_12 ( void );


/*======================================================================*/
/* FUNCTION:   set_screener_std                                         */
/* DESCRIPTION:Sets one of the four screeners (acceptance filters) of   */
/*             the CAN controller.                                      */
/* CAUTION:    Does assume the screeners are set-up to be used as "one  */
/*             long filter for standard messages"                       */
/* INPUT:      Screener - 1 to 4, one of the four screeners             */
/*             ID_Mask - Bit set: corresponding bit in ID is don't care */
/*               Bit clear: corresponding bit in ID must match ID_Match */
/*             ID_Match - Match/Code value for ID                       */
/*             B1_Mask - Bit set: cor. bit in data byte 1 is don't care */
/*               Bit clear: cor. bit in data byte 1 must match B1_Match */
/*             B1_Match - Match/Code value for data byte 1              */
/*             B2_Mask - Bit set: cor. bit in data byte 2 is don't care */
/*               Bit clear: cor. bit in data byte 2 must match B2_Match */
/*             B2_Match - Match/Code value for data byte 2              */
/* OUTPUT:     none                                                     */
/*======================================================================*/
void set_screener_std ( BYTE Screener,
                        WORD ID_Mask, WORD ID_Match,
                        BYTE B1_Mask, BYTE B1_Match,
                        BYTE B2_Mask, BYTE B2_Match);


/*======================================================================*/
/* FUNCTION:   transmit_message                                         */
/* DESCRIPTION:Transmits a single CAN message                           */
/* CAUTION:    Before transmitting, the function WAITS until the        */
/*             CAN controller is ready for the next data set            */
/* INPUT:      pTransmitBuf - data structure with the message           */
/* OUTPUT:     none                                                     */
/*======================================================================*/
void transmit_message ( MSG_BUF *pTransmitBuf );


/*======================================================================*/
/* FUNCTION:   receive_message                                          */
/* DESCRIPTION:Receives a single standard ID CAn mesage                 */
/* CAUTION:    Will only recive something, if a message is actually     */
/*             pending in the FIFO of the CAN controller                */
/* INPUT:      pReceiveBuf - Pointer to data structure for message      */
/* OUTPUT:     pReceiveBuf - the received message                       */
/*             RETURNS 0, if there was no message to receive            */
/*             RETURNS 0xFF, if a message was received                  */
/*======================================================================*/
BYTE receive_message(MSG_BUF *pReceiveBuf);


/*======================================================================*/
/* FUNCTION:   check_busoff_state                                       */
/* DESCRIPTION:Checks, if the CAN controller went into BUS OFF state    */
/* INPUT:      none                                                     */
/* OUTPUT:     RETURNS 0, if CAN controller still active                */
/*             RETURNS 0xFF, if CAN controller in BUS OFF state         */
/*======================================================================*/
BYTE check_busoff_state (void);


/*----------------------- END OF FILE ----------------------------------*/






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -