From bba708e59a0438c9153de8e7f54229f3c11b3e62 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:45:06 +0800 Subject: [PATCH 01/22] write and read eeprom --- src/common.h | 2 +- src/mcu.c | 59 ++++++++++++---------------------------------------- 2 files changed, 14 insertions(+), 47 deletions(-) diff --git a/src/common.h b/src/common.h index ba1f46a7..46828046 100644 --- a/src/common.h +++ b/src/common.h @@ -73,7 +73,7 @@ // mode // #define _RF_CALIB -// #define REV_UART +#define REV_UART // #define VIDEO_PAT // #define FIX_EEP // #define RESET_CONFIG diff --git a/src/mcu.c b/src/mcu.c index 208ad414..84a9a729 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -116,60 +116,27 @@ void version_info(void) { } void main(void) { + uint16_t i; + // init CPU_init(); WriteReg(0, 0xB0, 0x3E); WriteReg(0, 0xB2, 0x03); WriteReg(0, 0x80, 0xC8); - // WAIT(100); - version_info(); - Init_HW(); // init - fc_init(); // init displayport - -#ifdef USE_SMARTAUDIO_SW - SA_Init(); -#elif defined USE_TRAMP - tramp_init(); -#endif + WAIT(100); -#ifdef _DEBUG_MODE - Prompt(); +#if (0) + for (i = 0; i < 256; i++) { + I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0xc8); + } +#else + I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0xc8); #endif - + // #else + for (i = 0; i < 256; i++) { + _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); + } // main loop while (1) { - timer_task(); -#if defined USE_SMARTAUDIO_SW - while (SA_task()) - ; -#elif defined USE_SMARTAUDIO_HW - while (SA_task()) { - if (SA_timeout()) - break; - } -#elif defined USE_TRAMP - tramp_receive(); -#endif - -#ifdef _RF_CALIB - CalibProc(); -#elif defined _DEBUG_MODE - Monitor(); -#endif - video_detect(); - OnButton1(); - - if (last_SA_lock && seconds < WAIT_SA_CONFIG) - ; - else { - LED_Task(); - TempDetect(); // temperature dectect - PwrLMT(); // RF power ctrl - msp_task(); - Update_EEP_LifeTime(); - uart_baudrate_detect(); - runcam_shutter_fix(seconds); - } - RF_Delay_Init(); } } \ No newline at end of file From 893cdf9ebe33574ac48e33ce7574191023106d68 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Thu, 11 Jul 2024 09:56:22 +0800 Subject: [PATCH 02/22] only read eeprom --- src/mcu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mcu.c b/src/mcu.c index 84a9a729..7403d270 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -129,7 +129,8 @@ void main(void) { for (i = 0; i < 256; i++) { I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0xc8); } -#else +#endif +#if (0) I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0xc8); #endif // #else From ef857ab7aaa77edd16d2e8963feba7d40ab244c4 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:22:43 +0800 Subject: [PATCH 03/22] Update mcu.c --- src/mcu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mcu.c b/src/mcu.c index 7403d270..b3fb3fb8 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -116,27 +116,29 @@ void version_info(void) { } void main(void) { +#if (1) uint16_t i; + WAIT(100); // init CPU_init(); WriteReg(0, 0xB0, 0x3E); WriteReg(0, 0xB2, 0x03); WriteReg(0, 0x80, 0xC8); - WAIT(100); - +#endif #if (0) for (i = 0; i < 256; i++) { - I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0xc8); + I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0x11); } #endif #if (0) - I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0xc8); + I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); #endif - // #else +#if (0) for (i = 0; i < 256; i++) { _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); } +#endif // main loop while (1) { } From 55ac1a8724b2507af1bf079978486dbd9d011379 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:19:31 +0800 Subject: [PATCH 04/22] debug i2c read --- src/i2c.c | 9 +++++++-- src/mcu.c | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/i2c.c b/src/i2c.c index 2f165e5d..b35c4697 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -4,6 +4,7 @@ #include "common.h" #include "global.h" #include "print.h" +#include "uart.h" #define SCL_SET(n) SCL = n #define SDA_SET(n) SDA = n @@ -115,7 +116,7 @@ uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { I2C_stop(); - value = I2C_Read8(slave_addr, reg_addr); + // value = I2C_Read8(slave_addr, reg_addr); // debugf("\r\n0x%4x, 0x%4x", reg_addr, (uint16_t)val); return 0; } @@ -232,7 +233,11 @@ uint8_t I2C_Read8(uint8_t slave_addr, uint8_t reg_addr) { I2C_start(); - I2C_write_byte(slave); + if (I2C_write_byte(slave)) { + _outchar('X'); + while (1) { + } + } I2C_write_byte(reg_addr); diff --git a/src/mcu.c b/src/mcu.c index b3fb3fb8..833eac09 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -131,15 +131,15 @@ void main(void) { I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0x11); } #endif -#if (0) +#if (1) I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); -#endif -#if (0) - for (i = 0; i < 256; i++) { - _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); - } #endif // main loop while (1) { +#if (1) + for (i = 0; i < 256; i++) { + _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); + } +#endif } } \ No newline at end of file From 91befcbc84b2d79f7630a154a985b95c1020ae28 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:27:21 +0800 Subject: [PATCH 05/22] check nack and return when i2c read --- src/i2c.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/i2c.c b/src/i2c.c index b35c4697..0b4a702d 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -4,7 +4,6 @@ #include "common.h" #include "global.h" #include "print.h" -#include "uart.h" #define SCL_SET(n) SCL = n #define SDA_SET(n) SDA = n @@ -233,11 +232,8 @@ uint8_t I2C_Read8(uint8_t slave_addr, uint8_t reg_addr) { I2C_start(); - if (I2C_write_byte(slave)) { - _outchar('X'); - while (1) { - } - } + if (I2C_write_byte(slave)) // NACK + return 0; I2C_write_byte(reg_addr); From f450978051eb5f907eaf0a953fd2f12e0b95d68f Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:00:42 +0800 Subject: [PATCH 06/22] . --- src/i2c.c | 8 +++++--- src/mcu.c | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/i2c.c b/src/i2c.c index 0b4a702d..5cb972ef 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -97,9 +97,9 @@ uint8_t I2C_write_byte(uint8_t val) { } uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { +#if (1) uint8_t slave = slave_addr << 1; uint8_t value; - I2C_start(); value = I2C_write_byte(slave); @@ -114,7 +114,7 @@ uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { I2C_write_byte(val); I2C_stop(); - +#endif // value = I2C_Read8(slave_addr, reg_addr); // debugf("\r\n0x%4x, 0x%4x", reg_addr, (uint16_t)val); return 0; @@ -232,8 +232,10 @@ uint8_t I2C_Read8(uint8_t slave_addr, uint8_t reg_addr) { I2C_start(); - if (I2C_write_byte(slave)) // NACK + if (I2C_write_byte(slave)) { // NACK + I2C_stop(); return 0; + } I2C_write_byte(reg_addr); diff --git a/src/mcu.c b/src/mcu.c index 833eac09..00eb3d06 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -131,15 +131,15 @@ void main(void) { I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0x11); } #endif -#if (1) +#if (0) I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); #endif - // main loop - while (1) { #if (1) - for (i = 0; i < 256; i++) { - _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); - } + for (i = 0; i < 256; i++) { + _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); + } #endif + // main loop + while (1) { } } \ No newline at end of file From d4828ef6cf570a9644078d0037e4cbd85090e876 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:32:55 +0800 Subject: [PATCH 07/22] add i2c_en --- src/i2c.c | 18 ++++++++++++++++++ src/mcu.c | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/i2c.c b/src/i2c.c index 5cb972ef..59a9510f 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -5,6 +5,8 @@ #include "global.h" #include "print.h" +extern uint8_t I2C_EN; + #define SCL_SET(n) SCL = n #define SDA_SET(n) SDA = n @@ -29,6 +31,9 @@ void delay_10us() { #endif void I2C_start() { + if (!I2C_EN) + return; + SDA_SET(1); DELAY_Q; @@ -44,6 +49,9 @@ void I2C_start() { } void I2C_stop() { + if (!I2C_EN) + return; + SDA_SET(0); DELAY_Q; @@ -58,6 +66,9 @@ void I2C_stop() { uint8_t I2C_ack() { uint8_t ret; + if (!I2C_EN) + return 1; + SDA_SET(1); DELAY_Q; @@ -74,6 +85,10 @@ uint8_t I2C_ack() { uint8_t I2C_write_byte(uint8_t val) { uint8_t i; + + if (!I2C_EN) + return 1; + for (i = 0; i < 8; i++) { if (val >> 7) SDA_SET(1); @@ -196,6 +211,9 @@ uint8_t I2C_read_byte(uint8_t no_ack) { uint8_t i; uint8_t val = 0; + if (!I2C_EN) + return 0; + for (i = 0; i < 8; i++) { DELAY_Q; SCL_SET(1); diff --git a/src/mcu.c b/src/mcu.c index 00eb3d06..6d8a0a8a 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -115,11 +115,16 @@ void version_info(void) { #endif } +uint8_t I2C_EN = 0; + void main(void) { + I2C_EN = 0; #if (1) uint16_t i; - WAIT(100); + WAIT(600); + I2C_EN = 1; + // init CPU_init(); WriteReg(0, 0xB0, 0x3E); From 34038750b171bbce7633e7efd8b62cff8fef15ef Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:33:22 +0800 Subject: [PATCH 08/22] Check eeprom data integrity --- src/dm6300.c | 32 +++++----- src/hardware.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++++- src/hardware.h | 19 +++--- 3 files changed, 192 insertions(+), 25 deletions(-) diff --git a/src/dm6300.c b/src/dm6300.c index 799aced2..062629b9 100644 --- a/src/dm6300.c +++ b/src/dm6300.c @@ -27,14 +27,14 @@ uint8_t dm6300_lost = 0; #if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { // race band - {0x70, 0x68, 0x5c, 0x60}, - {0x70, 0x68, 0x5c, 0x60}, - {0x70, 0x68, 0x60, 0x60}, - {0x72, 0x6d, 0x60, 0x60}, - {0x74, 0x70, 0x62, 0x5c}, - {0x78, 0x74, 0x64, 0x5b}, - {0x7a, 0x77, 0x64, 0x5b}, - {0x7a, 0x77, 0x64, 0x5b}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, + {0x30, 0x50, 0x50, 0x58}, // e band {0x70, 0x68, 0x5c, 0x60}, // E1 // fatshark band @@ -54,14 +54,14 @@ uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { #else uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { // race band - {0x79, 0x83}, - {0x77, 0x81}, - {0x75, 0x80}, - {0x73, 0x7E}, - {0x72, 0x7C}, - {0x70, 0x7B}, - {0x72, 0x7E}, - {0x71, 0x7C}, + {0x5d, 0x66}, + {0x5d, 0x66}, + {0x5d, 0x66}, + {0x5d, 0x66}, + {0x5d, 0x66}, + {0x5d, 0x66}, + {0x5d, 0x66}, + {0x5d, 0x66}, // e band {0x79, 0x83}, // E1 // fatshark band diff --git a/src/hardware.c b/src/hardware.c index c8efcc21..87bab747 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -539,6 +539,7 @@ void Init_HW() { WAIT(100); SPI_Init(); LED_Init(); + check_eeprom(); #ifdef VIDEO_PAT #ifdef USE_TP9950 Set_720P60_8bit(0); @@ -1768,4 +1769,167 @@ uint8_t check_uart_loopback() { return 0; } } -#endif \ No newline at end of file +#endif +void _outstring(char *string) { + uint8_t i = 0; + for (i = 0; i < 128; i++) { + if (string[i] == 0) + break; + else + _outchar(string[i]); + } +} +void check_eeprom() { + const uint8_t tab_base_address[3] = { + EEP_ADDR_TAB1, + EEP_ADDR_TAB2, + EEP_ADDR_TAB3, + }; + const uint8_t dcoc_base_address[3] = { + EEP_ADDR_DCOC1, + EEP_ADDR_DCOC2, + EEP_ADDR_DCOC3, + }; + const uint8_t tab_range[2] = {20, 160}; + const uint8_t dcoc_range[2] = {80, 180}; + + uint8_t tab_list[3][FREQ_NUM_INTERNAL][POWER_MAX + 1]; + uint8_t dcoc_list[3][5]; + uint8_t ff_cnt[3]; + uint8_t i, j, k; + for (i = 0; i < 16; i++) { + I2C_Write8_Wait(10, ADDR_EEPROM, i, 0x11); + } + for (i = 0xc0; i < 0xc5; i++) { + I2C_Write8_Wait(10, ADDR_EEPROM, i, 0x11); + } + + // read all 3 table_power partitions + for (i = 0; i < 3; i++) { + ff_cnt[i] = 0; + for (j = 0; j < FREQ_NUM_INTERNAL; j++) { + for (k = 0; k < POWER_MAX + 1; k++) { + tab_list[i][j][k] = I2C_Read8(ADDR_EEPROM, tab_base_address[i] + j * (POWER_MAX + 1) + k); + _outchar(tab_list[i][j][k]); + ff_cnt[i] += (tab_list[i][j][k] == 0xff); + } + } + } + + // If eeprom is new, init partition 0 with default table_power + if (ff_cnt[0] == (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { + for (j = 0; j < FREQ_NUM_INTERNAL; j++) { + for (k = 0; k < POWER_MAX + 1; k++) { + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + j * (POWER_MAX + 1) + k, table_power[j][k]); + ff_cnt[i] += (tab_list[i][j][k] == 0xff); + } + } + _outstring("\r\nInit tab partition 0"); + } + + // Init partition 1/2 by copy paratition 0 if is needed (one time) + if ((ff_cnt[1] + ff_cnt[2]) > (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { + for (i = 1; i < 3; i++) { + for (j = 0; j < FREQ_NUM_INTERNAL; j++) { + for (k = 0; k < POWER_MAX + 1; k++) { + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[i] + j * (POWER_MAX + 1) + k, tab_list[0][j][k]); + } + } + } + _outstring("\r\nInit tab partition 1, 2"); + } + + // Check the validity of each value + for (i = 0; i < FREQ_NUM_INTERNAL; i++) { + for (j = 0; j < POWER_MAX + 1; j++) { + if (tab_list[0][i][j] == tab_list[1][i][j] && tab_list[1][i][j] == tab_list[2][i][j] && tab_list[0][i][j] > tab_range[0] && tab_list[0][i][j] < tab_range[1]) + // all partition are right + ; + else if (tab_list[0][i][j] == tab_list[1][i][j] && tab_list[1][i][j] != tab_list[2][i][j] && tab_list[0][i][j] > tab_range[0] && tab_list[0][i][j] < tab_range[1]) { + // partition 2 value is error + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[2] + i * (POWER_MAX + 1) + j, tab_list[0][i][j]); + _outstring("\r\ntab2:"); + _outchar('0' + i); + _outchar('0' + j); + } else if (tab_list[0][i][j] == tab_list[2][i][j] && tab_list[1][i][j] != tab_list[2][i][j] && tab_list[0][i][j] > tab_range[0] && tab_list[0][i][j] < tab_range[1]) { + // partition 1 value is error + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[1] + i * (POWER_MAX + 1) + j, tab_list[0][i][j]); + _outstring("\r\ntab1:"); + _outchar('0' + i); + _outchar('0' + j); + } else if (tab_list[0][i][j] != tab_list[2][i][j] && tab_list[1][i][j] == tab_list[2][i][j] && tab_list[1][i][j] > tab_range[0] && tab_list[1][i][j] < tab_range[1]) { + // partition 0 value is error + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + i * (POWER_MAX + 1) + j, tab_list[1][i][j]); + _outstring("\r\ntab0:"); + _outchar('0' + i); + _outchar('0' + j); + } else { + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + i * (POWER_MAX + 1) + j, table_power[i][j]); + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[1] + i * (POWER_MAX + 1) + j, table_power[i][j]); + I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[2] + i * (POWER_MAX + 1) + j, table_power[i][j]); + _outstring("\r\ntab all:"); + _outchar('0' + i); + _outchar('0' + j); + } + } + } + + // read all 3 dcoc partitions + for (i = 0; i < 3; i++) { + ff_cnt[i] = 0; + for (j = 0; j < 5; j++) { + dcoc_list[i][j] = I2C_Read8(ADDR_EEPROM, dcoc_base_address[i] + j); + ff_cnt[i] += (dcoc_list[i][j] == 0xff); + } + } + + // Init partition 1/2 by copy paratition 0 if is needed (one time) + if ((ff_cnt[1] + ff_cnt[2]) > 5) { + for (i = 1; i < 3; i++) { + for (j = 0; j < 5; j++) { + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[i] + j, dcoc_list[0][j]); + } + } + _outstring("\r\nInit dcoc partition 1, 2"); + } + + // Check the validity of each value + if (ff_cnt[0] == 5) + return; + if (dcoc_list[0][0] == dcoc_list[1][0] && dcoc_list[1][0] == dcoc_list[2][0] && dcoc_list[0][0] == 0x00) { + ; + } else { + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[0], 0); + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[1], 0); + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[2], 0); + _outstring("\r\ndcoc en err"); + } + + for (i = 1; i < 5; i++) { + if (dcoc_list[0][i] == dcoc_list[1][i] && dcoc_list[1][i] == dcoc_list[2][i] && dcoc_list[0][i] > dcoc_range[0] && dcoc_list[0][i] < dcoc_range[1]) + // all partition are right + ; + else if (dcoc_list[0][i] == dcoc_list[1][i] && dcoc_list[1][i] != dcoc_list[2][i] && dcoc_list[0][i] > dcoc_range[0] && dcoc_list[0][i] < dcoc_range[1]) { + // partition 2 value is error + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[2] + i, dcoc_list[0][i]); + _outstring("\r\ndcoc2:"); + _outchar('0' + i); + } else if (dcoc_list[0][i] != dcoc_list[1][i] && dcoc_list[1][i] == dcoc_list[2][i] && dcoc_list[1][i] > dcoc_range[0] && dcoc_list[1][i] < dcoc_range[1]) { + // partition 0 value is error + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[0] + i, dcoc_list[1][i]); + _outstring("\r\ndcoc0:"); + _outchar('0' + i); + } else if (dcoc_list[0][i] != dcoc_list[1][i] && dcoc_list[0][i] == dcoc_list[2][i] && dcoc_list[0][i] > dcoc_range[0] && dcoc_list[0][i] < dcoc_range[1]) { + // partition 1 value is error + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[1] + i, dcoc_list[0][i]); + _outstring("\r\ndcoc1:"); + _outchar('0' + i); + } else { + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[0] + i, 128); + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[1] + i, 128); + I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[2] + i, 128); + _outstring("\r\ndcoc all:"); + _outchar('0' + i); + } + } +} \ No newline at end of file diff --git a/src/hardware.h b/src/hardware.h index aa81e69a..73303136 100644 --- a/src/hardware.h +++ b/src/hardware.h @@ -16,17 +16,15 @@ typedef enum { BW_17M } BWType_e; -#define PWR_DEFAULT 2 -#define SPARKLE_T 20 - // eeprom parameter -#define EEP_ADDR_CAM_TYPE 0x40 -#define EEP_ADDR_CAM_PROFILE 0x41 +#define EEP_ADDR_TAB1 0x00 // 0x00 - 0x1F +#define EEP_ADDR_TAB2 0x20 // 0x20 - 0x3F +#define EEP_ADDR_CAM_TYPE 0x40 +#define EEP_ADDR_CAM_PROFILE 0x41 // profile 1: 0x42~0x51 // profile 2: 0x52~0x61 -// profile 2: 0x62~0x71 -#define EEP_ADDR_CAM_SETTING 0x42 - +// profile 3: 0x62~0x71 +#define EEP_ADDR_CAM_SETTING 0x42 #define EEP_ADDR_RF_FREQ 0x80 #define EEP_ADDR_RF_POWER 0x81 #define EEP_ADDR_LPMODE 0x82 @@ -39,11 +37,15 @@ typedef enum { #define EEP_ADDR_BAUDRATE 0x8B #define EEP_ADDR_LOWBAND_LOCK 0x8C #define EEP_ADDR_SHORTCUT 0x8D +#define EEP_ADDR_TAB3 0xA0 // 0xA0 - 0xBF +#define EEP_ADDR_DCOC1 0xC0 // 0xC0 - 0xC4 #define EEP_ADDR_DCOC_EN 0xC0 #define EEP_ADDR_DCOC_IH 0xC1 #define EEP_ADDR_DCOC_IL 0xC2 #define EEP_ADDR_DCOC_QH 0xC3 #define EEP_ADDR_DCOC_QL 0xC4 +#define EEP_ADDR_DCOC2 0xC5 // 0xC5 - 0xC9 +#define EEP_ADDR_DCOC3 0xCA // 0xCA - 0xCE #define EEP_ADDR_LIFETIME_0 0xF0 #define EEP_ADDR_LIFETIME_1 0xF1 #define EEP_ADDR_LIFETIME_2 0xF2 @@ -80,6 +82,7 @@ void GetVtxParameter(); void Setting_Save(); void Imp_RF_Param(); void CFG_Back(); +void check_eeprom(); void Set_720P50(uint8_t page); void Set_720P60(uint8_t page); From 357dab607df9995ca2f0523f8fd828308c2538ee Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:37:06 +0800 Subject: [PATCH 09/22] . --- src/hardware.c | 2 +- src/mcu.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 87bab747..f89f6c3a 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -570,7 +570,7 @@ void Init_HW() { Get_EEP_LifeTime(); camera_init(); - uart_set_baudrate(BAUDRATE); + uart_set_baudrate(0); //--------- dm6300 -------------------- // move to RF_Delay_Init() #endif diff --git a/src/mcu.c b/src/mcu.c index 6d8a0a8a..d6cc9097 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -130,6 +130,7 @@ void main(void) { WriteReg(0, 0xB0, 0x3E); WriteReg(0, 0xB2, 0x03); WriteReg(0, 0x80, 0xC8); + Init_HW(); #endif #if (0) for (i = 0; i < 256; i++) { @@ -139,7 +140,7 @@ void main(void) { #if (0) I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); #endif -#if (1) +#if (0) for (i = 0; i < 256; i++) { _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); } From 53d12a584dd01d836c27a8346fb9f31e596dfa4d Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:37:45 +0800 Subject: [PATCH 10/22] clear debug code --- src/hardware.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 87bab747..e2fa1ef3 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1797,12 +1797,6 @@ void check_eeprom() { uint8_t dcoc_list[3][5]; uint8_t ff_cnt[3]; uint8_t i, j, k; - for (i = 0; i < 16; i++) { - I2C_Write8_Wait(10, ADDR_EEPROM, i, 0x11); - } - for (i = 0xc0; i < 0xc5; i++) { - I2C_Write8_Wait(10, ADDR_EEPROM, i, 0x11); - } // read all 3 table_power partitions for (i = 0; i < 3; i++) { From 246375f9b41de321e5233134e2b79aea993ee211 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:43:17 +0800 Subject: [PATCH 11/22] . --- src/hardware.c | 3 +-- src/mcu.c | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 6fac33d8..9cd5b0ec 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -570,7 +570,7 @@ void Init_HW() { Get_EEP_LifeTime(); camera_init(); - uart_set_baudrate(0); + uart_set_baudrate(BAUDRATE); //--------- dm6300 -------------------- // move to RF_Delay_Init() #endif @@ -1804,7 +1804,6 @@ void check_eeprom() { for (j = 0; j < FREQ_NUM_INTERNAL; j++) { for (k = 0; k < POWER_MAX + 1; k++) { tab_list[i][j][k] = I2C_Read8(ADDR_EEPROM, tab_base_address[i] + j * (POWER_MAX + 1) + k); - _outchar(tab_list[i][j][k]); ff_cnt[i] += (tab_list[i][j][k] == 0xff); } } diff --git a/src/mcu.c b/src/mcu.c index d6cc9097..2a72865c 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -130,7 +130,7 @@ void main(void) { WriteReg(0, 0xB0, 0x3E); WriteReg(0, 0xB2, 0x03); WriteReg(0, 0x80, 0xC8); - Init_HW(); + check_eeprom(); #endif #if (0) for (i = 0; i < 256; i++) { @@ -140,9 +140,10 @@ void main(void) { #if (0) I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); #endif -#if (0) +#if (1) for (i = 0; i < 256; i++) { - _outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); + //_outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); + I2C_Read8_Wait(10, ADDR_EEPROM, i); } #endif // main loop From 5bde99721212bbca664e9e36ce3aa9fcbb12c771 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:41:13 +0800 Subject: [PATCH 12/22] fix check_eeprom() --- src/hardware.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 9cd5b0ec..048858ff 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1810,15 +1810,14 @@ void check_eeprom() { } // If eeprom is new, init partition 0 with default table_power - if (ff_cnt[0] == (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { + /*if (ff_cnt[0] == (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { for (j = 0; j < FREQ_NUM_INTERNAL; j++) { for (k = 0; k < POWER_MAX + 1; k++) { I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + j * (POWER_MAX + 1) + k, table_power[j][k]); - ff_cnt[i] += (tab_list[i][j][k] == 0xff); } } _outstring("\r\nInit tab partition 0"); - } + }*/ // Init partition 1/2 by copy paratition 0 if is needed (one time) if ((ff_cnt[1] + ff_cnt[2]) > (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { @@ -1826,6 +1825,7 @@ void check_eeprom() { for (j = 0; j < FREQ_NUM_INTERNAL; j++) { for (k = 0; k < POWER_MAX + 1; k++) { I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[i] + j * (POWER_MAX + 1) + k, tab_list[0][j][k]); + tab_list[i][j][k] = tab_list[0][j][k]; } } } @@ -1881,6 +1881,7 @@ void check_eeprom() { for (i = 1; i < 3; i++) { for (j = 0; j < 5; j++) { I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[i] + j, dcoc_list[0][j]); + dcoc_list[i][j] = dcoc_list[0][j]; } } _outstring("\r\nInit dcoc partition 1, 2"); From 203def0fb9f4d7e7998c2580e1ab0b96eec9f251 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:41:39 +0800 Subject: [PATCH 13/22] more strict I2C_EN --- src/i2c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/i2c.c b/src/i2c.c index 59a9510f..88fd0caa 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -31,7 +31,7 @@ void delay_10us() { #endif void I2C_start() { - if (!I2C_EN) + if (I2C_EN != 1) return; SDA_SET(1); @@ -49,7 +49,7 @@ void I2C_start() { } void I2C_stop() { - if (!I2C_EN) + if (I2C_EN != 1) return; SDA_SET(0); @@ -66,7 +66,7 @@ void I2C_stop() { uint8_t I2C_ack() { uint8_t ret; - if (!I2C_EN) + if (I2C_EN != 1) return 1; SDA_SET(1); @@ -86,7 +86,7 @@ uint8_t I2C_ack() { uint8_t I2C_write_byte(uint8_t val) { uint8_t i; - if (!I2C_EN) + if (I2C_EN != 1) return 1; for (i = 0; i < 8; i++) { @@ -211,7 +211,7 @@ uint8_t I2C_read_byte(uint8_t no_ack) { uint8_t i; uint8_t val = 0; - if (!I2C_EN) + if (I2C_EN != 1) return 0; for (i = 0; i < 8; i++) { From 60e88214d30ab1c9ae6520d99b5547882832ede4 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:51:46 +0800 Subject: [PATCH 14/22] add I2C_EN --- src/hardware.c | 14 ++++++++------ src/mcu.c | 16 +++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 048858ff..ecafc618 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1809,15 +1809,17 @@ void check_eeprom() { } } - // If eeprom is new, init partition 0 with default table_power - /*if (ff_cnt[0] == (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { +// If eeprom is new, init partition 0 with default table_power +#if (0) + if (ff_cnt[0] == (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { for (j = 0; j < FREQ_NUM_INTERNAL; j++) { for (k = 0; k < POWER_MAX + 1; k++) { I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + j * (POWER_MAX + 1) + k, table_power[j][k]); } } _outstring("\r\nInit tab partition 0"); - }*/ + } +#endif // Init partition 1/2 by copy paratition 0 if is needed (one time) if ((ff_cnt[1] + ff_cnt[2]) > (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { @@ -1860,7 +1862,7 @@ void check_eeprom() { I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + i * (POWER_MAX + 1) + j, table_power[i][j]); I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[1] + i * (POWER_MAX + 1) + j, table_power[i][j]); I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[2] + i * (POWER_MAX + 1) + j, table_power[i][j]); - _outstring("\r\ntab all:"); + _outstring("\r\n tab all:"); _outchar('0' + i); _outchar('0' + j); } @@ -1876,6 +1878,8 @@ void check_eeprom() { } } + if (ff_cnt[0] == 3) + return; // Init partition 1/2 by copy paratition 0 if is needed (one time) if ((ff_cnt[1] + ff_cnt[2]) > 5) { for (i = 1; i < 3; i++) { @@ -1888,8 +1892,6 @@ void check_eeprom() { } // Check the validity of each value - if (ff_cnt[0] == 5) - return; if (dcoc_list[0][0] == dcoc_list[1][0] && dcoc_list[1][0] == dcoc_list[2][0] && dcoc_list[0][0] == 0x00) { ; } else { diff --git a/src/mcu.c b/src/mcu.c index 2a72865c..b1123eb5 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -122,14 +122,20 @@ void main(void) { #if (1) uint16_t i; - WAIT(600); - I2C_EN = 1; - - // init CPU_init(); WriteReg(0, 0xB0, 0x3E); WriteReg(0, 0xB2, 0x03); WriteReg(0, 0x80, 0xC8); + + if (I2C_EN == 0) + I2C_EN = 2; + + WAIT(100); + + if (I2C_EN == 2) + I2C_EN = 1; + + // init check_eeprom(); #endif #if (0) @@ -140,7 +146,7 @@ void main(void) { #if (0) I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); #endif -#if (1) +#if (0) for (i = 0; i < 256; i++) { //_outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); I2C_Read8_Wait(10, ADDR_EEPROM, i); From 0c5da536e8a1b2f48f73fa6e76f756e6be2abc31 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:03:32 +0800 Subject: [PATCH 15/22] check eeprom --- src/common.h | 2 +- src/mcu.c | 54 ++++++++++++++++++++++++++++++++++++++++--- src/msp_displayport.c | 2 +- src/uart.c | 1 + 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/common.h b/src/common.h index 46828046..ba1f46a7 100644 --- a/src/common.h +++ b/src/common.h @@ -73,7 +73,7 @@ // mode // #define _RF_CALIB -#define REV_UART +// #define REV_UART // #define VIDEO_PAT // #define FIX_EEP // #define RESET_CONFIG diff --git a/src/mcu.c b/src/mcu.c index b1123eb5..d3f711ad 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -119,6 +119,7 @@ uint8_t I2C_EN = 0; void main(void) { I2C_EN = 0; + WAIT(1000); #if (1) uint16_t i; @@ -130,8 +131,6 @@ void main(void) { if (I2C_EN == 0) I2C_EN = 2; - WAIT(100); - if (I2C_EN == 2) I2C_EN = 1; @@ -152,7 +151,56 @@ void main(void) { I2C_Read8_Wait(10, ADDR_EEPROM, i); } #endif +#if (1) + version_info(); + Init_HW(); // init + fc_init(); // init displayport + +#ifdef USE_SMARTAUDIO_SW + SA_Init(); +#elif defined USE_TRAMP + tramp_init(); +#endif + +#ifdef _DEBUG_MODE + Prompt(); +#endif + // main loop while (1) { + timer_task(); +#if defined USE_SMARTAUDIO_SW + while (SA_task()) + ; +#elif defined USE_SMARTAUDIO_HW + while (SA_task()) { + if (SA_timeout()) + break; + } +#elif defined USE_TRAMP + tramp_receive(); +#endif + +#ifdef _RF_CALIB + CalibProc(); +#elif defined _DEBUG_MODE + Monitor(); +#endif + video_detect(); + OnButton1(); + + if (last_SA_lock && seconds < WAIT_SA_CONFIG) + ; + else { + LED_Task(); + TempDetect(); // temperature dectect + PwrLMT(); // RF power ctrl + msp_task(); + Update_EEP_LifeTime(); + uart_baudrate_detect(); + runcam_shutter_fix(seconds); + } + RF_Delay_Init(); } -} \ No newline at end of file +#endif +} diff --git a/src/msp_displayport.c b/src/msp_displayport.c index 645af7e0..43693559 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -102,7 +102,7 @@ void parse_get_osd_canvas(void); void msp_tx(uint8_t c) { if (msp_tx_en || seconds > 3) - RS_tx(c); + CMS_tx(c); } uint8_t msp_cmp_fc_variant(const char *variant) { diff --git a/src/uart.c b/src/uart.c index a10a7b5a..1f458740 100644 --- a/src/uart.c +++ b/src/uart.c @@ -29,6 +29,7 @@ volatile BIT_TYPE RS_Xbusy1 = 0; #endif void uart_set_baudrate(uint8_t baudIndex) { + baudIndex = 0; #if defined _DEBUG_MODE || defined _RF_CALIB baudIndex = 0; #endif From e749b525b0c218aa8dad1a48cf7800d6f745acb7 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:35:21 +0800 Subject: [PATCH 16/22] clear dirty code --- src/hardware.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index ecafc618..57c0769c 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -536,10 +536,8 @@ void Init_6300RF(uint8_t freq, uint8_t pwr) { } void Init_HW() { - WAIT(100); SPI_Init(); LED_Init(); - check_eeprom(); #ifdef VIDEO_PAT #ifdef USE_TP9950 Set_720P60_8bit(0); From 5c4ea4bbb1b3ead7ac7f605238070336b1fadbf5 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:42:01 +0800 Subject: [PATCH 17/22] wait 500ms before cpu_init --- src/mcu.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/mcu.c b/src/mcu.c index d3f711ad..a37a6cf3 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -119,9 +119,7 @@ uint8_t I2C_EN = 0; void main(void) { I2C_EN = 0; - WAIT(1000); -#if (1) - uint16_t i; + WAIT(500); CPU_init(); WriteReg(0, 0xB0, 0x3E); @@ -129,29 +127,10 @@ void main(void) { WriteReg(0, 0x80, 0xC8); if (I2C_EN == 0) - I2C_EN = 2; - - if (I2C_EN == 2) I2C_EN = 1; // init check_eeprom(); -#endif -#if (0) - for (i = 0; i < 256; i++) { - I2C_Write8_Wait(10, ADDR_EEPROM, (uint8_t)i, 0x11); - } -#endif -#if (0) - I2C_Write8_Wait(10, ADDR_EEPROM, 0x80, 0x11); -#endif -#if (0) - for (i = 0; i < 256; i++) { - //_outchar(I2C_Read8_Wait(10, ADDR_EEPROM, i)); - I2C_Read8_Wait(10, ADDR_EEPROM, i); - } -#endif -#if (1) version_info(); Init_HW(); // init fc_init(); // init displayport @@ -202,5 +181,4 @@ void main(void) { } RF_Delay_Init(); } -#endif -} +} \ No newline at end of file From b816844ac59eb88b2948445e9acf7339a2379294 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:42:42 +0800 Subject: [PATCH 18/22] modify table_power init value --- src/dm6300.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dm6300.c b/src/dm6300.c index 062629b9..39019046 100644 --- a/src/dm6300.c +++ b/src/dm6300.c @@ -54,14 +54,14 @@ uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { #else uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { // race band - {0x5d, 0x66}, - {0x5d, 0x66}, - {0x5d, 0x66}, - {0x5d, 0x66}, - {0x5d, 0x66}, - {0x5d, 0x66}, - {0x5d, 0x66}, - {0x5d, 0x66}, + {0x50, 0x60}, + {0x50, 0x60}, + {0x50, 0x60}, + {0x50, 0x60}, + {0x50, 0x60}, + {0x50, 0x60}, + {0x50, 0x60}, + {0x50, 0x60}, // e band {0x79, 0x83}, // E1 // fatshark band From 5ac17270d4e43631e932913d30790d7b33144107 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:42:58 +0800 Subject: [PATCH 19/22] clean dirty code --- src/hardware.c | 2 +- src/i2c.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 57c0769c..eaed1fae 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1807,8 +1807,8 @@ void check_eeprom() { } } -// If eeprom is new, init partition 0 with default table_power #if (0) + // If eeprom is new, init partition 0 with default table_power if (ff_cnt[0] == (FREQ_NUM_INTERNAL * (POWER_MAX + 1))) { for (j = 0; j < FREQ_NUM_INTERNAL; j++) { for (k = 0; k < POWER_MAX + 1; k++) { diff --git a/src/i2c.c b/src/i2c.c index 88fd0caa..a911cb33 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -112,7 +112,6 @@ uint8_t I2C_write_byte(uint8_t val) { } uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { -#if (1) uint8_t slave = slave_addr << 1; uint8_t value; I2C_start(); @@ -129,7 +128,6 @@ uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { I2C_write_byte(val); I2C_stop(); -#endif // value = I2C_Read8(slave_addr, reg_addr); // debugf("\r\n0x%4x, 0x%4x", reg_addr, (uint16_t)val); return 0; From 56a95545b292d675ab7b74526600c8ffaa8db304 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:34:50 +0800 Subject: [PATCH 20/22] remove debug print --- src/hardware.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index eaed1fae..92b10aae 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -1768,6 +1768,8 @@ uint8_t check_uart_loopback() { } } #endif + +#if (0) void _outstring(char *string) { uint8_t i = 0; for (i = 0; i < 128; i++) { @@ -1777,6 +1779,7 @@ void _outstring(char *string) { _outchar(string[i]); } } +#endif void check_eeprom() { const uint8_t tab_base_address[3] = { EEP_ADDR_TAB1, @@ -1829,7 +1832,7 @@ void check_eeprom() { } } } - _outstring("\r\nInit tab partition 1, 2"); + //_outstring("\r\nInit tab partition 1, 2"); } // Check the validity of each value @@ -1841,28 +1844,28 @@ void check_eeprom() { else if (tab_list[0][i][j] == tab_list[1][i][j] && tab_list[1][i][j] != tab_list[2][i][j] && tab_list[0][i][j] > tab_range[0] && tab_list[0][i][j] < tab_range[1]) { // partition 2 value is error I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[2] + i * (POWER_MAX + 1) + j, tab_list[0][i][j]); - _outstring("\r\ntab2:"); - _outchar('0' + i); - _outchar('0' + j); + //_outstring("\r\ntab2:"); + // _outchar('0' + i); + //_outchar('0' + j); } else if (tab_list[0][i][j] == tab_list[2][i][j] && tab_list[1][i][j] != tab_list[2][i][j] && tab_list[0][i][j] > tab_range[0] && tab_list[0][i][j] < tab_range[1]) { // partition 1 value is error I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[1] + i * (POWER_MAX + 1) + j, tab_list[0][i][j]); - _outstring("\r\ntab1:"); - _outchar('0' + i); - _outchar('0' + j); + //_outstring("\r\ntab1:"); + //_outchar('0' + i); + //_outchar('0' + j); } else if (tab_list[0][i][j] != tab_list[2][i][j] && tab_list[1][i][j] == tab_list[2][i][j] && tab_list[1][i][j] > tab_range[0] && tab_list[1][i][j] < tab_range[1]) { // partition 0 value is error I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + i * (POWER_MAX + 1) + j, tab_list[1][i][j]); - _outstring("\r\ntab0:"); - _outchar('0' + i); - _outchar('0' + j); + //_outstring("\r\ntab0:"); + //_outchar('0' + i); + //_outchar('0' + j); } else { I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[0] + i * (POWER_MAX + 1) + j, table_power[i][j]); I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[1] + i * (POWER_MAX + 1) + j, table_power[i][j]); I2C_Write8_Wait(10, ADDR_EEPROM, tab_base_address[2] + i * (POWER_MAX + 1) + j, table_power[i][j]); - _outstring("\r\n tab all:"); - _outchar('0' + i); - _outchar('0' + j); + //_outstring("\r\n tab all:"); + //_outchar('0' + i); + //_outchar('0' + j); } } } @@ -1886,7 +1889,7 @@ void check_eeprom() { dcoc_list[i][j] = dcoc_list[0][j]; } } - _outstring("\r\nInit dcoc partition 1, 2"); + //_outstring("\r\nInit dcoc partition 1, 2"); } // Check the validity of each value @@ -1896,7 +1899,7 @@ void check_eeprom() { I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[0], 0); I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[1], 0); I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[2], 0); - _outstring("\r\ndcoc en err"); + //_outstring("\r\ndcoc en err"); } for (i = 1; i < 5; i++) { @@ -1906,24 +1909,24 @@ void check_eeprom() { else if (dcoc_list[0][i] == dcoc_list[1][i] && dcoc_list[1][i] != dcoc_list[2][i] && dcoc_list[0][i] > dcoc_range[0] && dcoc_list[0][i] < dcoc_range[1]) { // partition 2 value is error I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[2] + i, dcoc_list[0][i]); - _outstring("\r\ndcoc2:"); - _outchar('0' + i); + //_outstring("\r\ndcoc2:"); + //_outchar('0' + i); } else if (dcoc_list[0][i] != dcoc_list[1][i] && dcoc_list[1][i] == dcoc_list[2][i] && dcoc_list[1][i] > dcoc_range[0] && dcoc_list[1][i] < dcoc_range[1]) { // partition 0 value is error I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[0] + i, dcoc_list[1][i]); - _outstring("\r\ndcoc0:"); - _outchar('0' + i); + //_outstring("\r\ndcoc0:"); + //_outchar('0' + i); } else if (dcoc_list[0][i] != dcoc_list[1][i] && dcoc_list[0][i] == dcoc_list[2][i] && dcoc_list[0][i] > dcoc_range[0] && dcoc_list[0][i] < dcoc_range[1]) { // partition 1 value is error I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[1] + i, dcoc_list[0][i]); - _outstring("\r\ndcoc1:"); - _outchar('0' + i); + //_outstring("\r\ndcoc1:"); + //_outchar('0' + i); } else { I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[0] + i, 128); I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[1] + i, 128); I2C_Write8_Wait(10, ADDR_EEPROM, dcoc_base_address[2] + i, 128); - _outstring("\r\ndcoc all:"); - _outchar('0' + i); + //_outstring("\r\ndcoc all:"); + //_outchar('0' + i); } } } \ No newline at end of file From d3d663a927f99d6a4c4f45b119518913b6be9c13 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:37:36 +0800 Subject: [PATCH 21/22] Restore uart baudrate --- src/uart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/uart.c b/src/uart.c index 1f458740..a10a7b5a 100644 --- a/src/uart.c +++ b/src/uart.c @@ -29,7 +29,6 @@ volatile BIT_TYPE RS_Xbusy1 = 0; #endif void uart_set_baudrate(uint8_t baudIndex) { - baudIndex = 0; #if defined _DEBUG_MODE || defined _RF_CALIB baudIndex = 0; #endif From 8a5bcc242ba73f600e4adeccaa276f53ffa5fcf5 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:44:03 +0800 Subject: [PATCH 22/22] update table_power default value --- src/dm6300.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/dm6300.c b/src/dm6300.c index 39019046..d162790c 100644 --- a/src/dm6300.c +++ b/src/dm6300.c @@ -24,7 +24,34 @@ uint32_t dcoc_qh = 0x075F0000; uint8_t dm6300_init_done = 0; uint8_t dm6300_lost = 0; -#if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 +#if defined HDZERO_FREESTYLE_V1 +uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { + // race band + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x60, 0x60}, + {0x72, 0x6d, 0x60, 0x60}, + {0x74, 0x70, 0x62, 0x5c}, + {0x78, 0x74, 0x64, 0x5b}, + {0x7a, 0x77, 0x64, 0x5b}, + {0x7a, 0x77, 0x64, 0x5b}, + // e band + {0x70, 0x68, 0x5c, 0x60}, // E1 + // fatshark band + {0x70, 0x68, 0x60, 0x60}, // F1 + {0x72, 0x6d, 0x60, 0x60}, // F2 + {0x74, 0x70, 0x62, 0x5c}, // F4 + // low band + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, + {0x70, 0x68, 0x5c, 0x60}, +}; +#elif defined HDZERO_FREESTYLE_V2 uint8_t table_power[FREQ_NUM_EXTERNAL][POWER_MAX + 1] = { // race band {0x30, 0x50, 0x50, 0x58},