diff --git a/src/camera.c b/src/camera.c index 486da28..6804619 100644 --- a/src/camera.c +++ b/src/camera.c @@ -34,10 +34,6 @@ void camera_type_detect(void) { camera_type == CAMERA_TYPE_RUNCAM_NANO_90 || camera_type == CAMERA_TYPE_RUNCAM_MICRO_V3) { camera_mfr = CAMERA_MFR_RUNCAM; -#ifdef _DEBUG_CAMERA - debugf("\r\ncamera mfr : RUNCAM"); - debugf("\r\ncamera type: %d", (uint16_t)camera_type); -#endif return; } } @@ -82,30 +78,13 @@ void camera_mode_detect(uint8_t init) { #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); - -#ifdef _DEBUG_MODE - debugf("\r\nchipID"); -#endif id = I2C_Read8(ADDR_TP9950, 0xfe); -#ifdef _DEBUG_MODE - debugf("\r\n fe:%2x", id); -#endif - id = I2C_Read8(ADDR_TP9950, 0xff); -#ifdef _DEBUG_MODE - debugf("\r\n ff:%2x\r\n", id); -#endif WAIT(200); I2C_Write8(ADDR_TP9950, 0x26, 0x01); @@ -222,23 +201,14 @@ void camera_mode_detect(uint8_t init) { if (video_format == VDO_FMT_720P50) { Init_TC3587(0); Set_720P50(IS_RX); -#ifdef _DEBUG_CAMERA - debugf("\r\nCamDetect: Set 50fps."); -#endif } else if (video_format == VDO_FMT_720P60) { Init_TC3587(0); Set_720P60(IS_RX); -#ifdef _DEBUG_CAMERA - debugf("\r\nCamDetect: Set 60fps."); -#endif } WAIT(100); for (detect_tries = 0; detect_tries < 5; detect_tries++) { status_reg = ReadReg(0, 0x02); -#ifdef _DEBUG_CAMERA - debugf("\r\nCamDetect status_reg: %x", status_reg); -#endif if ((status_reg >> 4) != 0) { loss = 1; } @@ -272,13 +242,6 @@ void camera_mode_detect(uint8_t init) { RF_BW = BW_27M; RF_BW_last = RF_BW; } -#ifdef _DEBUG_MODE - debugf("\r\ncameraID: %x, bw: ", (uint16_t)camera_type); - if (RF_BW == BW_17M) - debugf("17M"); - else - debugf("27M"); -#endif } #endif @@ -291,7 +254,6 @@ void camera_button_init() { void camera_reg_write_eep(uint16_t addr, uint8_t val) { I2C_Write8_Wait(10, ADDR_EEPROM, addr, val); - debugf("\r\neep write(%02x,%d)", addr, (uint16_t)val); } uint8_t camera_reg_read_eep(uint16_t addr) { return I2C_Read8_Wait(10, ADDR_EEPROM, addr); @@ -333,9 +295,6 @@ void camera_setting_profile_check(uint8_t profile) { if (need_reset) { camera_setting_profile_reset(profile); camera_setting_profile_write(profile); -#ifdef _DEBUG_CAMERA - debugf("\r\ncamera setting need to be reset"); -#endif } } void camera_profile_read(void) { @@ -373,9 +332,6 @@ void camera_setting_read(void) { } camera_reg_write_eep(EEP_ADDR_CAM_TYPE, camera_type); i = camera_reg_read_eep(EEP_ADDR_CAM_TYPE); -#ifdef _DEBUG_CAMERA - debugf("\r\ncamera changed(%d==>%d), reset camera setting", camera_type_last, i); -#endif } else { camera_profile_read(); camera_profile_check(); @@ -392,10 +348,6 @@ void camera_setting_reg_menu_update(void) { uint8_t i; for (i = 0; i < CAMERA_SETTING_NUM; i++) camera_setting_reg_menu[i] = camera_setting_reg_eep[camera_profile_menu][i]; - -#ifdef _DEBUG_CAMERA - debugf("\r\ncamera profile:%d", camera_profile_menu); -#endif } void camera_setting_reg_eep_update(void) { @@ -537,7 +489,7 @@ void camera_menu_draw_value(void) { uint8ToString(camera_setting_reg_menu[i - 1], str); strcpy(&osd_buf[i][osd_menu_offset + 25], str); break; - case CAM_STATUS_HVFLIP: // hv flip + case CAM_STATUS_HVFLIP: // hv flip strcpy(&osd_buf[i][osd_menu_offset + 21], hv_flip_str[camera_setting_reg_menu[i - 1]]); break; case CAM_STATUS_NIGHT_MODE: // night mode @@ -877,9 +829,6 @@ uint8_t camera_status_update(uint8_t op) { break; case CAM_STATUS_REPOWER: if (op == BTN_RIGHT) { -#ifdef _DEBUG_MODE - debugf("\r\nRF_Delay_Init: None"); -#endif camera_profile_write(); reset_isp_need |= camera_set(camera_setting_reg_menu, 1, 0); camera_setting_reg_eep_update(); diff --git a/src/common.h b/src/common.h index dc0a4f7..ce7bb7e 100644 --- a/src/common.h +++ b/src/common.h @@ -85,15 +85,7 @@ #ifndef _RF_CALIB // #define _DEBUG_MODE -// #define _DEBUG_DM6300 -// #define _DEBUG_TC3587 -// #define _DEBUG_CAMERA -// #define _DEBUG_LIFETIME -// #define _DEBUG_SMARTAUDIO -// #define _DEBUG_DISPLAYPORT -// #define _DEBUG_RUNCAM // #define _DEBUG_SPI -// #define _DEBUG_TRAMP #endif #define Raceband diff --git a/src/dm6300.c b/src/dm6300.c index d162790..ec95c04 100644 --- a/src/dm6300.c +++ b/src/dm6300.c @@ -252,7 +252,6 @@ const uint16_t frequencies[] = { void DM6300_write_reg_map(const dm6300_reg_value_t *reg_map, uint8_t size) { uint8_t i = 0; for (i = 0; i < size; i++) { - // debugf("\r\nDM6300_write_reg_map: %bx %x %lx", reg_map[i].trans, reg_map[i].addr, reg_map[i].dat); SPI_Write(reg_map[i].trans, reg_map[i].addr, reg_map[i].dat); } } @@ -294,10 +293,6 @@ dm6300_reg_value_t dm6300_set_channel_regs[] = { }; void DM6300_SetChannel(uint8_t ch) { -#ifdef _DEBUG_MODE - debugf("\r\nset ch:%x", (uint16_t)ch); -#endif - if (ch >= FREQ_NUM) ch = 0; @@ -339,9 +334,7 @@ void DM6300_SetPower(uint8_t pwr, uint8_t freq, uint8_t offset) { uint16_t a_tab[2] = {0x21F, 0x41F}; #endif int16_t p; -#ifdef _DEBUG_MODE - debugf("\r\nDM6300 set power:%x, offset:%x", (uint16_t)pwr, (uint16_t)offset); -#endif + if (freq >= FREQ_NUM) freq = 0; SPI_Write(0x6, 0xFF0, 0x00000018); @@ -400,13 +393,7 @@ void DM6300_InitAUXADC() { SPI_Write(0x6, 0xFF0, 0x00000018); SPI_Read(0x3, 0x254, &dat); -#ifdef _DEBUG_DM6300 - debugf("\r\nDM6300 0x254 = %x%x.\r\n", (uint16_t)((dat >> 16) & 0xFFFF), (uint16_t)(dat & 0xFFFF)); -#endif dat |= 0x200; -#ifdef _DEBUG_DM6300 - debugf("\r\nDM6300 0x254 = %x%x.\r\n", (uint16_t)((dat >> 16) & 0xFFFF), (uint16_t)(dat & 0xFFFF)); -#endif SPI_Write(0x3, 0x254, dat); SPI_Write(0x6, 0xFF0, 0x00000019); @@ -444,9 +431,6 @@ void DM6300_InitAUXADC() { if (auxadc_offset < 0x420) auxadc_offset = 0x420; #endif -#ifdef _DEBUG_DM6300 - debugf("\r\nDM6300 AUXADC Calib done. data1=%x, data2=%x, data3=%x, offset=%x", dat1, dat2, dat3, auxadc_offset); -#endif } void DM6300_AUXADC_Calib() { @@ -469,12 +453,10 @@ void DM6300_AUXADC_Calib() { for (i=0;i<8;i++){ DM6300_SetChannel(i); DM6300_SetPower(0, i, 0); - debugf("\r\nPA voltage detect: channel = %d,voltage =",(uint16_t)i); for(j=0;j<8;j++){ SPI_Write(0x6, 0xFF0, 0x00000019); SPI_Read (0x3, 0x17C, &dl); vol = (((int32_t)dl) >> 20) + auxadc_offset; - debugf("%x ", vol); } //WAIT(1000); } @@ -932,15 +914,7 @@ uint8_t DM6300_detect(void) { uint32_t rdat = 0; SPI_Write(0x6, 0xFF0, 0x18); SPI_Read(0x6, 0xFF0, &rdat); - -#ifdef _DEBUG_MODE - if (rdat != 0x18) { - debugf("\r\ndm6300 lost"); - } else { - debugf("\r\ndm6300 alive"); - } -#endif - return (rdat != 0x18) ? 1 : 0; + return rdat != 0x18; } void DM6300_Init(uint8_t ch, BWType_e bw) { @@ -986,9 +960,6 @@ void DM6300_Init(uint8_t ch, BWType_e bw) { DM6300_EFUSE2(); #endif SPI_Write(0x6, 0xFF0, 0x00000018); -#ifdef _DEBUG_MODE - debugf("\r\nDM6300 init done."); -#endif } //////////////////////////////////////////////////////////////////////////////// @@ -1173,13 +1144,8 @@ void DM6300_EFUSE1() { efuse.macro.m1.ical = (efuse.macro.m1.ical >> 8) | (efuse.macro.m1.ical << 8); efuse.macro.m1.rcal = (efuse.macro.m1.rcal >> 8) | (efuse.macro.m1.rcal << 8); #endif - // debugf("\r\nband_num=%x", efuse.macro.m0.band_num); - // debugf("\r\nbandgap=%lx", efuse.macro.m1.bandgap); - // debugf("\r\nical=%x", efuse.macro.m1.ical); - // debugf("\r\nrcal=%x", efuse.macro.m1.rcal); dat = ((efuse.macro.m1.ical & 0x1F) << 3) | (efuse.macro.m1.rcal & 0x7); - // debugf("\r\nrh=%lx", rh); SPI_Write(0x6, 0xF14, efuse.macro.m1.bandgap); SPI_Write(0x6, 0xF18, dat); @@ -1203,9 +1169,6 @@ void DM6300_EFUSE2() { for (i = 0; i < 4; i++) { version[i] = efuse.macro.m0.efuse_ver[i]; } -#ifdef _DEBUG_DM6300 - debugf("\r\n version = %s", version); -#endif // version[1]; //version[1] M.N---M // version[3]; //version[3] M.N---N @@ -1214,11 +1177,8 @@ void DM6300_EFUSE2() { for (i = 0; i < efuse.macro.m0.band_num; i++) // find match macro 5.8G // for(i=0; i> 8) | (efuse.macro.m2[i].tx1.freq_start << 8); -// efuse.macro.m2[i].tx1.freq_stop = (efuse.macro.m2[i].tx1.freq_stop >> 8) | (efuse.macro.m2[i].tx1.freq_stop << 8); -#ifdef _DEBUG_DM6300 - debugf("\r\n start=%x, stop=%x", efuse.macro.m2[i].tx1.freq_start, efuse.macro.m2[i].tx1.freq_stop); -#endif + // efuse.macro.m2[i].tx1.freq_start = (efuse.macro.m2[i].tx1.freq_start >> 8) | (efuse.macro.m2[i].tx1.freq_start << 8); + // efuse.macro.m2[i].tx1.freq_stop = (efuse.macro.m2[i].tx1.freq_stop >> 8) | (efuse.macro.m2[i].tx1.freq_stop << 8); if (efuse.macro.m2[i].tx1.freq_start >= 5000 && efuse.macro.m2[i].tx1.freq_stop <= 6000) { //*((volatile unsigned int *)0x200D08) = efuse.macro.m2[i].tx1.iqmismatch; @@ -1247,15 +1207,6 @@ void DM6300_EFUSE2() { ((efuse.macro.m2[i].tx1.dcoc_q >> 8) & 0xFF00) | ((efuse.macro.m2[i].tx1.dcoc_q << 8) & 0xFF0000) | ((efuse.macro.m2[i].tx1.dcoc_q << 24) & 0xFF000000); -#endif -#ifdef _DEBUG_DM6300 - debugf("\r\niqmismatch_old=%lx", efuse.macro.m2[i].tx1.iqmismatch); - debugf("\r\ndcoc_i_old=%lx", efuse.macro.m2[i].tx1.dcoc_i); - debugf("\r\ndcoc_q_old=%lx", efuse.macro.m2[i].tx1.dcoc_q); - - // change dc_i/dc_q - debugf("\r\n version[1] = %c", (uint16_t)version[1]); - debugf("\r\n version[3] = %c", (uint16_t)version[3]); #endif // if((version[1]>'2') | ((version[1]>='2') && (version[3]>'1'))){ //version > 2.1 if ((version[1] == '2') && (version[3] == '2')) { // version = 2.2 @@ -1272,19 +1223,12 @@ void DM6300_EFUSE2() { SPI_Write(0x3, 0x380, efuse.macro.m2[i].tx1.dcoc_i); SPI_Write(0x3, 0x388, efuse.macro.m2[i].tx1.dcoc_q); - debugf("\r\niqmismatch=%lx", efuse.macro.m2[i].tx1.iqmismatch); - debugf("\r\ndcoc_i=%lx", efuse.macro.m2[i].tx1.dcoc_i); - debugf("\r\ndcoc_q=%lx", efuse.macro.m2[i].tx1.dcoc_q); - dcoc_ih = efuse.macro.m2[i].tx1.dcoc_i & 0xFFFF0000; dcoc_qh = efuse.macro.m2[i].tx1.dcoc_q & 0xFFFF0000; if (EE_VALID) { rdat = I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_DCOC_EN); if ((rdat & 0xFF) == 0) { -#ifdef _DEBUG_DM6300 - debugf("\r\nDCOC read from EEPROM:"); -#endif SPI_Write(0x6, 0xFF0, 0x00000018); rdat = I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_DCOC_IH); @@ -1292,47 +1236,14 @@ void DM6300_EFUSE2() { rdat |= I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_DCOC_IL); rdat |= dcoc_ih; SPI_Write(0x3, 0x380, rdat); -#ifdef _DEBUG_DM6300 - debugf("\r\ndcoc_i=%lx", rdat); -#endif rdat = I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_DCOC_QH); rdat <<= 8; rdat |= I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_DCOC_QL); rdat |= dcoc_qh; SPI_Write(0x3, 0x388, rdat); -#ifdef _DEBUG_DM6300 - debugf("\r\ndcoc_q=%lx", rdat); -#endif } } - - /*if(EE_VALID){ - d0 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xa8); - d1 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xa9); - d2 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xaa); - d3 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xab); - d4 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xac); - d5 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xad); - d6 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xae); - d7 = I2C_Read8_Wait(10, ADDR_EEPROM, 0xaf); - - debugf("\r\nd0=%lx,d1=%lx,d2=%lx,d3=%lx", d0,d1,d2,d3); - debugf("\r\nd4=%lx,d5=%lx,d6=%lx,d7=%lx", d4,d5,d6,d7); - - wdat = 0x075F0000; - wdat = wdat | (d0<<8) | d1; - SPI_Write(0x3, 0x380, wdat); - debugf("\r\nreg380=%lx", wdat); - wdat = 0x075F0000; - wdat = wdat | (d2<<8) | d3; - SPI_Write(0x3, 0x388, wdat); - debugf("\r\nreg388=%lx", wdat); - wdat = (d4 << 24) | (d5 << 16) | (d6 << 8) | d7; - SPI_Write(0x3, 0xD08, wdat); - debugf("\r\nregD08=%lx", wdat); - }*/ - break; } } diff --git a/src/hardware.c b/src/hardware.c index 9e99837..6c47fd3 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -351,22 +351,7 @@ void Setting_Save() { err |= I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_25MW, OFFSET_25MW); err |= I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_TEAM_RACE, TEAM_RACE); err |= I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_SHORTCUT, SHORTCUT); -#ifdef _DEBUG_MODE - if (!err) - debugf("\r\nEEPROM write success"); -#endif } - -#ifdef _DEBUG_MODE - debugf("\r\nSetting Save\r\n"); - debugf(" RF_FREQ=%d\r\n", (uint16_t)RF_FREQ); - debugf(" RF_POWER=%d\r\n", (uint16_t)RF_POWER); - debugf(" LP_MODE=%d\r\n", (uint16_t)LP_MODE); - debugf(" PIT_MODE=%d\r\n", (uint16_t)PIT_MODE); - debugf(" OFFSET_25MW=%d\r\n", (uint16_t)OFFSET_25MW); - debugf(" TEAM_RACE=%d\r\n", (uint16_t)TEAM_RACE); - debugf(" SHORTCUT=%d\r\n", (uint16_t)SHORTCUT); -#endif } void CFG_Back() { @@ -389,10 +374,6 @@ void GetVtxParameter() { EE_VALID = !I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_EEP_VLD, 0xFF); -#ifdef _DEBUG_MODE - debugf("\r\nEE_VALID:%x", (uint16_t)EE_VALID); -#endif - if (EE_VALID) { // eeprom valid #ifdef FIX_EEP @@ -429,9 +410,6 @@ void GetVtxParameter() { } if (ee_vld) { -#ifdef _DEBUG_MODE - debugf("\r\nUSE EEPROM for rf_pwr_tab."); -#endif for (i = 0; i < FREQ_NUM_EXTERNAL; i++) { for (j = 0; j <= POWER_MAX; j++) { table_power[i][j] = tab[i][j]; @@ -445,9 +423,6 @@ void GetVtxParameter() { } } } else { -#ifdef _DEBUG_MODE - debugf("\r\nEEPROM is NOT initialized. Use default rf_pwr_tab."); -#endif #ifdef _RF_CALIB for (i = 0; i < FREQ_NUM_INTERNAL; i++) { @@ -469,10 +444,6 @@ void GetVtxParameter() { SHORTCUT = I2C_Read8(ADDR_EEPROM, EEP_ADDR_SHORTCUT); CFG_Back(); -#ifdef _DEBUG_MODE - debugf("\r\nUSE EEPROM for VTX setting:RF_FREQ=%d, RF_POWER=%d, LPMODE=%d PIT_MODE=%d", (uint16_t)RF_FREQ, (uint16_t)RF_POWER, (uint16_t)LP_MODE, (uint16_t)PIT_MODE); -#endif - // last_SA_lock #if defined USE_SMARTAUDIO_SW || defined USE_SMARTAUDIO_HW last_SA_lock = I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_SA_LOCK); @@ -480,9 +451,6 @@ void GetVtxParameter() { last_SA_lock = 0; I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_SA_LOCK, last_SA_lock); } -#ifdef _DEBUG_MODE - debugf("\r\nlast_SA_lock %x", (uint16_t)last_SA_lock); -#endif #endif #if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 @@ -492,15 +460,6 @@ void GetVtxParameter() { } else { CFG_Back(); } - -#ifdef _DEBUG_DM6300 - for (i = 0; i < FREQ_NUM_EXTERNAL; i++) { - debugf("\r\nrf_pwr_tab[%d]=", (uint16_t)i); - for (j = 0; j <= POWER_MAX; j++) - debugf(" %x", (uint16_t)table_power[i][j]); - } - debugf("\r\nUSE EEPROM for VTX setting:RF_FREQ=%d, RF_POWER=%d, LPMODE=%d PIT_MODE=%d", (uint16_t)RF_FREQ, (uint16_t)RF_POWER, (uint16_t)LP_MODE, (uint16_t)PIT_MODE); -#endif } void Init_6300RF(uint8_t freq, uint8_t pwr) { @@ -521,9 +480,6 @@ void Init_6300RF(uint8_t freq, uint8_t pwr) { } WriteReg(0, 0x8F, 0x11); rf_delay_init_done = 1; -#ifdef _DEBUG_MODE - debugf("\r\nInit_6300RF(%x, %x)", (uint16_t)freq, (uint16_t)pwr); -#endif } void Init_HW() { @@ -602,11 +558,6 @@ void TempDetect() { temperature = temperature - (temperature >> 2) + temp_new; temp0 = temp0 - (temp0 >> 2) + temp_new0; - -#ifdef _DEBUG_MODE -// verbosef("\r\ntempADC detect: temp = %d, temp_new = %d", (uint16_t)(temperature>>2), (uint16_t)temp_new); -// verbosef("\r\ntemp6300 detect: temp = 0x%x, temp_new = 0x%x", (uint16_t)(temp0>>2), (uint16_t)temp_new0); -#endif } } } @@ -626,10 +577,6 @@ void TempDetect() { } else { temp_new = DM6300_GetTemp(); temperature = temperature - (temperature >> 2) + temp_new; - -#ifdef _DEBUG_MODE -// verbosef("\r\ntemp detect: temp = %x, temp_new = %x", (uint16_t)(temperature>>2), (uint16_t)temp_new); -#endif } } } @@ -709,10 +656,6 @@ void PowerAutoSwitch() { ; else { DM6300_SetPower(RF_POWER, RF_FREQ, pwr_offset); -#ifdef _DEBUG_MODE - verbosef("\r\nPowerAutoSwitch: temp = %x%x, ", (uint16_t)(temperature >> 10), (uint16_t)((temperature >> 2) & 0xff)); - verbosef("pwr_offset = %d", (uint16_t)pwr_offset); -#endif cur_pwr = RF_POWER; } } @@ -823,15 +766,9 @@ void PowerAutoSwitch() { } if (last_ofs != pwr_offset) { -#ifdef _DEBUG_MODE - verbosef("\r\nPowerAutoSwitch:Yes 0x%x 0x%x", temp, (uint16_t)pwr_offset); -#endif DM6300_SetPower(RF_POWER, RF_FREQ, pwr_offset); cur_pwr = RF_POWER; } else { -#ifdef _DEBUG_MODE - verbosef("\r\nPowerAutoSwitch: No 0x%x 0x%x", temp, (uint16_t)pwr_offset); -#endif } last_ofs = pwr_offset; @@ -863,14 +800,6 @@ void HeatProtect() { sec = 0; temp = temperature >> 2; // temp = temperature >> 5; //LM75AD -#ifdef _DEBUG_MODE -#ifdef USE_TEMPERATURE_SENSOR - verbosef("\r\nHeat detect: temp = %d, pwr_offset=%d", (uint16_t)temp, (uint16_t)pwr_offset); -#else - // verbosef("\r\nHeat Protect detect: 0x%x", temp); -#endif -#endif - #ifdef USE_TEMPERATURE_SENSOR ; #else @@ -888,9 +817,6 @@ void HeatProtect() { { cnt++; if (cnt == 3) { -#ifdef _DEBUG_MODE - debugf("\r\nHeat Protect."); -#endif heat_protect = 1; #if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 WriteReg(0, 0x8F, 0x00); @@ -944,7 +870,6 @@ void PwrLMT() { p = table_power[RF_FREQ][3]; } else { p += 0x4; - debugf("\r\npwr_plus 2dbm,p=%x", (uint16_t)p); } SPI_Write(0x3, 0xD1C, (uint32_t)p); @@ -952,10 +877,6 @@ void PwrLMT() { } } #endif - -#ifdef _DEBUG_MODE - debugf("\r\npwr_lmt_sec %x", (uint16_t)pwr_lmt_sec); -#endif if (pwr_lmt_sec >= PWR_LMT_SEC) { DM6300_SetPower(RF_POWER, RF_FREQ, pwr_offset); cur_pwr = RF_POWER; @@ -963,10 +884,6 @@ void PwrLMT() { pwr_lmt_sec = 0; // test: power init reset p_init = 1; - -#ifdef _DEBUG_MODE - debugf("\r\nPower limit done."); -#endif Prompt(); } } @@ -1016,7 +933,6 @@ void PwrLMT() { p = table_power[RF_FREQ][3]; else { p += 0x4; - debugf("\r\npwr_plus 2dbm,p=%x", (uint16_t)p + pwr_offset); } SPI_Write(0x3, 0xD1C, (uint32_t)(p + pwr_offset)); // digital offset SPI_Write(0x3, 0x330, 0x31F); // analog offset 1W @@ -1024,9 +940,6 @@ void PwrLMT() { } #endif // HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 -#ifdef _DEBUG_MODE - debugf("\r\npwr_lmt_sec %x", (uint16_t)pwr_lmt_sec); -#endif if (pwr_lmt_sec >= PWR_LMT_SEC) { DM6300_SetPower(RF_POWER, RF_FREQ, pwr_offset); cur_pwr = RF_POWER; @@ -1035,9 +948,6 @@ void PwrLMT() { // test: power init reset p_init = 1; -#ifdef _DEBUG_MODE - debugf("\r\nPower limit done."); -#endif Prompt(); } } @@ -1073,59 +983,6 @@ void video_detect(void) { last_sec = seconds; sec++; -#ifdef _DEBUG_TC3587 - debugf("\r\nTC3587 reg:"); - val = I2C_Read16(ADDR_TC3587, 0x0062); - debugf("\r\n0x0062 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0064); - debugf("\r\n0x0064 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0066); - debugf("\r\n0x0066 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0068); - debugf("\r\n0x0068 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x006A); - debugf("\r\n0x006A = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x006C); - debugf("\r\n0x006C = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x006E); - debugf("\r\n0x006E = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0070); - debugf("\r\n0x0070 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0080); - debugf("\r\n0x0080 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0082); - debugf("\r\n0x0082 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0084); - debugf("\r\n0x0084 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0086); - debugf("\r\n0x0086 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0088); - debugf("\r\n0x0088 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x008A); - debugf("\r\n0x008A = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x008C); - debugf("\r\n0x008C = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x008E); - debugf("\r\n0x008E = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x0090); - debugf("\r\n0x0090 = 0x%x", val); - val = I2C_Read16(ADDR_TC3587, 0x00F8); - debugf("\r\n0x00F8 = 0x%x", val); - debugf("\r\n"); - I2C_Write16(ADDR_TC3587, 0x0064, 0x01ff); - I2C_Write16(ADDR_TC3587, 0x0068, 0x0000); - I2C_Write16(ADDR_TC3587, 0x006C, 0x0000); - I2C_Write16(ADDR_TC3587, 0x0080, 0x0000); - I2C_Write16(ADDR_TC3587, 0x0082, 0x0000); - I2C_Write16(ADDR_TC3587, 0x0084, 0x0000); - I2C_Write16(ADDR_TC3587, 0x0086, 0x0000); - I2C_Write16(ADDR_TC3587, 0x0088, 0x0000); - I2C_Write16(ADDR_TC3587, 0x008A, 0x0000); - I2C_Write16(ADDR_TC3587, 0x008C, 0x0000); - I2C_Write16(ADDR_TC3587, 0x008E, 0x0000); - I2C_Write16(ADDR_TC3587, 0x0090, 0x0000); -#endif - if (heat_protect) return; #if (0) @@ -1149,9 +1006,6 @@ void video_detect(void) { WAIT(1); } cameraLost = (video_type_id != 0x1E); // YUV422 -#ifdef _DEBUG_CAMERA - debugf("\r\nvideo_TypeID:%d, cameraLost:%d", video_type_id, uint16_t(val)); -#endif return; } @@ -1164,9 +1018,6 @@ void video_detect(void) { 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; @@ -1195,17 +1046,11 @@ void Imp_RF_Param() { } void Button1_SP() { -#ifdef _DEBUG_MODE - debugf("\r\nButton1_SP."); -#endif cfg_to_cnt = 0; // exit 0mW if (vtx_pit_save == PIT_0MW) { -#ifdef _DEBUG_MODE - debugf("\n\rDM6300 init"); -#endif Init_6300RF(RF_FREQ, RF_POWER); DM6300_AUXADC_Calib(); cur_pwr = RF_POWER; @@ -1287,9 +1132,6 @@ void Button1_SP() { if (LP_MODE) { DM6300_SetPower(0, RF_FREQ, 0); // limit power to 25mW cur_pwr = 0; -#ifdef _DEBUG_MODE - debugf("\n\rEnter LP_MODE"); -#endif } else { DM6300_SetPower(RF_POWER, RF_FREQ, 0); } @@ -1299,13 +1141,9 @@ void Button1_SP() { Setting_Save(); break; } - // debugf("\r\nShort Press: cfg_step=%d, RF_FREQ=%d, RF_POWER=%d", (uint16_t)cfg_step, (uint16_t)RF_FREQ, (uint16_t)RF_POWER); } void Button1_LP() { -#ifdef _DEBUG_MODE - debugf("\r\nButton1_LP."); -#endif cfg_to_cnt = 0; switch (cfg_step) { case 0: @@ -1325,13 +1163,9 @@ void Button1_LP() { set_segment(0xFF); break; } - // debugf("\r\nShort Press: cfg_step=%d, FREQ_CFG=%d, POWER_CFG=%d", (uint16_t)cfg_step, (uint16_t)FREQ_CFG, (uint16_t)POWER_CFG); } void Button1_LLP() { -#ifdef _DEBUG_MODE - debugf("\r\nButton1_LLP."); -#endif cfg_to_cnt = 0; if (cfg_step == 0) { cfg_step = 3; @@ -1413,9 +1247,6 @@ void CFGTimeout() { cfg_step = 0; set_segment(0xFF); -#ifdef _DEBUG_MODE - debugf("\r\nCFG Timeout."); -#endif Prompt(); } } @@ -1557,9 +1388,6 @@ uint8_t RF_BW_to_be_changed(void) { RF_BW_last = RF_BW; ret = 1; } -#ifdef _DEBUG_MODE - debugf("\r\ncamera_type:%x, video_mode:%x, RF_BW:%x, RF_BW_last:%x ret=%x", (uint16_t)camera_type, (uint16_t)camera_setting_reg_set[11], (uint16_t)RF_BW, (uint16_t)RF_BW_last, (uint16_t)ret); -#endif return ret; } @@ -1588,9 +1416,6 @@ void uart_baudrate_detect(void) { void vtx_paralized(void) { // Sleep until repower WriteReg(0, 0x8F, 0x00); -#ifdef _DEBUG_MODE - debugf("\r\nvtx paralized"); -#endif while (1) { LED_Flip(); WAIT(50); @@ -1644,9 +1469,6 @@ void RF_Delay_Init() { if (seconds >= WAIT_SA_CONFIG) { I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_SA_LOCK, SA_lock); SA_saved = 1; -#ifdef _DEBUG_MODE - debugf("\r\nSave SA_lock(%x) to EEPROM", (uint16_t)SA_lock); -#endif } } @@ -1666,9 +1488,6 @@ void RF_Delay_Init() { rf_delay_init_done = 1; if (last_SA_lock) { -#ifdef _DEBUG_MODE - debugf("\r\nRF_Delay_Init: SA"); -#endif pwr_lmt_sec = PWR_LMT_SEC; if (SA_lock) { if (pwr_init == POWER_MAX + 2) { // 0mW @@ -1676,21 +1495,12 @@ void RF_Delay_Init() { cur_pwr = POWER_MAX + 2; } else if (PIT_MODE) { Init_6300RF(ch_init, POWER_MAX + 1); -#ifdef _DEBUG_MODE - debugf("\r\n ch%x, pwr%x", (uint16_t)ch_init, (uint16_t)cur_pwr); -#endif } else { Init_6300RF(ch_init, pwr_init); -#ifdef _DEBUG_MODE - debugf("\r\n ch%x, pwr%x", (uint16_t)ch_init, (uint16_t)cur_pwr); -#endif } DM6300_AUXADC_Calib(); } } else if (!mspVtxLock) { -#ifdef _DEBUG_MODE - debugf("\r\nRF_Delay_Init: None"); -#endif if (TEAM_RACE == 0x01) vtx_paralized(); #if (0) diff --git a/src/i2c.c b/src/i2c.c index a911cb3..a46d4da 100644 --- a/src/i2c.c +++ b/src/i2c.c @@ -128,8 +128,7 @@ uint8_t I2C_Write8(uint8_t slave_addr, uint8_t reg_addr, uint8_t val) { I2C_write_byte(val); I2C_stop(); - // value = I2C_Read8(slave_addr, reg_addr); - // debugf("\r\n0x%4x, 0x%4x", reg_addr, (uint16_t)val); + return 0; } @@ -142,7 +141,6 @@ uint8_t I2C_Write8_Wait(uint16_t ms, uint8_t slave_addr, uint8_t reg_addr, uint8 uint8_t I2C_Write16(uint8_t slave_addr, uint16_t reg_addr, uint16_t val) { uint8_t slave, reg_addr_1, value; - uint16_t rdat; slave = slave_addr << 1; @@ -170,14 +168,11 @@ uint8_t I2C_Write16(uint8_t slave_addr, uint16_t reg_addr, uint16_t val) { I2C_stop(); - rdat = I2C_Read16(slave_addr, reg_addr); - // debugf("\r\n0x%4x, 0x%4x", reg_addr, (uint16_t)val); return 0; } uint8_t I2C_Write16_a8(uint8_t slave_addr, uint8_t reg_addr, uint16_t val) { uint8_t slave, value; - uint16_t rdat; slave = slave_addr << 1; @@ -201,8 +196,6 @@ uint8_t I2C_Write16_a8(uint8_t slave_addr, uint8_t reg_addr, uint16_t val) { I2C_stop(); - rdat = I2C_Read16(slave_addr, reg_addr); - // debugf("\r\n0x%4x, 0x%4x", reg_addr, (uint16_t)val); return 0; } uint8_t I2C_read_byte(uint8_t no_ack) { @@ -341,9 +334,6 @@ uint8_t RUNCAM_Write(uint8_t cam_id, uint32_t addr, uint32_t val) { value = I2C_write_byte(cam_id); // slave if (value) { I2C_stop(); -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM_Write error id: %x value: %d", (uint16_t)cam_id, (uint16_t)value); -#endif return 1; } @@ -371,11 +361,8 @@ uint8_t RUNCAM_Write(uint8_t cam_id, uint32_t addr, uint32_t val) { I2C_write_byte(value); I2C_stop(); // stop -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM_Write: %d, %d, %d", (uint16_t)cam_id, (uint16_t)addr, (uint16_t)val); -#else + WAIT(10); -#endif return 0; } @@ -416,11 +403,8 @@ uint32_t RUNCAM_Read(uint8_t cam_id, uint32_t addr) { ret = (ret << 8) | value; I2C_stop(); // stop -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM_Read: %d, %d: %d", (uint16_t)cam_id, (uint16_t)addr, (uint16_t)ret); -#else + WAIT(10); -#endif return ret; } diff --git a/src/i2c_device.c b/src/i2c_device.c index fd8a027..7874935 100644 --- a/src/i2c_device.c +++ b/src/i2c_device.c @@ -85,32 +85,9 @@ void Init_TC3587(uint8_t fmt) { WAIT(20); #endif -#ifdef _DEBUG_TC3587 - debugf("\r\nDetecte TC3587..."); -#endif -#if (0) // some vtx cannot pass tc3587 detect, I don't know the reason. - while (1) { - val = I2C_Read16(ADDR_TC3587, 0x0000); - if (val == 0x4401) { - LED_BLUE_ON; - led_status = ON; - break; - } else { - if (led_status == ON) { - LED_BLUE_OFF; - led_status = OFF; - WAIT(50); - } else { - LED_BLUE_ON; - led_status = ON; - WAIT(20); - } - } - } -#else LED_BLUE_ON; led_status = ON; -#endif + I2C_Write16(ADDR_TC3587, 0x0002, 0x0001); I2C_Write16(ADDR_TC3587, 0x0002, 0x0000); // srst @@ -133,8 +110,4 @@ void Init_TC3587(uint8_t fmt) { I2C_Write16(ADDR_TC3587, 0x0018, 0x0113); // pll I2C_Write16(ADDR_TC3587, 0x0002, 0x0001); I2C_Write16(ADDR_TC3587, 0x0002, 0x0000); - // WAIT(100); -#ifdef _DEBUG_TC3587 - debugf("\r\nInit TC3587 done"); -#endif } diff --git a/src/lifetime.c b/src/lifetime.c index 6cc44c5..c9b6150 100644 --- a/src/lifetime.c +++ b/src/lifetime.c @@ -45,10 +45,6 @@ void Update_EEP_LifeTime(void) { diff = sysLifeTime_last ^ sysLifeTime; -#ifdef _DEBUG_LIFETIME - debugf("\r\nsysLifeTime:%ld", sysLifeTime); -#endif - if ((diff >> 0) & 0xff) { u8 = (sysLifeTime >> 0) & 0xff; I2C_Write8_Wait(10, ADDR_EEPROM, EEP_ADDR_LIFETIME_0, u8); diff --git a/src/msp_displayport.c b/src/msp_displayport.c index 4369355..b8f7b12 100644 --- a/src/msp_displayport.c +++ b/src/msp_displayport.c @@ -153,12 +153,6 @@ void msp_task() { static uint8_t t1 = 0; static uint8_t vmax = OSD_CANVAS_SD_VMAX; -#ifdef _DEBUG_DISPLAYPORT - if (RS0_ERR) { - RS0_ERR = 0; - _outchar('$'); // RS0 buffer full - } -#endif DP_tx_task(); // decide by osd_frame size/rate and dptx rate @@ -177,10 +171,6 @@ void msp_task() { len = get_tx_data_osd(t1); if (hdzero_dynamic_osd_refresh_adapter(t1)) insert_tx_buf(len); - -#ifdef _DEBUG_DISPLAYPORT -// debugf("\n\r%x ", (uint16_t)t1); -#endif t1++; if (t1 >= vmax) t1 = 0; @@ -241,10 +231,6 @@ uint8_t msp_read_one_frame() { ptr = 0; state = MSP_HEADER_M; } -#ifdef _DEBUG_DISPLAYPORT - else - _outchar('&'); -#endif break; case MSP_HEADER_M: @@ -293,7 +279,6 @@ uint8_t msp_read_one_frame() { state = MSP_CRC1; else state = MSP_RX1; - // debugf("\r\ncmd:%x ", (uint16_t)rx); break; case MSP_RX1: @@ -335,10 +320,6 @@ uint8_t msp_read_one_frame() { } } } -#ifdef _DEBUG_DISPLAYPORT - else - _outchar('^'); -#endif state = MSP_HEADER_START; break; @@ -670,10 +651,6 @@ uint8_t get_tx_data_osd(uint8_t index) // prepare osd+data to VTX void insert_tx_byte(uint8_t c) { dptxbuf[dptx_wptr++] = c; -#ifdef _DEBUG_DISPLAYPORT - if (dptx_wptr == dptx_rptr) // dptxbuf full - _outchar('*'); -#endif } #ifdef SDCC @@ -967,10 +944,6 @@ void msp_set_vtx_config(uint8_t power, uint8_t save) { crc ^= 0x00; // disable/clear vtx table msp_tx(crc); -#ifdef _DEBUG_MODE - debugf("\r\nmsp_set_vtx_config:FRQ%x,PWR%x,PIT:%x, LP:%x, SAVE:%x", (uint16_t)RF_FREQ, (uint16_t)power, (uint16_t)PIT_MODE, (uint16_t)LP_MODE, (uint16_t)save); -#endif - if (save) msp_eeprom_write(); } @@ -987,10 +960,6 @@ void parse_status() { vtx_paralized(); } #endif - -#if (0) - debugf("\n\rstatus:%x %x %x %x", (uint16_t)msp_rx_buf[6], (uint16_t)msp_rx_buf[7], (uint16_t)msp_rx_buf[8], (uint16_t)msp_rx_buf[9]); -#endif } void parse_variant() { @@ -1018,9 +987,7 @@ void parse_rc() { uint8_t msp_vtx_set_channel(uint8_t const channel) { if (channel == INVALID_CHANNEL || channel == RF_FREQ) return 0; -#ifdef _DEBUG_MODE - debugf("\r\nRF_FREQ to %x", (uint16_t)channel); -#endif + vtx_channel = channel; RF_FREQ = channel; if (dm6300_init_done) @@ -1083,7 +1050,6 @@ void msp_set_osd_canvas(void) { msp_tx(OSD_CANVAS_HD_VMAX0); crc ^= OSD_CANVAS_HD_VMAX0; msp_tx(crc); - // debugf("\r\nmsp_set_osd_canvas"); } } @@ -1128,25 +1094,7 @@ void parseMspVtx_V2(uint16_t const cmd_u16) { pwr_lmt_done = 1; mspVtxLock |= 1; -#ifdef _DEBUG_MODE - debugf("\r\nparseMspVtx_V2"); - debugf("\r\n fc_vtx_dev: %x", (uint16_t)msp_rx_buf[0]); - debugf("\r\n fc_band_rx: %x", (uint16_t)msp_rx_buf[1]); - debugf("\r\n fc_channel_rx: %x", (uint16_t)msp_rx_buf[2]); - debugf("\r\n fc_pwr_rx: %x", (uint16_t)fc_pwr_rx); - debugf("\r\n fc_pit_rx : %x", (uint16_t)fc_pit_rx); - debugf("\r\n fc_frequency : %x", ((uint16_t)msp_rx_buf[6] << 8) + msp_rx_buf[5]); - debugf("\r\n fc_vtx_status: %x", (uint16_t)msp_rx_buf[7]); - debugf("\r\n fc_lp_rx: %x", (uint16_t)fc_lp_rx); - debugf("\r\n fc_bands: %x", (uint16_t)msp_rx_buf[12]); - debugf("\r\n fc_channels: %x", (uint16_t)msp_rx_buf[13]); - debugf("\r\n fc_powerLevels %x", (uint16_t)msp_rx_buf[14]); -#endif - if (SA_lock || (init_table_done == 0 && !init_table_unsupported)) { -#ifdef _DEBUG_MODE - debugf("\r\nparseMspVtx_V2 skipped. (SA_lock: %i, init_table_done: %i, init_table_unsupported: %i)\r\n", SA_lock, init_table_done, init_table_unsupported); -#endif return; } @@ -1194,9 +1142,6 @@ void parseMspVtx_V2(uint16_t const cmd_u16) { } PIT_MODE = fc_pit_rx & 1; -#ifdef _DEBUG_MODE - debugf("\r\nPIT_MODE = %x", (uint16_t)PIT_MODE); -#endif if (fc_pit_rx != last_pit) { if (PIT_MODE) { DM6300_SetPower(POWER_MAX + 1, RF_FREQ, pwr_offset); @@ -1279,10 +1224,6 @@ void parseMspVtx_V2(uint16_t const cmd_u16) { if (needSaveEEP) ; // Setting_Save(); - -#ifdef _DEBUG_MODE - debugf("\r\nparseMspVtx_V2 pwr:%x, pit:%x", (uint16_t)nxt_pwr, (uint16_t)fc_pit_rx); -#endif } uint8_t parse_displayport(uint8_t len) { @@ -1303,24 +1244,12 @@ uint8_t parse_displayport(uint8_t len) { if (disp_mode == DISPLAY_OSD) clear_screen(); osd_ready = 0; -#ifdef _DEBUG_DISPLAYPORT - _outchar('\r'); - _outchar('\n'); - _outchar('C'); -#endif return 0; } else if (msp_rx_buf[0] == SUBCMD_WRITE) { -#ifdef _DEBUG_DISPLAYPORT - _outchar('W'); -#endif osd_ready = 0; state_osd = MSP_OSD_LOC; } else if (msp_rx_buf[0] == SUBCMD_DRAW) { osd_ready = 1; -#ifdef _DEBUG_DISPLAYPORT - _outchar('D'); - _outchar(' '); -#endif if (!(fc_lock & FC_OSD_LOCK)) { Flicker_LED(3); fc_lock |= FC_OSD_LOCK; @@ -1446,28 +1375,23 @@ void update_cms_menu(uint16_t roll, uint16_t pitch, uint16_t yaw, uint16_t throt if (!g_IS_ARMED) { if (stick_cmd_exit_0mw && (cur_pwr == POWER_MAX + 2)) { cms_state = CMS_EXIT_0MW; - // debugf("\r\ncms_state(%x),cur_pwr(%x)",cms_state, cur_pwr); cms_cnt = 0; break; } else if (IS_HI_yaw && IS_LO_throttle && IS_LO_roll && IS_LO_pitch) { cms_state = CMS_ENTER_VTX_MENU; - // debugf("\r\ncms_state(%x)",cms_state); vtx_menu_init(); vtx_menu_state = VTX_MENU_CHANNEL; } else if (stick_cmd_enter_0mw) { if (cur_pwr != POWER_MAX + 2) { cms_state = CMS_ENTER_0MW; - // debugf("\r\ncms_state(%x)",cms_state); cms_cnt = 0; } } else if (VirtualBtn == BTN_ENTER) { cms_state = CMS_ENTER_CAM; - // debugf("\r\ncms_state(%x)",cms_state); cms_cnt = 0; } else cms_cnt = 0; } - // debugf("\n\r CMS_OSD"); break; case CMS_ENTER_0MW: @@ -1514,10 +1438,6 @@ void update_cms_menu(uint16_t roll, uint16_t pitch, uint16_t yaw, uint16_t throt Init_6300RF(RF_FREQ, POWER_MAX + 1); cur_pwr = POWER_MAX + 1; DM6300_AUXADC_Calib(); -#ifdef _DEBUG_MODE - debugf("\r\nExit 0mW\r\n"); -#endif - // debugf("\r\n exit0"); } else { save_vtx_param(); pit_mode_cfg_done = 1; // avoid to config DM6300 again @@ -1525,10 +1445,6 @@ void update_cms_menu(uint16_t roll, uint16_t pitch, uint16_t yaw, uint16_t throt // SPI_Write(0x3, 0xd00, 0x00000003); Init_6300RF(RF_FREQ, RF_POWER); DM6300_AUXADC_Calib(); -#ifdef _DEBUG_MODE - debugf("\r\nExit 0mW\r\n"); -#endif - // debugf("\r\n exit0"); } } @@ -1977,11 +1893,8 @@ void set_vtx_param() { if (vtx_pit_save == PIT_0MW) { WriteReg(0, 0x8F, 0x10); dm6300_init_done = 0; -// SPI_Write(0x6, 0xFF0, 0x00000018); -// SPI_Write(0x3, 0xd00, 0x00000000); -#ifdef _DEBUG_MODE - debugf("\r\nDM6300 0mW"); -#endif + // SPI_Write(0x6, 0xFF0, 0x00000018); + // SPI_Write(0x3, 0xd00, 0x00000000); cur_pwr = POWER_MAX + 2; temp_err = 1; } else // if(vtx_pit_save == PIT_P1MW) @@ -1991,9 +1904,6 @@ void set_vtx_param() { DM6300_AUXADC_Calib(); } else DM6300_SetPower(POWER_MAX + 1, RF_FREQ, 0); -#ifdef _DEBUG_MODE - debugf("\r\nDM6300 P1mW"); -#endif cur_pwr = POWER_MAX + 1; } } @@ -2002,9 +1912,6 @@ void set_vtx_param() { if (LP_MODE) { DM6300_SetPower(0, RF_FREQ, 0); // limit power to 25mW cur_pwr = 0; -#ifdef _DEBUG_MODE - debugf("\n\rEnter LP_MODE"); -#endif } lp_mode_cfg_done = 1; } @@ -2025,9 +1932,6 @@ void set_vtx_param() { } } else if (PIT_MODE || LP_MODE) { // exit pitmode or lp_mode -#ifdef _DEBUG_MDOE - debugf("\n\rExit PIT or LP"); -#endif #ifndef VIDEO_PAT #if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2 if (RF_POWER == 3 && !g_IS_ARMED) @@ -2063,9 +1967,6 @@ void set_vtx_param() { if (LP_MODE == 1) { DM6300_SetPower(0, RF_FREQ, 0); // limit power to 25mW during disarmed cur_pwr = 0; -#ifdef _DEBUG_MODE - debugf("\n\rEnter LP_MODE"); -#endif } } @@ -2135,10 +2036,6 @@ void InitVtxTable() { uint8_t crc; uint8_t const *power_table[5]; -#ifdef _DEBUG_MODE - debugf("\r\nInitVtxTable"); -#endif - // set band num, channel num and power level number if (TEAM_RACE) msp_set_vtx_config(POWER_MAX + 1, 0); diff --git a/src/runcam.c b/src/runcam.c index b8b8020..6f19ecb 100644 --- a/src/runcam.c +++ b/src/runcam.c @@ -230,9 +230,6 @@ void runcam_brightness(uint8_t val, uint8_t led_mode) { d -= ((uint32_t)camera_attribute[0][CAM_SETTING_ITEM_DEFAULT] << 16); RUNCAM_Read_Write(camera_device, 0x50, d); -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM brightness:0x%02x, led_mode:%02x", (uint16_t)val, (uint16_t)led_mode); -#endif } void runcam_sharpness(uint8_t val) { @@ -257,9 +254,6 @@ void runcam_sharpness(uint8_t val) { RUNCAM_Read_Write(camera_device, 0x0003CC, 0x28303840); RUNCAM_Read_Write(camera_device, 0x0003D8, 0x28303840); } -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM sharpness:0x%02x", (uint16_t)val); -#endif } void runcam_contrast(uint8_t val) { @@ -280,9 +274,6 @@ void runcam_contrast(uint8_t val) { d += 0x04040404; RUNCAM_Read_Write(camera_device, 0x00038C, d); -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM contrast:%02x", (uint16_t)val); -#endif } void runcam_saturation(uint8_t val) { @@ -313,10 +304,6 @@ void runcam_saturation(uint8_t val) { d += 0x04041418; RUNCAM_Read_Write(camera_device, 0x0003A4, d); - -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM saturation:%02x", (uint16_t)val); -#endif } void runcam_wb(uint8_t wbMode, uint8_t wbRed, uint8_t wbBlue) { @@ -341,10 +328,6 @@ void runcam_wb(uint8_t wbMode, uint8_t wbRed, uint8_t wbBlue) { } else { // AWB RUNCAM_Read_Write(camera_device, 0x0001b8, 0x020b0079); } -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM wb:red(%02x),blue(%02x),mode(%02x)", - (uint16_t)wbRed, (uint16_t)wbBlue, (uint16_t)wbMode); -#endif } void runcam_hv_flip(uint8_t val) { @@ -361,9 +344,6 @@ void runcam_hv_flip(uint8_t val) { RUNCAM_Read_Write(camera_device, 0x000040, 0x0026ffa9); else if (val == 3) // h flip RUNCAM_Read_Write(camera_device, 0x000040, 0x002affa9); -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM hvFlip:%02x", (uint16_t)val); -#endif } void runcam_night_mode(uint8_t val) { @@ -393,9 +373,6 @@ void runcam_night_mode(uint8_t val) { RUNCAM_Read_Write(camera_device, 0x00071c, 0x29002800); RUNCAM_Read_Write(camera_device, 0x000720, 0x29002900); } -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM nightMode:%02x", (uint16_t)val); -#endif } uint8_t runcam_video_format(uint8_t val) { @@ -457,20 +434,12 @@ uint8_t runcam_video_format(uint8_t val) { ret |= RUNCAM_Read_Write(camera_device, 0x000008, 0x8208811f); } -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM video format:%02x", (uint16_t)val); -#endif - return ret; } void runcam_shutter(uint8_t val) { uint32_t dat = 0; -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM shutter:%02x", (uint16_t)val); -#endif - camera_setting_reg_set[4] = val; if (camera_type == CAMERA_TYPE_RUNCAM_MICRO_V1) { RUNCAM_Write(camera_device, 0x00006c, 0x000004a6); @@ -490,7 +459,7 @@ void runcam_shutter(uint8_t val) { RUNCAM_Write(camera_device, 0x000044, 0x80009629); WAIT(50); } else { // manual - dat = (uint32_t)(val)*25; + dat = (uint32_t)(val) * 25; } RUNCAM_Write(camera_device, 0x00006c, dat); @@ -512,7 +481,7 @@ void runcam_shutter_fix(uint16_t sec) { if (val == 0) { dat = 0x447; } else { - dat = (uint32_t)(val)*25; + dat = (uint32_t)(val) * 25; } RUNCAM_Write(camera_device, 0x00006c, dat); @@ -536,16 +505,10 @@ uint8_t runcam_setting_update_need(uint8_t *setting_p, uint8_t start, uint8_t st void runcam_save(void) { RUNCAM_Write(camera_device, 0x000694, 0x00000310); RUNCAM_Write(camera_device, 0x000694, 0x00000311); -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM Save"); -#endif } void runcam_reset_isp(void) { RUNCAM_Write(camera_device, 0x000694, 0x00000130); -#ifdef _DEBUG_RUNCAM - debugf("\r\nRUNCAM reset isp"); -#endif } uint8_t runcam_set(uint8_t *setting_profile) { diff --git a/src/smartaudio_protocol.c b/src/smartaudio_protocol.c index d90d19e..5757e5c 100644 --- a/src/smartaudio_protocol.c +++ b/src/smartaudio_protocol.c @@ -168,31 +168,13 @@ void SA_Response(uint8_t cmd) { } void SA_Update(uint8_t cmd) { -#ifdef _DEBUG_SMARTAUDIO - if (SUART_ready()) { - _outchar('^'); - return; - } -#endif switch (cmd) { -#ifdef _DEBUG_SMARTAUDIO - case SA_GET_SETTINGS: - _outchar('G'); - debugf(" ch:%x", (uint16_t)ch_init); - debugf(" pwr:%x", (uint16_t)pwr_init); - debugf(" mode:%x", (uint16_t)mode_o); - break; -#endif case SA_SET_PWR: if (!(sa_rbuf[0] >> 7)) return; SA_dbm = sa_rbuf[0] & 0x7f; -#ifdef _DEBUG_SMARTAUDIO - debugf("dbm:%x", (uint16_t)SA_dbm); -#endif - if (SA_dbm_last != SA_dbm) { // need to update power if (SA_dbm == 0) { // Enter 0mW cur_pwr = POWER_MAX + 2; @@ -202,9 +184,6 @@ void SA_Update(uint8_t cmd) { if (last_SA_lock && seconds < WAIT_SA_CONFIG) { pwr_init = cur_pwr; } else { -#ifdef _DEBUG_SMARTAUDIO - debugf("\n\rEnter 0mW"); -#endif WriteReg(0, 0x8F, 0x10); // reset RF_chip dm6300_init_done = 0; temp_err = 1; @@ -217,10 +196,6 @@ void SA_Update(uint8_t cmd) { if (last_SA_lock && seconds < WAIT_SA_CONFIG) pwr_init = cur_pwr; else { -#ifdef _DEBUG_MDOE - debugf("\n\rExit 0mW"); -#endif - Init_6300RF(RF_FREQ, RF_POWER); PIT_MODE = 0; @@ -256,12 +231,6 @@ void SA_Update(uint8_t cmd) { uint8_t const channel = bfChannel_to_channel(sa_rbuf[0]); if (channel < INVALID_CHANNEL) { ch_bf = sa_rbuf[0]; - -#ifdef _DEBUG_SMARTAUDIO - _outchar('C'); - debugf("%x", (uint16_t)channel); -#endif - if (channel != RF_FREQ) { RF_FREQ = channel; if (last_SA_lock && (seconds < WAIT_SA_CONFIG)) @@ -279,12 +248,6 @@ void SA_Update(uint8_t cmd) { uint8_t const channel = DM6300_GetChannelByFreq(freq); if (channel < INVALID_CHANNEL) { ch_bf = channel_to_bfChannel(channel); - -#ifdef _DEBUG_SMARTAUDIO - _outchar('F'); - debugf("%x", (uint16_t)channel); -#endif - if (channel != RF_FREQ) { RF_FREQ = channel; if (last_SA_lock && (seconds < WAIT_SA_CONFIG)) @@ -318,9 +281,6 @@ void SA_Update(uint8_t cmd) { cur_pwr = POWER_MAX + 2; PIT_MODE = 0; vtx_pit = PIT_0MW; -#ifdef _DEBUG_SMARTAUDIO - debugf("\n\rSA:Enter 0mW"); -#endif WriteReg(0, 0x8F, 0x10); // reset RF_chip dm6300_init_done = 0; temp_err = 1; @@ -335,9 +295,6 @@ void SA_Update(uint8_t cmd) { cur_pwr = POWER_MAX + 2; PIT_MODE = 0; vtx_pit = PIT_0MW; -#ifdef _DEBUG_SMARTAUDIO - debugf("\n\rSA:Enter 0mW"); -#endif WriteReg(0, 0x8F, 0x10); // reset RF_chip dm6300_init_done = 0; temp_err = 1; @@ -347,9 +304,6 @@ void SA_Update(uint8_t cmd) { if ((RF_POWER == 3) && (!g_IS_ARMED)) { pwr_lmt_done = 0; cur_pwr = 3; -#ifdef _DEBUG_SMARTAUDIO - debugf("\r\npwr_lmt_done reset"); -#endif } else #endif #endif @@ -362,16 +316,9 @@ void SA_Update(uint8_t cmd) { Setting_Save(); } -#ifdef _DEBUG_SMARTAUDIO - debugf("M_P:%x ", (uint16_t)mode_p); - debugf("M_O:%x", (uint16_t)mode_o); -#endif break; default: -#ifdef _DEBUG_SMARTAUDIO - _outchar('#'); -#endif break; } } @@ -386,11 +333,6 @@ uint8_t SA_task(void) { SA_is_0 = 1; IE = 0xC2; // UART1 & Timer0 enabled, UART0 disabled st = 1; -#ifdef _DEBUG_SMARTAUDIO - _outchar('\n'); - _outchar('\r'); - _outchar('<'); -#endif } } else { if (SA_Process()) { @@ -398,9 +340,6 @@ uint8_t SA_task(void) { IE = 0xD2; // UART1 & Timer0 enabled, UART0 0 enable st = 0; SA = 0xFF; -#ifdef _DEBUG_SMARTAUDIO - _outchar('>'); -#endif } } return st; @@ -430,12 +369,6 @@ uint8_t SA_Process() { if (SUART_ready()) { rx = SUART_rx(); -#if (1) - CMS_tx(rx); -#endif -#ifdef _DEBUG_SMARTAUDIO -// debugf("%x ", (uint16_t)rx); -#endif switch (status) { case SA_HEADER0: if (rx == SA_HEADER0_BYTE) { @@ -497,10 +430,6 @@ uint8_t SA_Process() { SA_lock = 1; SA_Update(cmd); SA_Response(cmd); - } else { -#ifdef _DEBUG_SMARTAUDIO - _outchar('$'); -#endif } ret = 1; status = SA_HEADER0; @@ -511,11 +440,8 @@ uint8_t SA_Process() { status = SA_HEADER0; break; } - } else { -#ifdef _DEBUG_SMARTAUDIO - _outchar('.'); -#endif } + return ret; } diff --git a/src/spi.c b/src/spi.c index 498b70a..1c5417a 100644 --- a/src/spi.c +++ b/src/spi.c @@ -137,10 +137,4 @@ void SPI_Read(uint8_t trans, uint16_t addr, uint32_t *dat_l) { SET_CS(1); // end SET_CK(0); SET_DO(0); - -#ifdef _DEBUG_SPI - rlh = ((*dat_l) >> 16) & 0xFFFF; - rll = (*dat_l) & 0xFFFF; - debugf("\r\nSPI READ: addr=%x data=%x%x.\r\n", addr, rlh, rll); -#endif } diff --git a/src/tramp_protocol.c b/src/tramp_protocol.c index 8109fcc..9f9068e 100644 --- a/src/tramp_protocol.c +++ b/src/tramp_protocol.c @@ -60,10 +60,6 @@ static void set_freq(uint16_t freq) { DM6300_SetChannel(RF_FREQ); } } -#ifdef _DEBUG_TRAMP - _outchar('0' + ch / 10); - _outchar('0' + ch % 10); -#endif } } @@ -145,12 +141,6 @@ static uint8_t tramp_reply(void) { const uint8_t locked = 0; uint8_t pitmode = 0; -#ifdef _DEBUG_TRAMP - _outchar('\r'); - _outchar('\n'); - _outchar('<'); - _outchar(respCode); -#endif memset(tbuf, 0x00, 16); switch (respCode) { case 'r': { @@ -164,9 +154,6 @@ static uint8_t tramp_reply(void) { tbuf[7] = 200 >> 8; trampResponse(); -#ifdef _DEBUG_TRAMP - _outchar('>'); -#endif return respCode; } @@ -183,28 +170,18 @@ static uint8_t tramp_reply(void) { tbuf[9] = power >> 8; trampResponse(); -#ifdef _DEBUG_TRAMP - _outchar('>'); -#endif return respCode; } case 'F': { freq = ((uint16_t)rbuf[2] & 0xff) | ((uint16_t)rbuf[3] << 8); set_freq(freq); -#ifdef _DEBUG_TRAMP - _outchar('>'); -#endif return respCode; } case 'P': { power = ((uint16_t)rbuf[2] & 0xff) | ((uint16_t)rbuf[3] << 8); set_power(power); -#ifdef _DEBUG_TRAMP - _outchar('0' + RF_POWER); - _outchar('>'); -#endif return respCode; } @@ -215,9 +192,6 @@ static uint8_t tramp_reply(void) { tbuf[7] = 0x00; trampResponse(); -#ifdef _DEBUG_TRAMP - _outchar('>'); -#endif return respCode; } @@ -257,12 +231,6 @@ void tramp_receive(void) { tramp_lock = 1; tramp_reply(); } -#ifdef _DEBUG_TRAMP - else { - _outchar('?'); - _outchar(rbuf[1]); - } -#endif // Reset state machine ready for next response tramp_reset_receive(); diff --git a/src/uart.c b/src/uart.c index 0e44299..fed15f6 100644 --- a/src/uart.c +++ b/src/uart.c @@ -42,9 +42,6 @@ void uart_set_baudrate(uint8_t baudIndex) { TH1 = 0xF6; break; } -#ifdef _DEBUG_MODE - debugf("\r\nSet uart baudrate to %bx", baudIndex); -#endif } void uart_init() { @@ -216,10 +213,6 @@ void suart_rxint() // ISR SUART_rbuf[SUART_rin++] = rxbyte; SUART_rin &= (SUART_BUF_MAX - 1); -#ifdef _DEBUG_SMARTAUDIO - if (SUART_rin == SUART_rout) - SUART_rERR = 1; -#endif } } } @@ -234,12 +227,6 @@ uint8_t SUART_ready() { uint8_t SUART_rx() { uint8_t ret; -#ifdef _DEBUG_SMARTAUDIO - if (SUART_rERR) { - SUART_rERR = 0; - _outchar('&'); - } -#endif ret = SUART_rbuf[SUART_rout]; SUART_rout++;