From 194bc83e859f50e57d7774d42824c5901fdf4676 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:20:39 +0800 Subject: [PATCH 1/6] add HDZ FREESTYLE V2 target --- platformio.ini | 1 + src/common.h | 5 +++ src/dm6300.c | 4 ++- src/dm6300.h | 2 +- src/hardware.c | 35 +++++++++++-------- src/hardware.h | 4 +-- src/msp_displayport.c | 60 ++++++++++++++++++++++----------- src/smartaudio_protocol.c | 8 ++--- targets/hdzero_freestyle_v2.ini | 9 +++++ 9 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 targets/hdzero_freestyle_v2.ini diff --git a/platformio.ini b/platformio.ini index b6c1235..82d6085 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,4 +19,5 @@ extra_configs = targets/hdzero_race_v2.ini targets/foxeer_vtx.ini targets/hdzero_race_v3.ini + targets/hdzero_freestyle_v2.ini \ No newline at end of file diff --git a/src/common.h b/src/common.h index b62fcda..3d0b86f 100644 --- a/src/common.h +++ b/src/common.h @@ -15,6 +15,7 @@ // #define HDZERO_FREESTYLE // #define FOXEER_VTX // #define HDZERO_RACE_V3 +// define HDZERO_FREESTYLE_V2 /* define VTX ID start */ #if defined HDZERO_WHOOP @@ -31,6 +32,8 @@ #define VTX_ID 0x59 #elif defined HDZERO_RACE_V3 #define VTX_ID 0x5a +#elif defined HDZERO_FREESTYLE_V2 +#define VTX_ID 0x5b #else #define VTX_ID 0x00 #endif @@ -50,6 +53,8 @@ #define VTX_NAME "FOX VTX" #elif defined HDZERO_RACE_V3 #define VTX_NAME "HDZ RACE V3" +#elif defined HDZERO_FREESTYLE_V2 +#define VTX_NAME "HDZ FREESTYLE V2" #else #define VTX_NAME " " #endif diff --git a/src/dm6300.c b/src/dm6300.c index cabc32f..2195ce6 100644 --- a/src/dm6300.c +++ b/src/dm6300.c @@ -23,7 +23,7 @@ uint32_t dcoc_ih = 0x075F0000; uint32_t dcoc_qh = 0x075F0000; uint8_t dm6300_init_done = 0; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 uint8_t table_power[FREQ_MAX_EXT + 1][POWER_MAX + 1] = { {0x70, 0x68, 0x5c, 0x60}, {0x70, 0x68, 0x5c, 0x60}, @@ -164,6 +164,8 @@ uint16_t DM6300_GetFreqByChannel(uint8_t const ch) { void DM6300_SetPower(uint8_t pwr, uint8_t freq, uint8_t offset) { #ifdef HDZERO_FREESTYLE uint16_t a_tab[4] = {0x204, 0x11F, 0x21F, 0x31F}; +#elif defined HDZERO_FREESTYLE_V2 + uint16_t a_tab[4] = {0x21F, 0x21F, 0x31F, 0x31F}; #else uint16_t a_tab[2] = {0x21F, 0x41F}; #endif diff --git a/src/dm6300.h b/src/dm6300.h index a8494d1..1872878 100644 --- a/src/dm6300.h +++ b/src/dm6300.h @@ -4,7 +4,7 @@ #include "common.h" #include "hardware.h" -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 #define PIT_POWER 0x18 // 2dbm #else #define PIT_POWER 0x26 diff --git a/src/hardware.c b/src/hardware.c index e4f1221..8bd805e 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -18,7 +18,7 @@ uint8_t KEYBOARD_ON = 0; // avoid conflict between keyboard and cam_control uint8_t EE_VALID = 0; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 uint8_t powerLock = 1; #endif @@ -26,7 +26,7 @@ uint8_t powerLock = 1; // // POWER MODE // -// HDZERO_FREESTYLE +// HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 // 0------------25mW (14dBm) // 1------------200mW (23dBm) // 2------------500mW (27dBm) @@ -349,7 +349,8 @@ void GetVtxParameter() { for (j = 0; j <= POWER_MAX; j++) { table_power[i][j] = tab[i][j]; #ifndef _RF_CALIB -#ifndef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 +#else if (j == 0) // 25mw +3dbm table_power[i][j] += 0xC; #endif @@ -362,7 +363,8 @@ void GetVtxParameter() { table_power[8][j] = tab[3][j]; table_power[9][j] = tab[4][j]; if (j == 0) { // 25mw +3dbm -#ifndef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 +#else table_power[8][j] += 0x0C; table_power[9][j] += 0x0C; #endif @@ -413,7 +415,7 @@ void GetVtxParameter() { #endif #endif -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 // powerLock powerLock = 0x01 & I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_POWER_LOCK); #endif @@ -471,7 +473,7 @@ void Init_6300RF(uint8_t freq, uint8_t pwr) { DM6300_Init(freq, RF_BW); DM6300_SetChannel(freq); #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if ((pwr == 3) && (!g_IS_ARMED)) pwr_lmt_done = 0; else @@ -789,7 +791,11 @@ void HeatProtect() { int16_t temp; #ifdef USE_TEMPERATURE_SENSOR - int16_t temp_max = 0x5A; +#ifdef HDZERO_FREESTYLE_V2 + int16_t temp_max = 95; +#else + int16_t temp_max = 90; +#endif #else int16_t temp_max = 0x5C0; int16_t temp_err_data = 0x700; @@ -833,7 +839,7 @@ void HeatProtect() { debugf("\r\nHeat Protect."); #endif heat_protect = 1; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 WriteReg(0, 0x8F, 0x00); msp_set_vtx_config(POWER_MAX + 1, 0); #else @@ -870,7 +876,7 @@ void PwrLMT() { pwr_tflg = 0; pwr_lmt_sec++; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 // test: power plus every sec if (pwr_lmt_sec >= 3) { if (RF_POWER == 3) { @@ -925,6 +931,7 @@ void PwrLMT() { */ else if (g_IS_ARMED) { // Armed PowerAutoSwitch(); + HeatProtect(); } else { // Disarmed if (PIT_MODE) { /*if(cur_pwr == 0mW) @@ -942,7 +949,7 @@ void PwrLMT() { pwr_tflg = 0; pwr_lmt_sec++; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 // test: power plus every sec if (pwr_lmt_sec >= 3) { if (RF_POWER == 3) { @@ -962,7 +969,7 @@ void PwrLMT() { SPI_Write(0x3, 0x330, 0x31F); // analog offset 1W } } -#endif // HDZERO_FREESTYLE +#endif // HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 #ifdef _DEBUG_MODE debugf("\r\npwr_lmt_sec %x", (uint16_t)pwr_lmt_sec); @@ -1117,7 +1124,7 @@ void Imp_RF_Param() { if (LP_MODE && !g_IS_ARMED) return; #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (RF_POWER == 3 && !g_IS_ARMED) pwr_lmt_done = 0; else @@ -1180,7 +1187,7 @@ void Button1_SP() { RF_POWER = 0; else RF_POWER++; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (powerLock) RF_POWER &= 0x01; #endif @@ -1193,7 +1200,7 @@ void Button1_SP() { cur_pwr = 0; } else { #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (RF_POWER == 3 && !g_IS_ARMED) pwr_lmt_done = 0; else diff --git a/src/hardware.h b/src/hardware.h index 3c0b124..adb22d6 100644 --- a/src/hardware.h +++ b/src/hardware.h @@ -50,7 +50,7 @@ typedef enum { #define FREQ_MAX 7 #define FREQ_MAX_EXT 9 -#if defined HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 #define POWER_MAX 3 #else #define POWER_MAX 1 @@ -97,7 +97,7 @@ void vtx_paralized(void); void timer_task(); -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 extern uint8_t powerLock; #endif extern uint8_t RF_FREQ; diff --git a/src/msp_displayport.c b/src/msp_displayport.c index 4624423..0dda710 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -474,9 +474,31 @@ uint8_t get_tx_data_5680() // prepare data to VRX // VTX temp and overhot #ifdef USE_TEMPERATURE_SENSOR +#if defined HDZERO_FREESTYLE_V2 + temp = temperature >> 2; + if (temp > 90) + temp = 8; + else if (temp > 85) + temp = 7; + else if (temp > 80) + temp = 6; + else if (temp > 75) + temp = 5; + else if (temp > 70) + temp = 4; + else if (temp > 60) + temp = 3; + else if (temp > 50) + temp = 2; + else if (temp > 40) + temp = 1; + else + temp = 0; +#else temp = temperature_level() >> 1; if (temp > 8) temp = 8; +#endif tx_buf[10] = 0x80 | (heat_protect << 6) | temp; #else tx_buf[10] = 0; @@ -723,10 +745,10 @@ void msp_set_vtx_config(uint8_t power, uint8_t save) { uint8_t band; uint16_t const freq = DM6300_GetFreqByChannel(channel); - if (channel < 8) { // race band + if (channel < 8) { // race band band = 5; channel = channel + 1; - } else { // fatshark band + } else { // fatshark band band = 4; if (channel == 8) channel = 2; @@ -769,7 +791,7 @@ void msp_set_vtx_config(uint8_t power, uint8_t save) { crc ^= 0x05; // band count CMS_tx(0x08); crc ^= 0x08; // channel count -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (powerLock) { CMS_tx(3); crc ^= (3); // power count @@ -834,9 +856,9 @@ void parse_rc() { } uint8_t parse_vtx_band_and_channel(uint8_t const band, uint8_t const channel) { - if (band == 5) { // race band + if (band == 5) { // race band return (channel - 1); - } else if (band == 4) { // fatshark band + } else if (band == 4) { // fatshark band if (channel == 2) { return 8; } @@ -862,9 +884,8 @@ uint8_t msp_vtx_set_channel(uint8_t const channel) { void parse_vtx_config() { uint8_t nxt_ch; - //uint8_t const power = msp_rx_buf[3]; - //uint8_t const pitmode = msp_rx_buf[4]; - + // uint8_t const power = msp_rx_buf[3]; + // uint8_t const pitmode = msp_rx_buf[4]; /* nxt_pwr: @@ -873,9 +894,9 @@ void parse_vtx_config() { ..... POWER_MAX+1: 0mw */ - //uint8_t nxt_pwr = 0; - //uint8_t pit_update = 0; - //uint8_t needSaveEEP = 0; + // uint8_t nxt_pwr = 0; + // uint8_t pit_update = 0; + // uint8_t needSaveEEP = 0; fc_lock |= FC_VTX_CONFIG_LOCK; @@ -901,7 +922,6 @@ void parse_vtx_config() { msp_vtx_set_channel(nxt_ch); // PIT_MODE ? // RF_POWER ? - } void msp_set_osd_canvas(void) { @@ -1022,7 +1042,7 @@ void parseMspVtx_V2(uint16_t const cmd_u16) { vtx_pit_save = PIT_MODE; } else { #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if ((RF_POWER == 3) && (!g_IS_ARMED)) pwr_lmt_done = 0; else @@ -1074,7 +1094,7 @@ void parseMspVtx_V2(uint16_t const cmd_u16) { if (dm6300_init_done) { if (cur_pwr != RF_POWER) { #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if ((RF_POWER == 3) && (!g_IS_ARMED)) pwr_lmt_done = 0; else @@ -1393,7 +1413,7 @@ void update_cms_menu(uint16_t roll, uint16_t pitch, uint16_t yaw, uint16_t throt ; else { vtx_power++; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (powerLock) vtx_power &= 0x01; #endif @@ -1407,7 +1427,7 @@ void update_cms_menu(uint16_t roll, uint16_t pitch, uint16_t yaw, uint16_t throt ; else { vtx_power--; -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (powerLock) vtx_power &= 0x01; #endif @@ -1843,7 +1863,7 @@ void set_vtx_param() { debugf("\n\rExit PIT or LP"); #endif #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (RF_POWER == 3 && !g_IS_ARMED) pwr_lmt_done = 0; else @@ -1854,7 +1874,7 @@ void set_vtx_param() { cur_pwr = RF_POWER; } } else if (heat_protect) { -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 WriteReg(0, 0x8F, 0x00); WriteReg(0, 0x8F, 0x01); DM6300_Init(RF_FREQ, RF_BW); @@ -1887,7 +1907,7 @@ void set_vtx_param() { } #ifdef INIT_VTX_TABLE -#define FACTORY_BAND 0 // BF requires band to be CUSTOM with VTX_MSP +#define FACTORY_BAND 0 // BF requires band to be CUSTOM with VTX_MSP CODE_SEG const uint8_t bf_vtx_band_table[6][31] = { /*BOSCAM_A*/ @@ -1943,7 +1963,7 @@ void InitVtxTable() { power_table[0] = bf_vtx_power_table[0]; power_table[1] = bf_vtx_power_table[1]; -#if defined HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (!powerLock) { // if we dont have power lock, enable 500mw and 1W power_table[2] = bf_vtx_power_500mW; diff --git a/src/smartaudio_protocol.c b/src/smartaudio_protocol.c index 2bf41fd..600c7ae 100644 --- a/src/smartaudio_protocol.c +++ b/src/smartaudio_protocol.c @@ -118,7 +118,7 @@ void SA_Response(uint8_t cmd) { tbuf[7] = freq_new_h; // cur_freq_h tbuf[8] = freq_new_l; // cur_freq_l tbuf[9] = SA_dbm; // power dbm -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (powerLock) { tbuf[10] = 1 + 1; // amount of power level for (i = 0; i <= 1; i++) @@ -249,7 +249,7 @@ void SA_Update(uint8_t cmd) { } } else { cur_pwr = dbm_to_pwr(SA_dbm); -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if (powerLock) cur_pwr &= 0x01; #endif @@ -258,7 +258,7 @@ void SA_Update(uint8_t cmd) { pwr_init = cur_pwr; else { #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if ((RF_POWER == 3) && (!g_IS_ARMED)) pwr_lmt_done = 0; else @@ -364,7 +364,7 @@ void SA_Update(uint8_t cmd) { temp_err = 1; } else { #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if ((RF_POWER == 3) && (!g_IS_ARMED)) { pwr_lmt_done = 0; cur_pwr = 3; diff --git a/targets/hdzero_freestyle_v2.ini b/targets/hdzero_freestyle_v2.ini new file mode 100644 index 0000000..882f80c --- /dev/null +++ b/targets/hdzero_freestyle_v2.ini @@ -0,0 +1,9 @@ +[env:hdzero_freestyle_v2] +extends = DM5680 +build_flags = + ${DM5680.build_flags} + -DHDZERO_FREESTYLE_V2 + -DUSE_SMARTAUDIO_SW + -DUSE_TEMPERATURE_SENSOR + -DUSE_PA_EN + -DUSE_TC3587_LED \ No newline at end of file From 7f25fdcfc3076810ae751ab8929adedb0da3de7e Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:27:07 +0800 Subject: [PATCH 2/6] Update msp_displayport.c --- src/msp_displayport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msp_displayport.c b/src/msp_displayport.c index f0ba1f6..3ad71be 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -1121,7 +1121,7 @@ void parseMspVtx_V2(uint16_t const cmd_u16) { if (dm6300_init_done) { if (cur_pwr != nxt_pwr) { #ifndef VIDEO_PAT -#ifdef HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 +#if defined HDZERO_FREESTYLE || HDZERO_FREESTYLE_V2 if ((nxt_pwr == 3) && (!g_IS_ARMED)) pwr_lmt_done = 0; else From 16eb03705359cd34781d42631d51302fde5347d5 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:57:34 +0800 Subject: [PATCH 3/6] add SPI_DLY1 for HDZ_L2 --- src/hardware.c | 2 +- src/monitor.c | 2 +- src/rom.c | 6 +++--- src/spi.c | 12 ++++++++++++ src/uart.c | 3 +++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 838b928..de4201c 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -384,7 +384,7 @@ void GetVtxParameter() { #ifdef _RF_CALIB for (i = 0; i < FREQ_NUM_INTERNAL; i++) { for (j = 0; j <= POWER_MAX; j++) { - I2C_Write8_Wait(10, ADDR_EEPROM, i * (POWER_MAX + 1) + j, table_power[0][i][j]); + I2C_Write8_Wait(10, ADDR_EEPROM, i * (POWER_MAX + 1) + j, table_power[i][j]); } } #endif diff --git a/src/monitor.c b/src/monitor.c index 6c2eeaa..8c2cd0e 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -188,7 +188,7 @@ void MonEE(uint8_t op, uint8_t d) { } val = I2C_Read8_Wait(10, ADDR_EEPROM, addr); - table_power[0][RF_FREQ][RF_POWER] = val; + table_power[RF_FREQ][RF_POWER] = val; debugf("\r\nRF TAB[%d][%d] = %x", (uint16_t)RF_FREQ, (uint16_t)RF_POWER, val); DM6300_SetPower(RF_POWER, RF_FREQ, pwr_offset); diff --git a/src/rom.c b/src/rom.c index c29e351..23ba178 100644 --- a/src/rom.c +++ b/src/rom.c @@ -29,16 +29,16 @@ void CalibProc() { switch (rxbuf[0]) { case 'r': for (cnt = 0; cnt < FREQ_NUM_INTERNAL * (POWER_MAX + 1); cnt++) { - Rom_tx(table_power[0][cnt / (POWER_MAX + 1)][cnt % (POWER_MAX + 1)]); + Rom_tx(table_power[cnt / (POWER_MAX + 1)][cnt % (POWER_MAX + 1)]); } break; case 'w': - table_power[0][RF_FREQ][RF_POWER] = rxbuf[1]; + table_power[RF_FREQ][RF_POWER] = rxbuf[1]; DM6300_SetPower(RF_POWER, RF_FREQ, pwr_offset); - I2C_Write8_Wait(10, ADDR_EEPROM, RF_FREQ * (POWER_MAX + 1) + RF_POWER, table_power[0][RF_FREQ][RF_POWER]); + I2C_Write8_Wait(10, ADDR_EEPROM, RF_FREQ * (POWER_MAX + 1) + RF_POWER, table_power[RF_FREQ][RF_POWER]); break; case 'c': diff --git a/src/spi.c b/src/spi.c index 498b70a..179442f 100644 --- a/src/spi.c +++ b/src/spi.c @@ -15,6 +15,14 @@ while (i--) \ ; \ } +#ifdef HDZERO_FREESTYLE_V2 +#define SPI_DLY1 \ + { \ + int i = 5; \ + while (i--) \ + ; \ + } +#endif void SPI_Init() { SET_CS(1); @@ -29,7 +37,11 @@ void SPI_Write_Byte(uint8_t dat) { SPI_DLY; SET_DO((dat >> i) & 0x01); +#ifdef HDZERO_FREESTYLE_V2 + SPI_DLY1; +#else SPI_DLY; +#endif SET_CK(1); SPI_DLY; diff --git a/src/uart.c b/src/uart.c index 9ccbf74..a10a7b5 100644 --- a/src/uart.c +++ b/src/uart.c @@ -29,6 +29,9 @@ volatile BIT_TYPE RS_Xbusy1 = 0; #endif void uart_set_baudrate(uint8_t baudIndex) { +#if defined _DEBUG_MODE || defined _RF_CALIB + baudIndex = 0; +#endif switch (baudIndex) { case 0: // 115200 CKCON = 0x1F; From 4529e4037fafa120fd1264e6df2591092a112977 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:03:15 +0800 Subject: [PATCH 4/6] spi dly is 1 --- src/spi.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/spi.c b/src/spi.c index 179442f..498b70a 100644 --- a/src/spi.c +++ b/src/spi.c @@ -15,14 +15,6 @@ while (i--) \ ; \ } -#ifdef HDZERO_FREESTYLE_V2 -#define SPI_DLY1 \ - { \ - int i = 5; \ - while (i--) \ - ; \ - } -#endif void SPI_Init() { SET_CS(1); @@ -37,11 +29,7 @@ void SPI_Write_Byte(uint8_t dat) { SPI_DLY; SET_DO((dat >> i) & 0x01); -#ifdef HDZERO_FREESTYLE_V2 - SPI_DLY1; -#else SPI_DLY; -#endif SET_CK(1); SPI_DLY; From ed8942b6c3f26074b7c72e7c3d60fe1d7c97c958 Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:54:47 +0800 Subject: [PATCH 5/6] Do not init rf if calib --- src/mcu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mcu.c b/src/mcu.c index f80d412..78ac210 100644 --- a/src/mcu.c +++ b/src/mcu.c @@ -210,6 +210,10 @@ void timer_task() { void RF_Delay_Init() { static uint8_t SA_saved = 0; +#ifdef _RF_CALIB + return; +#endif + if (tramp_lock) return; From bbd27f2ea78f1febb828ab793475d6fb1196126a Mon Sep 17 00:00:00 2001 From: ligenxxxx <59721724+ligenxxxx@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:35:42 +0800 Subject: [PATCH 6/6] L2 is too hot, so adjust pwr_offset --- src/hardware.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware.c b/src/hardware.c index de4201c..5d40868 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -623,6 +623,9 @@ void PowerAutoSwitch() { #ifdef HDZERO_WHOOP_LITE pwr_offset >>= 1; +#elif defined HDZERO_FREESTYLE_V2 + if (pwr_offset > 16) + pwr_offset = 16; #endif if ((!g_IS_ARMED) && (last_ofs == pwr_offset))