Merge DiSlord improvements, add Listen to tinySA4, change cal level to -25dBm

Removed_REF_marker
erikkaashoek 5 years ago
parent 7f6c9fe609
commit 6805c661c2

@ -667,9 +667,9 @@ void ili9341_read_memory(int x, int y, int w, int h, uint16_t *out)
// Parse received data to RGB565 format while data receive by DMA // Parse received data to RGB565 format while data receive by DMA
uint8_t *rgbbuf = (uint8_t *)out; uint8_t *rgbbuf = (uint8_t *)out;
do { do {
uint16_t left = dmaStreamGetTransactionSize(dmarx); // Get DMA data left uint16_t left = dmaStreamGetTransactionSize(dmarx) + 3; // Get DMA data left
if (left+3 > len) continue;// Next pixel RGB data not ready if (left > len) continue; // Next pixel RGB data not ready
while (left < len){ // Process completed by DMA data do{ // Process completed by DMA data
uint8_t r, g, b; // read data is always 18bit in RGB888 format uint8_t r, g, b; // read data is always 18bit in RGB888 format
r = rgbbuf[0]; r = rgbbuf[0];
g = rgbbuf[1]; g = rgbbuf[1];
@ -677,7 +677,7 @@ void ili9341_read_memory(int x, int y, int w, int h, uint16_t *out)
*out++ = RGB565(r, g, b); *out++ = RGB565(r, g, b);
rgbbuf+= 3; rgbbuf+= 3;
len -= 3; len -= 3;
} } while (left < len);
} while(len); } while(len);
dmaWaitCompletionRxTx(); // Wait DMA completion and stop it dmaWaitCompletionRxTx(); // Wait DMA completion and stop it
#endif #endif

@ -2937,6 +2937,7 @@ int main(void)
* by the Reference Manual. * by the Reference Manual.
*/ */
dacStart(&DACD2, &dac1cfg1); dacStart(&DACD2, &dac1cfg1);
dacStart(&DACD1, &dac1cfg1);
setup_sa(); setup_sa();
set_sweep_points(POINTS_COUNT); set_sweep_points(POINTS_COUNT);

@ -72,6 +72,7 @@
//#define __LIMITS__ //#define __LIMITS__
#ifdef TINYSA4 #ifdef TINYSA4
#define __HARMONIC__ #define __HARMONIC__
#else
#endif #endif
#ifdef TINYSA3 #ifdef TINYSA3
@ -1310,7 +1311,7 @@ enum {
}; };
extern const int SI4432_RBW_count; extern const uint8_t SI4432_RBW_count;
extern void SI4432_Listen(int s); extern void SI4432_Listen(int s);
#ifdef TINYSA4 #ifdef TINYSA4

@ -304,21 +304,29 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
return; return;
} }
int mode = get_str_index(argv[0], cmd_mode_list); int mode = get_str_index(argv[0], cmd_mode_list);
if (mode < 0) goto usage;
float v; float v;
if (argc == 2) if (argc == 2){
v = my_atof(argv[1]); v = my_atof(argv[1]);
else if (argc == 3 && get_str_index(argv[1], "output") == 0) switch (mode){
case 0: config.low_level_offset = v; break;
case 1: config.high_level_offset = v; break;
case 2: config.switch_offset = v; break;
default: goto usage;
}
dirty = true;
return;
}
if (argc == 3 && get_str_index(argv[1], "output") == 0){
v = my_atof(argv[2]); v = my_atof(argv[2]);
else switch (mode){
goto usage; case 0: config.low_level_output_offset = v; break;
switch (mode){ case 1: config.high_level_output_offset = v; break;
case 0: config.low_level_offset = v; break; default: goto usage;
case 1: config.high_level_offset = v; break; }
case 2: config.switch_offset = v; break; dirty = true;
default: goto usage; return;
} }
dirty = true;
return;
usage: usage:
shell_printf("leveloffset [%s] {output} [-20..+20]\r\n", cmd_mode_list); shell_printf("leveloffset [%s] {output} [-20..+20]\r\n", cmd_mode_list);
} }

@ -3920,11 +3920,11 @@ enum {
#define W2P(w) (sweep_points * w / 100) // convert width in % to actual sweep points #define W2P(w) (sweep_points * w / 100) // convert width in % to actual sweep points
#ifdef TINYSA4 //#ifdef TINYSA4
#define CAL_LEVEL -30 //#define CAL_LEVEL -30
#else //#else
#define CAL_LEVEL -25 #define CAL_LEVEL -25
#endif //#endif
// TODO made more compact this structure (need use aligned data) // TODO made more compact this structure (need use aligned data)
typedef struct test_case { typedef struct test_case {
@ -4577,7 +4577,6 @@ void self_test(int test)
// setting.step_delay = setting.step_delay * 4 / 5; // setting.step_delay = setting.step_delay * 4 / 5;
// goto do_again; // goto do_again;
// } // }
// if (peakLevel < -35) { // if (peakLevel < -35) {
// shell_printf("Peak level too low, abort\n\r"); // shell_printf("Peak level too low, abort\n\r");
// return; // return;
@ -4774,6 +4773,9 @@ void calibrate(void)
#ifndef TINYSA4 #ifndef TINYSA4
setting.agc = S_ON; setting.agc = S_ON;
setting.lna = S_OFF; setting.lna = S_OFF;
set_RBW(6000);
#else
set_RBW(1000);
#endif #endif
test_acquire(TEST_POWER); // Acquire test test_acquire(TEST_POWER); // Acquire test
local_test_status = test_validate(TEST_POWER); // Validate test local_test_status = test_validate(TEST_POWER); // Validate test
@ -4790,11 +4792,11 @@ void calibrate(void)
ili9341_drawstring_7x13("Calibration failed", 30, 140); ili9341_drawstring_7x13("Calibration failed", 30, 140);
goto quit; goto quit;
} else { } else {
#ifdef TINYSA4 //#ifdef TINYSA4
set_actual_power(-30.0); // Should be -23.5dBm (V0.2) OR 25 (V0.3) // set_actual_power(-30.0); // Should be -23.5dBm (V0.2) OR 25 (V0.3)
#else //#else
set_actual_power(-25.0); // Should be -23.5dBm (V0.2) OR 25 (V0.3) set_actual_power(CAL_LEVEL); // Should be -23.5dBm (V0.2) OR 25 (V0.3)
#endif //#endif
chThdSleepMilliseconds(1000); chThdSleepMilliseconds(1000);
} }
} }

@ -447,7 +447,7 @@ static const RBW_t RBW_choices[] =
}; };
const int SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t))); const uint8_t SI4432_RBW_count = ARRAY_COUNT(RBW_choices);
static pureRSSI_t SI4432_RSSI_correction = float_TO_PURE_RSSI(-120); static pureRSSI_t SI4432_RSSI_correction = float_TO_PURE_RSSI(-120);

@ -1914,6 +1914,75 @@ again:
} }
#endif #endif
#ifdef __LISTEN__
const uint8_t dBm_to_volt [] =
{
255,
225,
198,
175,
154,
136,
120,
106,
93,
82,
72,
64,
56,
50,
44,
39,
34,
30,
26,
23,
21,
18,
16,
14,
12,
11,
10,
8,
7,
7,
6,
5,
5,
};
void SI4432_Listen(int s)
{
(void) s;
uint8_t max = 0;
uint16_t count = 0;
operation_requested = OP_NONE;
do {
uint8_t v;
uint8_t data[3] = {
SI446X_CMD_GET_MODEM_STATUS,
0xFF
};
uint8_t out[3];
__disable_irq();
SI4463_do_api(data, 2, out, 3); // TODO no clear of interrupts
__enable_irq();
v = out[2];
if (max < v) // Peak
max = v;
if (count > 1000) { // Decay
max -= 1;
count = 0;
} else
count++;
v = max - v;
dacPutChannelX(&DACD1, 0, dBm_to_volt[v] << 4);
} while(operation_requested == OP_NONE);
count = 0;
// dacPutChannelX(&DACD2, 0, 0);
}
#endif
int16_t Si446x_RSSI(void) int16_t Si446x_RSSI(void)
@ -2298,7 +2367,7 @@ static const RBW_t RBW_choices[] =
{SI4463_RBW_850kHz,0,6000}, {SI4463_RBW_850kHz,0,6000},
}; };
const int SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t))); const uint8_t 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;

Loading…
Cancel
Save

Powered by TurnKey Linux.