Trigger working

Removed_REF_marker
erikkaashoek 5 years ago
parent 8f3a4da50e
commit c4a9d02bd5

@ -376,7 +376,7 @@ extern uint16_t graph_bottom;
// Maximum menu buttons count // Maximum menu buttons count
#define MENU_BUTTON_MAX 8 #define MENU_BUTTON_MAX 8
#define MENU_BUTTON_WIDTH 80 #define MENU_BUTTON_WIDTH 80
#define MENU_BUTTON_HEIGHT (LCD_HEIGHT/8-2) #define MENU_BUTTON_HEIGHT (LCD_HEIGHT/8-1)
#define MENU_BUTTON_BORDER 1 #define MENU_BUTTON_BORDER 1
#define KEYBOARD_BUTTON_BORDER 2 #define KEYBOARD_BUTTON_BORDER 2
#define FORM_BUTTON_BORDER 2 #define FORM_BUTTON_BORDER 2

@ -1755,6 +1755,9 @@ static void calculate_static_correction(void) // Calculate the
correct_RSSI = correct_RSSI =
#ifdef __SI4432__ #ifdef __SI4432__
getSI4432_RSSI_correction() getSI4432_RSSI_correction()
#endif
#ifdef __SI4463__
getSI4463_RSSI_correction()
#endif #endif
- get_signal_path_loss() - get_signal_path_loss()
+ float_TO_PURE_RSSI( + float_TO_PURE_RSSI(
@ -2195,11 +2198,10 @@ modulation_again:
pureRSSI = DEVICE_TO_PURE_RSSI((deviceRSSI_t)SI4432_Read_Byte(SI4432_REG_RSSI)); pureRSSI = DEVICE_TO_PURE_RSSI((deviceRSSI_t)SI4432_Read_Byte(SI4432_REG_RSSI));
#endif #endif
#ifdef __SI4463__ #ifdef __SI4463__
pureRSSI = DEVICE_TO_PURE_RSSI((deviceRSSI_t)Si446x_RSSI()); pureRSSI = Si446x_RSSI();
#endif #endif
if (break_on_operation && operation_requested) // allow aborting a wait for trigger if (break_on_operation && operation_requested) // allow aborting a wait for trigger
return 0; // abort return 0; // abort
// Store data level bitfield (remember only last 2 states) // Store data level bitfield (remember only last 2 states)
// T_LEVEL_UNDEF mode bit drop after 2 shifts // T_LEVEL_UNDEF mode bit drop after 2 shifts
data_level = ((data_level<<1) | (pureRSSI < trigger_lvl ? T_LEVEL_BELOW : T_LEVEL_ABOVE))&(T_LEVEL_CLEAN); data_level = ((data_level<<1) | (pureRSSI < trigger_lvl ? T_LEVEL_BELOW : T_LEVEL_ABOVE))&(T_LEVEL_CLEAN);
@ -2214,8 +2216,8 @@ modulation_again:
SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer
} }
#endif #endif
#ifdef __SI446x__ #ifdef __SI4463__
if (setting.spur_removal == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { if (/* S_STATE(setting.spur_removal) == 0 && */ SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
SI446x_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer SI446x_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer
} }
#endif #endif
@ -2225,7 +2227,8 @@ modulation_again:
} }
start_of_sweep_timestamp = chVTGetSystemTimeX(); start_of_sweep_timestamp = chVTGetSystemTimeX();
} }
else { else
{
#ifdef __SI4432__ #ifdef __SI4432__
pureRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)); // Get RSSI, either from pre-filled buffer pureRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)); // Get RSSI, either from pre-filled buffer
#endif #endif
@ -2234,8 +2237,8 @@ modulation_again:
#endif #endif
} }
#ifdef __SPUR__ #ifdef __SPUR__
static pureRSSI_t spur_RSSI = -1; // Initialization only to avoid warning. static pureRSSI_t spur_RSSI = 10000; // Initialization only to avoid warning.
if (S_STATE(setting.spur_removal)) { if (setting.mode == M_LOW && S_STATE(setting.spur_removal)) {
if (!spur_second_pass) { // If first spur pass if (!spur_second_pass) { // If first spur pass
spur_RSSI = pureRSSI; // remember measure RSSI spur_RSSI = pureRSSI; // remember measure RSSI
spur_second_pass = true; spur_second_pass = true;

@ -43,8 +43,8 @@
// Hardware or software SPI use // Hardware or software SPI use
#ifdef USE_HARDWARE_SPI_MODE #ifdef USE_HARDWARE_SPI_MODE
#define SI4432_SPI SPI1 #define SI4432_SPI SPI1
#define SI4432_SPI_SPEED SPI_BR_DIV8
//#define SI4432_SPI_SPEED SPI_BR_DIV64 //#define SI4432_SPI_SPEED SPI_BR_DIV64
#define SI4432_SPI_SPEED SPI_BR_DIV8
static uint32_t old_spi_settings; static uint32_t old_spi_settings;
#else #else
static uint32_t old_port_moder; static uint32_t old_port_moder;
@ -1236,7 +1236,7 @@ int SI4463_wait_for_cts(void)
{ {
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
while (!SI4463_READ_CTS) { while (!SI4463_READ_CTS) {
my_microsecond_delay(10); my_microsecond_delay(1);
} }
return 1; return 1;
} }
@ -1266,7 +1266,6 @@ void SI4463_write_buffer(uint8_t ADR, uint8_t *DATA, int len)
uint8_t SI4463_read_byte( uint8_t ADR ) uint8_t SI4463_read_byte( uint8_t ADR )
{ {
set_SPI_mode(SPI_MODE_SI);
uint8_t DATA ; uint8_t DATA ;
set_SPI_mode(SPI_MODE_SI); set_SPI_mode(SPI_MODE_SI);
SI_CS_LOW; SI_CS_LOW;
@ -1303,7 +1302,7 @@ uint8_t SI4463_wait_response(void* buff, uint8_t len, uint8_t use_timeout)
uint16_t timeout = 40000; uint16_t timeout = 40000;
while(!SI4463_get_response(buff, len)) while(!SI4463_get_response(buff, len))
{ {
my_microsecond_delay(10); my_microsecond_delay(1);
if(use_timeout && !--timeout) if(use_timeout && !--timeout)
{ {
((char *)buff)[0] = 1; ((char *)buff)[0] = 1;
@ -1322,10 +1321,13 @@ void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen)
if (SI4463_wait_for_cts()) if (SI4463_wait_for_cts())
#endif #endif
{ {
// SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8);
SI_CS_LOW; SI_CS_LOW;
for(uint8_t i=0;i<len;i++) { for(uint8_t i=0;i<len;i++) {
shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i])); shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i]));
} }
// SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8);
SI_CS_HIGH; SI_CS_HIGH;
#if 0 #if 0
if(((uint8_t*)data)[0] == SI446X_CMD_IRCAL) // If we're doing an IRCAL then wait for its completion without a timeout since it can sometimes take a few seconds if(((uint8_t*)data)[0] == SI446X_CMD_IRCAL) // If we're doing an IRCAL then wait for its completion without a timeout since it can sometimes take a few seconds
@ -1721,9 +1723,12 @@ void SI446x_Fill(int s, int start)
int i = start; int i = start;
uint8_t data[3]; uint8_t data[3];
do { do {
again:
data[0] = SI446X_CMD_GET_MODEM_STATUS; data[0] = SI446X_CMD_GET_MODEM_STATUS;
data[1] = 0xFF; data[1] = 0xFF;
SI4463_do_api(data, 2, data, 3); SI4463_do_api(data, 1, data, 3); // TODO no clear of interrups
if (data[2] == 0) goto again;
if (data[2] == 255) goto again;
age[i]=(char)data[2]; age[i]=(char)data[2];
if (++i >= sweep_points) break; if (++i >= sweep_points) break;
if (t) if (t)
@ -1770,22 +1775,22 @@ int16_t Si446x_RSSI(void)
SI4463_frequency_changed = false; SI4463_frequency_changed = false;
} }
int j = 3; //setting.repeat; int j = 1; //setting.repeat;
int RSSI_RAW_ARRAY[3]; int RSSI_RAW_ARRAY[3];
do{ do{
again: again:
data[0] = SI446X_CMD_GET_MODEM_STATUS; data[0] = SI446X_CMD_GET_MODEM_STATUS;
data[1] = 0xFF; data[1] = 0xFF;
SI4463_do_api(data, 2, data, 3); SI4463_do_api(data, 2, data, 3); // TODO no clear of interrupts
if (data[2] == 255) { if (data[2] == 255) {
my_microsecond_delay(10); my_microsecond_delay(10);
goto again; goto again;
} }
RSSI_RAW_ARRAY[--j] = data[2] - 120 * 2; RSSI_RAW_ARRAY[--j] = data[2];
if (j == 0) break; if (j == 0) break;
my_microsecond_delay(100); my_microsecond_delay(20);
}while(1); }while(1);
#if 1 #if 0
int t; int t;
if (RSSI_RAW_ARRAY[0] > RSSI_RAW_ARRAY[1]) { if (RSSI_RAW_ARRAY[0] > RSSI_RAW_ARRAY[1]) {
t = RSSI_RAW_ARRAY[1]; t = RSSI_RAW_ARRAY[1];
@ -2128,6 +2133,10 @@ const int SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));
static pureRSSI_t SI4463_RSSI_correction = float_TO_PURE_RSSI(-120); static pureRSSI_t SI4463_RSSI_correction = float_TO_PURE_RSSI(-120);
static int prev_band = -1; static int prev_band = -1;
pureRSSI_t getSI4463_RSSI_correction(void){
return SI4463_RSSI_correction;
};
uint16_t force_rbw(int f) uint16_t force_rbw(int f)
{ {
@ -2210,7 +2219,7 @@ void SI4463_set_freq(uint32_t freq)
my_microsecond_delay(10); my_microsecond_delay(10);
} }
if ((SI4463_band == prev_band)) { if ((SI4463_band == prev_band)) {
int vco = 2091 + (((freq - 850000000)/1000) * 492) / 200000; int vco = 2091 + ((((freq / 4 ) * SI4463_outdiv - 850000000)/1000) * 492) / 200000;
if (SI4463_in_tx_mode) { if (SI4463_in_tx_mode) {
uint8_t data[] = { uint8_t data[] = {

@ -188,6 +188,7 @@ si446x_state_t getState(void);
void setState(si446x_state_t newState); void setState(si446x_state_t newState);
extern const int SI4432_RBW_count; extern const int SI4432_RBW_count;
extern si446x_info_t SI4463_info; extern si446x_info_t SI4463_info;
pureRSSI_t getSI4463_RSSI_correction(void);
void Si446x_getInfo(si446x_info_t* info); void Si446x_getInfo(si446x_info_t* info);
void SI446x_Fill(int s, int start); void SI446x_Fill(int s, int start);
void SI4463_init(void); void SI4463_init(void);

Loading…
Cancel
Save

Powered by TurnKey Linux.