debug: 增加 Loopback_Test 硬件电气回环自检及对应的调试串口指令 'l'
This commit is contained in:
@@ -150,6 +150,8 @@ void Debug_ProcessCommand(char cmd)
|
||||
RF_DiagnosticMode('t'); // 触发射频连续发射诊断 (绿色爆闪)
|
||||
} else if (cmd == 'r' || cmd == 'R') {
|
||||
RF_DiagnosticMode('r'); // 触发 5 秒射频接收监听诊断
|
||||
} else if (cmd == 'l' || cmd == 'L') {
|
||||
Loopback_Test(); // 触发物理电气回环测试 (短路 P2.1 和 P3.6 自检)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
43
Drivers/rf.c
43
Drivers/rf.c
@@ -355,3 +355,46 @@ void RF_DiagnosticMode(char choice)
|
||||
Uart_SendString("=== RF RX Test End ===\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 电气回环自检测试 (物理短路 P2.1 与 P3.6 自检)
|
||||
* @details 用户通过短路 P2.1 和 P3.6 来实现 GPIO 的物理连通性自检
|
||||
*/
|
||||
void Loopback_Test(void)
|
||||
{
|
||||
u16 match_count = 0;
|
||||
u16 i;
|
||||
|
||||
EAXFR = 1;
|
||||
RF_SetMode(1); // 开启接收芯片
|
||||
Delay_ms(100);
|
||||
|
||||
Uart_SendString("Starting RF Hardware Loopback Test (P2.1 -> P3.6)...\r\n");
|
||||
Uart_SendString("Please use a metal tweezers to short-circuit P2.1 (Pin 22) and P3.6 (Pin 19)!\r\n");
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
RF_TX_DAT = 1;
|
||||
Delay_us(500);
|
||||
if (RF_RX_DATA == 1) match_count++;
|
||||
|
||||
RF_TX_DAT = 0;
|
||||
Delay_us(500);
|
||||
if (RF_RX_DATA == 0) match_count++;
|
||||
}
|
||||
|
||||
Uart_SendString("Loopback Match Count: ");
|
||||
Uart_SendHex16(match_count);
|
||||
Uart_SendString("/200\r\n");
|
||||
|
||||
if (match_count > 150)
|
||||
{
|
||||
Uart_SendString("Result: PASS! Pin P2.1 and P3.6 are electrical connected successfully!\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Uart_SendString("Result: FAIL! GPIO coupling check failed. Short-circuit the pins and test again.\r\n");
|
||||
}
|
||||
|
||||
RF_SetMode(0); // 关断射频
|
||||
}
|
||||
|
||||
@@ -61,4 +61,9 @@ bit EV1527_Decode(u32 *out_addr, u8 *out_data);
|
||||
*/
|
||||
void RF_DiagnosticMode(char choice);
|
||||
|
||||
/**
|
||||
* @brief 电气回环自检测试 (物理短路 P2.1 与 P3.6 自检)
|
||||
*/
|
||||
void Loopback_Test(void);
|
||||
|
||||
#endif // __RF_H__
|
||||
|
||||
Reference in New Issue
Block a user