Skip to content

Commit

Permalink
Merge pull request #215 from ligenxxxx/remove-smartaudio
Browse files Browse the repository at this point in the history
Remove Smart Audio
  • Loading branch information
ligenxxxx authored Aug 21, 2024
2 parents 96d2b6c + 8e0574f commit c60b566
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 990 deletions.
7 changes: 2 additions & 5 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
// #define _DEBUG_TC3587
// #define _DEBUG_CAMERA
// #define _DEBUG_LIFETIME
// #define _DEBUG_SMARTAUDIO
// #define _DEBUG_DISPLAYPORT
// #define _DEBUG_RUNCAM
// #define _DEBUG_SPI
Expand Down Expand Up @@ -117,7 +116,7 @@
#define PRESS_LL 8
#define PWR_LMT_SEC 10

#if defined USE_SMARTAUDIO_SW || defined USE_SMARTAUDIO_HW || defined USE_TRAMP
#if defined USE_TRAMP
#define WAIT_SA_LOCK 4
#define WAIT_SA_CONFIG 9
#else
Expand All @@ -138,9 +137,7 @@
#elif !defined USE_TC3587_LED
#define LED_1 P0_2
#endif
#if defined USE_SMARTAUDIO_SW
#define SUART_PORT P0_3
#elif defined USE_TC3587_RSTB
#if defined USE_TC3587_RSTB
#define TC3587_RSTB P0_3
#elif defined USE_USB_DET
#define USB_DET P0_3
Expand Down
5 changes: 0 additions & 5 deletions src/dm5680_fw_tx.uvproj
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,6 @@
<FileType>1</FileType>
<FilePath>.\msp_displayport.c</FilePath>
</File>
<File>
<FileName>smartaudio_protocol.c</FileName>
<FileType>1</FileType>
<FilePath>.\smartaudio_protocol.c</FilePath>
</File>
<File>
<FileName>camera.c</FileName>
<FileType>1</FileType>
Expand Down
111 changes: 2 additions & 109 deletions src/hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "msp_displayport.h"
#include "print.h"
#include "sfr_ext.h"
#include "smartaudio_protocol.h"
#include "spi.h"
#include "tramp_protocol.h"
#include "uart.h"
Expand Down Expand Up @@ -59,7 +58,6 @@ int16_t temperature = 0;
uint8_t pwr_offset = 0;
uint8_t heat_protect = 0;

uint8_t last_SA_lock = 0;
/*
cur_pwr:
0: 25mW
Expand Down Expand Up @@ -482,18 +480,6 @@ void GetVtxParameter() {
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);
if (last_SA_lock == 0xff) {
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
// powerLock
powerLock = 0x01 & I2C_Read8_Wait(10, ADDR_EEPROM, EEP_ADDR_POWER_LOCK);
Expand Down Expand Up @@ -932,68 +918,14 @@ void PwrLMT() {
return;

#ifndef _RF_CALIB
if (SA_lock) { // Smart Audio
HeatProtect();
if (!heat_protect) {
if (pwr_lmt_done == 0) {
if (pwr_tflg) {
pwr_tflg = 0;
pwr_lmt_sec++;

#if defined HDZERO_FREESTYLE_V1 || HDZERO_FREESTYLE_V2
// test: power plus every sec
if (pwr_lmt_sec >= 3) {
if (RF_POWER == 3) {
if (p_init) {
p = table_power[RF_FREQ][3] - 0x1C;
p_init = 0;
}

SPI_Write(0x6, 0xFF0, 0x00000018);

if (p >= table_power[RF_FREQ][3]) {
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);
SPI_Write(0x3, 0x330, 0x31F); // 1W
}
}
#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;
pwr_lmt_done = 1;
pwr_lmt_sec = 0;
// test: power init reset
p_init = 1;

#ifdef _DEBUG_MODE
debugf("\r\nPower limit done.");
#endif
Prompt();
}
}
} else {
PowerAutoSwitch();
}
}
}
/*
else if(!fc_lock){ //No FC connected
HeatProtect();
if(!heat_protect && seconds > 5)
PowerAutoSwitch();
}
*/
else if (g_IS_ARMED) { // Armed
if (g_IS_ARMED) { // Armed
PowerAutoSwitch();
HeatProtect();
} else { // Disarmed
Expand Down Expand Up @@ -1440,9 +1372,6 @@ void OnButton1() {
static uint16_t cur_sec = 0;
static uint8_t last_keyon = 0;

if (SA_lock)
return;

if (cur_sec != seconds) {
cur_sec = seconds;

Expand Down Expand Up @@ -1638,31 +1567,17 @@ void timer_task() {
}

void RF_Delay_Init() {
static uint8_t SA_saved = 0;

#ifdef _RF_CALIB
return;
#endif

if (tramp_lock)
return;

if (SA_saved == 0) {
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
}
}

// init_rf
if (seconds < WAIT_SA_CONFIG) { // wait for SA config vtx
if (seconds < WAIT_SA_LOCK)
return;
else if (SA_lock)
return;
else
seconds = WAIT_SA_CONFIG;
} else if (rf_delay_init_done)
Expand All @@ -1672,29 +1587,7 @@ void RF_Delay_Init() {
else
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
RF_POWER = POWER_MAX + 2;
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) {
if (!mspVtxLock) {
#ifdef _DEBUG_MODE
debugf("\r\nRF_Delay_Init: None");
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,11 @@ extern uint8_t heat_protect;
extern uint8_t fc_lock;
extern uint8_t vtx_pit;
extern uint8_t vtx_pit_save;
extern uint8_t SA_lock;
extern uint8_t pwr_lmt_sec;
extern uint8_t pwr_lmt_done;

extern uint8_t cur_pwr;

extern uint8_t last_SA_lock;
extern uint8_t pwr_init;
extern uint8_t ch_init;

Expand Down
53 changes: 3 additions & 50 deletions src/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "rom.h"
#include "runcam.h"
#include "sfr_ext.h"
#include "smartaudio_protocol.h"
#include "tramp_protocol.h"
#include "uart.h"
#include "version.h"
Expand All @@ -26,17 +25,6 @@ BIT_TYPE int1_req = 0;

void Timer0_isr(void) INTERRUPT(1) {
TH0 = 138;

#ifdef USE_SMARTAUDIO_SW
if (SA_config) {
if (suart_tx_en) {
// TH0 = 139;
suart_txint();
} else
suart_rxint();
}
#endif

timer_ms10x++;
}

Expand Down Expand Up @@ -66,30 +54,6 @@ void UART0_isr() INTERRUPT(4) {
RS_Xbusy = 0;
}
}
#ifdef USE_SMARTAUDIO_HW
void UART1_isr() INTERRUPT(6) {

if (RI1) { // RX int
RI1 = 0;
if (sa_status == SA_ST_IDLE) {
uart_set_baudrate(3);
sa_status = SA_ST_RX;
sa_start_ms = timer_ms10x;
}
if (sa_status == SA_ST_TX)
return;

RS_buf1[RS_in1++] = SBUF1;
if (RS_in1 >= BUF1_MAX)
RS_in1 = 0;
}

if (TI1) { // TX int
TI1 = 0;
RS_Xbusy1 = 0;
}
}
#else
void UART1_isr() INTERRUPT(6) {

if (RI1 && (tr_tx_busy == 0)) { // RX int
Expand All @@ -104,7 +68,6 @@ void UART1_isr() INTERRUPT(6) {
RS_Xbusy1 = 0;
}
}
#endif

void version_info(void) {
#ifdef _DEBUG_MODE
Expand Down Expand Up @@ -135,9 +98,7 @@ void main(void) {
Init_HW(); // init
fc_init(); // init displayport

#ifdef USE_SMARTAUDIO_SW
SA_Init();
#elif defined USE_TRAMP
#if defined USE_TRAMP
tramp_init();
#endif

Expand All @@ -148,15 +109,7 @@ void main(void) {
// 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
#if defined USE_TRAMP
tramp_receive();
#endif

Expand All @@ -168,7 +121,7 @@ void main(void) {
video_detect();
OnButton1();

if (last_SA_lock && seconds < WAIT_SA_CONFIG)
if (seconds < WAIT_SA_CONFIG)
;
else {
LED_Task();
Expand Down
Loading

0 comments on commit c60b566

Please sign in to comment.