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

📄 communication_lib.s

📁 移动机器人(小车)的物理坐标和逻辑坐标的转换源码
💻 S
📖 第 1 页 / 共 2 页
字号:
	.word 0x0,0x0
	.byte 0,0,0,0,0,0,0,0
	.area text(rom, con, rel)
	.dbfile E:\单片机\ROOBCO~1\全向定位系统\坐标转换模块\相对定位模块应用版\Relative_Locate_Module\Communication_LIB.c
	.dbfunc s MSGMap_Acknowledge _MSGMap_Acknowledge fc
;         pcData -> R10,R11
;        fBuffer -> y+1
;       pMsgItem -> R20,R21
	.even
_MSGMap_Acknowledge:
	rcall push_xgset300C
	movw R20,R16
	sbiw R28,13
	.dbline -1
	.dbline 138
; }
; 
; /***********************************************************
; *   函数说明:模块应答消息处理函数                         *
; *   输入:    收到的消息                                   *
; *   输出:    消息是否得到了处理                           *
; *   调用函数:无                                           *
; ***********************************************************/
; static BOOL MSGMap_Acknowledge(MSG_ITEM *pMsgItem)
; {
	.dbline 139
;     uint8 *pcData = pMsgItem->pData;
	movw R30,R20
	ldd R10,z+2
	ldd R11,z+3
	.dbline 140
;     float fBuffer[3] = {0};
	ldi R24,<L24
	ldi R25,>L24
	movw R30,R28
	adiw R30,1
	ldi R16,12
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	rcall asgncblk
	.dbline 142
;     
;     fBuffer[0] = g_fX;
	lds R4,_g_fX+2
	lds R5,_g_fX+2+1
	lds R2,_g_fX
	lds R3,_g_fX+1
	std y+1,R2
	std y+2,R3
	std y+3,R4
	std y+4,R5
	.dbline 143
;     fBuffer[1] = g_fY;
	lds R4,_g_fY+2
	lds R5,_g_fY+2+1
	lds R2,_g_fY
	lds R3,_g_fY+1
	std y+5,R2
	std y+6,R3
	std y+7,R4
	std y+8,R5
	.dbline 144
;     fBuffer[2] = g_fAngle;
	lds R4,_g_fAngle+2
	lds R5,_g_fAngle+2+1
	lds R2,_g_fAngle
	lds R3,_g_fAngle+1
	std y+9,R2
	std y+10,R3
	std y+11,R4
	std y+12,R5
	.dbline 147
;     
;     //发送坐标信息
;     Send_MSG(COM_CMD_ACK,(BYTE *)fBuffer,sizeof(fBuffer));
	ldi R24,12
	std y+0,R24
	movw R18,R28
	subi R18,255  ; offset = 1
	sbci R19,255
	ldi R16,172
	rcall _Send_MSG
	.dbline 149
;     
;     return TRUE;
	ldi R16,1
	.dbline -2
L23:
	.dbline 0 ; func end
	adiw R28,13
	rjmp pop_xgset300C
	.dbsym r pcData 10 pc
	.dbsym l fBuffer 1 A[12:3]D
	.dbsym r pMsgItem 20 pS[MsgItem]
	.dbend
	.dbfunc s MSGMap_Set _MSGMap_Set fc
;        cflags0 -> R10
;             n1 -> R20
;         chXOR0 -> R10
; fAbsoluteAngle0 -> y+1
;         chCTR0 -> R20
;         pcData -> R22,R23
;       pMsgItem -> R20,R21
	.even
_MSGMap_Set:
	rcall push_xgsetF00C
	movw R20,R16
	sbiw R28,5
	.dbline -1
	.dbline 159
; }
; 
; /***********************************************************
; *   函数说明:模块设定消息处理函数                         *
; *   输入:    收到的消息                                   *
; *   输出:    消息是否得到了处理                           *
; *   调用函数:无                                           *
; ***********************************************************/
; static BOOL MSGMap_Set(MSG_ITEM *pMsgItem)
; {
	.dbline 160
;     uint8 *pcData = pMsgItem->pData;
	movw R30,R20
	ldd R22,z+2
	ldd R23,z+3
	.dbline 162
;     
;     if ((pMsgItem->cDataLength) < (1 + sizeof(float) * 3))
	ldd R24,z+1
	cpi R24,13
	brsh L28
X3:
	.dbline 163
;     {
	.dbline 165
;         //指令错误
;         return FALSE;
	clr R16
	rjmp L27
L28:
	.dbline 168
;     }
;     
;     {
	.dbline 169
;         UINT8 chCTR = pcData[0];
	movw R30,R22
	ldd R20,z+0
	.dbline 170
;         float fAbsoluteAngle = g_fAbsoluteAngle;
	lds R4,_g_fAbsoluteAngle+2
	lds R5,_g_fAbsoluteAngle+2+1
	lds R2,_g_fAbsoluteAngle
	lds R3,_g_fAbsoluteAngle+1
	std y+1,R2
	std y+2,R3
	std y+3,R4
	std y+4,R5
	.dbline 172
;         
;         if (chCTR & BIT(2))
	sbrs R20,2
	rjmp L30
X4:
	.dbline 173
;         {
	.dbline 175
;             //设置角度
;             g_chCMDBuffer[2] |= BIT(2);
	lds R24,_g_chCMDBuffer+2
	ori R24,4
	sts _g_chCMDBuffer+2,R24
	.dbline 176
;             fAbsoluteAngle = TYPE_CONVERSION(&pcData[9],float) - K_ANGLE * (float)g_wCounter;
	adiw R30,9
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	ldi R16,<L33
	ldi R17,>L33
	rcall lpm32
	movw R6,R16
	movw R8,R18
	lds R16,_g_wCounter
	lds R17,_g_wCounter+1
	rcall uint2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R6
	movw R18,R8
	rcall fpmule2x
	movw R16,R2
	movw R18,R4
	rcall fpsub2
	std y+1,R16
	std y+2,R17
	std y+3,R18
	std y+4,R19
	.dbline 177
;             TYPE_CONVERSION(&g_chCMDBuffer[11],float) = fAbsoluteAngle;
	ldd R2,y+1
	ldd R3,y+2
	ldd R4,y+3
	ldd R5,y+4
	ldi R30,<_g_chCMDBuffer+11
	ldi R31,>_g_chCMDBuffer+11
	std z+0,R2
	std z+1,R3
	std z+2,R4
	std z+3,R5
	.dbline 178
;         }
L30:
	.dbline 180
;         
;         fAbsoluteAngle += PI;
	ldd R2,y+1
	ldd R3,y+2
	ldd R4,y+3
	ldd R5,y+4
	ldi R16,<L35
	ldi R17,>L35
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R2
	movw R18,R4
	rcall fpadd2
	std y+1,R16
	std y+2,R17
	std y+3,R18
	std y+4,R19
	.dbline 182
;         
;         if (chCTR & BIT(0))
	sbrs R20,0
	rjmp L36
X5:
	.dbline 183
;         {
	.dbline 185
;             //设置X坐标
;             g_chCMDBuffer[2] |= BIT(0);
	lds R24,_g_chCMDBuffer+2
	ori R24,1
	sts _g_chCMDBuffer+2,R24
	.dbline 187
;             
;             TYPE_CONVERSION(&g_chCMDBuffer[3],float) = 
	ldd R16,y+1
	ldd R17,y+2
	ldd R18,y+3
	ldd R19,y+4
	rcall _cosf
	movw R2,R16
	movw R4,R18
	movw R30,R22
	ldd R6,z+1
	ldd R7,z+2
	ldd R8,z+3
	ldd R9,z+4
	ldi R16,<L40
	ldi R17,>L40
	rcall lpm32
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	rcall fpmule2x
	movw R16,R6
	movw R18,R8
	rcall fpadd2
	ldi R30,<_g_chCMDBuffer+3
	ldi R31,>_g_chCMDBuffer+3
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	.dbline 190
;                 TYPE_CONVERSION(&pcData[1],float) + 
;                 RELATIVE_L * cos(fAbsoluteAngle);
;         }
L36:
	.dbline 191
;         if (chCTR & BIT(1))
	sbrs R20,1
	rjmp L41
X6:
	.dbline 192
;         {
	.dbline 194
;             //设置Y坐标
;             g_chCMDBuffer[2] |= BIT(1);
	lds R24,_g_chCMDBuffer+2
	ori R24,2
	sts _g_chCMDBuffer+2,R24
	.dbline 195
;             TYPE_CONVERSION(&g_chCMDBuffer[7],float) = 
	ldd R16,y+1
	ldd R17,y+2
	ldd R18,y+3
	ldd R19,y+4
	rcall _sinf
	movw R2,R16
	movw R4,R18
	movw R30,R22
	ldd R6,z+5
	ldd R7,z+6
	ldd R8,z+7
	ldd R9,z+8
	ldi R16,<L40
	ldi R17,>L40
	rcall lpm32
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	rcall fpmule2x
	movw R16,R6
	movw R18,R8
	rcall fpadd2
	ldi R30,<_g_chCMDBuffer+7
	ldi R31,>_g_chCMDBuffer+7
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	.dbline 198
;                 TYPE_CONVERSION(&pcData[5],float) +
;                 RELATIVE_L * sin(fAbsoluteAngle);
;         }
L41:
	.dbline 200
;         
;         if (chCTR & 0x07)
	mov R24,R20
	andi R24,7
	breq L45
X7:
	.dbline 201
;         {
	.dbline 202
;             UINT8 n = 0;
	.dbline 203
;             BYTE chXOR = 0;
	clr R10
	.dbline 205
;             
;             for (n = 1;n < 15;n++)
	ldi R20,1
	rjmp L50
L47:
	.dbline 206
;             {
	.dbline 207
;                 chXOR ^= g_chCMDBuffer[n];
	ldi R24,<_g_chCMDBuffer
	ldi R25,>_g_chCMDBuffer
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	eor R10,R2
	.dbline 208
;             }
L48:
	.dbline 205
	inc R20
L50:
	.dbline 205
	cpi R20,15
	brlo L47
X8:
	.dbline 209
;             g_chCMDBuffer[15] = chXOR;
	sts _g_chCMDBuffer+15,R10
	.dbline 211
;         
;             SAFE_CODE_PERFORMANCE
	.dbline 211
	in R10,0x3f
	.dbline 211
	cli
	.dbline 211
	ldi R24,1
	sts _g_bIfSendCMD,R24
	.dbline 211
	clr R2
	sts _g_bIfStartCMD,R2
	.dbline 211
	sts _g_bIfSendHead,R2
	.dbline 211
	.dbline 211
	out 0x3f,R10
	.dbline 211
	.dbline 217
;             (
;                 g_bIfSendCMD = TRUE;
;                 g_bIfStartCMD = FALSE;
;                 g_bIfSendHead = FALSE;
;             )
;         }
L45:
	.dbline 219
; 
;     }
	.dbline 222
;     
;     
;     Send_MSG(COM_CMD_SET,NULL,0);
	clr R2
	std y+0,R2
	clr R18
	clr R19
	ldi R16,161
	rcall _Send_MSG
	.dbline 224
;     
;     return TRUE;
	ldi R16,1
	.dbline -2
L27:
	.dbline 0 ; func end
	adiw R28,5
	rjmp pop_xgsetF00C
	.dbsym r cflags0 10 c
	.dbsym r n1 20 c
	.dbsym r chXOR0 10 c
	.dbsym l fAbsoluteAngle0 1 D
	.dbsym r chCTR0 20 c
	.dbsym r pcData 22 pc
	.dbsym r pMsgItem 20 pS[MsgItem]
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\单片机\ROOBCO~1\全向定位系统\坐标转换模块\相对定位模块应用版\Relative_Locate_Module\Communication_LIB.c
_SFPLocateModuleShellMsgItem::
	.blkb 32
	.dbsym e SFPLocateModuleShellMsgItem _SFPLocateModuleShellMsgItem A[32:32]c
_SFPLocateModuleShellBuffer::
	.blkb 32
	.dbsym e SFPLocateModuleShellBuffer _SFPLocateModuleShellBuffer A[32:32]c
_SFPLocateModuleShell::
	.blkb 37
	.dbsym e SFPLocateModuleShell _SFPLocateModuleShell S[SerialFrameProcess]
_MSGMapLocateModuleShellItemArray::
	.blkb 6
	.dbsym e MSGMapLocateModuleShellItemArray _MSGMapLocateModuleShellItemArray A[6:2]S[MsgMapItem]
_MSGMapLocateModuleShell::
	.blkb 3
	.dbsym e MSGMapLocateModuleShell _MSGMapLocateModuleShell S[MsgMap]
	.area lit(rom, con, rel)
L40:
	.word 0x8000,0x4317
L35:
	.word 0xfdb,0x4049
L33:
	.word 0xfdb,0x3bc9
; }
	.area  func_lit
PL_UARTaddDataToTxBuff:	.word `_UARTaddDataToTxBuff
PL_UARTgetDataFromRxBuff:	.word `_UARTgetDataFromRxBuff
PL_SFP_NULL_Peek_Data_Function:	.word `_SFP_NULL_Peek_Data_Function
PL_SFP_NULL_Output_Data_Function:	.word `_SFP_NULL_Output_Data_Function
PL_SFP_NULL_Input_Data_Function:	.word `_SFP_NULL_Input_Data_Function
PL_ADT_Queue_Peek_From_Buffer:	.word `_ADT_Queue_Peek_From_Buffer
PL_ADT_Queue_Check_Empty:	.word `_ADT_Queue_Check_Empty
PL_ADT_Queue_Get_From_Buffer:	.word `_ADT_Queue_Get_From_Buffer
PL_ADT_Queue_Add_To_Buffer:	.word `_ADT_Queue_Add_To_Buffer
PL_MSGMap_Acknowledge:	.word `_MSGMap_Acknowledge
PL_MSGMap_Set:	.word `_MSGMap_Set
PL_MSG_NULL_PROC:	.word `_MSG_NULL_PROC

⌨️ 快捷键说明

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