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

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

?? srecord.c

?? Avr系列單片機反匯編器源代碼.GCC編譯
?? C
字號:
/* *  srecord.h *  Utility functions to create, read, write, and print Motorola S-Record binary records. * *  Written by Vanya A. Sergeev <vsergeev@gmail.com> *  Version 1.0 - December 2006 * *  Public Domain * */#include "srecord.h"/* Lengths of the ascii hex encoded address fields of different SRecord types */ static int SRecord_Address_Lengths[] = {	4, // S0	4, // S1	6, // S2	8, // S3	8, // S4	4, // S5	6, // S6	8, // S7	6, // S8	4, // S9};/* Initializes a new IHexRecord structure that the paramater ihexRecord points to with the passed * S-Record type, up to 32-bit integer address, 8-bit data array, and size of 8-bit data array. */int New_SRecord(int type, uint32_t address, uint8_t data[], int dataLen, SRecord *srec) {	/* Data length size check, assertion of srec */	if (dataLen < 0 || dataLen > SRECORD_MAX_DATA_LEN/2 || srec == NULL)		return SRECORD_ERROR_INVALID_ARGUMENTS;		srec->type = type;	srec->address = address;	memcpy(srec->data, data, dataLen);	srec->dataLen = dataLen;	srec->checksum = Checksum_SRecord(*srec);		return SRECORD_OK;	}/* Utility function to read an S-Record from a file */int Read_SRecord(SRecord *srec, FILE *in) {	char recordBuff[SRECORD_RECORD_BUFF_SIZE];	/* A temporary buffer to hold ascii hex encoded data, set to the maximum length we would ever need */	char hexBuff[SRECORD_MAX_ADDRESS_LEN+1];	int asciiAddressLen, asciiDataLen, dataOffset, fieldDataCount, i;		/* Check our file pointer and the S-Record struct */	if (in == NULL || srec == NULL)		return SRECORD_ERROR_INVALID_ARGUMENTS;		if (fgets(recordBuff, SRECORD_RECORD_BUFF_SIZE, in) == NULL) {			/* In case we hit EOF, don't report a file error */			if (feof(in) != 0)				return SRECORD_ERROR_EOF;			else				return SRECORD_ERROR_FILE;	}	/* Get rid of that \n */	recordBuff[strlen(recordBuff)-1] = 0;		/* Size check for type and count fields */	if (strlen(recordBuff) < SRECORD_TYPE_LEN + SRECORD_COUNT_LEN)		return SRECORD_ERROR_INVALID_RECORD;		/* Check for the S-Record start code at the beginning of every record */	if (recordBuff[SRECORD_START_CODE_OFFSET] != SRECORD_START_CODE)		return SRECORD_ERROR_INVALID_RECORD;		/* Copy the ascii hex encoding of the type field into hexBuff, convert it into a usable integer */	strncpy(hexBuff, recordBuff+SRECORD_TYPE_OFFSET, SRECORD_TYPE_LEN);	hexBuff[SRECORD_TYPE_LEN] = 0;	srec->type = strtol(hexBuff, (char **)NULL, 16);		/* Copy the ascii hex encoding of the count field into hexBuff, convert it to a usable integer */	strncpy(hexBuff, recordBuff+SRECORD_COUNT_OFFSET, SRECORD_COUNT_LEN);	hexBuff[SRECORD_COUNT_LEN] = 0;	fieldDataCount = strtol(hexBuff, (char **)NULL, 16);		/* Check that our S-Record type is valid */	if (srec->type < SRECORD_TYPE_S0 || srec->type > SRECORD_TYPE_S9)		return SRECORD_ERROR_INVALID_RECORD;	/* Get the ascii hex address length of this particular S-Record type */	asciiAddressLen = SRecord_Address_Lengths[srec->type];		/* Size check for address field */	if (strlen(recordBuff) < SRECORD_ADDRESS_OFFSET+asciiAddressLen)		return SRECORD_ERROR_INVALID_RECORD;			/* Copy the ascii hex encoding of the count field into hexBuff, convert it to a usable integer */	strncpy(hexBuff, recordBuff+SRECORD_ADDRESS_OFFSET, asciiAddressLen);	hexBuff[asciiAddressLen] = 0;	srec->address = strtol(hexBuff, (char **)NULL, 16);		/* Compute the ascii-hex data length by subtracting the remaining field lengths from the S-Record 	 * count field (times 2 to account for the number of characters used in ascii hex encoding) */	asciiDataLen = (fieldDataCount*2) - asciiAddressLen - SRECORD_CHECKSUM_LEN;	/* Bailout if we get an invalid data length */	if (asciiDataLen < 0 || asciiDataLen > SRECORD_MAX_DATA_LEN)		return SRECORD_ERROR_INVALID_RECORD;			/* Size check for final data field and checksum field */	if (strlen(recordBuff) < SRECORD_ADDRESS_OFFSET+asciiAddressLen+asciiDataLen+SRECORD_CHECKSUM_LEN)		return SRECORD_ERROR_INVALID_RECORD;			dataOffset = SRECORD_ADDRESS_OFFSET+asciiAddressLen;		/* Loop through each ascii hex byte of the data field, pull it out into hexBuff,	 * convert it and store the result in the data buffer of the S-Record */	for (i = 0; i < asciiDataLen/2; i++) {		/* Times two i because every byte is represented by two ascii hex characters */		strncpy(hexBuff, recordBuff+dataOffset+2*i, SRECORD_ASCII_HEX_BYTE_LEN);		hexBuff[SRECORD_ASCII_HEX_BYTE_LEN] = 0;		srec->data[i] = strtol(hexBuff, (char **)NULL, 16);	}	/* Real data len is divided by two because every byte is represented by two ascii hex characters */	srec->dataLen = asciiDataLen/2;		/* Copy out the checksum ascii hex encoded byte, and convert it back to a usable integer */	strncpy(hexBuff, recordBuff+dataOffset+asciiDataLen, SRECORD_CHECKSUM_LEN);	hexBuff[SRECORD_CHECKSUM_LEN] = 0;	srec->checksum = strtol(hexBuff, (char **)NULL, 16);	if (srec->checksum != Checksum_SRecord(*srec))		return SRECORD_ERROR_INVALID_RECORD;		return SRECORD_OK;}/* Utility function to write an S-Record to a file */int Write_SRecord(const SRecord srec, FILE *out) {	char strAddress[SRECORD_MAX_ADDRESS_LEN+1];	int asciiAddressLen, asciiAddressOffset, fieldDataCount, i;		/* Check our file pointer */	if (out == NULL)		return SRECORD_ERROR_INVALID_ARGUMENTS;		/* Check that the type and data length is within range */	if (srec.type < SRECORD_TYPE_S0 || srec.type > SRECORD_TYPE_S9 || srec.dataLen > SRECORD_MAX_DATA_LEN/2)		return SRECORD_ERROR_INVALID_RECORD;		/* Compute the record count, address and checksum lengths are halved because record count	 * is the number of bytes left in the record, not the length of the ascii hex representation */	fieldDataCount = SRecord_Address_Lengths[srec.type]/2 + srec.dataLen + SRECORD_CHECKSUM_LEN/2;		asciiAddressLen = SRecord_Address_Lengths[srec.type];	/* The offset of the ascii hex encoded address from zero, this is used so we only write as	 * many bytes of the address as permitted by the S-Record type. */	asciiAddressOffset = SRECORD_MAX_ADDRESS_LEN-asciiAddressLen;		if (fprintf(out, "%c%2.1X%2.2X", SRECORD_START_CODE, srec.type, fieldDataCount) < 0)		return SRECORD_ERROR_FILE;	/* Write the ascii hex representation of the address, starting from the offset to only	 * write as much of the address as permitted by the S-Record type (calculated above). */	/* Fix the hex to be 8 hex digits of precision, to fit all 32-bits, including zeros */	snprintf(strAddress, sizeof(strAddress), "%2.8X", srec.address);	if (fprintf(out, "%s", strAddress+asciiAddressOffset) < 0)		return SRECORD_ERROR_FILE;		/* Write each byte of the data, guaranteed to be two hex ascii characters each since	 * srec.data[i] has the type of uint8_t */	for (i = 0; i < srec.dataLen; i++) {		if (fprintf(out, "%2.2X", srec.data[i]) < 0)			return SRECORD_ERROR_FILE;	}			/* Last but not least, the checksum */	if (fprintf(out, "%2.2X\r\n", Checksum_SRecord(srec)) < 0)		return SRECORD_ERROR_FILE;		return SRECORD_OK;}/* Utility function to print (formatted) the information stored in an S-Record */void Print_SRecord(const SRecord srec) {	int i;	printf("S-Record Type: S%d\n", srec.type);	printf("S-Record Address: 0x%2.8X\n", srec.address);	printf("S-Record Data: {");	for (i = 0; i < srec.dataLen; i++) {		printf("0x%02X, ", srec.data[i]);	}	printf("}\n");	printf("S-Record Checksum: 0x%2.2X\n", srec.checksum);}/* Utility function to calculate the checksum of an S-Record */uint8_t Checksum_SRecord(const SRecord srec) {	uint8_t checksum;	int fieldDataCount, i;		/* Compute the record count, address and checksum lengths are halved because record count	 * is the number of bytes left in the record, not the length of the ascii hex representation */	fieldDataCount = SRecord_Address_Lengths[srec.type]/2 + srec.dataLen + SRECORD_CHECKSUM_LEN/2;	/* Add the count, address, and data fields together */	checksum = fieldDataCount;	/* Add each byte of the address individually */	checksum += (uint8_t)(srec.address & 0x000000FF);	checksum += (uint8_t)((srec.address & 0x0000FF00) >> 8);	checksum += (uint8_t)((srec.address & 0x00FF0000) >> 16);	checksum += (uint8_t)((srec.address & 0xFF000000) >> 24);	for (i = 0; i < srec.dataLen; i++)		checksum += srec.data[i];		/* One's complement the checksum */	checksum = ~checksum;		return checksum;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99视频一区二区| 美腿丝袜亚洲三区| 国产91清纯白嫩初高中在线观看| 欧美性猛片aaaaaaa做受| 欧美国产精品劲爆| 狠狠色综合播放一区二区| 日韩欧美在线综合网| 亚洲国产综合视频在线观看| 99麻豆久久久国产精品免费优播| 日日嗨av一区二区三区四区| 欧美日韩一级视频| 男男视频亚洲欧美| 久久一日本道色综合| 国产一区二三区好的| 国产免费观看久久| 日韩一级精品视频在线观看| www.成人在线| 国产91色综合久久免费分享| 久久99久久精品欧美| 国产欧美日韩另类视频免费观看| 日韩欧美一区二区视频| 久久国产精品无码网站| 久久理论电影网| 色综合一区二区三区| 亚洲久草在线视频| 欧美日韩免费不卡视频一区二区三区 | 欧美激情中文不卡| www亚洲一区| 2019国产精品| 精品国产精品一区二区夜夜嗨| 国产美女主播视频一区| 麻豆国产欧美日韩综合精品二区| 视频一区视频二区在线观看| 丝袜亚洲另类欧美综合| 日韩精品三区四区| 免费视频最近日韩| 毛片av中文字幕一区二区| 日韩av电影免费观看高清完整版 | 欧美自拍偷拍午夜视频| 日本成人中文字幕在线视频| 天天色综合成人网| 国产精品久久久久永久免费观看 | 99久免费精品视频在线观看 | 欧美一激情一区二区三区| 欧美日韩国产综合久久| 在线成人av影院| 成人app在线| 亚洲成在线观看| 国产精品成人一区二区三区夜夜夜 | 99v久久综合狠狠综合久久| 日韩va欧美va亚洲va久久| 日韩在线一区二区三区| 天堂午夜影视日韩欧美一区二区| 日韩成人一级片| 国精产品一区一区三区mba桃花| 国产专区欧美精品| 成人av高清在线| 欧美伊人精品成人久久综合97 | 中文字幕综合网| 欧美高清精品3d| 欧美一区二区三区的| 在线观看国产精品网站| 欧美色网一区二区| 日韩欧美亚洲国产另类| 久久综合999| 亚洲免费观看视频| 欧美韩日一区二区三区| 亚洲日本va在线观看| 亚洲人成在线观看一区二区| 欧美日韩大陆在线| 中文字幕精品一区二区精品绿巨人| 国产精品成人在线观看| 一区二区三区毛片| voyeur盗摄精品| 国产伦精品一区二区三区免费| 国产精品123| 亚洲成人免费影院| 在线亚洲免费视频| 日韩精品在线网站| 中文字幕日韩欧美一区二区三区| 欧美一级国产精品| 国产人妖乱国产精品人妖| 亚洲精选视频免费看| 欧美aaaaa成人免费观看视频| 国产一区高清在线| 在线亚洲+欧美+日本专区| 日韩免费福利电影在线观看| 国产日韩影视精品| 亚洲成av人影院在线观看网| 国产成人精品一区二区三区四区 | 91精品国产色综合久久不卡电影 | 亚洲丰满少妇videoshd| 国产在线麻豆精品观看| 91丝袜高跟美女视频| 久久国产麻豆精品| 成人18精品视频| 欧美一区二区三区性视频| 亚洲欧美国产77777| 日本特黄久久久高潮| 99久久伊人久久99| 91精品啪在线观看国产60岁| 欧美午夜精品一区二区蜜桃| 久久精品一区二区| 中文字幕成人在线观看| 亚洲小说欧美激情另类| 成人在线视频首页| 99久久精品免费| 精品国产伦一区二区三区观看体验 | 国产精品美女久久久久久| 精品久久久三级丝袜| 欧美性一区二区| 国产精品自在欧美一区| 懂色av一区二区在线播放| 日韩欧美一级二级| 91麻豆国产福利在线观看| 成人小视频免费在线观看| 日韩一区二区三区高清免费看看| 亚洲欧美一区二区三区孕妇| 国产一区二区剧情av在线| 91精品在线一区二区| 亚洲丝袜自拍清纯另类| 国产suv精品一区二区883| 日韩精品综合一本久道在线视频| 亚洲制服丝袜av| 亚洲大片免费看| 色老综合老女人久久久| 91精品国产aⅴ一区二区| 亚洲国产一区二区三区| 在线观看免费亚洲| 亚洲国产经典视频| 国产成人啪免费观看软件| 精品国产一区二区精华| 日本中文字幕一区二区视频| 欧美日韩大陆在线| 亚洲高清视频在线| 欧美精品欧美精品系列| 亚洲福利一区二区| 欧美日韩aaaaa| 亚洲午夜精品网| 欧美日韩精品欧美日韩精品一 | 久久国产生活片100| 欧美sm美女调教| 精品在线观看视频| 日韩欧美激情一区| 精品无码三级在线观看视频| 精品国产自在久精品国产| 黑人巨大精品欧美黑白配亚洲| 精品国产亚洲在线| 国产成人午夜视频| 1024国产精品| 欧日韩精品视频| 日本亚洲欧美天堂免费| 精品乱码亚洲一区二区不卡| 国产一区二三区| 国产精品久久久久久妇女6080| 99视频在线精品| 亚洲亚洲人成综合网络| 欧美一级免费大片| 国产精品性做久久久久久| 国产精品高潮久久久久无| 欧美午夜精品免费| 奇米影视7777精品一区二区| 久久久久久久久久美女| 99re这里都是精品| 日韩极品在线观看| 国产欧美一区二区在线观看| 97精品电影院| 男人的j进女人的j一区| 国产偷国产偷亚洲高清人白洁| 99视频国产精品| 日韩电影在线看| 久久久99精品久久| 91黄色激情网站| 久久99国产精品久久99果冻传媒| 中文字幕二三区不卡| 欧美日韩高清一区| 成人在线视频一区| 视频在线在亚洲| 最好看的中文字幕久久| 欧美一区二区三区在| 99精品久久99久久久久| 美女视频黄频大全不卡视频在线播放| 久久精品免视看| 欧美吞精做爰啪啪高潮| 国产久卡久卡久卡久卡视频精品| 一区二区三区鲁丝不卡| 欧美精品一区二区三区视频| 91在线视频官网| 国产又黄又大久久| 亚洲国产精品久久久久秋霞影院| 2023国产精品| 欧美色图在线观看| 成人激情小说网站| 久久国产人妖系列| 亚洲第一精品在线| 1000部国产精品成人观看| 精品国产一二三区| 制服丝袜中文字幕亚洲| 91在线无精精品入口| 国产盗摄女厕一区二区三区|