📄 can_api_by_wr.c
字号:
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 function 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 function clears data overrun flag for a particular channel* Valid only for channels with mode = WNCAN_CHN_RECEIVE in case of simple * controllers or * channels with mode = WNCAN_CHN_RECEIVE and WNCAN_CHN_RTR_REQUESTER in * 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 function tests if the message has the RTR bit set. The mode of the * channel must be WNCAN_CHN_TRANSMIT or WNCAN_CHN_RECEIVE* This function can be used on simple controllers such as the SJA1000 only* The function will return an error if called on an advanced controller, such* as the TouCAN and I82527.* For advanced controllers, to receive an RTR message, choose mode of channel* to be 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 function tests if the message has the RTR bit set. The mode of the * channel must be WNCAN_CHN_TRANSMIT.* This function can be used on simple controllers such as the SJA1000 only.* The function will return an error if called on an advanced controller, such* as the TouCAN and I82527. For advanced controllers, to send an RTR message,* choose mode of channel to be 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 function 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 function puts the CAN controller into sleep mode if the hardware* supports this functionality; otherwise, this function 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 - Forces 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 function 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.** 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 disables channel* ** 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 function 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 controllerOffsets.h (e.g. toucanOffsets.h or sja1000Offsets.h)* A pointer to the data buffer holding the data to be written is passed to the* function 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, /* offset from base of CAN controller memory */ UCHAR *data, /* byte pointer to data to be written */ UINT length /* data length - number of bytes to be written*/ ){ return (pDev->WriteReg(pDev, offset, data, length));}/******************************************************************************** CAN_ReadReg - Access memory and read data* * This function 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 controllerOffsets.h (e.g. 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, /* offset from base of CAN controller memory */ UCHAR *data, /* return data place holder */ UINT length /* 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 function returns the crystal frequency of the CAN controller.** RETURNS: XtalFreq - 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 function returns the controller type of the CAN controller.** RETURNS: WNCAN_ControllerType - 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 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 + -