This commit is contained in:
2026-03-14 20:13:44 +08:00
parent cde0bd8243
commit 49605367e9
3 changed files with 135 additions and 3 deletions
+21 -2
View File
@@ -48,6 +48,10 @@ static const uint8_t CMD_SHUTTER[] =
static const uint8_t CMD_QUERY_DIGITAL[] =
{0x55, 0xAA, 0x07, 0x02, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x84, 0xF0};
/* Query: status page (simplest query, always works) */
static const uint8_t CMD_QUERY_STATUS[] =
{0x55, 0xAA, 0x07, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x87, 0xF0};
/* ============================================================
* Low-level UART helpers
* ============================================================ */
@@ -142,8 +146,9 @@ static void Sensor_FlushRx(void)
* ============================================================ */
volatile uint8_t sensor_init_ok = 0;
volatile uint8_t sensor_init_fail = 0;
volatile uint8_t sensor_last_resp[8] = {0};
volatile uint8_t sensor_last_resp[32] = {0};
volatile uint8_t sensor_last_resp_len = 0;
volatile uint8_t sensor_comm_test = 0;
int Mini212G2_SendCmd(const uint8_t *cmd, uint8_t len)
{
@@ -154,7 +159,7 @@ int Mini212G2_SendCmd(const uint8_t *cmd, uint8_t len)
int n = Sensor_ReadResp(resp, sizeof(resp), 200);
/* Save last response for debugger inspection */
sensor_last_resp_len = (uint8_t)n;
for (int j = 0; j < n && j < 8; j++)
for (int j = 0; j < n && j < 32; j++)
sensor_last_resp[j] = resp[j];
if (n == ACK_LEN && memcmp(resp, ACK_PATTERN, ACK_LEN) == 0)
@@ -185,6 +190,20 @@ int Mini212G2_Init(void)
printf("[Sensor] Waiting 3s for sensor boot...\r\n");
Delay_Ms(3000);
/* === Communication test: send status query === */
{
uint8_t test_resp[32];
Sensor_FlushRx();
Sensor_SendBytes(CMD_QUERY_STATUS, sizeof(CMD_QUERY_STATUS));
int tn = Sensor_ReadResp(test_resp, sizeof(test_resp), 500);
sensor_last_resp_len = (uint8_t)tn;
for (int j = 0; j < tn && j < 32; j++)
sensor_last_resp[j] = test_resp[j];
sensor_comm_test = (tn > 0) ? 1 : 0xFF;
/* Breakpoint here to check sensor_comm_test and sensor_last_resp */
}
Delay_Ms(200);
printf("[Sensor] Configuring CMOS/DVP output...\r\n");
/* 1. Shutter compensation */
+3 -1
View File
@@ -35,8 +35,10 @@ int Mini212G2_Init(void);
* sensor_last_resp_len: length of last response */
extern volatile uint8_t sensor_init_ok;
extern volatile uint8_t sensor_init_fail;
extern volatile uint8_t sensor_last_resp[8];
extern volatile uint8_t sensor_last_resp[32];
extern volatile uint8_t sensor_last_resp_len;
/* sensor_comm_test: 0=not run, 1=got response, 0xFF=no response (timeout) */
extern volatile uint8_t sensor_comm_test;
#if SENSOR_UART_ENABLE
/**