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

📄 can_api_by_wr.c

📁 美国wind river 公司的CAN总线源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
*             S_can_illegal_config*/long CAN_ReadID(struct WNCAN_Device *pDev, /* CAN device pointer */UCHAR channelNum,          /* channel number */BOOL* ext                  /* extended flag */                           ){   return(pDev->ReadID(pDev,channelNum,ext));}/***************************************************************************   * CAN_WriteID - write the CAN Id to the specified channel.** This function writes the CAN Id to the channel. The type of Id * (standard or extended) is specified. the behaviour of the function for* every channel mode is specified as follows:* WNCAN_CHN_INVALID: not allowed. ERROR is returned.* WNCAN_CHN_INACTIVE: not allowed. ERROR is returned.* WNCAN_CHN_RECEIVE: CAN messages with this Id will be received.* WNCAN_CHN_RTR_RESPONDER: the data bytes to respond with must be set up with* a call to CAN_WriteData previosuly,CAN messages with this Id will be received* and a remote response message sent back.* WNCAN_CHN_RTR_REQUESTER: CAN meesage with RTR bit set and the specified ID* will be transmitted when CAN_Tx is called* WNCAN_CHN_TRANSMIT: CAN meesage with the specified ID will be transmitted* when CAN_Tx is called** RETURNS: OK, or ERROR if an input parameter is invalid.** ERRNO: S_can_illegal_channel_no*        S_can_illegal_config**/STATUS CAN_WriteID(struct WNCAN_Device *pDev, /* CAN device pointer   */UCHAR chnNum,              /* channel number       */ULONG canID,               /* CAN Id               */BOOL ext                   /* extended flag (TRUE = extended CAN msg) */){   return(pDev->WriteID(pDev,chnNum,canID,ext));}/***************************************************************************   * CAN_ReadData - read data from the specified channel** This function reads "len" bytes of data from the channel and sets the value* of len to the number of bytes read. The range of "len" is zero (for zero * length data) to a maximum of eight. The mode of the channel must not be * WNCAN_CHN_INVALID or WNCAN_CHN_INACTIVE; however, the newData flag is valid * only for channels with mode equal to WNCAN_CHN_RECEIVE or * WNCAN_CHN_RTR_REQUESTER. For receive channels, if no new data has been* received since the last CAN_ReadData  function call, the newData flag is * set to FALSE; otherwise, the flag is TRUE. In both cases, the data and * length of the data currently in the channel are read.* The input parameter *len, contains length of data buffer on entering the* function. On return *len contains number of bytes copied into data buffer.* ** RETURNS:        OK, or ERROR if an input parameter is invalid.*   * ERRNO:          S_can_illegal_channel_no*                 S_can_illegal_config*                 S_can_buffer_overflow*                 S_can_illegal_data_length**/STATUS CAN_ReadData(struct WNCAN_Device  *pDev,      /* i/p - CAN device pointer*/UCHAR                chnNum,     /* i/p - channel number*/UCHAR                *data,      /* o/p - pointer to buffer for data */UCHAR                *len,       /* i/p and o/p - length pointer*/BOOL                 *newData    /* o/p - new data pointer     */){   return(pDev->ReadData(pDev,chnNum,data,len,newData));}/***************************************************************************   * CAN_GetMessageLength - get the message length* * This function returns the length of the message data in the channel on the * controller. The minimum value returned is 0, and the maximum value is 8. * This number is equal to the "len" argument in CAN_ReadData. If the data * has zero length, this function returns zero. The mode of the channel* must not be WNCAN_CHN_INACTIVE or WNCAN_CHN_INVALID** RETURNS:        Length of data, or -1 if an input parameter is invalid.*   * ERRNO:          S_can_illegal_channel_no*                 S_can_illegal_config*/int CAN_GetMessageLength(struct WNCAN_Device *pDev, /* CAN device pointer   */UCHAR channelNum           /* channelNum           */){   return(pDev->GetMessageLength(pDev,channelNum));}/***************************************************************************   * CAN_WriteData - write the data to the specified channel ** This function writes "len" bytes of data to the channel. An error is returned* if the number of bytes to be written exceed 8. The mode of the channel must* WNCAN_CHN_TRANSMIT or WNCAN_CHN_RTR_RESPONDER.** RETURNS:        ERROR if an input parameter is invalid, OK otherwise.*   * ERRNO:          S_can_illegal_channel_no,*                 S_can_illegal_config,*                 S_can_illegal_data_length**/STATUS CAN_WriteData(struct WNCAN_Device *pDev,       /* i/p - CAN device pointer */UCHAR                channelNum, /* i/p - channel number */UCHAR                *data,      /* o/p - pointer to buffer for data */UCHAR                len         /* i/p - contains length of data buffer */  								 ){   return(pDev->WriteData(pDev,channelNum,data,len));}/***************************************************************************   * CAN_Tx - transmit the CAN message on the specified channel** This function transmits the CAN Id and data currently in the channel of* the specified controller on the device. The mode of the channel must be* WNCAN_CHN_TRANSMIT or WNCAN_CHN_RTR_REQUESTER*** RETURNS:        ERROR if an input parameter is invalid, OK otherwise.*   * ERRNO:          S_can_illegal_channel_no*                 S_can_illegal_config*/STATUS CAN_Tx(struct WNCAN_Device *pDev,  /* CAN device pointer */UCHAR channelNum            /* channel number */){   return(pDev->Tx(pDev,channelNum));}/***************************************************************************   * CAN_TxMsg - transmit a CAN message with all parameters specified** This function performs the same function as the following series* of function calls:** 1. CAN_WriteID(context,channelNum,canID,ext);* 2. CAN_WriteData(context,channelNum,data,len);* 3. CAN_Tx(context,channel);** The mode of the channel must be WNCAN_CHN_TRANSMIT or * WNCAN_CHN_RTR_REQUESTER. If the length specified exceeds 8 byes an error* will be returned.* The extended flag must be set to TRUE if the ID has extended format, * for standard ID it must be set to FALSE.** RETURNS:        ERROR if an input parameter is invalid, OK otherwise.*   * ERRNO:          S_can_illegal_channel_no,*                 S_can_illegal_config,*                 S_can_illegal_data_length**/STATUS CAN_TxMsg(struct WNCAN_Device *pDev, /* CAN device pointer */UCHAR channelNum,          /* channel number */ULONG canId,               /* CAN Id */BOOL ext,                  /* extended message flag */UCHAR *data,               /* pointer to buffer for data */UCHAR len                  /* message length */){   return(pDev->TxMsg(pDev,channelNum,canId,ext,data,len));}/***************************************************************************   * CAN_SetGlobalRxFilter - set the global filter in the controller** This function sets the global HW filter mask for incoming messages on the * device controller. If the controller does not have a global filter this* function is a no-op. If the ext parameter is TRUE, the mask value applies* to extended messages; otherwise, the mask values applies to standard * messages. A value of "0" for a particular bit position of the mask means * don't care (i.e. the incoming message Id could have a value of zero or * one for this bit position); otherwise, a value of 1 means the * corresponding bit of the message Id must match identically.** If the mask value specified is outside, permissible CAN ID range an* error is returned. If the controller does not have a global mask an error* is returned.** RETURNS: OK or ERROR*   * ERRNO:   S_can_hwfeature_not_available*          S_can_illegal_mask_value   **/STATUS CAN_SetGlobalRxFilter(    struct WNCAN_Device *pDev,   /* CAN device pointer */    long   mask,                 /* filter mask value */    BOOL   ext                   /* extended flag */){   return(pDev->SetGlobalRxFilter(pDev,mask,ext));}/***************************************************************************   * CAN_GetGlobalRxFilter - returns the global filter value** This function return the programmed value in the Global filter resgiter* Based on the value of ext passed to the function, this function reads the * appropriate format of the global mask, and returns the value in the specified,* extended or standard identifier format.* If the controller does not have a global mask, a value of -1 is returned.* This is not a valid CAN ID.** RETURNS: long :  mask or -1 in case of error*   * ERRNO:   S_can_hwfeature_not_available**/long CAN_GetGlobalRxFilter(    struct WNCAN_Device *pDev,   /* CAN device pointer */    BOOL  ext                    /* extended flag */){   return(pDev->GetGlobalRxFilter(pDev,ext));}/***************************************************************************   * CAN_SetLocalMsgFilter - set a local message object filter ** This function sets a local message object filter for incoming messages on a * particular channel. ** If the ext parameter is TRUE, the mask value applies to extended messages;* otherwise, the mask value applies to standard messages. A value of "0" for* a particular bit position of the mask means don't care (i.e. the incoming* message Id could have a value of zero or one for this bit position);* otherwise, a value of 1 means the corresponding bit of the message Id must* match identically. Channel number is provided for controllers that have* more than one local message object filter. ** If the mask value specified is outside, permissible CAN ID range an* error is returned. If the controller does not have a local mask for the * channel specified an error is returned.*** RETURNS: OK, ERROR*   * ERRNO:   S_can_illegal_channel_no*          S_can_hwfeature_not_available*          S_can_illegal_mask_value   **/STATUS CAN_SetLocalMsgFilter(    struct WNCAN_Device *pDev,   /* CAN device pointer */    UCHAR  channel,              /* channel number     */     long   mask,                 /* filter mask value  */    BOOL   ext                   /* extended flag      */   ){   return(pDev->SetLocalMsgFilter(pDev,channel,mask,ext));}/***************************************************************************   * CAN_GetLocalMsgFilter - returns the specified local filter value** This function returns the programmed value in the local filter resgiter* Based on the value of ext passed to the function, this function reads the * appropriate format of the local mask, and returns the value in the specified,* extended or standard identifier format.* The channel argument identifies the local filter associated with the particular* channel number** If the controller does not have a global mask, a value of -1 is returned.* This is not a valid CAN ID.** RETURNS: long: mask or -1 on error*   * ERRNO:   S_can_hwfeature_not_available**/long CAN_GetLocalMsgFilter(    struct WNCAN_Device *pDev,   /* CAN device pointer */	UCHAR  channel,              /* channel number */     BOOL   ext                   /* extended flag */){   return(pDev->GetLocalMsgFilter(pDev, channel, ext));}/***************************************************************************   * CAN_GetIntStatus - get the interrupt status of a CAN interrupt.** This function returns the interrupt status on the controller: **    WNCAN_INT_NONE     = no interrupt occurred*    WNCAN_INT_ERROR    = bus error*    WNCAN_INT_TX       = interrupt resuting from a CAN transmission*    WNCAN_INT_RX       = interrupt resulting form message reception*    WNCAN_INT_BUS_OFF  = interrupt resulting from bus off condition*    WNCAN_INT_WAKE_UP  = interrupt resulting from controller waking up*                         after being put in sleep mode*    WNCAN_INT_SPURIOUS = unknown interrupt** NOTE: If the interrupt was caused by the transmission or reception of a * message, the channel number that generated the interrupt is set; otherwise,* this value is undefined.** RETURNS:    The interrupt status** ERRNO: N/A*/

⌨️ 快捷键说明

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