diff --git a/platformio.ini b/platformio.ini index 8a226f5..3e8bbf1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -21,4 +21,5 @@ extra_configs = targets/hdzero_race_v3.ini targets/hdzero_freestyle_v2.ini targets/hdzero_eco.ini + targets/hdzero_aio.ini \ No newline at end of file diff --git a/src/camera.c b/src/camera.c index 923688f..964d8e1 100644 --- a/src/camera.c +++ b/src/camera.c @@ -54,7 +54,7 @@ void camera_ratio_detect(void) { case CAMERA_TYPE_RUNCAM_NANO_90: camRatio = 1; break; -#ifdef HDZERO_ECO +#ifdef USE_TP9950 case CAMERA_TYPE_OUTDATED: camRatio = 1; break; @@ -74,10 +74,23 @@ void camera_mode_detect(uint8_t init) { init = 0; +#ifdef USE_TC3587_RSTB TC3587_RSTB = 0; WAIT(100); TC3587_RSTB = 1; WAIT(100); +#endif + + Set_720P60_8bit(0); + + debugf("\r\nchipID"); + id = I2C_Read8(ADDR_TP9950, 0xfe); + debugf("\r\n fe:%2x", id); + id = I2C_Read8(ADDR_TP9950, 0xff); + debugf("\r\n ff:%2x\r\n", id); + WAIT(200); + + debugf("\r\nCamDetect"); Set_720P60_8bit(0); diff --git a/src/common.h b/src/common.h index ba1f46a..ea2b90b 100644 --- a/src/common.h +++ b/src/common.h @@ -17,6 +17,7 @@ // #define HDZERO_RACE_V3 // #define HDZERO_FREESTYLE_V2 // #define HDZERO_ECO +// #define HDZERO_AIO /* define VTX ID start */ #if defined HDZERO_WHOOP @@ -37,6 +38,8 @@ #define VTX_ID 0x5b #elif defined HDZERO_ECO #define VTX_ID 0x5c +#elif defined HDZERO_AIO +#define VTX_ID 0x5d #else #define VTX_ID 0x00 #endif @@ -60,6 +63,8 @@ #define VTX_NAME "HDZ FREESTYLE V2" #elif defined HDZERO_ECO #define VTX_NAME "HDZ ECO" +#elif defined HDZERO_AIO +#define VTX_NAME "HDZ AIO" #else #define VTX_NAME " " #endif @@ -137,6 +142,8 @@ #define SUART_PORT P0_3 #elif defined USE_TC3587_RSTB #define TC3587_RSTB P0_3 +#elif defined USE_USB_DET +#define USB_DET P0_3 #endif #define CAM_PWM P0_4 #define BTN_1 P0_5 diff --git a/src/hardware.c b/src/hardware.c index c8efcc2..7b2de06 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -606,6 +606,9 @@ void TempDetect() { #ifdef HDZERO_ECO if (temp_new > 10) temp_new -= 10; +#elif defined HDZERO_AIO + if (temp_new > 15) + temp_new -= 15; #endif temperature = temperature - (temperature >> 2) + temp_new; @@ -1723,6 +1726,7 @@ void RF_Delay_Init() { DM6300_AUXADC_Calib(); } } + void reset_config() { RF_FREQ = 0; RF_POWER = 0; @@ -1768,4 +1772,21 @@ uint8_t check_uart_loopback() { return 0; } } +#endif + +#ifdef USE_USB_DET +typedef void (*reset_mcu_ptr)(void); +reset_mcu_ptr reset_mcu = (reset_mcu_ptr)0x0000; + +void usb_det_task() { + if (USB_DET == 1) { + LED_BLUE_OFF; + WriteReg(0, 0x8F, 0x10); // reset RF_chip + while (USB_DET == 1) { + WAIT(1); + } + // reset 5680 + reset_mcu(); + } +} #endif \ No newline at end of file diff --git a/src/hardware.h b/src/hardware.h index d1840f1..466f0b0 100644 --- a/src/hardware.h +++ b/src/hardware.h @@ -102,7 +102,9 @@ void vtx_paralized(void); void timer_task(); void RF_Delay_Init(); - +#ifdef USE_USB_DET +void usb_det_task(); +#endif #if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 extern uint8_t powerLock; #endif diff --git a/src/mcu.c b/src/mcu.c index 208ad41..089bbe5 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -171,5 +171,9 @@ void main(void) { runcam_shutter_fix(seconds); } RF_Delay_Init(); + +#ifdef USE_USB_DET + usb_det_task(); +#endif } } \ No newline at end of file diff --git a/targets/hdzero_aio.ini b/targets/hdzero_aio.ini new file mode 100644 index 0000000..96f3db0 --- /dev/null +++ b/targets/hdzero_aio.ini @@ -0,0 +1,8 @@ +[env:hdzero_aio] +extends = DM5680 +build_flags = + ${DM5680.build_flags} + -DHDZERO_AIO + -DUSE_TP9950 + -DUSE_TEMPERATURE_SENSOR + -DUSE_USB_DET \ No newline at end of file