亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sja1000.c

?? CAN例程 源碼 CAN例程 源碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
** ERRNO:   N/A**/static void SJA1000_DisableInt(struct WNCAN_Device *pDev){    int    oldLevel;    oldLevel = intLock();    pDev->pBrd->canOutByte(pDev, SJA1000_IER, 0);    intUnlock(oldLevel);    return;}/************************************************************************** SJA1000_GetBusError - get the bus error** This function returns an ORed bit mask of all the bus errors that have* occured during the last bus activity.* Bus errors returned by this function can have the following values:* WNCAN_ERR_NONE: No errors detected* WNCAN_ERR_BIT: Bit error. * WNCAN_ERR_ACK: Acknowledgement error. * WNCAN_ERR_CRC: CRC error* WNCAN_ERR_FORM: Form error* WNCAN_ERR_STUFF: Stuff error* WNCAN_ERR_UNKNOWN: this condition should not occur* The five errors are not mutually exclusive. * The occurence of an error will be indicated by an interrupt. Typically, * this function will be called from the error interrupt handling case in the* user's ISR callback function, to find out the kind of error that occured* on the bus.** RETURNS: the bus error** ERRNO: N/A**/static WNCAN_BusError SJA1000_GetBusError(struct WNCAN_Device *pDev){    UCHAR value;    WNCAN_BusError error=0;    /* read the error code capture register */    value = pDev->pBrd->canInByte(pDev, SJA1000_ECC);    switch(value >> 6)    {        case 0:            error |= WNCAN_ERR_BIT;            break;        case 1:            error |= WNCAN_ERR_FORM;            break;        case 2:            error |= WNCAN_ERR_STUFF;            break;        case 3:            switch(value & 0x1F)            {                case 8:                    error |= WNCAN_ERR_CRC;                    break;                case 24:                    error |= WNCAN_ERR_CRC;                    break;                case 25:                    error |= WNCAN_ERR_ACK;                    break;                case 27:                    error |= WNCAN_ERR_ACK;                    break;                default:                    error |= WNCAN_ERR_NONE;                    break;            }            break;    }    return error;}/************************************************************************** SJA1000_GetIntStatus - get the interrupt status on the controller** 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.** ERRNO: N/A**/static WNCAN_IntType SJA1000_GetIntStatus      (	  struct WNCAN_Device *pDev,	  UCHAR *channelNum	  ){    UCHAR       regInt;    WNCAN_IntType   intStatus=WNCAN_INT_NONE;	UCHAR regStatus;    /* read the interrupt register */    regInt = pDev->pBrd->canInByte(pDev, SJA1000_IR);	if(regInt & IR_RI) {		/*receive interrupt*/        intStatus = WNCAN_INT_RX;        *channelNum = 0;	}		if( regInt & IR_TI) {		/*transmit interrupt*/        intStatus = WNCAN_INT_TX;        *channelNum = 1;	}	if(regInt & IR_WUI)	{		intStatus = WNCAN_INT_WAKE_UP;	}	/*flag WNCAN_INT_ERROR, if data overrun error int, or	  bus error int is detected */	if(regInt & IR_BEI) {		/*error interrupt*/        intStatus = WNCAN_INT_ERROR;	}	if(regInt & IR_EI) {		/*bus off interrupt*/		/* read the status register */        regStatus = pDev->pBrd->canInByte(pDev, SJA1000_SR);		if(regStatus & SR_BS)			intStatus = WNCAN_INT_BUS_OFF;	}	    return intStatus;}/************************************************************************** sja1000ISR - interrupt service routine** RETURNS: N/A** ERRNO: N/A**/void sja1000ISR(ULONG context){    WNCAN_DEVICE     *pDev;    WNCAN_IntType  intStatus=WNCAN_INT_NONE;    UCHAR          chnNum;	    pDev = (WNCAN_DEVICE *)context;    /* notify board that we're entering isr */    if(pDev->pBrd->onEnterISR)        pDev->pBrd->onEnterISR(pDev);    /* Get the interrupt status */    intStatus = SJA1000_GetIntStatus((void*)context, &chnNum);	 if (intStatus != WNCAN_INT_NONE)	 {		 		 pDev->pISRCallback(pDev, intStatus, chnNum);		 		 if (intStatus == WNCAN_INT_RX)		 {			 /* release the receive buffer */			 /* this will temporarily cleat RI bit */			 pDev->pBrd->canOutByte(pDev, SJA1000_CMR, CMR_RRB);		 }		 else if (intStatus == WNCAN_INT_ERROR)		 {			 /* clear bei interrupt flag */			 pDev->pBrd->canInByte(pDev, SJA1000_ECC);		 }	 }		    /* notify board that we're leaving isr */    if(pDev->pBrd->onLeaveISR)        pDev->pBrd->onLeaveISR(pDev);   return;}/************************************************************************** SJA1000_ReadID - read the CAN Id** 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** RETURNS:        LONG: the CAN Id; on error return -1** ERRNO:          S_can_illegal_channel_no,*                 S_can_illegal_config**/static long SJA1000_ReadID(struct WNCAN_Device *pDev, UCHAR channelNum,                            BOOL* ext){    UCHAR           value;    struct TxMsg    *pTxMsg;    ULONG           msgID=0xffffffff;    if (channelNum >= SJA1000_MAX_MSG_OBJ)    {        errnoSet(S_can_illegal_channel_no);    }    else if((pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INACTIVE) ||            (pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INVALID))    {        errnoSet(S_can_illegal_config);    }    else    {        /* Set up frame and ID registers based on channel mode */        if(pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_RECEIVE)        {            /* get the frame format */            value = pDev->pBrd->canInByte(pDev, SJA1000_SFF);            /* test if message ID is extended or standard */            if (value & 0x80)            {                *ext = 1;                value = pDev->pBrd->canInByte(pDev,SJA1000_RXID);                msgID = (value << (24-3));                value = pDev->pBrd->canInByte(pDev,SJA1000_RXID+1);                msgID |= (value << (16-3));                value = pDev->pBrd->canInByte(pDev,SJA1000_RXID+2);                msgID |= (value << (8-3));                value = pDev->pBrd->canInByte(pDev,SJA1000_RXID+3);                msgID |= (value >> 3);            }            else            {                *ext = 0;                value = pDev->pBrd->canInByte(pDev,SJA1000_RXID);                msgID = (value << (8-5));                value = pDev->pBrd->canInByte(pDev,SJA1000_RXID+1);                msgID |= (value >> 5);            }        }        else        {            pTxMsg = (struct TxMsg *)pDev->pCtrl->csData;            *ext = pTxMsg->ext;            msgID = pTxMsg->id;        }    }    return ((long) msgID);}/************************************************************************** SJA1000_WriteID - write the CAN Id to the channel number** 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_TRANSMIT: CAN meesage with the specified ID will be transmitted* when CAN_Tx is called** If this function is called while the controller is online, receive errors* may occur while the receive buffer id is being changed. *** RETURNS:        OK, or ERROR** ERRNO:          S_can_illegal_channel_no,*                 S_can_illegal_config**/static STATUS SJA1000_WriteID(struct WNCAN_Device *pDev, UCHAR channelNum,                             unsigned long canId, BOOL ext){	struct TxMsg    *pTxMsg;    UCHAR           value, regVal, rxIEOff;     	    STATUS          retCode = ERROR; /* pessimistic */		    if (channelNum >= SJA1000_MAX_MSG_OBJ)    {        errnoSet(S_can_illegal_channel_no);    }    else if((pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INACTIVE) ||		(pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INVALID))    {        errnoSet(S_can_illegal_config);    }    else    {        if(pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_RECEIVE)        {			/*check if receive interrupts are turned on. If yes, disable			interrupts */			regVal = pDev->pBrd->canInByte(pDev,SJA1000_IER);			if(regVal & IER_RIE)			{				rxIEOff = regVal & ~(IER_RIE);				pDev->pBrd->canOutByte(pDev, SJA1000_IER, rxIEOff);							}			            if (ext == TRUE)            {                value = canId >> (24-3);                pDev->pBrd->canOutByte(pDev, SJA1000_ACR0, value);                value = canId >> (16-3);                pDev->pBrd->canOutByte(pDev, SJA1000_ACR1, value);                value = canId >> (8-3);                pDev->pBrd->canOutByte(pDev, SJA1000_ACR2, value);                value = canId << 3;                pDev->pBrd->canOutByte(pDev, SJA1000_ACR3, value);				            }            else            {                value = canId >> 3;                pDev->pBrd->canOutByte(pDev, SJA1000_ACR0, value);                value = canId << 5;                pDev->pBrd->canOutByte(pDev, SJA1000_ACR1, value);							}			            /* restore receive interrupts if previously set*/			if(regVal & IER_RIE)			{				pDev->pBrd->canOutByte(pDev, SJA1000_IER, regVal);			}			                    }        else        {            pTxMsg = (struct TxMsg *)pDev->pCtrl->csData;            pTxMsg->id = canId;            pTxMsg->ext = ext;        }		        retCode = OK;    }	    return retCode;}/************************************************************************** SJA1000_ReadData - read 0 to 8 bytes of data from 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 * WNCAN_CHN_RECEIVE channel mode.* 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. ** RETURNS:        OK, or ERROR** ERRNO:          S_can_illegal_channel_no,*                 S_can_illegal_config,*                 S_can_buffer_overflow,*                 S_can_null_input_buffer**/static STATUS SJA1000_ReadData(struct WNCAN_Device *pDev, UCHAR channelNum,                       UCHAR *data, UCHAR *len, BOOL *newData){    UCHAR           value;    UCHAR           hwLength=0;    UINT            i;    UINT            offset;    struct TxMsg    *pTxMsg;    STATUS          retCode = ERROR; /* pessimistic */    if (channelNum >= SJA1000_MAX_MSG_OBJ)    {        errnoSet(S_can_illegal_channel_no);    }    else if((pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INACTIVE) ||            (pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INVALID))    {        errnoSet(S_can_illegal_config);    }    else    {        if(data == NULL)        {         errnoSet(S_can_null_input_buffer);	     return retCode;             }        if(pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_RECEIVE)        {            /* get the frame info and read the data */            value = pDev->pBrd->canInByte(pDev, SJA1000_SFF);            offset = (value & 0x80)? 2 : 0;            hwLength = value & 0xF;            if (hwLength > *len)            {             /*              If the actual number of bytes in the message are greater than              expected bytes by user, set error no and do not copy message              DLC into *len             */             errnoSet(S_can_buffer_overflow);            }            else            {             /*If the message DLC and the expected data length is equal,               copy message DLC into *len and continue */               *len = hwLength;               retCode = OK;            }            for (i = 0; i < *len; i++)                data[i] = pDev->pBrd->canInByte(pDev, (SJA1000_SFDATA + i + offset));            /* check the status register to see if the message was new */            value = pDev->pBrd->canInByte(pDev, SJA1000_SR);            if(value & SR_RBS)            {                *newData = 1;                /* release the receive buffer */                pDev->pBrd->canOutByte(pDev, SJA1000_CMR, CMR_RRB);            }            else                *newData = FALSE;        }        else        {            pTxMsg = (struct TxMsg *)pDev->pCtrl->csData;						/*transmit channel*/			/*check for overflow*/			if(pTxMsg->len > *len)			{				errnoSet(S_can_buffer_overflow);			}			else			{				*len = pTxMsg->len;				retCode = OK;			}            			for(i = 0 ; i < *len ; i++)                data[i] = pTxMsg->data[i];            			        }    }    return retCode;}/************************************************************************** SJA1000_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 error** ERRNO:          S_can_illegal_channel_no, S_can_illegal_config**/static int SJA1000_GetMessageLength      (	  struct WNCAN_Device *pDev,	  UCHAR channelNum	  ){    struct TxMsg *pTxMsg;    int retLen = -1; /* pessimistic */    if (channelNum >= SJA1000_MAX_MSG_OBJ)    {        errnoSet(S_can_illegal_channel_no);    }    else if((pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INACTIVE) ||            (pDev->pCtrl->chnMode[channelNum] == WNCAN_CHN_INVALID))    {        errnoSet(S_can_illegal_config);    }    else    {        if(pDev->pCtrl->chnMode[channelNum] != WNCAN_CHN_TRANSMIT)		{            retLen = pDev->pBrd->canInByte(pDev, SJA1000_SFF ) & 0x0f;		}        else        {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品区一区二区三| 黄页网站大全一区二区| 石原莉奈在线亚洲三区| 处破女av一区二区| 欧美日韩精品一二三区| 欧美激情一区二区三区蜜桃视频 | 蜜臀av性久久久久蜜臀aⅴ流畅| 风间由美一区二区三区在线观看 | 国产一区二区三区国产| 欧美调教femdomvk| 国产精品美日韩| 精品一区免费av| 欧美人与z0zoxxxx视频| 中文字幕综合网| 国产风韵犹存在线视精品| 欧美色欧美亚洲另类二区| 亚洲天堂福利av| 国产盗摄一区二区| 欧美mv和日韩mv国产网站| 亚洲福利一二三区| 色激情天天射综合网| 中文字幕一区视频| 高清成人免费视频| 精品福利二区三区| 久久精品国产精品亚洲综合| 欧美日韩一区二区三区免费看| 最近日韩中文字幕| 97精品国产97久久久久久久久久久久 | 色欧美片视频在线观看| 国产精品情趣视频| 国产成人免费视频网站高清观看视频| 精品欧美久久久| 久久se精品一区精品二区| 欧美一卡二卡在线| 男人操女人的视频在线观看欧美| 欧美影院精品一区| 亚洲国产欧美在线| 欧美女孩性生活视频| 亚洲1区2区3区4区| 91精品国产欧美日韩| 免费观看在线色综合| 日韩欧美视频一区| 国产一区二区三区蝌蚪| 久久久久久久久久久电影| 国产精品99久久久| 国产精品不卡一区二区三区| 99精品欧美一区二区蜜桃免费| 国产精品国产a| 欧美亚洲国产bt| 日本不卡在线视频| 久久久久久久久久久电影| 成人污污视频在线观看| 一区二区三区四区中文字幕| 欧美日韩一级片在线观看| 日本成人在线一区| 欧美高清在线一区二区| 色综合久久久久| 蜜桃av一区二区在线观看| 久久亚洲综合色| a级高清视频欧美日韩| 一区二区三区在线视频免费观看| 欧美日韩一级黄| 国产成人亚洲综合a∨婷婷图片| 国产精品国产自产拍高清av| 欧美丝袜丝交足nylons图片| 免费国产亚洲视频| 国产精品国产a| 欧美嫩在线观看| 成人午夜av电影| 日产欧产美韩系列久久99| 2021中文字幕一区亚洲| 色老头久久综合| 精品一区二区三区香蕉蜜桃| 亚洲欧洲精品成人久久奇米网| 欧美日韩你懂的| 成人午夜在线播放| 日韩极品在线观看| 亚洲欧洲制服丝袜| 欧美va天堂va视频va在线| 91蜜桃网址入口| 精品在线你懂的| 亚洲国产欧美日韩另类综合| 久久精子c满五个校花| 欧美高清一级片在线| 福利电影一区二区三区| 青青草国产精品亚洲专区无| ...av二区三区久久精品| 欧美不卡一二三| 欧美亚洲自拍偷拍| 成人激情视频网站| 久久精品久久综合| 午夜精品福利久久久| 亚洲色图在线播放| 国产女人aaa级久久久级| 欧美成人乱码一区二区三区| 欧美综合亚洲图片综合区| 国产成人av影院| 精品在线亚洲视频| 青青青伊人色综合久久| 亚洲午夜私人影院| 亚洲欧美日韩在线| 中文字幕精品在线不卡| 久久久精品天堂| ww久久中文字幕| 久久―日本道色综合久久| 911国产精品| 欧美日韩国产一级| 欧美色综合网站| 欧美视频自拍偷拍| 欧美在线你懂得| 色激情天天射综合网| 91免费版在线| 色爱区综合激月婷婷| av亚洲精华国产精华| av不卡免费在线观看| 粉嫩aⅴ一区二区三区四区五区| 国产伦理精品不卡| 国产精品66部| 成人黄色av网站在线| 成人av电影免费观看| 大胆亚洲人体视频| 成人av在线播放网址| 99国产精品久久久久久久久久| 成人激情av网| 91麻豆国产自产在线观看| 一本大道久久a久久精二百| 成人视屏免费看| 99久久精品费精品国产一区二区| 9色porny自拍视频一区二区| 成人av在线资源| 色欧美片视频在线观看| 欧美日韩国产免费| 日韩欧美在线综合网| 久久久精品黄色| 国产精品高潮久久久久无| 亚洲精品国产第一综合99久久| 亚洲一区视频在线观看视频| 亚洲成人tv网| 久久99精品国产.久久久久久 | 国产一区二区三区四| 成人精品小蝌蚪| 91久久线看在观草草青青| 制服丝袜一区二区三区| 亚洲精品在线三区| 亚洲欧洲av一区二区三区久久| 一区二区激情视频| 美女网站色91| www.久久久久久久久| 欧美日韩精品一区二区三区| 2021久久国产精品不只是精品 | 欧美一二三四在线| 国产日产精品1区| 亚洲一区二区在线免费看| 久久99国产精品成人| 99久久99久久免费精品蜜臀| 欧美精品久久久久久久多人混战| 久久久夜色精品亚洲| 亚洲国产日韩a在线播放性色| 久久99久久久久久久久久久| 色偷偷久久人人79超碰人人澡 | 欧美色图在线观看| 国产亚洲午夜高清国产拍精品| 亚洲影视在线观看| 国产剧情一区二区| 欧美日本一道本在线视频| 国产欧美日韩精品一区| 亚洲成a天堂v人片| 成人小视频免费在线观看| 在线播放一区二区三区| 亚洲欧洲日本在线| 久久99国产精品久久99| 欧美唯美清纯偷拍| 久久久天堂av| 日本欧美加勒比视频| 91视频免费播放| 国产欧美一区二区精品仙草咪| 亚洲国产精品自拍| 99久久亚洲一区二区三区青草 | 久久精品免费看| 欧美日本精品一区二区三区| 国产精品美日韩| 国产成人午夜99999| 日韩一区二区三区在线观看| 亚洲欧美日韩在线播放| 成人美女在线视频| 精品日本一线二线三线不卡| 亚洲成人综合视频| 在线一区二区观看| 国产精品久久影院| 国产一区二区视频在线| 日韩精品一区二区三区在线播放| 亚洲成人午夜电影| 在线观看日韩电影| 亚洲夂夂婷婷色拍ww47| 97se狠狠狠综合亚洲狠狠| 国产亚洲欧美一级| 国产不卡一区视频| 欧美国产一区二区| 菠萝蜜视频在线观看一区| 久久精品人人做人人综合|