debug: 增加 Loopback_Test 硬件电气回环自检及对应的调试串口指令 'l'

This commit is contained in:
2026-07-29 10:16:05 +08:00
parent a766ada53d
commit 58dfe5bb9c
3 changed files with 50 additions and 0 deletions

View File

@@ -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); // 关断射频
}

View File

@@ -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__