#ifndef MINI212G2_H_ #define MINI212G2_H_ #include "ch32v30x.h" /* ---- Sensor UART configuration ---- * 模组已通过 USB 预配置,不需要 MCU UART 配置。 * 注意:USART2 (PA2/PA3) 引脚已被占用,不可使用。 * 如需重新启用 MCU UART 配置传感器,将下面的 #if 0 改为 #if 1。 * 启用后仅可使用 USART3 (PB10/PB11),但会占用 printf 调试口。 */ #if 0 /* MCU UART 配置已禁用 */ #define SENSOR_USE_USART3 1 /* 必须用 USART3,USART2 引脚已占用 */ #define SENSOR_UART_ENABLE 1 #define SENSOR_UART USART3 #define SENSOR_UART_BAUD 115200 #else #define SENSOR_USE_USART3 0 #define SENSOR_UART_ENABLE 0 #define SENSOR_UART_BAUD 115200 #endif /** * Initialize sensor. When SENSOR_UART_ENABLE=1, configures via UART. * When SENSOR_UART_ENABLE=0, assumes sensor is pre-configured via USB. * Call BEFORE DVP_Init(). Returns 0 on success. */ int Mini212G2_Init(void); /* Debug variables — inspect via JTAG debugger when printf is unavailable. * sensor_init_ok: number of commands that succeeded * sensor_init_fail: number of commands that failed * sensor_last_resp[]: raw bytes of last failed response * 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[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 /** * Send a raw protocol command and wait for ACK. * Returns 0 on ACK received, -1 on timeout/bad response. */ int Mini212G2_SendCmd(const uint8_t *cmd, uint8_t len); /** * Query current digital video settings. Prints result to debug console. */ void Mini212G2_PrintDigitalVideoStatus(void); /** * Trigger shutter compensation (NUC). */ int Mini212G2_ShutterCompensation(void); #endif /* SENSOR_UART_ENABLE */ #endif