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

📄 can_api_by_wr.c

📁 美国wind river 公司的CAN总线源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
* In some cases tseg1 refers to the segment of bit time after the end of propseg * and upto the sample point. For such controllers, such as the TouCAN that, * have a settable propseg, there will be a controller specific function provided* to set it. There will be a place holder for the propseg in the CAN controller* struct as well, with the other bit timing parameters. For TouCAN the default* value of propseg is 7.*  ---------------------------------------------------------* |    |          |                |                        |  *  sync <--tseg1-> <---propseg -->^|^<---------tseg2 ------>*                          sample point ** The number of samples taken at the sample point is decided by the input argument * numSamples to the function* numSamples = 0 (FALSE) indicates one sample will be taken* numSamples = 1 (TRUE) indicates three samples will be taken* * RETURNS: ERROR if any of the input parameters have invalid values,           OK otherwise.*                       * ERRNO:   S_can_invalid_parameter*/STATUS  CAN_SetBitTiming(struct WNCAN_Device *pDev, /* CAN device pointer */UCHAR tseg1,               /* number of time quanta for segment 1 */UCHAR tseg2,               /* number of time quanta for segment 2 */UCHAR brp,                 /* baud rate prescaler */UCHAR sjw,                 /* syncro jump width */BOOL numSamples            /* number of samples */    ){   return (pDev->SetBitTiming(pDev,tseg1,tseg2,brp,sjw, numSamples));}/**************************************************************************** CAN_GetBaudRate: Returns programmed baud rate value ** This function returns the programmed baud rate value in bits per second.* The sample point value is returned by reference in the input parameter* *samplePoint. The sample point value is returned as a percentage.* It is the percentage of the bit time, at which the bit is sampled. ** RETURNS: UINT: baud rate* * ERRNO:   N/A*/UINT CAN_GetBaudRate(struct WNCAN_Device *pDev, /* CAN device pointer */UINT *samplePoint) {	return (pDev->GetBaudRate(pDev, samplePoint));}/***************************************************************************   * CAN_SetIntMask - enable controller level interrupts on the CAN device.** This function enables the specified list of controller level interrupts* on the CAN controller. Interrupts are not enabled at the CAN board level* or at the CPU level.* The interrupt masks available are:* WNCAN_INT_ERROR : enables interrupts due to errors on the CAN bus*                   This may be implemented as a single or multiple*                   interrupt sources on the CAN controller.* WNCAN_INT_BUS_OFF: enables interrupt indicating bus off condition  * WNCAN_INT_WAKE_UP: enables interrupt on wake up* All interrupt masks that need to be enabled must be specified in the list* passed to the function, in order to be set, every time the function* is called. ** RETURNS: OK, ERROR if interrupt setting not possible*   * ERRNO:   S_can_hwfeature_not_available, S_can_invalid_parameter*/STATUS CAN_SetIntMask(struct WNCAN_Device *pDev,  /* CAN Device pointer */ WNCAN_IntType intMask       /* ORed interrupt masks */){   STATUS status;   status = pDev->SetIntMask(pDev, intMask);   return (status);}/***************************************************************************   * CAN_EnableInt - enable interrupts from the CAN device to the CPU.** This function enables interrupts from the CAN controller to reach the* CPU. Typically, enables a global interrupt mask bit at the CPU level.** RETURNS: N/A*   * ERRNO:   N/A*/void CAN_EnableInt(struct WNCAN_Device *pDev  /* CAN Device pointer */ ){   pDev->EnableInt(pDev);   return;}/***************************************************************************   * CAN_DisableInt - disable interrupts from the CAN device to the CPU.** This function disables interrupts from the CAN controller from reaching the* CPU. Typically, disables a global interrupt mask bit at the CPU level.** RETURNS: N/A*   * ERRNO:   N/A*/void CAN_DisableInt(struct WNCAN_Device *pDev  /* CAN Device pointer */){   pDev->DisableInt(pDev);   return;}/***************************************************************************   * CAN_GetNumChannels - get the number of channels on the CAN controller.** This function returns the number of channels on the controller.* This number is fixed by the hardware and does not change during operation.** RETURNS: The number of channels on the controller.** ERRNO: N/A*/UCHAR CAN_GetNumChannels(struct WNCAN_Device *pDev     /* CAN Device pointer */){   return(pDev->pCtrl->numChn);}/***************************************************************************   * CAN_GetTxChannel - get a free transmit channel** This function returns a free channel uniquely identified by the output * argument "channelNum". The mode of the assigned channel is WNCAN_CHN_TRANSMIT,* A subsequent call to CAN_GetTxChannel() assigns the next available channel* with a different channel number.* The channel number remains unavailable to subsequent CAN_GetXXChannel()* calls until a CAN_FreeChannel() call is invoked on the channel.* CAN_FreeChannel() makes the channel available and resets the mode to* WNCAN_CHN_INVALID. After the CAN_GetTxChannel() call, the mode of* the channel can be changed by the CAN_SetMode(..) function call.** RETURNS:  ERROR if no channels are available, OK otherwise.** ERRNO: S_can_no_available_channels*/STATUS CAN_GetTxChannel(struct WNCAN_Device *pDev,    /* CAN device pointer */UCHAR *channelNum             /* channel number */){   return(WNCAN_GetTxChannel(pDev,channelNum));}/***************************************************************************   * CAN_GetRxChannel - get a free receive channel.** Gets a free receive channel uniquely identified by the output argument * "channelNum". The mode of the assigned channel is WNCAN_CHN_RECEIVE, * A subsequent call to CAN_GetRxChannel() assigns the next available receive* channel with a different number.* The channel number remains unavailable to subsequent CAN_GetXXChannel()* calls until a CAN_FreeChannel() call is invoked on the channel. * CAN_FreeChannel() makes the channel available and resets the mode to* WNCAN_CHN_INVALID. After the CAN_GetRxChannel() call, the mode of* the channel can be changed by the CAN_SetMode() function call.** RETURNS: ERROR if no channel is available, OK otherwise.** ERRNO: S_can_no_available_channels*/STATUS CAN_GetRxChannel(struct WNCAN_Device *pDev,  /* CAN device pointer */ UCHAR *channelNum           /* channel number */){   return(WNCAN_GetRxChannel(pDev,channelNum));}/*****************************************************************************   * CAN_GetRTRRequesterChannel - get a free channel for remote transmit receive** This function is relevant to advanced controllers only. Advanced controllers, * are controllers such as TouCAN that, have channels with the capability in * hardware to both transmit and receive a message in the same channel. * When a remote request is sent out from a particular channel, the reply * will be received in the same channel. This function will return an error* and set an error number, for simple controllers such as the SJA1000. * In case of simple controllers, the channels do not have the capability to* both transmit and receive messages in the same channel. The channel has a * fixed property of either transmitting or receiving a message.  ** This function returns a free channel uniquely identified by the output argument* "channelNum". The mode of the channel is assigned WNCAN_CHN_RTR_REQUESTER.* A subsequent call to CAN_GetRTRRequesterChannel() assigns the next available* channel with a different channel number.* The channel number remains unavailable to subsequent CAN_GetXXChannel()  * calls until a CAN_FreeChannel() call is invoked on the channel.* CAN_FreeChannel() makes the channel available and resets the mode to * WNCAN_CHN_INVALID. After the CAN_GetRTRRequesterChannel() call, the mode of* the channel can be changed by the CAN_SetMode(..) function call.** RETURNS:  for advanced controllers such as the TouCAN and I82527:*           ERROR if no channels are available, OK otherwise.**           for simple controllers such as the SJA1000:*           ERROR since this mode cannot be assigned.  ** ERRNO: for advanced controllers such as the TouCAN and I82527:*        S_can_no_available_channels**        for simple controllers such as the SJA1000:*        S_can_rtr_mode_not_supported*/STATUS CAN_GetRTRRequesterChannel(struct WNCAN_Device *pDev,    /* CAN device pointer */UCHAR *channelNum             /* channel number */){   return(WNCAN_GetRTRRequesterChannel(pDev,channelNum));}/******************************************************************************   * CAN_GetRTRResponderChannel - get a free channel for auto remote response** This function is relevant to advanced controllers only. Advanced controllers, * are controllers such as TouCAN whose channels have the capability in * hardware to both transmit and receive a message in the same channel. * An WNCAN_CHN_RTR_RESPONDER channel, can be programmed with data and id.* If a matching remote request is received in the channel, the hardware will* automatically respond with the programmed data ** This function will return an error and set an error number, for simple * controllers such as the SJA1000. In case of simple controllers, the channels* do not have the capability to both transmit and receive messages in the same* channel. The channel has a fixed property of either transmitting or * receiving a message.  ** This function returns a free transmit-receive channel uniquely identified by* the output argument "channelNum". The mode assigned to the  channel is * WNCAN_CHN_RTR_RESPONDER. A subsequent call to CAN_GetRTRResponderChannel()* assigns the next available channel with a different channel number.* The channel number remains unavailable to subsequent CAN_GetXXChannel() and * calls until a CAN_FreeChannel() call is invoked on the channel.* CAN_FreeChannel() makes the channel available and resets the mode to * WNCAN_CHN_INVALID. After the CAN_GetRTRResponderChannel() call, the mode of* the channel can be changed by the CAN_SetMode(..) function call.** RETURNS:  for advanced controllers such as the TouCAN and I82527:*           ERROR if no channels are available, OK otherwise.**           for simple controllers such as the SJA1000:*           ERROR since this mode cannot be assigned.  ** ERRNO:  for advanced controllers such as the TouCAN and I82527:*         S_can_no_available_channels**         for simple controllers such as the SJA1000:*         S_can_rtr_mode_not_supported**/STATUS CAN_GetRTRResponderChannel(struct WNCAN_Device *pDev,    /* CAN device pointer */UCHAR *channelNum             /* channel number */){   return(WNCAN_GetRTRResponderChannel(pDev,channelNum));}/***************************************************************************   * CAN_FreeChannel - free the specified channel** This function frees a channel by setting its mode to WNCAN_CHN_INVALID.** RETURNS: ERROR if requested channel is out of range, OK otherwise.** ERRNO: S_can_illegal_channel_no*/STATUS CAN_FreeChannel(struct WNCAN_Device *pDev, /* CAN device pointer   */UCHAR channelNum           /* channelNum           */){   return(WNCAN_FreeChannel(pDev,channelNum));}/************************************************************************** CAN_GetVersion - return the version number of the CAN drivers** This function returns a pointer to the struct WNCAN_VersionInfo,* which holds the WindNet CAN API's version number.** RETURNS: const WNCAN_VersionInfo * Version number*   * ERRNO: N/A**/const WNCAN_VersionInfo * CAN_GetVersion(){	return(WNCAN_GetVersion());}/***************************************************************************   * CAN_ReadID - read the CAN Id from the specified controller and channel.** This function reads the CAN Id corresponding to the channel number on* the controller. The standard or extended flag is set by the function.* The mode of the channel cannot be WNCAN_CHN_INACTIVE or WNCAN_CHN_INVALID* The extended flag is set to TRUE if the ID has extended format, otherwise* set to FALSE** RETURNS:    The CAN Id, or -1 if an input parameter is invalid** ERRNO:      S_can_illegal_channel_no

⌨️ 快捷键说明

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