Move radio definitions in to portab. Allow > 1 band per radio entry.

pull/4/head
CInsights 2018-05-13 09:33:32 +10:00
rodzic 03fcacd0c8
commit 506443045a
6 zmienionych plików z 83 dodań i 51 usunięć

Wyświetl plik

@ -20,6 +20,7 @@
#include "pkttypes.h"
#include "portab.h"
#include "usb.h"
#include "types.h"
#include <stdarg.h>
/*===========================================================================*/
@ -29,15 +30,15 @@
const radio_band_t band_2m = {
.start = BAND_MIN_2M_FREQ,
.end = BAND_MAX_2M_FREQ,
.step = 12500,
.def = BAND_DEF_2M_FREQ
.step = BAND_STEP_2M_HZ,
.def_aprs = BAND_DEF_2M_APRS
};
const radio_band_t band_70cm = {
.start = BAND_MIN_70CM_FREQ,
.end = BAND_MAX_70CM_FREQ,
.step = 25000,
.def = BAND_DEF_70CM_FREQ
.step = BAND_STEP_70CM_HZ,
.def_aprs = BAND_DEF_70CM_APRS
};
/*===========================================================================*/
@ -50,10 +51,13 @@ typedef struct SysProviders {
const radio_param_t radio_list[NUM_PKT_RADIOS] = {
{ /* Radio #1 */
.id = PKT_RADIO_1,
.unit = PKT_RADIO_1,
.type = SI4464,
.band = (radio_band_t * const)&band_2m
}/* End radio1 */
.band = {
(radio_band_t * const)&band_2m,
NULL
}
} /* End radio1 */
};
/*===========================================================================*/
@ -186,5 +190,36 @@ void sysConfigureCoreIO(void) {
#endif
}
/*
* Return a single radio parameter record pointer
* The radio parameter picks a single records.
* The current system does not work if the same radio is listed multiple times.
* TODO: Have an enumerate and check radio array on startup.
*/
radio_param_t *pktGetRadioParameters(radio_unit_t radio) {
(void)radio;
}
/*
*
*/
radio_freq_t pktCheckAllowedFrequency(radio_unit_t radio, radio_freq_t freq) {
/* Check validity. */
uint8_t radios = NUM_PKT_RADIOS/*sizeof(radio_list) / sizeof(radio_param_t)*/;
for(uint8_t i = 0; i < radios; i++) {
if(radio_list[i].unit != radio)
continue;
for(uint8_t x = 0; x < NUM_BANDS_PER_RADIO; x++) {
if(radio_list[i].band[x] == NULL)
/* No more bands in this radio. */
return FREQ_RADIO_INVALID;
if(radio_list[i].band[x]->start <= freq
&& freq < radio_list[i].band[x]->end)
return freq;
} /* End for bands */
} /* End for radios*/
return FREQ_RADIO_INVALID;
}
/** @} */

Wyświetl plik

@ -47,10 +47,12 @@
#define BAND_MIN_2M_FREQ 144000000 /* Minimum allowed frequency in Hz */
#define BAND_MAX_2M_FREQ 148000000 /* Maximum allowed frequency in Hz */
#define BAND_DEF_2M_FREQ 144800000 /* Default frequency in Hz. */
#define BAND_STEP_2M_HZ 12500
#define BAND_DEF_2M_APRS 144800000 /* Default frequency in Hz. */
#define BAND_MIN_70CM_FREQ 420000000 /* Minimum allowed frequency in Hz */
#define BAND_MAX_70CM_FREQ 450000000 /* Maximum allowed frequency in Hz */
#define BAND_DEF_70CM_FREQ 439100000 /* Default frequency in Hz. */
#define BAND_STEP_70CM_HZ 25000
#define BAND_DEF_70CM_APRS 439100000 /* Default frequency in Hz. */
#define DEFAULT_OPERATING_FREQ 144800000
@ -59,6 +61,7 @@
#define Si446x_CLK_TCXO_EN true /* Set this true, if a TCXO is used, false for XTAL */
#define NUM_PKT_RADIOS 1
#define NUM_BANDS_PER_RADIO 2
//#define LINE_OVERFLOW_LED LINE_LED3
#define LINE_DECODER_LED LINE_IO_BLUE
@ -149,6 +152,19 @@
/* Module data structures and types. */
/*===========================================================================*/
typedef struct radioBand {
radio_freq_t start;
radio_freq_t end;
channel_hz_t step;
radio_freq_t def_aprs;
} radio_band_t;
typedef struct radioParam {
radio_unit_t unit;
radio_type_t type;
radio_band_t *band[NUM_BANDS_PER_RADIO];
} radio_param_t;
/*===========================================================================*/
/* Module macros. */
/*===========================================================================*/
@ -157,7 +173,7 @@
/* External declarations. */
/*===========================================================================*/
extern const radio_param_t radio_list[NUM_PKT_RADIOS];
//extern const radio_param_t radio_list[NUM_PKT_RADIOS];
#ifdef __cplusplus
extern "C" {
@ -172,6 +188,7 @@ extern "C" {
void pktWrite(uint8_t *buf, uint32_t len);
void pktPowerUpRadio(radio_unit_t radio);
void pktPowerDownRadio(radio_unit_t radio);
radio_freq_t pktCheckAllowedFrequency(radio_unit_t radio, radio_freq_t freq);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -11,7 +11,7 @@ const conf_t conf_flash_default = {
// Primary position app
.pos_pri = {
.thread_conf = {
.active = true,
.active = false,
.cycle = TIME_S2I(60*60),
.init_delay = TIME_S2I(60*30)
},
@ -34,22 +34,22 @@ const conf_t conf_flash_default = {
.pos_sec = {
.thread_conf = {
.active = false,
.cycle = TIME_S2I(120),
.init_delay = TIME_S2I(60)
.cycle = TIME_S2I(60*1),
.init_delay = TIME_S2I(60*1)
},
.radio_conf = {
.pwr = 0x7F,
.freq = FREQ_APRS_DYNAMIC,
.mod = MOD_AFSK,
.freq = 144800000,
.mod = MOD_2FSK,
.cca = 0x4F
},
// App identity
.call = "DL7AD-14",
.path = "WIDE1-1",
.symbol = SYM_BALLOON,
.aprs_msg = true,
.tel_enc_cycle = TIME_S2I(10800)
.call = "VK2GJ-12",
.path = "WIDE2-1",
.symbol = SYM_ANTENNA,
.aprs_msg = false,
// How often to send telemetry config
.tel_enc_cycle = TIME_S2I(60*180)
},
// Primary image app

Wyświetl plik

@ -547,7 +547,7 @@ radio_freq_t pktGetReceiveOperatingFrequency(const radio_unit_t radio) {
/**
* @brief Compute an operating frequency.
* @notes All special frequency parameters are handled.
* @notes All special frequency codes are resolved to an actual frequency.
*
* @param[in] radio Radio unit ID.
* @param[in] base_freq Radio base frequency.
@ -571,7 +571,7 @@ radio_freq_t pktComputeOperatingFrequency(const radio_unit_t radio,
/* Get current RX frequency (or default) and use that. */
step = 0;
chan = 0;
/* FIXME: Should switch on all special codes to make system robust. */
/* FIXME: Should switch on all special codes for error check. */
base_freq = pktGetReceiveOperatingFrequency(radio);
}
@ -599,22 +599,11 @@ radio_freq_t pktComputeOperatingFrequency(const radio_unit_t radio,
/* Calculate operating frequency. */
radio_freq_t op_freq = base_freq + (step * chan);
/* Check validity. */
uint8_t radios = sizeof(radio_list) / sizeof(radio_param_t);
for(uint8_t i = 0; i < radios; i++) {
if(radio_list[i].id == radio) {
if(radio_list[i].band->start <= op_freq
&& op_freq < radio_list[i].band->end)
return op_freq;
else
return FREQ_RADIO_INVALID;
}
} /* End for */
return FREQ_RADIO_INVALID;
return pktCheckAllowedFrequency(radio, op_freq);
}
/**
* @brief Send on radio.
* @brief Send packet(s) on radio.
* @notes This is the API interface to the radio LLD.
* @notes Currently just map directly to 446x driver.
* @notes In future would implement a lookup and VMT to access radio methods.

Wyświetl plik

@ -29,6 +29,7 @@
/* The number of radio task object the FIFO has. */
#define RADIO_TASK_QUEUE_MAX 10
#define NUM_BANDS_PER_RADIO 2
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
@ -53,6 +54,7 @@ typedef enum radioCommand {
*/
typedef struct radioTask radio_task_object_t;
typedef struct packetHandlerData packet_svc_t;
typedef struct radioParam radio_param_t;
/**
* @brief Radio task notification callback type.
@ -90,6 +92,9 @@ struct radioTask {
/* External declarations. */
/*===========================================================================*/
//extern const radio_param_t radio_list[NUM_PKT_RADIOS];
#ifdef __cplusplus
extern "C" {
#endif

Wyświetl plik

@ -70,23 +70,9 @@ typedef enum radioTypes {
typedef enum radioMode {
RADIO_OFF,
RADIO_RX,
RADIO_TX,
RADIO_CCA
RADIO_TX
} radio_mode_t;
typedef struct radioBand {
radio_freq_t start;
radio_freq_t end;
channel_hz_t step;
radio_freq_t def;
} radio_band_t;
typedef struct radioParam {
radio_unit_t id;
radio_type_t type;
radio_band_t *band;
} radio_param_t;
typedef uint8_t ax25char_t;
typedef int32_t gps_coord_t;