You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

458 lines
18 KiB

C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 1
C51 COMPILER V9.54, COMPILATION OF MODULE DEBUG_DRV
OBJECT MODULE PLACED IN ..\out\debug_drv.obj
COMPILER INVOKED BY: E:\KeilC51\C51\BIN\C51.EXE ..\source\debug\debug_drv.c LARGE OMF2 OPTIMIZE(0,SIZE) BROWSE ORDER NOI
-NTPROMOTE INCDIR(..\source\bsp;..\source\msp;..\source\app;..\source\clib;..\source\cpu;..\source\ctask;..\source\tpc;..
-\source\asp;..\source\debug;..\source\msp\uart;..\source\msp\simiic;..\source\bsp\oled;..\source\bsp\TTSSbsp) DEBUG PRIN
-T(..\out\debug_drv.lst) TABS(2) OBJECT(..\out\debug_drv.obj)
line level source
1 /*****************************************************************************
2 * debug_drv.c: debug app
3 *
4 * Copyright(C) 2013, cc
5 * All rights reserved.
6 *
7 * History
8 * 2013.05.24 ver 1.00 Prelimnary version, first Release
9 *
10
11
12 if(ts_s2b_debug.idle)
13 {
14 ts_s2b_debug.idle = 0;
15 printf("\r\n O");
16 if(ts_s2b_debug.len > 0)
17 {
18 //// L1_uartD_sendArrayhex((U8 *)&ts_s2b_debug.t, 5);
19 /// xxxx///提取协议
20 /// if(debgu) ts_s2b_debug.ok =1;
21
22 printf("\r\n len = %d",(int)ts_s2b_debug.len);
23 ts_s2b_debug.len = 0;
24 }
25 }
26
27
28 ******************************************************************************/
29
30 #include "debug_drv.h"
*** WARNING C320 IN LINE 51 OF ..\source\bsp\TTSSbsp\bsp_config.h: "MainFre_22M"
31 #include "msp_iicMx.h"
32 #include "c_type51.h"
33 #include "tpc_road.h"
34 ///#include "bsp_lora_jx.h"
35 ///#include "bsp_lora.h"
36
37 #include "msp_eeprom.h"
38
39 TS_P_debug *pd = NULL;
40 TS_P_rs485 *pd485 = NULL;
41
42 u8 L3_tpc_D2uart(u8 cmd,u8 num)
43 {
44 1 if(cmd == 0x0D)
45 1 {////D2。。。。 透传给串口2的数据
46 2
47 2 if(2 == num)////发送D2 11 22 33的指令后 解析完D2,给串口2 发送11 22 33
48 2 {
49 3 printf1("\r\n - >2: %D ",(int)ts_Urec[D_UART1].num);
50 3 /// D_lora_wakeup();
51 3 /// L1_uart2_Array(&ts_Urec[D_UART1].sp[1], ts_Urec[D_UART1].num-1);
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 2
52 3 L0_uartN_Arrayhex_withoutbuf(D_UART1,&ts_Urec[D_UART1].sp[1], ts_Urec[D_UART1].num-1);
53 3 }else if(3 == num)
54 2 { printfs("\r\n->3:");
55 3 ////L1_uart3_Array(&ts_Urec[D_UART1].sp[1], ts_Urec[D_UART1].num-1);
56 3 }else if(4 == num)
57 2 { printfs("\r\n->4:");
58 3 ////L1_uart4_Array(&ts_Urec[D_UART1].sp[1], ts_Urec[D_UART1].num-1);
59 3 }else
60 2 {
61 3 printfs("\r\nmust in(D2,D3,D4):");
62 3 }
63 2 return 0;
64 2 }
65 1 return 0;
66 1 }
67
68 ////通过debug串口 透传协议
69 #if 0
u8 L3_tpc_hex(void)
{
u8 cmd=0, num=0;
cmd = D_uc_high(ts_Urec[D_UART1].sp[0]);////为485 调整 第一个
num = D_uc_low(ts_Urec[D_UART1].sp[0]);
printf(" 1->cmd=%X num=%X len = %d ",(int)cmd,(int)num, (int)ts_Urec[D_UART1].num);
////debug协议使用串口1 故而再次简单解析 要求第一个字符必须为Fx
if(0x0F == cmd)///fx r1 r2 r3 r4 ocr
{
///TS_P_debug
///printfs("\r\n cmd = ");
////pd = (TS_P_debug*)ts_Urec[D_UART1].sp;
L0_uartN_Arrayhex_withoutbuf(D_UART1,&ts_Urec[D_UART1].sp[0], ts_Urec[D_UART1].num);////(U8 *)&pd,错��
-�的表达方式 pd就是地址
if(num == 0x0e)
{
/// L3_tpc_FEdebug();return 0;
}
return 1;
}
if(L3_tpc_D2uart(cmd,num))
{
return 1;
}
else
{
return 0;
}
printfs("\r\n cmd error!!");
return 0;
}
#else
103 u8 L3_tpc_hex(void)
104 {
105 1 u8 filter = 0, slaveId = 0, cmd = 0;
106 1 filter = ts_Urec[D_UART1].sp[0];
107 1 slaveId = ts_Urec[D_UART1].sp[1];
108 1 cmd = ts_Urec[D_UART1].sp[2];
109 1 //printf(" 1->filter=%X slaveId=%X cmd=%X len = %d ",(int)filter,(int)slaveId, (int)cmd, (int)ts_Urec[D_U
-ART1].num);
110 1
111 1 ////debug协议使用串口1 故而再次简单解析 要求第一个字符必须为AA
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 3
112 1 ///AA 02 10 00 02 A3 B4 6C
113 1 if(0xAA == filter)
114 1 {
115 2 //L0_uartN_Arrayhex_withoutbuf(D_UART1,&ts_Urec[D_UART1].sp[0], ts_Urec[D_UART1].num);
116 2 if(0x02 == slaveId)
117 2 {
118 3 // if(ocr)
119 3 return 1;
120 3 }
121 2 }
122 1 // printfs("\r\n cmd error!!");
123 1 return 0;
124 1 }
125 #endif
126
127
128 ////启动透传指令 开关打开 可以模拟当前串口发送
129 vtype L2_debug_ONcomand(void)
130 {
131 1 if(1 == ts_Urec[D_UART1].debugok)
132 1 {
133 2 ts_Urec[D_UART1].debugok = 0;////解析协议
134 2 /// printf("\r\nw ts_Urec[D_UART1].max = %d num = %d",(int)ts_Urec[D_UART1].rmax,(int)ts_Urec[D_UART1].n
-um);
135 2 // printf1("\r\ndebugok %2x",(int)ts_Urec[D_UART1].debugok);
136 2 }
137 1
138 1 if(1 == ts_Urec[D_UART1].ok)
139 1 {
140 2 ts_Urec[D_UART1].ok = 0;////解析协议
141 2
142 2 //// printf1("\r\nD_UART1 ok %d ",(int) ts_Urec[D_UART1].num);
143 2 // D_LED1_REV();
144 2
145 2 pd485 = (TS_P_rs485 *)ts_Urecbuf.r1;
146 2
147 2 /// L0_uartN_Arrayhex_withoutbuf(D_UART1,ts_Urecbuf.r1, ts_Urec[D_UART1].num);
148 2 /// 串口1的协议分两类 1类是 Fx开头的针对外设x的标准debug协议;例如FD开头是��
-�统debug Fc是iic调试设备
149 2 /// 一类是Dx开头的对串口x透传协议 ////D2。。。。 透传给串口2的数据
150 2 return L3_tpc_hex();///
151 2 /// return 0;
152 2 }
153 1
154 1 /*********
155 1 if(1 == ts_Urec[D_UART2].ok)
156 1 { ts_Urec[D_UART2].ok = 0;////收到一帧数据
157 1 printf("\r\nUART2:rec: ");
158 1 ///sprintf(," %s ",ts_Urecbuf.r2);
159 1 //pd = (TS_P_debug*)ts_Urecbuf.r2;////
160 1 //L1_uartD_sendArrayhex((char *)pd, ts_Urec[D_UART2].num);
161 1 L1_uartD_Arrayhex(ts_Urecbuf.r2, ts_Urec[D_UART2].num);
162 1 Lc_buf_copy_uc(ts_Urecbuf.r5,ts_Urecbuf.r2,ts_Urec[D_UART2].num);
163 1 return L3_tpc_lora(ts_Urecbuf.r5);///
164 1 }
165 1 *********/
166 1
167 1 #ifdef D_USE_UART3
if(1 == ts_Urec[D_UART3].ok)
{ ts_Urec[D_UART3].ok = 0;////解析协议
printfs("\r\nD_UART3 ok ");
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 4
//pd = (TS_P_debug*)ts_Urecbuf.r2;////
//L1_uartD_sendArrayhex((char *)pd, ts_Urec[D_UART2].num);
L1_uartD_Arrayhex(ts_Urecbuf.r3, ts_Urec[D_UART3].num);
}
#else
177 1 #warning "CC: without uart3"
*** WARNING C320 IN LINE 177 OF ..\source\debug\debug_drv.c: "CC: without uart3"
178 1
179 1 #endif///D_USE_UART33
180 1
181 1 #ifdef D_USE_UART4
if(1 == ts_Urec[D_UART4].ok)
{ ts_Urec[D_UART4].ok = 0;////解析协议
printfs("\r\nD_UART3 ok ");
//pd = (TS_P_debug*)ts_Urecbuf.r2;////
//L1_uartD_sendArrayhex((char *)pd, ts_Urec[D_UART2].num);
L1_uartD_Arrayhex(ts_Urecbuf.r4, ts_Urec[D_UART4].num);
}
#else
191 1 #warning "CC: without uart4"
*** WARNING C320 IN LINE 191 OF ..\source\debug\debug_drv.c: "CC: without uart4"
192 1 #endif///D_USE_UART4
193 1 return 0;
194 1 }
195
196 void L3_test_ONdebug(u8 filter)//// ON listen function
197 {
198 1 if(filter == pd->filter)
199 1 {///filter num d1 d2 d3 ....dn
200 2 //// FD 08 11 22 33 44 55 66 77 88
201 2 printfs("\r\nDdebug:FD R1 R2 R3 R4 ocr FD->");
202 2
203 2 switch (pd->ocr)
204 2 { case 0x11:////Fd 11 22 33 44 55 66 11
205 3
206 3 if(pd->R6 == 0x66)
207 3 {///gb2312
208 4 printf(" \r\n \r\n准备烧写,确认主机版本+22M晶振+监测波特率921600 后使用download \
-r\n ");
209 4 printf(" \r\n \r\n 3秒内点击 下载按钮 \r\n ");
210 4
211 4 Lc_delay_ms(1000);
212 4 printf(" \r\n3\r\n ");
213 4 Lc_delay_ms(1000);
214 4 printf(" \r\n2\r\n ");
215 4 Lc_delay_ms(1000);
216 4 printf(" \r\n1\r\n ");
217 4 L0_IAP_enter_ISP();///BITN_1(IAP_CONTR, BITN6|BITN5);
218 4 }else
219 3 {
220 4 printf(" \r\n烧写命令错误\r\n ");///gb2312
221 4 }
222 3 break;
223 3 case 0x22:
224 3 ///FD 13 01 33 44 50 /// P13 =1
225 3 ///FX R1 R2 R3 R4 ocr
226 3 ///FD R1 R2 R3 R4 ocr
227 3 ///FD ch adr reg 12
228 3 ///FD 01 AE 09 44 22 读取 iic第一通道的01 | 地址AE的设备 | 寄存器09
229 3 pd->ocr = L2_IICMx_Read1Reg1D(pd->R1,pd->R2,pd->R3);
230 3 printf4("22 ch:(%2X)-%2X S %2X=%2X\r\n",(int)pd->R1,(int)pd->R2,(int)pd->R3,(int)pd->ocr);
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 5
231 3 break;
232 3 case 0x23:
233 3 ///FD 13 01 33 50 /// P13 =1
234 3 ///FX R1 R2 R3 R4 ocr
235 3 ///FX R1 R2 R3 R4 ocr
236 3 ///FD ch adr reg dat 12
237 3 ///FD 01 AE 09 04 23 iic第一通道的01 | 地址AE的设备 | 寄存器09 写入 04
238 3 printf4("23 ch:(%2X)-%2X W %2X=%2X\r\n",(int)pd->R1,(int)pd->R2,(int)pd->R3,(int)pd->R4);
239 3 L2_IICMx_WriteCmd(pd->R1,pd->R2,pd->R3,pd->R4);
240 3 break;
241 3
242 3
243 3 default:
244 3 printfs(" pp error\r\n ");
245 3
246 3 break;
247 3 };
248 2
249 2 printfs("333");
250 2 }
251 1 }
252
253 ///#define D_keil_sim
254 #ifdef D_keil_sim
void UartInit(void) //9600bps@11.0592MHz
{
SCON = 0x50; //8位数�?可变波特�?
AUXR |= 0x01; //串口1选择定时�?为波特率发生�?
AUXR |= 0x04; //定时�?时钟为Fosc,�?T
T2L = 0xE0; //设定定时初� �?
T2H = 0xFE; //设定定时初�?
AUXR |= 0x10; //启动定时�?
}
void L3_debug_drv_init(void)
{
Ts_debug.uxrev = D_ts_uartX_rev;
Ts_debug.td = (TS_P_debug *)Ts_debug.uxrev->buf;
Ts_debug.ok = &Ts_debug.uxrev->debugok;
UartInit();
}
char putchar(char ch)
{
SBUF = ch;
while(TI == 0);
TI = 0;
return ch;
}
#else
286 #warning "CC: putchar ok"
*** WARNING C320 IN LINE 286 OF ..\source\debug\debug_drv.c: "CC: putchar ok"
287
288 void L3_debug_drv_init(void)
289 {
290 1 /// D_s2b_road1_init();
291 1 }
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 6
292
293 char putchar(char ch)
294 {
295 1 /* Place your implementation of fputc here */
296 1 /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
297 1 /// HAL_UART_Transmit_IT(&huart4, (uint8_t *)&ch, 1);
298 1 L1_uartD_uc(ch);
299 1 return ch;
300 1 ///SBUF= ch;
301 1 /// while(t)
302 1 /// while(!TI);
303 1 // TI = 0;
304 1 /// return (SBUF = ch);
305 1 }
306 #endif ///#ifdef D_keil_sim
307
308 #if 0
void L3_debug_drv_init(void)
{
L0pf_send_uc = L0_uart0_uc;
Lc_print("\r\n debug shell init:\t");
/// io ���õı�׼д��
Lc_print("Mode:");
#ifdef D_debug_time
Lc_print(" debug");
#else
//D_debug_time_using
Lc_print(" normal");
#endif
}
#ifdef D_debug_sim
fff
void L3_debug_cycle(void)
{
INTERRUPT_UART();
TIMER0_IRQHandler();
}
#else
#endif
void L3_test_debug(u8 filter)
{
if(filter == Ts_debug.td->filter)
{///filter num d1 d2 d3 ....dn
//// FD 08 11 22 33 44 55 66 77 88
L1_uartD_sendArrayhex(Ts_debug.td,Ts_debug.td->R1);
}
}
void L3_iicx_debug(u8 filter)
{
if(filter == Ts_debug.td->filter)
{
if(0x10 == Ts_debug.td->ocr)///read reg1 num 读取reg1地址中的num个数�?
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 7
{
//NUM: 0 1 2 3 4
// Fx R1 R2 R3 ocr
// sla reg1 num
/// f1 32 15 06 10
//NUM: 0 1 2 3 4
// Fx R1 R2 R3 ocr
// sla reg1 num
/// f1 32 0x28 06 10
/// f1 32 0x28 06 10
/// 28
/// 0010 1000 28
/// 1010 1000 a8
L2_IICM1_ReadReg(Ts_debug.td->R1,Ts_debug.td->R2,Ts_debug.d,Ts_debug.td->R3);
///printf("\r\n 0x%2x 0x%2x\r\n",(int)Ts_debug.d[0],(int)Ts_debug.d[1]);
L1_uartD_sendArrayhex(Ts_debug.d,Ts_debug.td->R3);
/// printf("\r\n 0x%2x\r\n",(int)Ts_debug.td->ocr);
}
else if(0x11 == Ts_debug.td->ocr)
{
L2_IICM1_ReadReg(Ts_debug.td->R1,Ts_debug.td->R2,Ts_debug.d,Ts_debug.td->R3);
//printf("\r\n 0x%2x 0x%2x\r\n",(int)Ts_debug.d[0],(int)Ts_debug.d[1]);
//L1_uartD_sendArrayhex(Ts_debug.d,Ts_debug.td->R3);
printf("\r\n 0x%2x 0x%2x\r\n",(int)Ts_debug.d[0],(int)Ts_debug.d[1]);
}
else if(0x12 == Ts_debug.td->ocr)
{
}
else
{
}
}
}
#else
395
396
397
398 #endif
399
400
401
402 /******************************************************************************
403 ** End Of File
404 ******************************************************************************/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 969 ----
CONSTANT SIZE = 333 ----
XDATA SIZE = 13 ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
C51 COMPILER V9.54 DEBUG_DRV 09/06/2024 11:24:47 PAGE 8
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 4 WARNING(S), 0 ERROR(S)