summaryrefslogtreecommitdiff
path: root/util_tx_continuous/src/util_tx_continuous.c
diff options
context:
space:
mode:
Diffstat (limited to 'util_tx_continuous/src/util_tx_continuous.c')
-rw-r--r--util_tx_continuous/src/util_tx_continuous.c94
1 files changed, 55 insertions, 39 deletions
diff --git a/util_tx_continuous/src/util_tx_continuous.c b/util_tx_continuous/src/util_tx_continuous.c
index 7768c22..aeaae8d 100644
--- a/util_tx_continuous/src/util_tx_continuous.c
+++ b/util_tx_continuous/src/util_tx_continuous.c
@@ -37,6 +37,7 @@ Maintainer: Matthieu Leurent
#include "loragw_hal.h"
#include "loragw_reg.h"
#include "loragw_aux.h"
+#include "loragw_spi.h"
/* -------------------------------------------------------------------------- */
/* --- MACROS & CONSTANTS --------------------------------------------------- */
@@ -59,7 +60,7 @@ Maintainer: Matthieu Leurent
#define DEFAULT_FDEV_KHZ 25
#define DEFAULT_BT 2
#define DEFAULT_NOTCH_FREQ 129000U
-#define DEFAULT_ATTENUATION 0.0
+#define DEFAULT_ATTENUATION 0
/* -------------------------------------------------------------------------- */
/* --- GLOBAL VARIABLES ----------------------------------------------------- */
@@ -97,6 +98,7 @@ int main(int argc, char **argv)
{"bt", 1, 0, 0},
{"notch", 1, 0, 0},
{"attn", 1, 0, 0},
+ {"path", 1, 0, 0},
{0, 0, 0, 0}
};
unsigned int arg_u;
@@ -109,7 +111,7 @@ int main(int argc, char **argv)
uint8_t g_dac = DEFAULT_DAC_GAIN;
uint8_t g_mix = DEFAULT_MIXER_GAIN;
uint8_t g_pa = DEFAULT_PA_GAIN;
- float g_atten = DEFAULT_ATTENUATION;
+ uint8_t g_atten = DEFAULT_ATTENUATION;
char mod[64] = DEFAULT_MODULATION;
uint8_t sf = DEFAULT_SF;
unsigned int bw_khz = DEFAULT_BW_KHZ;
@@ -117,7 +119,6 @@ int main(int argc, char **argv)
uint8_t fdev_khz = DEFAULT_FDEV_KHZ;
uint8_t bt = DEFAULT_BT;
uint32_t tx_notch_freq = DEFAULT_NOTCH_FREQ;
-
int32_t offset_i, offset_q;
/* RF configuration (TX fail if RF chain is not enabled) */
@@ -149,7 +150,8 @@ int main(int argc, char **argv)
printf(" --br <float> FSK bitrate in kbps, [0.5:250]\n");
printf(" --fdev <uint> FSK frequency deviation in kHz, [1:250]\n");
printf(" --bt <uint> FSK gaussian filter BT trim, [0:3]\n");
- printf(" --attn <float> Attenuator value in dB, Full Card Only [0.0:31.75]\n");
+ printf(" --attn <uint> Attenuator value in dB, required LGA module or MTAC full card\n");
+ printf(" --path <string> Path of SPIDEV e.g. /dev/spidev0.0\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
return EXIT_SUCCESS;
break;
@@ -267,50 +269,59 @@ int main(int argc, char **argv)
}
}
else if (strcmp(long_options[option_index].name,"attn") == 0) {
- i = sscanf(optarg, "%f", &arg_f);
- if ((i != 1) || (arg_f < 0.0) || (arg_f > 31.75)) {
- printf("ERROR: argument parsing of --br argument. Use -h to print help\n");
+ i = sscanf(optarg, "%u", &arg_u);
+ if ((i != 1) || (arg_u > 127) ) {
+ printf("ERROR: argument parsing of --attn argument. Use -h to print help\n");
+ return EXIT_FAILURE;
+ }
+ else {
+ g_atten = arg_u;
+ }
+ } else if (strcmp(long_options[option_index].name,"path") == 0) {
+ i = sscanf(optarg, "%s", arg_s);
+ if ((i != 1) || (strncmp(arg_s, "/dev/", 5 ) != 0)) {
+ printf("ERROR: argument parsing of --path argument. Use -h to print help\n");
return EXIT_FAILURE;
}
else {
- g_atten = arg_f;
+ lgw_spi_set_path(arg_s);
}
- }
+ }
else {
printf("ERROR: argument parsing options. Use -h to print help\n");
return EXIT_FAILURE;
}
break;
- case 'f':
- i = sscanf(optarg, "%f", &arg_f);
- if ((i != 1) || (arg_f < 1)) {
- printf("ERROR: argument parsing of -f argument. Use -h to print help\n");
- return EXIT_FAILURE;
- }
- else {
- freq_hz = (uint32_t)((arg_f * 1e6) + 0.5);
- }
- break;
-
- case 'r':
- i = sscanf(optarg, "%u", &arg_u);
- switch (arg_u) {
- case 1255:
- radio_type = LGW_RADIO_TYPE_SX1255;
- break;
- case 1257:
- radio_type = LGW_RADIO_TYPE_SX1257;
- break;
- default:
- printf("ERROR: argument parsing of -r argument. Use -h to print help\n");
+ case 'f':
+ i = sscanf(optarg, "%f", &arg_f);
+ if ((i != 1) || (arg_f < 1)) {
+ printf("ERROR: argument parsing of -f argument. Use -h to print help\n");
return EXIT_FAILURE;
- }
- break;
+ }
+ else {
+ freq_hz = (uint32_t)((arg_f * 1e6) + 0.5);
+ }
+ break;
- default:
- printf("ERROR: argument parsing options. Use -h to print help\n");
- return EXIT_FAILURE;
+ case 'r':
+ i = sscanf(optarg, "%u", &arg_u);
+ switch (arg_u) {
+ case 1255:
+ radio_type = LGW_RADIO_TYPE_SX1255;
+ break;
+ case 1257:
+ radio_type = LGW_RADIO_TYPE_SX1257;
+ break;
+ default:
+ printf("ERROR: argument parsing of -r argument. Use -h to print help\n");
+ return EXIT_FAILURE;
+ }
+ break;
+
+ default:
+ printf("ERROR: argument parsing options. Use -h to print help\n");
+ return EXIT_FAILURE;
}
}
@@ -362,9 +373,10 @@ int main(int argc, char **argv)
txpkt.freq_hz = freq_hz;
txpkt.tx_mode = IMMEDIATE;
txpkt.rf_chain = TX_RF_CHAIN;
- txpkt.rf_power = 0;
- if (read_fpga_version() == 32) {
- i = lgw_set_attenuation(g_atten);
+ if (fpga_supports_attenuator()) {
+ txpkt.rf_power = 32 - g_atten;
+ } else {
+ txpkt.rf_power = 0;
}
if (strcmp(mod, "FSK") == 0) {
@@ -437,6 +449,10 @@ int main(int argc, char **argv)
printf("ERROR: undefined radio type\n");
break;
}
+
+ if (fpga_supports_attenuator()) {
+ printf("Attenuation : %d dB\n", g_atten);
+ }
printf("Frequency: %4.3f MHz\n", freq_hz/1e6);
printf("TX Gains: Digital:%d DAC:%d Mixer:%d PA:%d\n", g_dig, g_dac, g_mix, g_pa);
if (strcmp(mod, "CW") != 0) {