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

📄 can_api.c

📁 cpc-1631的BSP包for VxWorks操作系统
💻 C
📖 第 1 页 / 共 4 页
字号:
*
* RETURNS: The interrupt status.
*
* ERRNO: N/A
*/
WNCAN_IntType CAN_GetIntStatus
    (
    struct WNCAN_Device *pDev,       /* CAN device pointer */
    UCHAR               *channelNum  /* channel pointer */
    )
    {
       return(pDev->GetIntStatus(pDev,channelNum));
    }


/***************************************************************************
* CAN_IsMessageLost - test if a received CAN message has been lost
*
* This routine tests if the current message data in the channel overwrote
* the old message data before CAN_ReadData() was called. Valid only for
* channels with mode = WNCAN_CHN_RECEIVE or WNCAN_CHN_RTR_REQUESTER.
*
* RETURNS: 0 if 'FALSE', 1 if 'TRUE', or -1 if 'ERROR'.
*
* ERRNO: S_can_illegal_channel_no, S_can_illegal_config
*/
int CAN_IsMessageLost
    (
    struct WNCAN_Device *pDev,       /* CAN device pointer   */
    UCHAR                channelNum  /* channel number       */
    )
    {
       return(pDev->IsMessageLost(pDev,channelNum));
    }

/************************************************************************
* CAN_ClearMessageLost - clear message lost indication
*
* This routine clears the data overrun flag for a particular channel.
* Valid only for channels with mode = WNCAN_CHN_RECEIVE in the case of simple
* controllers or channels with mode = WNCAN_CHN_RECEIVE and
* WNCAN_CHN_RTR_REQUESTER in the case of advanced CAN controllers.
*
* RETURNS: 'OK', or 'ERROR'.
*
* ERRNO: S_can_illegal_channel_no, S_can_illegal_config
*
*/
STATUS CAN_ClearMessageLost
    (
    struct WNCAN_Device *pDev,       /* CAN device pointer   */
    UCHAR                channelNum  /* channel number       */
    )
    {
       return(pDev->IsMessageLost(pDev,channelNum));
    }


/***************************************************************************
* CAN_IsRTR - test if the message has the RTR bit set
*
* This routine tests if the message has the RTR bit set. The mode of the
* channel must be WNCAN_CHN_TRANSMIT or WNCAN_CHN_RECEIVE.
* This routine can only be used on simple controllers, such as the SJA1000.
* The routine will return an error if called on an advanced controller, such
* as the TouCAN and I82527.
* To receive an RTR message for advanced controllers, set the mode of
* the channel to WNCAN_CHN_RTR_RESPONDER.
*
* RETURNS: 0 if 'FALSE', 1 if 'TRUE', or -1 if 'ERROR'.
*
* ERRNO: S_can_illegal_channel_mode, S_can_illegal_config
*
*/
int CAN_IsRTR
    (
    struct WNCAN_Device *pDev,       /* CAN device pointer */
    UCHAR                channelNum  /* channel number */
    )
    {
       return(pDev->IsRTR(pDev,channelNum));
    }

/***************************************************************************
* CAN_SetRTR - test if the message has the RTR bit set
*
* This routine tests if the message has the RTR bit set. The mode of the
* channel must be WNCAN_CHN_TRANSMIT.
* This routine can only be used on simple controllers, such as the SJA1000.
* The routine will return an error if called on an advanced controller, such
* as the TouCAN and I82527. To send an RTR message for advanced controllers,
* set the mode of the channel to WNCAN_CHN_RTR_REQUESTER and call CAN_Tx().
*
* RETURNS: 'OK', or 'ERROR'.
*
* ERRNO: S_can_illegal_channel_mode, S_can_illegal_config
*
*/
STATUS CAN_SetRTR
    (
    struct WNCAN_Device *pDev,          /* CAN device pointer */
    UCHAR                channelNum ,   /* channel number */
    BOOL                 rtr            /* rtr flag ('TRUE' = set bit) */
    )
    {
       return(pDev->SetRTR(pDev,channelNum, rtr));
    }

/***************************************************************************
* CAN_TxAbort - abort the current CAN transmission
*
* This routine aborts any current CAN transmissions on the controller.
*
* RETURNS: N/A
*
* ERRNO: N/A
*/
void CAN_TxAbort
    (
    struct WNCAN_Device *pDev  /* CAN device pointer */
    )
    {
       return(pDev->TxAbort(pDev));
    }


/************************************************************************
* CAN_Sleep - put the CAN controller of the device into sleep mode
*
* This routine puts the CAN controller into sleep mode if the hardware
* supports this functionality; otherwise, this routine is a no-op.
*
* RETURNS: 'OK', or 'ERROR'.
*
* ERRNO: S_can_cannot_sleep_in_reset_mode
*
*/
STATUS CAN_Sleep
    (
    struct WNCAN_Device *pDev  /* CAN device pointer */
    )
    {
       return(pDev->Sleep(pDev));
    }

/************************************************************************
* CAN_WakeUp - force the CAN controller out of sleep mode
*
* This routine negates the Sleep bit to force the CAN controller out of
* sleep mode.
*
* RETURNS: 'OK', always.
*
* ERRNO: N/A
*
*/
STATUS CAN_WakeUp
    (
    struct WNCAN_Device *pDev
    )
    {
        return(pDev->WakeUp(pDev));
    }

/************************************************************************
*
* CAN_EnableChannel - enable channel and set interrupts
*
* This routine marks the channel valid. It also sets the type of channel
* interrupt requested. If the channel type does not match the type of
* interrupt requested it returns an error.
*
* The interrupt settings that are available are: (choose only one)
*
* \ml
* \m -
* WNCAN_INT_RX: Message reception interrupt.
* \m -
* WNCAN_INT_TX: Message transmission interrupt.
* \me
*
* RETURNS: 'OK' if successful, 'ERROR' otherwise.
*
* ERRNO: S_can_illegal_channel_no, S_can_illegal_config,
* S_can_invalid_parameter, S_can_type_mismatch
*
*/

STATUS CAN_EnableChannel
    (
    struct WNCAN_Device *pDev,       /* CAN device pointer */
    UCHAR                channelNum, /* channel number */
    WNCAN_IntType        intSetting  /* interrupt type */
    )
    {
        return(pDev->EnableChannel(pDev, channelNum, intSetting));
    }

/************************************************************************
*
* CAN_DisableChannel - reset channel interrupts and disable channel
*
* This routine resets channel interrupts and marks it invalid in hardware.
* After this routine is called the channel will not transmit or receive
* any messages.
*
* RETURNS: 'OK' if successful, 'ERROR' otherwise.
*
* ERRNO: S_can_illegal_channel_no
*
*/

STATUS CAN_DisableChannel
    (
    struct WNCAN_Device *pDev,        /*CAN device pointer*/
    UCHAR                channelNum   /* channel number */
    )
    {
        return(pDev->DisableChannel(pDev, channelNum));
    }

/******************************************************************************
*
* CAN_WriteReg - write data to offset in CAN controller's memory area
*
* This routine accesses the CAN controller memory at the offset specified.
* A list of valid offsets are defined as macros in a CAN controller specific
* header file, named as <controller>Offsets.h (for example, toucanOffsets.h or
* sja1000Offsets.h). A pointer to the data buffer holding the data to be written is passed to the
* routine in UCHAR *data. The number of data bytes to be copied from the data
* buffer to the CAN controller's memory area is specified by the length
* parameter.
*
* RETURNS: 'OK'.
*
* ERRNO: S_can_illegal_offset
*
*/
STATUS CAN_WriteReg
    (
    struct WNCAN_Device *pDev,    /* CAN device pointer */
    UINT                 offset,  /* from base of CAN controller memory */
    UCHAR               *data,    /* byte pointer to data to be written */
    UINT                 length   /* number of bytes to be written*/
    )
    {
        return (pDev->WriteReg(pDev, offset, data, length));
    }


/******************************************************************************
*
* CAN_ReadReg - access memory and read data
*
* This routine accesses the CAN controller memory at the offset specified.
* A list of valid offsets are defined as macros in a CAN controller specific
* header file, named as <controller>Offsets.h (for example, toucanOffsets.h or
* sja1000Offsets.h). A pointer to the data buffer to hold the data to be read,
* is passed through UINT *data. The length of the data to be copied is specified
* through the length parameter.
*
* RETURNS: 'OK'.
*
* ERRNO: S_can_illegal_offset
*
*/
STATUS CAN_ReadReg
    (
    struct WNCAN_Device *pDev,    /* CAN device pointer */
    UINT                 offset,  /* from base of CAN controller memory */
    UCHAR               *data,    /* return data place holder */
    UINT                 length   /* number of bytes to be copied */
    )
    {
        return (pDev->ReadReg(pDev, offset, data, length));
    }

/************************************************************************
*
* CAN_GetXtalFreq - get the crystal frequency of the CAN controller
*
* This routine returns the crystal frequency of the CAN controller.
*
* RETURNS: The crystal frequency.
*
* ERRNO: N/A
*/
XtalFreq CAN_GetXtalFreq
    (
    struct WNCAN_Device *pDev  /* CAN device pointer */
    )
    {
       return(pDev->pBrd->xtalFreq);
    }


/************************************************************************
* CAN_GetControllerType - get the controller type
*
* This routine returns the controller type of the CAN controller.
*
* RETURNS: The controller type.
*
* ERRNO: N/A
*/
WNCAN_ControllerType CAN_GetControllerType
    (
    struct WNCAN_Device *pDev  /* CAN device pointer */
    )
    {
       return(pDev->pCtrl->ctrlType);
    }


/* function prototypes */
/***************************************************************************
* CAN_InstallISRCallback - install the ISR callback function
*
* The ISR callback is written by the user, has three arguments, and returns
* void. The callback function executes user written message processing code
* inside the CAN ISR. The ISR is hardware specific and is implemented
* at the hardware layer of the device driver. The callback function is entered
* with board level CAN interrupts disabled. The first argument to the callback
* is the CAN device pointer. The second argument indicates the interrupt
* status. The third argument indicates the channel on which the interrupt
* was generated. The channel number is undefined if the interrupt is not due
* to a transmission or reception.
*
* RETURNS: 'OK', or 'ERROR'.
*
* ERRNO: S_can_invalid_parameter
*/
STATUS CAN_InstallISRCallback
    (
    struct WNCAN_Device *pDev,                /* CAN device pointer */
    void (*pFun)(struct WNCAN_Device *pDev2,  /* Isr callback func ptr */
                 WNCAN_IntType        intStatus,
                 UCHAR                chnNum)
    );

    #endif /* USE_CAN_FUNCTION_DEFS */

⌨️ 快捷键说明

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