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

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

?? frag.c

?? microchip公司的DeviceNet協議桟源碼
?? C
字號:
/*****************************************************************************
 *
 * Microchip DeviceNet Stack (Connection Object Fragmentation Source)
 *
 *****************************************************************************
 * FileName:        frag.c
 * Dependencies:    
 * Processor:       PIC18F with CAN
 * Compiler:       	C18 02.20.00 or higher
 * Linker:          MPLINK 03.40.00 or higher
 * Company:         Microchip Technology Incorporated
 *
 * Software License Agreement
 *
 * The software supplied herewith by Microchip Technology Incorporated
 * (the "Company") is intended and supplied to you, the Company's
 * customer, for use solely and exclusively with products manufactured
 * by the Company. 
 *
 * The software is owned by the Company and/or its supplier, and is 
 * protected under applicable copyright laws. All rights are reserved. 
 * Any use in violation of the foregoing restrictions may subject the 
 * user to criminal sanctions under applicable laws, as well as to 
 * civil liability for the breach of the terms and conditions of this 
 * license.
 *
 * THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, 
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 
 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 *
 * This file contains unacknowledged fragmentation support. Refer to 
 * section 4-4 of Volume 1 of the DeviceNet specification.
 * 
 *
 *
 * Author               Date        Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Ross Fosler			04/28/03	...	
 * 
 *****************************************************************************/




#include	"dnet.def"			// Global definitions file
#include 	"typedefs.h"

#if FRAGMENTATION_UNACK

#include	"conn.h"			// Internal definitions

#include	"services.h"		// Service codes
#include	"errors.h"			// Error codes
#include	"class.h"			// Class codes

#include	"dnet.h"			// Global symbols defined by the DeviceNet Obj
#include	"CAN.h"				// CAN driver






#define		_STATE_NOACK_PRODUCE_FIRST_FRAG			0
#define		_STATE_NOACK_PRODUCE_MID_FRAG			1
#define		_STATE_NOACK_PRODUCE_LAST_FRAG			2

#define		_STATE_NOACK_CONSUME_WAIT_FOR_FIRST_FRAG	0
#define		_STATE_NOACK_CONSUME_WAIT_FOR_FRAG			1


// Control flags for fragmented processing
//	<TX/RX><ACK/IO><RES><RES><RES><TXLOCK><ERR><FIN>

#if USE_ACCESS == TRUE
#pragma	udata access _A_FRAG_REGISTERS
#endif
 
NEAR FRAG _aFrag;
NEAR UINT _timer;




#pragma	udata

/*********************************************************************
 * Function:        void _FragNoAckConsume(void)
 *
 * PreCondition: 	The fragment structure must be loaded with the 
 *					last known state of the calling connection.  
 *
 * Input:       	none
 *                  
 * Output:      	none
 *
 * Side Effects:    _aFrag is updated.
 *
 * Overview:      	This function handles unacknowledged reception
 *					of fragmented data.
 *
 * Note:            This function only receives data and does not 
 *					free the CAN driver to receive. It is up to the
 *					calling function to release the hardware to 
 *					receive data.
 ********************************************************************/
void _FragNoAckConsume(void)
{
	unsigned char frag, type, len;
	unsigned char *pRxData;
	
	// Get a pointer to the buffer
	pRxData = CANGetRxDataPtr();
	
	// Get the fragmentation control byte then point to the data
	frag = *pRxData; //pRxData++;
	
	// Get the fragment type
	type = frag & 0xC0;
	
	switch (type)
	{
		// First fragment received
		case 0x00:
			// Is this the first or only fragment
			if (frag == 0x3F || frag == 0)
			{
				// Store the length minus the fragment control byte
				_aFrag.rx.len = CANGetRxCnt() - 1;
				
				// Copy this fragment to the buffer
				CANGetRxDataTyp1(_aFrag.rx.pMsg);
			//	*((_MSG_DATA_IO_FRAG *)_aFrag.rx.pMsg) = *((_MSG_DATA_IO_FRAG *)pRxData);
										
				// Is this the only fragment		
				if (frag == 0x3F)
				{
					// Set the finish flag
					_aFrag.rx.fragFlags.bits.b0 = 1;
				}
				else
				{
					// Change the state
					_aFrag.rx.fragState = _STATE_NOACK_CONSUME_WAIT_FOR_FRAG;
					_aFrag.rx.oldFrag = 0;
				} 
			}
			else
			{
				// This is an error
				_aFrag.rx.fragFlags.bits.b1 = 1;
			}
			break;
		
		// Middle or last fragment
		case 0x40:
		case 0x80:
			// Has the first fragment been received
			if (_aFrag.rx.fragState == _STATE_NOACK_CONSUME_WAIT_FOR_FRAG)
			{
				// Is this the next fragment in the sequence
				if (((frag ^ (_aFrag.rx.oldFrag + 1)) & 0x3F) == 0)
				{
					// Remember the fragment control byte
					_aFrag.rx.oldFrag = frag;
		
					// Copy the length
					len = _aFrag.rx.len;
		
					// Adjust the length 
					_aFrag.rx.len += (CANGetRxCnt() - 1);
					
					// Check the size of the buffer
					if (_aFrag.rx.len <= _aFrag.rx.lenMax)
					{		
						// Copy this fragment to the buffer
						CANGetRxDataTyp1(_aFrag.rx.pMsg + len);
			//			*((_MSG_DATA_IO_FRAG *)(_aFrag.rx.pMsg + len)) = 
			//				*((_MSG_DATA_IO_FRAG *)pRxData);
							
						// Is this the last fragment
						if (type == 0x80)
						{
							// Set the finish flag
							_aFrag.rx.fragFlags.bits.b0 = 1;
						
							// Change to the beginning state
							_aFrag.rx.fragState = _STATE_NOACK_CONSUME_WAIT_FOR_FIRST_FRAG;
						}
					}
					
					// Too much data to copy to the buffer
					else
					{
						// This is an error 
						_aFrag.rx.fragFlags.bits.b1 = 1;
					
						// Go back to the first fragment
						_aFrag.rx.fragState = _STATE_NOACK_CONSUME_WAIT_FOR_FIRST_FRAG;
					}
				}
				
				// Received a fragment out of sequence
				else
				{
					// This is an error 
					_aFrag.rx.fragFlags.bits.b1 = 1;
					
					// Go back to the first fragment
					_aFrag.rx.fragState = _STATE_NOACK_CONSUME_WAIT_FOR_FIRST_FRAG;
				}
			}
			break;
		
		// Received an acknowledge fragment, which is invalid for this 
		// type of fragmentation
		case 0xC0:
			// This is an error 
			_aFrag.rx.fragFlags.bits.b1 = 1;
			
			// Go back to the first fragment
			_aFrag.rx.fragState = _STATE_NOACK_CONSUME_WAIT_FOR_FIRST_FRAG;
			break;
	}
}



/*********************************************************************
 * Function:        void _FragNoAckProduce(void)
 *
 * PreCondition:    The fragment structure must be loaded with the 
 *					last known state of the calling connection.
 *
 * Input:       	none	
 *                  
 * Output:      	none
 *
 * Side Effects:    _aFrag is updated.
 *
 * Overview:        This function handles unacknowledged transmission
 *					of fragmented data.  
 *
 * Note:            This function does not issue any requests to the 
 *					driver to send data. It is up to the calling 
 *					to issue the transmit request.
 ********************************************************************/
void _FragNoAckProduce(void)
{
	unsigned char *pTxData;
	
	// Get a pointer to the buffer
	pTxData = CANGetTxDataPtr();
		
	switch (_aFrag.tx.fragState)
	{
		// Send an unacknowledged first fragment
		case _STATE_NOACK_PRODUCE_FIRST_FRAG:
				
			// If the whole message is less than the max fragment size
			// then send the only fragment
			if (_aFrag.tx.len < 8)
			{
				// Set the fragment control byte and point to the next data location
				*pTxData = 0x3F; pTxData++;
			
				// Copy this fragment to the transmit buffer
				CANPutTxDataTyp1(_aFrag.tx.pMsg);
	//			*((_MSG_DATA_IO_FRAG *)pTxData) = 
	//				*((_MSG_DATA_IO_FRAG *)(_aFrag.tx.pMsg));
					
				// Set the length of the data to send
				CANPutTxCnt(_aFrag.tx.len + 1);
				
				// Indicate the process is finished
				_aFrag.tx.fragFlags.bits.b0 = 1;					
			}
			
			// Else send the first fragment of the whole message
			else
			{
				// Set the fragment control byte and point to the next data location
				*pTxData = _aFrag.tx.oldFrag = 0; //pTxData++;
								
				// Copy this fragment to the transmit buffer
				CANPutTxDataTyp1(_aFrag.tx.pMsg);
		//		*((_MSG_DATA_IO_FRAG *)pTxData) = 
		//			*((_MSG_DATA_IO_FRAG *)(_aFrag.tx.pMsg));
					
				// Adjust the index
				_aFrag.tx.index = 7;
				
				// Set the length of the data to send
				CANPutTxCnt(8);
								
				// Set the next state
				if ((_aFrag.tx.len - _aFrag.tx.index) > 8)
					_aFrag.tx.fragState = _STATE_NOACK_PRODUCE_MID_FRAG;
				else
					_aFrag.tx.fragState = _STATE_NOACK_PRODUCE_LAST_FRAG;
			}
			break;
			
		// Send a middle fragment
		case _STATE_NOACK_PRODUCE_MID_FRAG:
		
			// Set the fragment control byte and point to the next data location
			*pTxData = _aFrag.tx.oldFrag = ((_aFrag.tx.oldFrag + 1) & 0x3F) | 0x40; 
		//	pTxData++;
		
			// Copy this fragment to the transmit buffer
			CANPutTxDataTyp1(_aFrag.tx.pMsg + _aFrag.tx.index);
	//		*((_MSG_DATA_IO_FRAG *)pTxData) = 
	//			*((_MSG_DATA_IO_FRAG *)(_aFrag.tx.pMsg + _aFrag.tx.index));
				
			// Adjust the index
			_aFrag.tx.index += 7;
			
			// Set the length of the data to send
			CANPutTxCnt(8);
						
			// Set the next state
			if ((_aFrag.tx.len - _aFrag.tx.index) > 8)
				_aFrag.tx.fragState = _STATE_NOACK_PRODUCE_MID_FRAG;
			else
				_aFrag.tx.fragState = _STATE_NOACK_PRODUCE_LAST_FRAG;
		
			break;
			
		// Send the last fragment
		case _STATE_NOACK_PRODUCE_LAST_FRAG:
		
			// Set the fragment control byte and point to the next data location
			*pTxData = _aFrag.tx.oldFrag = ((_aFrag.tx.oldFrag + 1) & 0x3F) | 0x80; 
	//		pTxData++;
		
			// Copy this fragment to the transmit buffer
			CANPutTxDataTyp1(_aFrag.tx.pMsg + _aFrag.tx.index);
	//		*((_MSG_DATA_IO_FRAG *)pTxData) = 
	//			*((_MSG_DATA_IO_FRAG *)(_aFrag.tx.pMsg + _aFrag.tx.index));
			
			// Set the length of the data to send
			CANPutTxCnt(_aFrag.tx.len - _aFrag.tx.index + 1);
			
			// Indicate the process is finished
			_aFrag.tx.fragFlags.bits.b0 = 1;	
					
		// Fallout state, should never get here except through the last fragment
		default:
			_aFrag.tx.fragState = _STATE_NOACK_PRODUCE_FIRST_FRAG;
	}
}




#endif

	  
	  
	  
	  
	  
	  
	  
	  
	  
	  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
高清国产一区二区| 国产欧美一区二区精品性色| 亚洲人亚洲人成电影网站色| 国产a级毛片一区| 国产嫩草影院久久久久| 国产精品自拍在线| 欧美韩国一区二区| 成人av资源在线| 一区二区三区四区乱视频| 欧美中文一区二区三区| 日韩av在线免费观看不卡| 日韩视频在线永久播放| 一本久久综合亚洲鲁鲁五月天| 一区二区高清免费观看影视大全 | 欧美成人一级视频| 欧美色图12p| 1区2区3区欧美| 欧美私模裸体表演在线观看| 日本欧美一区二区在线观看| 久久久不卡网国产精品二区| 色婷婷综合久久久久中文 | 亚洲精品国产精华液| 欧美丝袜丝nylons| 激情综合一区二区三区| 国产精品美女www爽爽爽| 在线国产亚洲欧美| 久久国产精品免费| 中文字幕一区在线观看视频| 欧美日本免费一区二区三区| 国产精品123| 亚洲国产精品久久久久秋霞影院 | 韩国欧美一区二区| 亚洲男女一区二区三区| 日韩欧美的一区二区| www.亚洲人| 欧美a级一区二区| 国产日产欧产精品推荐色 | 欧美疯狂做受xxxx富婆| 国产成人综合精品三级| 性久久久久久久久久久久| 国产午夜亚洲精品不卡| 欧美日韩国产高清一区二区| 成人激情免费视频| 麻豆精品在线观看| 亚洲综合色成人| 中文无字幕一区二区三区 | 欧美成人伊人久久综合网| 成人av网站在线观看| 日本大胆欧美人术艺术动态| 亚洲欧洲制服丝袜| 久久精品一区四区| 日韩午夜av一区| 精品视频999| 97aⅴ精品视频一二三区| 狠狠色丁香婷综合久久| 五月激情综合色| 国产精品美女久久久久久 | 成人在线综合网| 精品亚洲成a人在线观看| 亚洲国产精品久久人人爱蜜臀 | 国产精品国产精品国产专区不片| 欧美丰满少妇xxxbbb| 在线免费视频一区二区| 成人高清免费在线播放| 国产乱码精品一区二区三区忘忧草| 午夜精品国产更新| 亚洲综合久久av| 成人免费在线视频| 亚洲国产精品t66y| 欧美va亚洲va香蕉在线| 制服丝袜成人动漫| 欧美精品1区2区3区| 欧美日韩视频在线一区二区| 色综合久久九月婷婷色综合| 99re热这里只有精品免费视频| 国产精品一级片在线观看| 精品一区二区久久久| 黄色日韩网站视频| 国产精品资源在线观看| 国产乱子伦视频一区二区三区| 紧缚捆绑精品一区二区| 韩国三级在线一区| 国产精品中文有码| 国产成人8x视频一区二区| 国产九色sp调教91| 国产aⅴ精品一区二区三区色成熟| 国产美女精品一区二区三区| 国产在线精品一区二区夜色| 国产在线精品一区二区三区不卡| 九九视频精品免费| 国产成人精品综合在线观看 | 91精品国产色综合久久| 精品一区二区影视| 亚洲男人的天堂在线观看| 亚洲视频中文字幕| 一区二区三区中文字幕| 亚洲国产精品一区二区久久| 视频一区免费在线观看| 看片的网站亚洲| 国产精品白丝jk黑袜喷水| 成人激情综合网站| 91蜜桃视频在线| 91.xcao| 欧美一区二区三区白人| 精品久久久久香蕉网| 国产精品久久午夜夜伦鲁鲁| 国产精品国产三级国产aⅴ原创| 亚洲精品成人精品456| 五月天激情综合| 国产一区二区三区在线看麻豆| 国产精品18久久久久| 色婷婷av一区二区三区软件| 制服丝袜中文字幕一区| 国产欧美日韩精品a在线观看| 欧美激情一区二区三区不卡 | 欧美亚洲高清一区| 国产情人综合久久777777| 国产精品国产成人国产三级| 亚洲影视资源网| 国产一区二区在线免费观看| 99久久99久久久精品齐齐| 欧美一区二区久久久| 欧美韩国日本综合| 日韩国产精品大片| 成人国产免费视频| 3d动漫精品啪啪| 国产精品电影院| 日本vs亚洲vs韩国一区三区| 成人动漫中文字幕| 欧美一二三四在线| 亚洲免费毛片网站| 国内精品免费**视频| 色婷婷精品大在线视频| 久久久蜜桃精品| 日韩高清电影一区| 99久久精品国产一区| 欧美精品一区二区三区四区| 亚洲国产人成综合网站| 国产精品一区二区久激情瑜伽| 欧美人动与zoxxxx乱| 亚洲日本va在线观看| 国产一区不卡精品| 91麻豆精品国产91久久久久久| 最新高清无码专区| 国产成人综合自拍| 欧美成人精品高清在线播放| 一区二区三区不卡在线观看| 成人福利视频在线| 久久久久久综合| 精品中文字幕一区二区小辣椒| 色女孩综合影院| 亚洲三级免费电影| 国产99久久久久| 久久久久久久久久久久久久久99| 三级影片在线观看欧美日韩一区二区| 99久久精品国产精品久久| 国产女同性恋一区二区| 国产激情一区二区三区| 久久影视一区二区| 久久精品国产久精国产| 91麻豆精品国产91久久久使用方法| 亚洲精选在线视频| 色老汉一区二区三区| 亚洲免费在线播放| 91欧美一区二区| 亚洲人成影院在线观看| 成人av影视在线观看| 中文字幕中文字幕一区| 成人高清av在线| 国产精品国模大尺度视频| 成人高清免费观看| 成人免费在线视频| 91玉足脚交白嫩脚丫在线播放| 中文字幕国产一区| av一区二区三区| 亚洲视频一区二区在线| 一本久道中文字幕精品亚洲嫩| 欧美国产精品中文字幕| 成人av先锋影音| 亚洲一区免费观看| 欧美日韩不卡视频| 日本不卡的三区四区五区| 日韩一本二本av| 黑人精品欧美一区二区蜜桃| 久久品道一品道久久精品| 福利一区二区在线观看| 亚洲三级视频在线观看| 欧美日本高清视频在线观看| 奇米影视7777精品一区二区| 欧美mv日韩mv| 成人毛片视频在线观看| 亚洲综合在线第一页| 欧美一区日韩一区| 欧美亚洲国产怡红院影院| 日本v片在线高清不卡在线观看| 久久天天做天天爱综合色| www.综合网.com| 天堂成人国产精品一区| 久久久99精品免费观看| 97精品视频在线观看自产线路二|