From 311b02828095db5fbbc279a35d3a86cec432586f Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:12:18 +0800 Subject: [PATCH 01/15] add tp9950 driver --- src/camera.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ src/hardware.c | 29 ++++++++++++++++ src/hardware.h | 1 + src/i2c_device.h | 2 +- 4 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/camera.c b/src/camera.c index 16199bef..7e03b137 100644 --- a/src/camera.c +++ b/src/camera.c @@ -1,4 +1,5 @@ #include "camera.h" +#include "common.h" #include "dm6300.h" #include "global.h" #include "hardware.h" @@ -54,6 +55,92 @@ void camera_ratio_detect(void) { camRatio = 0; } +#ifdef USE_TP9950 +void camera_mode_detect(uint8_t init) { + + uint32_t frame = 0; + uint32_t agc_en = 0; + uint8_t id = 0; + + TC3587_RSTB = 0; + WAIT(100); + TC3587_RSTB = 1; + WAIT(100); + + 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"); + I2C_Write8(ADDR_TP9950, 0x26, 0x01); + I2C_Write8(ADDR_TP9950, 0x07, 0xC0); + I2C_Write8(ADDR_TP9950, 0x0B, 0xC0); + I2C_Write8(ADDR_TP9950, 0x22, 0x35); + agc_en = I2C_Read8(ADDR_TP9950, 0x06); + agc_en &= 0xFB; + I2C_Write8(ADDR_TP9950, 0x06, agc_en); + + while (1) { + I2C_Write8(ADDR_TP9950, 0x02, 0xca); + I2C_Write8(ADDR_TP9950, 0x0b, 0xc0); + I2C_Write8(ADDR_TP9950, 0x0c, 0x03); + I2C_Write8(ADDR_TP9950, 0x0d, 0x50); + I2C_Write8(ADDR_TP9950, 0x15, 0x13); + I2C_Write8(ADDR_TP9950, 0x16, 0x16); + I2C_Write8(ADDR_TP9950, 0x17, 0x00); + I2C_Write8(ADDR_TP9950, 0x18, 0x19); + I2C_Write8(ADDR_TP9950, 0x19, 0xD0); + I2C_Write8(ADDR_TP9950, 0x1a, 0x25); + I2C_Write8(ADDR_TP9950, 0x20, 0x30); + I2C_Write8(ADDR_TP9950, 0x21, 0x84); + I2C_Write8(ADDR_TP9950, 0x22, 0x36); + I2C_Write8(ADDR_TP9950, 0x23, 0x3c); + I2C_Write8(ADDR_TP9950, 0x26, 0x05); + I2C_Write8(ADDR_TP9950, 0x2b, 0x60); + I2C_Write8(ADDR_TP9950, 0x2c, 0x0a); + I2C_Write8(ADDR_TP9950, 0x2d, 0x30); + I2C_Write8(ADDR_TP9950, 0x2e, 0x70); + I2C_Write8(ADDR_TP9950, 0x30, 0x48); + I2C_Write8(ADDR_TP9950, 0x31, 0xbb); + I2C_Write8(ADDR_TP9950, 0x32, 0x2e); + I2C_Write8(ADDR_TP9950, 0x33, 0x90); + I2C_Write8(ADDR_TP9950, 0x39, 0x1c); + I2C_Write8(ADDR_TP9950, 0x3B, 0x26); + I2C_Write8(ADDR_TP9950, 0x18, 0x19); + I2C_Write8(ADDR_TP9950, 0x40, 0x08); + I2C_Write8(ADDR_TP9950, 0x13, 0x04); + I2C_Write8(ADDR_TP9950, 0x14, 0x04); + I2C_Write8(ADDR_TP9950, 0x40, 0x00); + I2C_Write8(ADDR_TP9950, 0x35, 0x05); + I2C_Write8(ADDR_TP9950, 0xfa, 0x08); + I2C_Write8(ADDR_TP9950, 0x4C, 0x40); + I2C_Write8(ADDR_TP9950, 0x4e, 0x05); + + I2C_Write8(ADDR_TP9950, 0x1c, 0x06); + I2C_Write8(ADDR_TP9950, 0x1d, 0x72); + // **** soft reset **** // + I2C_Write8(ADDR_TP9950, 0x06, 0xb2); + + WAIT(CAM_DET_DLY); + frame = I2C_Read8(ADDR_TP9950, 0x01); + debugf("\r\n720P60 0x01 = %2x", (uint16_t)frame); + if (frame == 0x7E) { + video_format = VDO_FMT_720P60; + camera_type = CAMERA_TYPE_OUTDATED; + LED_BLUE_ON; + led_status = ON; + break; + } + } + RF_BW = BW_27M; + RF_BW_last = RF_BW; +} +#else void camera_mode_detect(uint8_t init) { uint8_t cycles = 4; uint8_t loss = 0; @@ -157,6 +244,7 @@ void camera_mode_detect(uint8_t init) { debugf("27M"); #endif } +#endif void camera_button_init() { WriteReg(0, 0x17, 0xC0); diff --git a/src/hardware.c b/src/hardware.c index 267d0823..c874c260 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -143,6 +143,26 @@ void Set_720P60(uint8_t page) { WriteReg(page, 0x06, 0x01); } +void Set_720P60_8bit(uint8_t page) { + WriteReg(page, 0x21, 0x1F); + + WriteReg(page, 0x40, 0x00); + WriteReg(page, 0x41, 0x2A); + WriteReg(page, 0x42, 0xD0); + WriteReg(page, 0x43, 0xE4); + WriteReg(page, 0x44, 0x4C); + WriteReg(page, 0x45, 0xEE); + WriteReg(page, 0x49, 0x04); + WriteReg(page, 0x4c, 0x19); + WriteReg(page, 0x4f, 0x86); + WriteReg(page, 0x52, 0x04); + WriteReg(page, 0x53, 0x00); + WriteReg(page, 0x54, 0x3C); + WriteReg(0, 0x8e, 0x04); + + WriteReg(page, 0x06, 0x01); +} + void Set_960x720P60(uint8_t page) { WriteReg(page, 0x21, 0x1C); @@ -491,7 +511,11 @@ void Init_HW() { SPI_Init(); LED_Init(); #ifdef VIDEO_PAT +#ifdef USE_TP9950 + Set_720P60_8bit(0); +#else Set_720P60(0); +#endif WriteReg(0, 0x50, 0x01); RF_FREQ = 0; GetVtxParameter(); @@ -1102,10 +1126,15 @@ void video_detect(void) { } cameraLost = (ReadReg(0, 0x02) >> 4) & 1; + if (camera_type == CAMERA_TYPE_OUTDATED) + return; if (sec == 3) { sec = 0; if (cameraLost) { // video loss +#ifdef _DEBUG_CAMERA + debugf("r\ncamera lost"); +#endif if (video_format == VDO_FMT_720P50) { Set_720P60(IS_RX); video_format = VDO_FMT_720P60; diff --git a/src/hardware.h b/src/hardware.h index 57500239..70c5e60b 100644 --- a/src/hardware.h +++ b/src/hardware.h @@ -89,6 +89,7 @@ void Set_960x720P60(uint8_t page); void Set_720P30(uint8_t page, uint8_t is_43); void Set_540P60(uint8_t page); void Set_1080P30(uint8_t page); +void Set_720P60_8bit(uint8_t page); void Flicker_LED(uint8_t n); void LED_Flip(); diff --git a/src/i2c_device.h b/src/i2c_device.h index c0bf67c9..571d02cb 100644 --- a/src/i2c_device.h +++ b/src/i2c_device.h @@ -6,7 +6,7 @@ #define ADDR_MAX7315 0x20 // Rev1 Rev3 #define ADDR_PCA9554 0x38 // Rev2 -#define ADDR_TP2825 0x44 +#define ADDR_TP9950 0x44 #define ADDR_TC3587 0x0E #define ADDR_EEPROM 0x50 #define ADDR_TEMPADC 0x48 From ca2cfd29c86be5e773aa65f883489aba729069ce Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:00:31 +0800 Subject: [PATCH 02/15] LED_BLUE_OFF if no ahd camera is detected --- src/camera.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/camera.c b/src/camera.c index 7e03b137..e0259e88 100644 --- a/src/camera.c +++ b/src/camera.c @@ -135,6 +135,9 @@ void camera_mode_detect(uint8_t init) { LED_BLUE_ON; led_status = ON; break; + } else { + LED_BLUE_OFF; + led_status = OFF; } } RF_BW = BW_27M; From 8108ef126ff5174fee4101fc223e1bc63aa39b98 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:28:01 +0800 Subject: [PATCH 03/15] Update common.h --- src/common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common.h b/src/common.h index 1276cd8d..97ad578c 100644 --- a/src/common.h +++ b/src/common.h @@ -85,6 +85,8 @@ // #define _DEBUG_SPI // #define _DEBUG_TRAMP #endif +#define USE_TP9950 +#define USE_TEMPERATURE_SENSOR #define Raceband #define USE_EFUSE From f951128d0067b843be0d23a04004b79d8ac3361e Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:27:11 +0800 Subject: [PATCH 04/15] do not detect camera resolution --- src/camera.c | 100 +++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 55 deletions(-) diff --git a/src/camera.c b/src/camera.c index 16b45cdf..3502da06 100644 --- a/src/camera.c +++ b/src/camera.c @@ -90,61 +90,51 @@ void camera_mode_detect(uint8_t init) { agc_en &= 0xFB; I2C_Write8(ADDR_TP9950, 0x06, agc_en); - while (1) { - I2C_Write8(ADDR_TP9950, 0x02, 0xca); - I2C_Write8(ADDR_TP9950, 0x0b, 0xc0); - I2C_Write8(ADDR_TP9950, 0x0c, 0x03); - I2C_Write8(ADDR_TP9950, 0x0d, 0x50); - I2C_Write8(ADDR_TP9950, 0x15, 0x13); - I2C_Write8(ADDR_TP9950, 0x16, 0x16); - I2C_Write8(ADDR_TP9950, 0x17, 0x00); - I2C_Write8(ADDR_TP9950, 0x18, 0x19); - I2C_Write8(ADDR_TP9950, 0x19, 0xD0); - I2C_Write8(ADDR_TP9950, 0x1a, 0x25); - I2C_Write8(ADDR_TP9950, 0x20, 0x30); - I2C_Write8(ADDR_TP9950, 0x21, 0x84); - I2C_Write8(ADDR_TP9950, 0x22, 0x36); - I2C_Write8(ADDR_TP9950, 0x23, 0x3c); - I2C_Write8(ADDR_TP9950, 0x26, 0x05); - I2C_Write8(ADDR_TP9950, 0x2b, 0x60); - I2C_Write8(ADDR_TP9950, 0x2c, 0x0a); - I2C_Write8(ADDR_TP9950, 0x2d, 0x30); - I2C_Write8(ADDR_TP9950, 0x2e, 0x70); - I2C_Write8(ADDR_TP9950, 0x30, 0x48); - I2C_Write8(ADDR_TP9950, 0x31, 0xbb); - I2C_Write8(ADDR_TP9950, 0x32, 0x2e); - I2C_Write8(ADDR_TP9950, 0x33, 0x90); - I2C_Write8(ADDR_TP9950, 0x39, 0x1c); - I2C_Write8(ADDR_TP9950, 0x3B, 0x26); - I2C_Write8(ADDR_TP9950, 0x18, 0x19); - I2C_Write8(ADDR_TP9950, 0x40, 0x08); - I2C_Write8(ADDR_TP9950, 0x13, 0x04); - I2C_Write8(ADDR_TP9950, 0x14, 0x04); - I2C_Write8(ADDR_TP9950, 0x40, 0x00); - I2C_Write8(ADDR_TP9950, 0x35, 0x05); - I2C_Write8(ADDR_TP9950, 0xfa, 0x08); - I2C_Write8(ADDR_TP9950, 0x4C, 0x40); - I2C_Write8(ADDR_TP9950, 0x4e, 0x05); - - I2C_Write8(ADDR_TP9950, 0x1c, 0x06); - I2C_Write8(ADDR_TP9950, 0x1d, 0x72); - // **** soft reset **** // - I2C_Write8(ADDR_TP9950, 0x06, 0xb2); - - WAIT(CAM_DET_DLY); - frame = I2C_Read8(ADDR_TP9950, 0x01); - debugf("\r\n720P60 0x01 = %2x", (uint16_t)frame); - if (frame == 0x7E) { - video_format = VDO_FMT_720P60; - camera_type = CAMERA_TYPE_OUTDATED; - LED_BLUE_ON; - led_status = ON; - break; - } else { - LED_BLUE_OFF; - led_status = OFF; - } - } + I2C_Write8(ADDR_TP9950, 0x02, 0xca); + I2C_Write8(ADDR_TP9950, 0x0b, 0xc0); + I2C_Write8(ADDR_TP9950, 0x0c, 0x03); + I2C_Write8(ADDR_TP9950, 0x0d, 0x50); + I2C_Write8(ADDR_TP9950, 0x15, 0x13); + I2C_Write8(ADDR_TP9950, 0x16, 0x16); + I2C_Write8(ADDR_TP9950, 0x17, 0x00); + I2C_Write8(ADDR_TP9950, 0x18, 0x19); + I2C_Write8(ADDR_TP9950, 0x19, 0xD0); + I2C_Write8(ADDR_TP9950, 0x1a, 0x25); + I2C_Write8(ADDR_TP9950, 0x20, 0x30); + I2C_Write8(ADDR_TP9950, 0x21, 0x84); + I2C_Write8(ADDR_TP9950, 0x22, 0x36); + I2C_Write8(ADDR_TP9950, 0x23, 0x3c); + I2C_Write8(ADDR_TP9950, 0x26, 0x05); + I2C_Write8(ADDR_TP9950, 0x2b, 0x60); + I2C_Write8(ADDR_TP9950, 0x2c, 0x0a); + I2C_Write8(ADDR_TP9950, 0x2d, 0x30); + I2C_Write8(ADDR_TP9950, 0x2e, 0x70); + I2C_Write8(ADDR_TP9950, 0x30, 0x48); + I2C_Write8(ADDR_TP9950, 0x31, 0xbb); + I2C_Write8(ADDR_TP9950, 0x32, 0x2e); + I2C_Write8(ADDR_TP9950, 0x33, 0x90); + I2C_Write8(ADDR_TP9950, 0x39, 0x1c); + I2C_Write8(ADDR_TP9950, 0x3B, 0x26); + I2C_Write8(ADDR_TP9950, 0x18, 0x19); + I2C_Write8(ADDR_TP9950, 0x40, 0x08); + I2C_Write8(ADDR_TP9950, 0x13, 0x04); + I2C_Write8(ADDR_TP9950, 0x14, 0x04); + I2C_Write8(ADDR_TP9950, 0x40, 0x00); + I2C_Write8(ADDR_TP9950, 0x35, 0x05); + I2C_Write8(ADDR_TP9950, 0xfa, 0x08); + I2C_Write8(ADDR_TP9950, 0x4C, 0x40); + I2C_Write8(ADDR_TP9950, 0x4e, 0x05); + + I2C_Write8(ADDR_TP9950, 0x1c, 0x06); + I2C_Write8(ADDR_TP9950, 0x1d, 0x72); + // **** soft reset **** // + I2C_Write8(ADDR_TP9950, 0x06, 0xb2); + + video_format = VDO_FMT_720P60; + camera_type = CAMERA_TYPE_OUTDATED; + LED_BLUE_ON; + led_status = ON; + RF_BW = BW_27M; RF_BW_last = RF_BW; } From 793913ca9db4fa59f5f6b5eb9ee489d43e2fce7d Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 15 Dec 2023 09:18:21 +0800 Subject: [PATCH 05/15] add new vtx hdzero_pico --- platformio.ini | 1 + src/camera.c | 2 ++ src/common.h | 7 +++++-- targets/hdzero_pico.ini | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 targets/hdzero_pico.ini diff --git a/platformio.ini b/platformio.ini index 2bce6806..4a3a151f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,4 +20,5 @@ extra_configs = targets/foxeer_vtx.ini targets/hdzero_race_v3.ini targets/hdzero_freestyle_v2.ini + targets/hdzero_pico.ini \ No newline at end of file diff --git a/src/camera.c b/src/camera.c index 4f9d3c0d..d425b877 100644 --- a/src/camera.c +++ b/src/camera.c @@ -67,6 +67,8 @@ void camera_mode_detect(uint8_t init) { uint32_t agc_en = 0; uint8_t id = 0; + init = 0; + TC3587_RSTB = 0; WAIT(100); TC3587_RSTB = 1; diff --git a/src/common.h b/src/common.h index 97ad578c..e11da577 100644 --- a/src/common.h +++ b/src/common.h @@ -16,6 +16,7 @@ // #define FOXEER_VTX // #define HDZERO_RACE_V3 // #define HDZERO_FREESTYLE_V2 +// #define HDZERO_PICO /* define VTX ID start */ #if defined HDZERO_WHOOP @@ -34,6 +35,8 @@ #define VTX_ID 0x5a #elif defined HDZERO_FREESTYLE_V2 #define VTX_ID 0x5b +#elif defined HDZERO_PICO +#define VTX_ID 0x5c #else #define VTX_ID 0x00 #endif @@ -55,6 +58,8 @@ #define VTX_NAME "HDZ RACE V3" #elif defined HDZERO_FREESTYLE_V2 #define VTX_NAME "HDZ FREESTYLE V2" +#elif defined HDZERO_PICO +#define VTX_NAME "HDZ PICO" #else #define VTX_NAME " " #endif @@ -85,8 +90,6 @@ // #define _DEBUG_SPI // #define _DEBUG_TRAMP #endif -#define USE_TP9950 -#define USE_TEMPERATURE_SENSOR #define Raceband #define USE_EFUSE diff --git a/targets/hdzero_pico.ini b/targets/hdzero_pico.ini new file mode 100644 index 00000000..7f063491 --- /dev/null +++ b/targets/hdzero_pico.ini @@ -0,0 +1,8 @@ +[env:hdzero_pico] +extends = DM5680 +build_flags = + ${DM5680.build_flags} + -DHDZERO_PICO + -DUSE_TC3587_RSTB + -DUSE_TP9950 + -DUSE_TEMPERATURE_SENSOR \ No newline at end of file From 8afe0ee8601884218f57124a0a2fc7ca180f0d87 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 25 Dec 2023 10:55:26 +0800 Subject: [PATCH 06/15] optimized pico vtx _RF_CALIB --- src/camera.c | 11 +++++++++++ src/common.h | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/camera.c b/src/camera.c index d425b877..8359ad08 100644 --- a/src/camera.c +++ b/src/camera.c @@ -139,6 +139,17 @@ void camera_mode_detect(uint8_t init) { RF_BW = BW_27M; RF_BW_last = RF_BW; + +#ifdef _RF_CALIB + WAIT(1000); + if (I2C_Read8(ADDR_TP9950, 0x01) != 0x7E) { // if camera lost + WriteReg(0, 0x50, 0x01); // set to video pattern + } + RF_POWER = 0; + RF_FREQ = 0; + Init_6300RF(RF_FREQ, RF_POWER); + DM6300_AUXADC_Calib(); +#endif } #else void camera_mode_detect(uint8_t init) { diff --git a/src/common.h b/src/common.h index e11da577..73dfdd37 100644 --- a/src/common.h +++ b/src/common.h @@ -120,9 +120,8 @@ #define WAIT_SA_CONFIG 3 #endif -#define CFG_TO_SEC 10 -#define CAM_DET_DLY 1000 -#define DISP_TIME 3 // 3/8s +#define CFG_TO_SEC 10 +#define DISP_TIME 3 // 3/8s // gpio #define SCL P0_0 From 4123e80ed3a232f689b9c2ac72db87da4754e373 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 29 Dec 2023 10:42:15 +0800 Subject: [PATCH 07/15] add HDZero ECO VTX --- platformio.ini | 2 +- src/common.h | 8 ++++---- targets/{hdzero_pico.ini => hdzero_eco.ini} | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename targets/{hdzero_pico.ini => hdzero_eco.ini} (77%) diff --git a/platformio.ini b/platformio.ini index 4a3a151f..8a226f5e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,5 +20,5 @@ extra_configs = targets/foxeer_vtx.ini targets/hdzero_race_v3.ini targets/hdzero_freestyle_v2.ini - targets/hdzero_pico.ini + targets/hdzero_eco.ini \ No newline at end of file diff --git a/src/common.h b/src/common.h index 73dfdd37..ba1f46a7 100644 --- a/src/common.h +++ b/src/common.h @@ -16,7 +16,7 @@ // #define FOXEER_VTX // #define HDZERO_RACE_V3 // #define HDZERO_FREESTYLE_V2 -// #define HDZERO_PICO +// #define HDZERO_ECO /* define VTX ID start */ #if defined HDZERO_WHOOP @@ -35,7 +35,7 @@ #define VTX_ID 0x5a #elif defined HDZERO_FREESTYLE_V2 #define VTX_ID 0x5b -#elif defined HDZERO_PICO +#elif defined HDZERO_ECO #define VTX_ID 0x5c #else #define VTX_ID 0x00 @@ -58,8 +58,8 @@ #define VTX_NAME "HDZ RACE V3" #elif defined HDZERO_FREESTYLE_V2 #define VTX_NAME "HDZ FREESTYLE V2" -#elif defined HDZERO_PICO -#define VTX_NAME "HDZ PICO" +#elif defined HDZERO_ECO +#define VTX_NAME "HDZ ECO" #else #define VTX_NAME " " #endif diff --git a/targets/hdzero_pico.ini b/targets/hdzero_eco.ini similarity index 77% rename from targets/hdzero_pico.ini rename to targets/hdzero_eco.ini index 7f063491..ae2f4ecb 100644 --- a/targets/hdzero_pico.ini +++ b/targets/hdzero_eco.ini @@ -1,8 +1,8 @@ -[env:hdzero_pico] +[env:hdzero_eco] extends = DM5680 build_flags = ${DM5680.build_flags} - -DHDZERO_PICO + -DHDZERO_ECO -DUSE_TC3587_RSTB -DUSE_TP9950 -DUSE_TEMPERATURE_SENSOR \ No newline at end of file From 93d1417cab9eed0a93eb3cbc553aa2a0f7e133b6 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:38:40 +0800 Subject: [PATCH 08/15] set eco camera ratio to 4:3 --- src/camera.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/camera.c b/src/camera.c index 8359ad08..76f9a61a 100644 --- a/src/camera.c +++ b/src/camera.c @@ -54,6 +54,11 @@ void camera_ratio_detect(void) { case CAMERA_TYPE_RUNCAM_NANO_90: camRatio = 1; break; +#ifdef HDZERO_ECO + case CAMERA_TYPE_OUTDATED: + camRatio = 1; + break; +#endif default: camRatio = 0; break; @@ -134,6 +139,7 @@ void camera_mode_detect(uint8_t init) { video_format = VDO_FMT_720P60; camera_type = CAMERA_TYPE_OUTDATED; + camera_ratio_detect(); LED_BLUE_ON; led_status = ON; From 3c47f443feb0760f1e11b9c0b60d750f60be82f7 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:21:34 +0800 Subject: [PATCH 09/15] aio ioconfig --- src/common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.h b/src/common.h index ba1f46a7..36062783 100644 --- a/src/common.h +++ b/src/common.h @@ -124,14 +124,14 @@ #define DISP_TIME 3 // 3/8s // gpio -#define SCL P0_0 +#define SCL P0_2 #define SDA P0_1 -#define CAM_SCL P0_0 +#define CAM_SCL P0_2 #define CAM_SDA P0_1 #ifdef USE_PA_EN #define PA_EN P0_2 #elif !defined USE_TC3587_LED -#define LED_1 P0_2 +#define LED_1 P0_0 #endif #if defined USE_SMARTAUDIO_SW #define SUART_PORT P0_3 From a3a832f4dc8f6556ce222c2403c286257e06c7e7 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 9 May 2024 14:34:17 +0800 Subject: [PATCH 10/15] add aio target; add usb_det_task() --- platformio.ini | 1 + src/camera.c | 3 ++- src/common.h | 12 +++++++++--- src/hardware.c | 16 +++++++++++++++- src/hardware.h | 4 +++- src/mcu.c | 4 ++++ targets/hdzero_aio.ini | 7 +++++++ 7 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 targets/hdzero_aio.ini diff --git a/platformio.ini b/platformio.ini index 8a226f5e..3e8bbf1d 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 76f9a61a..772c081f 100644 --- a/src/camera.c +++ b/src/camera.c @@ -73,11 +73,12 @@ void camera_mode_detect(uint8_t init) { uint8_t id = 0; init = 0; - +#ifdef USE_TC3587_RSTB TC3587_RSTB = 0; WAIT(100); TC3587_RSTB = 1; WAIT(100); +#endif Set_720P60_8bit(0); diff --git a/src/common.h b/src/common.h index 36062783..c344df37 100644 --- a/src/common.h +++ b/src/common.h @@ -37,6 +37,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 +62,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 @@ -124,19 +128,21 @@ #define DISP_TIME 3 // 3/8s // gpio -#define SCL P0_2 +#define SCL P0_0 #define SDA P0_1 -#define CAM_SCL P0_2 +#define CAM_SCL P0_0 #define CAM_SDA P0_1 #ifdef USE_PA_EN #define PA_EN P0_2 #elif !defined USE_TC3587_LED -#define LED_1 P0_0 +#define LED_1 P0_2 #endif #if defined USE_SMARTAUDIO_SW #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 34b13775..705e7678 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1681,4 +1681,18 @@ void RF_Delay_Init() { } DM6300_AUXADC_Calib(); } -} \ No newline at end of file +} + +#ifdef USE_USB_DET +void usb_det_task() { + if (USB_DET == 1) { + // Turn off 63400 + // TODO + while (USB_DET == 1) { + WAIT(1); + } + // reset 5680 + // TODO + } +} +#endif \ No newline at end of file diff --git a/src/hardware.h b/src/hardware.h index 9076af8a..92d0689e 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 208ad414..089bbe55 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 00000000..a7ff630f --- /dev/null +++ b/targets/hdzero_aio.ini @@ -0,0 +1,7 @@ +[env:hdzero_aio] +extends = DM5680 +build_flags = + ${DM5680.build_flags} + -DHDZERO_AIO + -DUSE_TP9950 + -DUSE_USB_DET \ No newline at end of file From 022edba61263152c8dbf5872f71b0e13cd2ffe02 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 9 May 2024 17:22:02 +0800 Subject: [PATCH 11/15] add reset_mcu(); --- src/hardware.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 705e7678..94f899e3 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1684,15 +1684,17 @@ void RF_Delay_Init() { } #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) { - // Turn off 63400 - // TODO + WriteReg(0, 0x8F, 0x10); // reset RF_chip while (USB_DET == 1) { WAIT(1); } // reset 5680 - // TODO + reset_mcu(); } } #endif \ No newline at end of file From c5a92d15b3f7f4c97c3e7c51ead3474451a189bb Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 9 May 2024 17:25:28 +0800 Subject: [PATCH 12/15] turn off blue led if usb is detected --- src/hardware.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hardware.c b/src/hardware.c index 94f899e3..5dae1f78 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1689,6 +1689,7 @@ 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); From 2690f4c75695abacb03ebdf731f8f7f8e52437b8 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 9 May 2024 17:36:04 +0800 Subject: [PATCH 13/15] fix camera ratio for aio --- src/camera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/camera.c b/src/camera.c index 772c081f..ea75b405 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; From 6ad1590a8caa3e506717ab9f9f94912393a65b23 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 9 May 2024 17:43:46 +0800 Subject: [PATCH 14/15] fix merge issue --- src/camera.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/camera.c b/src/camera.c index e7605bef..964d8e1b 100644 --- a/src/camera.c +++ b/src/camera.c @@ -73,16 +73,12 @@ void camera_mode_detect(uint8_t init) { uint8_t id = 0; init = 0; -<<<<<<< HEAD -#ifdef USE_TC3587_RSTB - == == == = ->>>>>>> main - TC3587_RSTB = 0; +#ifdef USE_TC3587_RSTB + TC3587_RSTB = 0; WAIT(100); TC3587_RSTB = 1; WAIT(100); -<<<<<<< HEAD #endif Set_720P60_8bit(0); @@ -95,9 +91,8 @@ void camera_mode_detect(uint8_t init) { WAIT(200); debugf("\r\nCamDetect"); - == == == = - Set_720P60_8bit(0); + Set_720P60_8bit(0); #ifdef _DEBUG_MODE debugf("\r\nchipID"); @@ -113,7 +108,6 @@ void camera_mode_detect(uint8_t init) { #endif WAIT(200); ->>>>>>> main I2C_Write8(ADDR_TP9950, 0x26, 0x01); I2C_Write8(ADDR_TP9950, 0x07, 0xC0); I2C_Write8(ADDR_TP9950, 0x0B, 0xC0); From 2cd8c24dd7c2e6c251178aebc05b8ea8f8c27a85 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Sat, 11 May 2024 11:17:16 +0800 Subject: [PATCH 15/15] fix aio temperature --- src/hardware.c | 3 +++ targets/hdzero_aio.ini | 1 + 2 files changed, 4 insertions(+) diff --git a/src/hardware.c b/src/hardware.c index 7e4e4422..7b2de069 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; diff --git a/targets/hdzero_aio.ini b/targets/hdzero_aio.ini index a7ff630f..96f3db03 100644 --- a/targets/hdzero_aio.ini +++ b/targets/hdzero_aio.ini @@ -4,4 +4,5 @@ build_flags = ${DM5680.build_flags} -DHDZERO_AIO -DUSE_TP9950 + -DUSE_TEMPERATURE_SENSOR -DUSE_USB_DET \ No newline at end of file