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

📄 rs485_pc.s

📁 电梯楼层采集器代码
💻 S
📖 第 1 页 / 共 4 页
字号:
	lds R2,_Device_Address
	movw R30,R22
	ldd R3,z+0
	cp R3,R2
	breq X46
	xjmp L97
X46:
X42:
	.dbline 325
;  {
	.dbline 326
;    if(p_buf->Length==3)
	ldd R24,z+1
	ldd R25,z+2
	cpi R24,3
	ldi R26,0
	cpc R25,R26
	breq X47
	xjmp L99
X47:
X43:
	.dbline 327
;    {
	.dbline 328
;      point = *(unsigned int *)p_buf->Data;
	ldd R10,z+4
	ldd R11,z+5
	.dbline 329
;      if(point < sizeof(struct StructOfLiftSchedule))
	movw R24,R10
	cpi R24,105
	ldi R26,0
	cpc R25,R26
	brlo X48
	xjmp L101
X48:
X44:
	.dbline 330
; 	 {
	.dbline 331
; 	   count = sizeof(struct StructOfLiftSchedule) - point;
	ldi R24,105
	ldi R25,0
	movw R12,R24
	sub R12,R10
	sbc R13,R11
	.dbline 332
; 	   if(count< 256 - 8) p_buf->Length = count + 1;
	movw R24,R12
	cpi R24,248
	ldi R26,0
	cpc R25,R26
	brsh L103
X45:
	.dbline 332
	adiw R24,1
	std z+2,R25
	std z+1,R24
	xjmp L104
L103:
	.dbline 333
; 	   else p_buf->Length = 256 - 8;
	ldi R24,248
	ldi R25,0
	movw R30,R22
	std z+2,R25
	std z+1,R24
L104:
	.dbline 334
; 	   point += LIFT_SCHEDULE_Address;
	movw R24,R10
	adiw R24,54
	movw R10,R24
	.dbline 335
; 	   I2C_Initial();
	xcall _I2C_Initial
	.dbline 336
; 	   AT24_Read((unsigned char *)&p_buf->Data,point,p_buf->Length-1);
	movw R30,R22
	ldd R24,z+1
	ldd R25,z+2
	sbiw R24,1
	std y+0,R24
	movw R18,R10
	movw R16,R30
	subi R16,252  ; offset = 4
	sbci R17,255
	xcall _AT24_Read
	.dbline 337
; 	   I2C_Close();
	xcall _I2C_Close
	.dbline 338
;   	   communication->pc_txd = 1; 
	ldi R24,1
	movw R30,R20
	std z+1,R24
	.dbline 339
; 	 }
	xjmp L100
L101:
	.dbline 340
; 	 else if(TEST) CommandReply(RESP_INVALID_DATA);
	xjmp L100
L99:
	.dbline 342
;   	}
; 	else if(TEST) CommandReply(RESP_INVALID_DATA);
	xjmp L107
L107:
L100:
	.dbline 343
;  }
L97:
	.dbline -2
L96:
	.dbline 0 ; func end
	adiw R28,1
	xjmp pop_xgsetF03C
	.dbsym r communication 20 pS[data]
	.dbsym r count 12 i
	.dbsym r point 10 i
	.dbsym r p_buf 22 pS[StructOfProtocol]
	.dbend
	.dbfunc e SET_AUTH_TIME _SET_AUTH_TIME fV
;          count -> R10,R11
;          point -> R22,R23
;          p_buf -> R20,R21
	.even
_SET_AUTH_TIME::
	xcall push_xgsetF00C
	sbiw R28,1
	.dbline -1
	.dbline 354
; }
; //------------------------------------------------------------------------------
; /*
; 15.	设电梯授权时间组 = CMD_SET_AUTH_TIME
; 命令码:		CMD_SET_AUTH_TIME
; 数据:		    内存位置                  2字节,高字节在前,值域 0 - 524	
;       从指定位置开始的资料,不超过250字节
; 正常回应:	    [OK]
; */
; void SET_AUTH_TIME(void)
; {
	.dbline 357
;  unsigned int point,count;
;  struct StructOfProtocol *p_buf;
;  p_buf = (struct StructOfProtocol *)Buffer485;
	ldi R20,<_Buffer485
	ldi R21,>_Buffer485
	.dbline 358
;  *C51Buffer485 = *Buffer485;
	lds R2,_Buffer485
	sts _C51Buffer485,R2
	.dbline 359
;  point = *(unsigned int *)p_buf->Data;
	movw R30,R20
	ldd R22,z+4
	ldd R23,z+5
	.dbline 360
;  if(point < sizeof(struct StructOfLiftSchedule))
	cpi R22,105
	ldi R26,0
	cpc R23,R26
	brlo X53
	xjmp L110
X53:
X49:
	.dbline 361
;  {
	.dbline 362
;    count = sizeof(struct StructOfLiftSchedule) - point;
	ldi R24,105
	ldi R25,0
	movw R10,R24
	sub R10,R22
	sbc R11,R23
	.dbline 363
;    p_buf->Length -= 3;
	movw R24,R30
	adiw R24,1
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	sbiw R24,3
	std z+1,R25
	std z+0,R24
	.dbline 364
;    if(p_buf->Length&&(p_buf->Length<=count))
	movw R30,R20
	ldd R2,z+1
	ldd R3,z+2
	tst R2
	brne X50
	tst R3
	breq L112
X50:
	cp R10,R2
	cpc R11,R3
	brlo L112
X51:
	.dbline 365
;    {
	.dbline 366
;     point += LIFT_SCHEDULE_Address;
	subi R22,202  ; offset = 54
	sbci R23,255
	.dbline 367
; 	I2C_Initial();
	xcall _I2C_Initial
	.dbline 368
;     AT24_Write((unsigned char *)&p_buf->Data[2],point,p_buf->Length);	
	movw R30,R20
	ldd R2,z+1
	ldd R3,z+2
	std y+0,R2
	movw R18,R22
	movw R16,R30
	subi R16,250  ; offset = 6
	sbci R17,255
	xcall _AT24_Write
	.dbline 369
; 	I2C_Close();
	xcall _I2C_Close
	.dbline 370
;     if (p_buf->Address!= 0xff) 
	movw R30,R20
	ldd R24,z+0
	cpi R24,255
	breq L111
X52:
	.dbline 371
; 	{
	.dbline 372
; 	   Cyc_manage |= 0x04;//打开更新51控制板的数据
	lds R24,_Cyc_manage
	ori R24,4
	sts _Cyc_manage,R24
	.dbline 373
;    	   CommandReply(RESP_CMD_OK);
	ldi R16,129
	xcall _CommandReply
	.dbline 374
; 	 }
	.dbline 375
;    }
	xjmp L111
L112:
	.dbline 376
;    else if(TEST && p_buf->Address != 0xff)
	xjmp L111
L110:
	.dbline 379
;        CommandReply(RESP_INVALID_DATA);
;  }
;  else if(TEST && p_buf->Address != 0xff)
	xjmp L118
L118:
L111:
	.dbline -2
L109:
	.dbline 0 ; func end
	adiw R28,1
	xjmp pop_xgsetF00C
	.dbsym r count 10 i
	.dbsym r point 22 i
	.dbsym r p_buf 20 pS[StructOfProtocol]
	.dbend
	.dbfunc e GET_CONFIG _GET_CONFIG fV
;  communication -> R20,R21
;          p_buf -> R22,R23
	.even
_GET_CONFIG::
	xcall push_xgsetF000
	sbiw R28,1
	.dbline -1
	.dbline 386
;      CommandReply(RESP_INVALID_DATA);
; }
; //------------------------------------------------------------------------------
; //------------------------------------------------------------------------------
; /*取系统配置参数*/
; void GET_CONFIG(void)
; {
	.dbline 389
;  struct StructOfProtocol *p_buf;
;  struct data *communication;
;  p_buf = (struct StructOfProtocol *)Buffer485;
	ldi R22,<_Buffer485
	ldi R23,>_Buffer485
	.dbline 390
;  if(p_buf->Address==Device_Address)
	lds R2,_Device_Address
	movw R30,R22
	ldd R3,z+0
	cp R3,R2
	brne L121
X54:
	.dbline 391
;  {
	.dbline 392
;    if (p_buf->Length == 1)  /*接收数据包长度确认*/
	ldd R24,z+1
	ldd R25,z+2
	cpi R24,1
	ldi R26,0
	cpc R25,R26
	brne L123
X55:
	.dbline 393
;    {
	.dbline 394
;      p_buf->Length = sizeof(SystemConfig) + 1;
	ldi R24,33
	ldi R25,0
	std z+2,R25
	std z+1,R24
	.dbline 395
; 	 I2C_Initial();
	xcall _I2C_Initial
	.dbline 396
; 	 AT24_Read((unsigned char *)&p_buf->Data,SystemConfig_Address,p_buf->Length-1);
	movw R30,R22
	ldd R24,z+1
	ldd R25,z+2
	sbiw R24,1
	std y+0,R24
	clr R18
	clr R19
	movw R16,R30
	subi R16,252  ; offset = 4
	sbci R17,255
	xcall _AT24_Read
	.dbline 397
; 	 I2C_Close();
	xcall _I2C_Close
	.dbline 398
;   	 communication->pc_txd = 1; 
	ldi R24,1
	movw R30,R20
	std z+1,R24
	.dbline 399
;    }
	xjmp L124
L123:
	.dbline 400
;    else if(TEST) CommandReply(RESP_INVALID_DATA);          /*包长度异常*/
	xjmp L125
L125:
L124:
	.dbline 401
;   }
L121:
	.dbline -2
L120:
	.dbline 0 ; func end
	adiw R28,1
	xjmp pop_xgsetF000
	.dbsym r communication 20 pS[data]
	.dbsym r p_buf 22 pS[StructOfProtocol]
	.dbend
	.dbfunc e SET_CONFIG _SET_CONFIG fV
;          count -> <dead>
;          point -> <dead>
;          p_buf -> R20,R21
	.even
_SET_CONFIG::
	st -y,R20
	st -y,R21
	sbiw R28,1
	.dbline -1
	.dbline 406
; }
; //------------------------------------------------------------------------------
; /*设置系统配置参数*/
; void SET_CONFIG(void)
; {
	.dbline 409
;  unsigned int point,count;
;  struct StructOfProtocol *p_buf;
;  p_buf = (struct StructOfProtocol *)Buffer485;
	ldi R20,<_Buffer485
	ldi R21,>_Buffer485
	.dbline 410
;  *C51Buffer485 = *Buffer485;
	lds R2,_Buffer485
	sts _C51Buffer485,R2
	.dbline 411
;  if (p_buf->Length == sizeof(SystemConfig) + 1)                /*接收数据包长度确认*/
	movw R30,R20
	ldd R24,z+1
	ldd R25,z+2
	cpi R24,33
	ldi R30,0
	cpc R25,R30
	brne L128
X56:
	.dbline 412
;  {
	.dbline 413
;   	I2C_Initial();
	xcall _I2C_Initial
	.dbline 414
;   	AT24_Write((unsigned char *)&p_buf->Data,SystemConfig_Address,sizeof(SystemConfig));
	ldi R24,32
	std y+0,R24
	clr R18
	clr R19
	movw R16,R20
	subi R16,252  ; offset = 4
	sbci R17,255
	xcall _AT24_Write
	.dbline 415
; 	I2C_Close();
	xcall _I2C_Close
	.dbline 416
;     if (p_buf->Address != 0xff)     
	movw R30,R20
	ldd R24,z+0
	cpi R24,255
	breq L129
X57:
	.dbline 417
; 	{
	.dbline 418
; 	   Cyc_manage |= 0x04;//打开更新51控制板的数据
	lds R24,_Cyc_manage
	ori R24,4
	sts _Cyc_manage,R24
	.dbline 419
;        CommandReply(RESP_CMD_OK);
	ldi R16,129
	xcall _CommandReply
	.dbline 420
; 	}
	.dbline 421
;   }
	xjmp L129
L128:
	.dbline 422
;   else if (TEST && p_buf->Address != 0xff)    
	xjmp L132
L132:
L129:
	.dbline -2
L127:
	.dbline 0 ; func end
	adiw R28,1
	ld R21,y+
	ld R20,y+
	ret
	.dbsym l count 2 i
	.dbsym l point 2 i
	.dbsym r p_buf 20 pS[StructOfProtocol]
	.dbend
	.dbfunc e GET_PRODUCT_CODE _GET_PRODUCT_CODE fV
;  communication -> R20,R21
;          p_buf -> R22,R23
	.even
_GET_PRODUCT_CODE::
	xcall push_xgsetF000
	sbiw R28,1
	.dbline -1
	.dbline 429
;   	   CommandReply(RESP_INVALID_DATA);
; } 
; //------------------------------------------------------------------------------
; //------------------------------------------------------------------------------
;  /*取产品标签代码*/
; void GET_PRODUCT_CODE(void)
; {
	.dbline 432
;  struct StructOfProtocol *p_buf;
;  struct data *communication;
;  p_buf = (struct StructOfProtocol *)Buffer485;
	ldi R22,<_Buffer485
	ldi R23,>_Buffer485
	.dbline 433
;  if (p_buf->Address == Device_Address)                                /*本机地址响应*/
	lds R2,_Device_Address
	movw R30,R22
	ldd R3,z+0
	cp R3,R2
	brne L135
X58:
	.dbline 434
;  {
	.dbline 435
;   if (p_buf->Length == 1)                                     /*接收数据包长度确认*/
	ldd R24,z+1
	ldd R25,z+2
	cpi R24,1
	ldi R26,0
	cpc R25,R26
	brne L137
X59:
	.dbline 436
;   {
	.dbline 437
;      p_buf->Length = sizeof(struct StructOfProductCode) + 1;
	ldi R24,251
	ldi R25,0
	std z+2,R25
	std z+1,R24
	.dbline 438
; 	 I2C_Initial();
	xcall _I2C_Initial
	.dbline 439
; 	 AT24_Read((unsigned char *)&p_buf->Data,StructOfProductCode_Address,p_buf->Length-1);
	movw R30,R22
	ldd R24,z+1
	ldd R25,z+2
	sbiw R24,1
	std y+0,R24
	ldi R18,39610
	ldi R19,154
	movw R16,R30
	subi R16,252  ; offset = 4
	sbci R17,255
	xcall _AT24_Read
	.dbline 440
; 	 I2C_Close();
	xcall _I2C_Close
	.dbline 441
;   	 communication->pc_txd = 1; 
	ldi R24,1
	movw R30,R20
	std z+1,R24
	.dbline 442
;   }
	xjmp L138
L137:
	.dbline 443
;   else if(TEST)     
	xjmp L139
L139:
L138:
	.dbline 445
;   	  CommandReply(RESP_INVALID_DATA);          /*包长度异常*/
;  }
L135:
	.dbline -2
L134:
	.dbline 0 ; func end
	adiw R28,1
	xjmp pop_xgsetF000
	.dbsym r communication 20 pS[data]
	.dbsym r p_buf 22 pS[StructOfProtocol]
	.dbend
	.dbfunc e SET_PRODUCT_CODE _SET_PRODUCT_CODE fV
;          p_buf -> R20,R21
	.even
_SET_PRODUCT_CODE::
	st -y,R20
	st -y,R21
	sbiw R28,1
	.dbline -1
	.dbline 450
; }
; //------------------------------------------------------------------------------
; /*设置产品标签代码*/
; void SET_PRODUCT_CODE(void)
; {
	.dbline 452
;  struct StructOfProtocol *p_buf;
;  p_buf = (struct StructOfProtocol *)Buffer485;
	ldi R20,<_Buffer485
	ldi R21,>_Buffer485
	.dbline 453
;  *C51Buffer485 = *Buffer485;
	lds R2,_Buffer485
	sts _C51Buffer485,R2
	.dbline 454
;  if (p_buf->Length == sizeof(struct StructOfProductCode) + 1)  /*接收数据包长度确认*/
	movw R30,R20
	ldd R24,z+1
	ldd R25,z+2
	cpi R24,251
	ldi R30,0
	cpc R25,R30
	brne L142
X60:
	.dbline 455
;  {	
	.dbline 456
;  	I2C_Initial();
	xcall _I2C_Initial
	.dbline 457
; 	AT24_Write((unsigned char *)&p_buf->Data,StructOfProductCode_Address,sizeof(struct StructOfProductCode));	
	ldi R24,250
	std y+0,R24
	ldi R18,39610
	ldi R19,154
	movw R16,R20
	subi R16,252  ; offset = 4
	sbci R17,255
	xcall _AT24_Write
	.dbline 458
; 	I2C_Close();	
	xcall _I2C_Close
	.dbline 459
;     if (p_buf->Address != 0xff)  
	movw R30,R20
	ldd R24,z+0
	cpi R24,255
	breq L143
X61:
	.dbline 460
;     { 
	.dbline 461
; 	  Cyc_manage |= 0x04;//打开更新51控制板的数据
	lds R24,_Cyc_manage
	ori R24,4
	sts _Cyc_manage,R24
	.dbline 462
;       CommandReply(RESP_CMD_OK);
	ldi R16,129
	xcall _CommandReply
	.dbline 463
;     }
	.dbline 464
;  }
	xjmp L143
L142:
	.dbline 465
;  else if(TEST && p_buf->Address != 0xff)   
	xjmp L146
L146:
L143:

⌨️ 快捷键说明

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