- Deprecate EXTI from mcuconf.h
- Move setting out of pktconf.c and deprecate it
- New status codes and diagnostics added to AFSK decoder
- Revise allocation packet service and AFSK driver structures
- Revise 446x conditional initialisation placement
pull/4/head
bob 2018-08-11 00:36:05 +10:00
rodzic 1fefc9818d
commit bce5a30d75
17 zmienionych plików z 261 dodań i 182 usunięć

Wyświetl plik

@ -86,6 +86,7 @@
/*
* EXT driver system settings.
*/
/*
#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
@ -98,6 +99,7 @@
#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
#define STM32_EXT_EXTI22_IRQ_PRIORITY 15
*/
/*
* GPT driver system settings.

Wyświetl plik

@ -42,7 +42,7 @@ const si446x_mcucfg_t radio1_cfg = {
.sdn = LINE_RADIO_SDN,
.cs = LINE_RADIO_CS,
.spi = PKT_RADIO1_SPI,
.icu = RADIO1_ICU_DRIVER,
.icu = PKT_RADIO1_ICU,
.alt = (PAL_MODE_INPUT | PAL_MODE_ALTERNATE(2)),
.cfg = {
ICU_INPUT_ACTIVE_HIGH,
@ -59,7 +59,7 @@ const si446x_mcucfg_t radio1_cfg = {
}
};
/* Definition of radio specific data for radio on this board. */
/* Definition of radio driver specific data for radio on this board. */
si446x_data_t radio1_dat = {
.lastTemp = 0x7FFF
/* TODO: Move part and func structs into here
@ -73,11 +73,13 @@ const radio_band_t *const radio_bands[] = {
NULL
};
/* Radios on this board. */
/* Configuration objects for radios on this board. */
const radio_config_t radio_list[] = {
{ /* Radio #1 */
.unit = PKT_RADIO_1,
.type = SI446X,
.pkt = (pkt_service_t *const)&RPKTD1,
.afsk = (AFSKDemodDriver *const)&AFSKD1,
.cfg = (si446x_mcucfg_t *const)&radio1_cfg,
.dat = (si446x_data_t *)&radio1_dat,
.bands = (radio_band_t **const)radio_bands
@ -87,7 +89,9 @@ const radio_config_t radio_list[] = {
}
};
/**
* Debug serial port setting.
*/
const SerialConfig debug_config = {
115200,
0,
@ -120,16 +124,6 @@ void pktConfigSerialDiag(void) {
#endif
}
/**
* TODO: Move this into pktradio.c or make it an Si446x function in si446x.c
* The GPIO assignments per radio should be in the radio record.
*/
/*ioline_t pktSetLineModeICU(const radio_unit_t radio) {
(void)radio;
palSetLineMode(LINE_ICU, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(2));
return LINE_ICU;
}*/
/*
* Read GPIO that are used for:
* a) general use
@ -191,6 +185,7 @@ void pktWrite(uint8_t *buf, uint32_t len) {
}
void pktConfigureCoreIO(void) {
/* TODO: Put ALT mode selections in definitions. */
/* Setup SPI3. */
palSetLineMode(LINE_SPI_SCK, PAL_MODE_ALTERNATE(6)
| PAL_STM32_OSPEED_HIGHEST); // SCK

Wyświetl plik

@ -88,11 +88,6 @@
#define LINE_IO7 PAL_NOLINE
#define LINE_IO8 PAL_NOLINE
/* Si446x clock setup. */
#define Si446x_CLK STM32_HSECLK /* Oscillator frequency in Hz */
#define Si446x_CLK_OFFSET 22 /* Oscillator frequency drift in ppm */
#define Si446x_CLK_TCXO_EN true /* Set this true, if a TCXO is used, false for XTAL */
/*
* Radio GPIO definitions.
*/
@ -114,7 +109,7 @@
#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_STEP_70CM_HZ 25000
#define BAND_STEP_70CM_HZ 12500
#define BAND_DEF_70CM_APRS 439100000 /* Default frequency in Hz. */
#define DEFAULT_OPERATING_FREQ 144800000
@ -127,8 +122,6 @@
#define Si446x_CLK_OFFSET 22 /* Oscillator frequency drift in ppm */
#define Si446x_CLK_TCXO_EN true /* Set this true, if a TCXO is used, false for XTAL */
//#define NUM_BANDS_PER_RADIO 2
/* LED status indicators (set to PAL_NOLINE if not available). */
#define LINE_OVERFLOW_LED PAL_NOLINE
#define LINE_DECODER_LED LINE_IO_BLUE
@ -139,10 +132,6 @@
/* Diagnostic PWM mirror port. */
#define LINE_PWM_MIRROR PAL_NOLINE
/* Radio ports. */
//#define LINE_CCA LINE_RADIO_NIRQ
//#define LINE_ICU LINE_RADIO_GPIO1
//#define LINE_UART4_TX PAL_LINE(GPIOA, 12U)
//#define LINE_UART4_RX PAL_LINE(GPIOA, 11U)
@ -173,7 +162,7 @@
/**
* ICU related definitions.
*/
#define RADIO1_ICU_DRIVER &ICUD4
#define PKT_RADIO1_ICU &ICUD4
#define PWM_ICU_CLK STM32_TIMCLK1
@ -240,6 +229,9 @@
/* Module pre-compile time settings. */
/*===========================================================================*/
#define PKT_SVC_USE_RADIO1 TRUE
#define PKT_SVC_USE_RADIO2 FALSE
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@ -259,24 +251,26 @@
extern const radio_band_t band_2m;
extern const radio_band_t band_70cm;
extern const radio_config_t radio_list[];
extern pkt_service_t RPKTD1;
extern AFSKDemodDriver AFSKD1;
#ifdef __cplusplus
extern "C" {
#endif
void pktConfigSerialDiag(void);
void pktConfigSerialPkt(void);
void pktConfigureCoreIO(void);
ioline_t pktSetLineModeICU(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO1(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO0(const radio_unit_t radio);
void pktSerialStart(void);
void dbgWrite(uint8_t level, uint8_t *buf, uint32_t len);
int dbgPrintf(uint8_t level, const char *format, ...);
void pktWrite(uint8_t *buf, uint32_t len);
uint8_t pktReadIOlines(void);
void pktRadioICUWidth(ICUDriver *icup);
void pktRadioICUPeriod(ICUDriver *icup);
void pktRadioICUOverflow(ICUDriver *icup);
void pktConfigSerialDiag(void);
void pktConfigSerialPkt(void);
void pktConfigureCoreIO(void);
ioline_t pktSetLineModeICU(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO1(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO0(const radio_unit_t radio);
void pktSerialStart(void);
void dbgWrite(uint8_t level, uint8_t *buf, uint32_t len);
int dbgPrintf(uint8_t level, const char *format, ...);
void pktWrite(uint8_t *buf, uint32_t len);
uint8_t pktReadIOlines(void);
void pktRadioICUWidth(ICUDriver *icup);
void pktRadioICUPeriod(ICUDriver *icup);
void pktRadioICUOverflow(ICUDriver *icup);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -17,8 +17,6 @@
#ifndef _MCUCONF_H_
#define _MCUCONF_H_
#include "config.h"
/*
* STM32F4xx drivers configuration.
* The following settings override the default settings present in
@ -84,6 +82,7 @@
/*
* EXT driver system settings.
*/
/*
#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
@ -96,6 +95,7 @@
#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
#define STM32_EXT_EXTI22_IRQ_PRIORITY 15
*/
/*
* GPT driver system settings.

Wyświetl plik

@ -42,7 +42,7 @@ const si446x_mcucfg_t radio1_cfg = {
.sdn = LINE_RADIO_SDN,
.cs = LINE_RADIO_CS,
.spi = PKT_RADIO1_SPI,
.icu = RADIO1_ICU_DRIVER,
.icu = PKT_RADIO1_ICU,
.alt = (PAL_MODE_INPUT | PAL_MODE_ALTERNATE(2)),
.cfg = {
ICU_INPUT_ACTIVE_HIGH,
@ -76,6 +76,8 @@ const radio_config_t radio_list[] = {
{ /* Radio #1 */
.unit = PKT_RADIO_1,
.type = SI446X,
.pkt = (pkt_service_t *const)&RPKTD1,
.afsk = (AFSKDemodDriver *const)&AFSKD1,
.cfg = (si446x_mcucfg_t *const)&radio1_cfg,
.dat = (si446x_data_t *)&radio1_dat,
.bands = (radio_band_t **const)radio_bands
@ -86,7 +88,7 @@ const radio_config_t radio_list[] = {
};
/**
*
* Debug serial port setting.
*/
const SerialConfig debug_config = {
115200,

Wyświetl plik

@ -18,11 +18,6 @@
*/
#define SERIAL_CFG_DEBUG_DRIVER &SD3
/*
* TODO: Need to use radio unit ID to set assigned GPIO & SPI.
* Only if there is a multi radio board...
*/
/*
* SPI definitions
*/
@ -94,11 +89,6 @@
#define LINE_IO7 PAL_NOLINE
#define LINE_IO8 PAL_NOLINE
// Hardware dependent settings
#define Si446x_CLK STM32_HSECLK /* Oscillator frequency in Hz */
#define Si446x_CLK_OFFSET 22 /* Oscillator frequency drift in ppm */
#define Si446x_CLK_TCXO_EN true /* Set this true, if a TCXO is used, false for XTAL */
/*
* Radio GPIO definitions.
*/
@ -113,14 +103,14 @@
#define LINE_SPI_MISO PAL_LINE(GPIOB, 4U)
#define LINE_SPI_MOSI PAL_LINE(GPIOB, 5U)
/* TODO: Move into pktradio.h */
/* TODO: Move into pktradio.h? */
#define BAND_MIN_2M_FREQ 144000000 /* Minimum allowed frequency in Hz */
#define BAND_MAX_2M_FREQ 148000000 /* Maximum allowed 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_STEP_70CM_HZ 25000
#define BAND_STEP_70CM_HZ 12500
#define BAND_DEF_70CM_APRS 439100000 /* Default frequency in Hz. */
#define DEFAULT_OPERATING_FREQ 144800000
@ -133,37 +123,31 @@
#define Si446x_CLK_OFFSET 22 /* Oscillator frequency drift in ppm */
#define Si446x_CLK_TCXO_EN true /* Set this true, if a TCXO is used, false for XTAL */
//#define NUM_BANDS_PER_RADIO 2
/* LED status indicators (set to PAL_NOLINE if not available). */
#define LINE_OVERFLOW_LED PAL_NOLINE
#define LINE_DECODER_LED LINE_IO_BLUE
#define LINE_SQUELCH_LED PAL_NOLINE
#define LINE_NO_FIFO_LED PAL_NOLINE
#define LINE_NO_BUFF_LED PAL_NOLINE
#define LINE_OVERFLOW_LED PAL_NOLINE
#define LINE_DECODER_LED LINE_IO_BLUE
#define LINE_SQUELCH_LED PAL_NOLINE
#define LINE_NO_FIFO_LED PAL_NOLINE
#define LINE_NO_BUFF_LED PAL_NOLINE
/* Diagnostic PWM mirror port. */
#define LINE_PWM_MIRROR PAL_NOLINE
/* Radio ports. */
//#define LINE_CCA LINE_RADIO_NIRQ
//#define LINE_ICU LINE_RADIO_GPIO1
#define LINE_PWM_MIRROR PAL_NOLINE
//#define LINE_UART4_TX PAL_LINE(GPIOA, 12U)
//#define LINE_UART4_RX PAL_LINE(GPIOA, 11U)
/* The external port can be used for bit bang I2C. */
#define ENABLE_EXTERNAL_I2C TRUE
#define ENABLE_EXTERNAL_I2C TRUE
#define EI2C_SCL LINE_GPIO_PIN1 /* SCL */
#define EI2C_SDA LINE_GPIO_PIN2 /* SDA */
#define EI2C_SCL LINE_GPIO_PIN1 /* SCL */
#define EI2C_SDA LINE_GPIO_PIN2 /* SDA */
/* To use IO_TXD/IO_RXD for UART debug channel. */
#define ENABLE_SERIAL_DEBUG TRUE
#define ENABLE_SERIAL_DEBUG TRUE
#if ENABLE_SERIAL_DEBUG == TRUE
#define LINE_USART3_TX LINE_IO_TXD
#define LINE_USART3_RX LINE_IO_RXD
#define LINE_USART3_TX LINE_IO_TXD
#define LINE_USART3_RX LINE_IO_RXD
#endif
/* If set to true, the console using USB interface will be switched on.
@ -172,14 +156,14 @@
* This option will also run the STM32 at 48MHz (AHB) permanently.
* USB needs 48MHz speed to operate.
*/
#define ACTIVATE_CONSOLE TRUE
#define ACTIVATE_CONSOLE TRUE
/**
* ICU related definitions.
*/
#define RADIO1_ICU_DRIVER &ICUD4
#define PKT_RADIO1_ICU &ICUD4
#define PWM_ICU_CLK STM32_TIMCLK1
#define PWM_ICU_CLK STM32_TIMCLK1
/* ICU counter frequency. */
/*
@ -187,13 +171,13 @@
* ICU has to run at an integer divide from APBx clock.
*/
#define ICU_COUNT_FREQUENCY 6000000U
#define ICU_COUNT_FREQUENCY 6000000U
#if ((PWM_ICU_CLK % ICU_COUNT_FREQUENCY) != 0)
#error "Invalid ICU frequency for APBx clock setting"
#endif
#define USE_12_BIT_PWM FALSE
#define USE_12_BIT_PWM FALSE
/*
* Allocate PWM buffers from a CCM heap/pool.
@ -202,29 +186,30 @@
* Decoder side swaps queue/buffer on in-band message.
* The retired buffer is reticulated to the pool ready for re-use.
*/
#define USE_HEAP_PWM_BUFFER TRUE
#define USE_CCM_BASED_HEAP TRUE
#define TRACE_PWM_BUFFER_STATS FALSE
#define USE_HEAP_PWM_BUFFER TRUE
#define USE_CCM_BASED_HEAP TRUE
#define TRACE_PWM_BUFFER_STATS FALSE
/* Definitions for ICU FIFO implemented using chfactory. */
#if USE_HEAP_PWM_BUFFER == TRUE
/* Use factory FIFO as stream control with separate chained PWM buffers. */
#define NUMBER_PWM_FIFOS 5U
#define NUMBER_PWM_FIFOS 5U
/* Number of PWM data entries per queue object. */
#define PWM_DATA_SLOTS 200
#define PWM_DATA_SLOTS 200
/* Number of PWM queue objects in total. */
#define PWM_DATA_BUFFERS 30
#define PWM_DATA_BUFFERS 30
#else /* USE_HEAP_PWM_BUFFER != TRUE */
/* Use factory FIFO as stream control with integrated PWM buffer. */
#define NUMBER_PWM_FIFOS 3U
#define PWM_DATA_SLOTS 6000
#define NUMBER_PWM_FIFOS 3U
#define PWM_DATA_SLOTS 6000
#endif /* USE_HEAP_PWM_BUFFER == TRUE */
/* Number of frame receive buffers. */
#define NUMBER_RX_PKT_BUFFERS 3U
#define USE_CCM_HEAP_RX_BUFFERS TRUE
#define NUMBER_RX_PKT_BUFFERS 3U
#define USE_CCM_HEAP_RX_BUFFERS TRUE
#define PKT_RX_RLS_USE_NO_FIFO TRUE
/* Set TRUE to use the idle thread sweeper to release terminated threads. */
#define PKT_RX_RLS_USE_NO_FIFO TRUE
/*
* Number of general AX25/APRS processing & frame send buffers.
@ -244,6 +229,9 @@
/* Module pre-compile time settings. */
/*===========================================================================*/
#define PKT_SVC_USE_RADIO1 TRUE
#define PKT_SVC_USE_RADIO2 FALSE
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@ -263,24 +251,26 @@
extern const radio_band_t band_2m;
extern const radio_band_t band_70cm;
extern const radio_config_t radio_list[];
extern pkt_service_t RPKTD1;
extern AFSKDemodDriver AFSKD1;
#ifdef __cplusplus
extern "C" {
#endif
void pktConfigSerialDiag(void);
void pktConfigSerialPkt(void);
void pktConfigureCoreIO(void);
ioline_t pktSetLineModeICU(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO1(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO0(const radio_unit_t radio);
void pktSerialStart(void);
void dbgWrite(uint8_t level, uint8_t *buf, uint32_t len);
int dbgPrintf(uint8_t level, const char *format, ...);
void pktWrite(uint8_t *buf, uint32_t len);
uint8_t pktReadIOlines(void);
void pktRadioICUWidth(ICUDriver *icup);
void pktRadioICUPeriod(ICUDriver *icup);
void pktRadioICUOverflow(ICUDriver *icup);
void pktConfigSerialDiag(void);
void pktConfigSerialPkt(void);
void pktConfigureCoreIO(void);
ioline_t pktSetLineModeICU(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO1(const radio_unit_t radio);
ioline_t pktSetLineModeRadioGPIO0(const radio_unit_t radio);
void pktSerialStart(void);
void dbgWrite(uint8_t level, uint8_t *buf, uint32_t len);
int dbgPrintf(uint8_t level, const char *format, ...);
void pktWrite(uint8_t *buf, uint32_t len);
uint8_t pktReadIOlines(void);
void pktRadioICUWidth(ICUDriver *icup);
void pktRadioICUPeriod(ICUDriver *icup);
void pktRadioICUOverflow(ICUDriver *icup);
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -17,10 +17,13 @@
#include "pktconf.h"
#include "portab.h"
/*===========================================================================*/
/* Module exported variables. */
/* Driver exported variables. */
/*===========================================================================*/
/* TODO: Move into pktservice.c . */
packet_svc_t RPKTD1;

Wyświetl plik

@ -13,7 +13,7 @@ const conf_t conf_flash_default = {
// Primary position app
.pos_pri = {
.beacon = {
.active = true,
.active = false,
.cycle = TIME_S2I(60 * 5),
.init_delay = TIME_S2I(60),
.fixed = false // Add lat, lon, alt fields when enabling fixed
@ -34,7 +34,7 @@ const conf_t conf_flash_default = {
// Secondary position app
.pos_sec = {
.beacon = {
.active = true,
.active = false,
.cycle = TIME_S2I(60 * 30), // Beacon interval
.init_delay = TIME_S2I(60),
.fixed = true, // Add lat, lon alt fields when enabling fixed
@ -58,7 +58,7 @@ const conf_t conf_flash_default = {
// Primary image app
.img_pri = {
.svc_conf = {
.active = true,
.active = false,
.cycle = TIME_S2I(60 * 5),
.init_delay = TIME_S2I(60 * 1),
.send_spacing = TIME_S2I(5)
@ -179,7 +179,7 @@ const conf_t conf_flash_default = {
.gps_high_alt = GPS_AIRBORNE_1G,
// APRS
// How often to send telemetry config
// How often to send telemetry config (global for beacons)
.tel_enc_cycle = TIME_S2I(60 * 60 * 2),
// The default APRS frequency when geofence is not resolved

Wyświetl plik

@ -555,7 +555,7 @@ bool Si446x_setBandParameters(const radio_unit_t radio,
/*
* Initialize radio.
*/
Si446x_conditional_init(radio);
//Si446x_conditional_init(radio);
/* Set the band parameter. */
uint32_t sy_sel = 8;
@ -1139,9 +1139,13 @@ bool Si4464_enableReceive(const radio_unit_t radio,
rx_chan,
rx_rssi, getModulation(rx_mod));
/* Initialize radio before any commands as it may have been powered down. */
Si446x_conditional_init(radio);
/* Frequency must be an absolute frequency in Hz. */
if(!Si446x_setBandParameters(radio, op_freq, rx_step))
return false;
return Si446x_receiveNoLock(radio, op_freq, rx_step,
rx_chan, rx_rssi, rx_mod);
}
@ -1248,7 +1252,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
chSysHalt("TX AFSK exit");
}
/* Initialize radio as it may have been powered down. */
/* Initialize radio before any commands as it may have been powered down. */
Si446x_conditional_init(radio);
/* Base frequency is an absolute frequency in Hz. */
@ -1505,7 +1509,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
/* We never arrive here. */
}
/* Initialize radio as it may have been powered down. */
/* Initialize radio before any commands as it may have been powered down. */
Si446x_conditional_init(radio);
/* Set 446x back to READY from RX (if active). */

Wyświetl plik

@ -145,7 +145,13 @@ float32_t pre_filter_coeff_f32[PRE_FILTER_NUM_TAPS] = {
/*
* Data structure for AFSK decoding.
*/
#if PKT_SVC_USE_RADIO1 || defined(__DOXYGEN__)
AFSKDemodDriver AFSKD1;
#endif
#if PKT_SVC_USE_RADIO2 || defined(__DOXYGEN__)
AFSKDemodDriver AFSKD2;
#endif
/*===========================================================================*/
/* Decoder local variables and types. */
@ -434,10 +440,10 @@ static void pktResetAFSKDecoder(AFSKDemodDriver *myDriver) {
* @note The si radio has no AFSK decoding capability.
* @note The PWM RX_DATA from the radio is decoded as AFSK by the uC.
*
* @post An ICU and GPIO ports for the Radio are attached and initialized.
* @post A dynamic object FIFO is created for buffering radio PWM data.
* @post Buffers are posted to demodulator where decoding takes place.
* @post Multiple PWM sessions may be queued by the Radio for demodulation.
* @post An ICU and GPIO ports for the radio are attached and initialized.
* @post A dynamic object FIFO is created for streaming radio PWM data.
* @post A steam object is posted to demodulator where decoding takes place.
* @post Multiple PWM sessions may be queued by the radio for demodulation.
*
* @param[in] pktHandler pointer to a @p PKTDriver structure
* @param[in] radio radio ID.
@ -451,8 +457,15 @@ AFSKDemodDriver *pktCreateAFSKDecoder(packet_svc_t *pktHandler) {
chDbgAssert(pktHandler != NULL, "no packet handler");
AFSKDemodDriver *myDriver = &AFSKD1;
const radio_config_t *data = pktGetRadioData(pktHandler->radio);
chDbgAssert(data != NULL, "invalid radio ID");
if(data == NULL)
return NULL;
/* Get afsk object from radio data. */
AFSKDemodDriver *myDriver = data->afsk;
chDbgAssert(data != NULL, "invalid AFSK driver");
/*
* Initialize the decoder event object.
*/
@ -785,7 +798,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
/* Decrease ref count on AX25 FIFO. */
chFactoryReleaseObjectsFIFO(pkt_fifo);
pktAddEventFlags(myHandler, EVT_PKT_NO_BUFFER);
//myDriver->active_demod_object->status |= EVT_AX25_NO_BUFFER;
myDriver->active_demod_object->status |= STA_PKT_NO_BUFFER;
myDriver->decoder_state = DECODER_RESET;
break;
}
@ -826,32 +839,33 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
if(n != sizeof(packed_pwm_counts_t)) {
/* PWM stream wait timeout. */
pktAddEventFlags(myHandler, EVT_PWM_STREAM_TIMEOUT);
//myDriver->active_demod_object->status |= EVT_PWM_STREAM_TIMEOUT;
myDriver->active_demod_object->status |= STA_PWM_STREAM_TIMEOUT;
myDriver->decoder_state = DECODER_RESET;
break;
}
array_min_pwm_counts_t radio;
pktUnpackPWMData(data, &radio);
array_min_pwm_counts_t stream;
pktUnpackPWMData(data, &stream);
#if AFSK_DEBUG_TYPE == AFSK_PWM_DATA_CAPTURE_DEBUG
char buf[80];
int out = chsnprintf(buf, sizeof(buf), "%i, %i\r\n",
radio.pwm.impulse, radio.pwm.valley);
stream.pwm.impulse, stream.pwm.valley);
pktWrite( (uint8_t *)buf, out);
#endif
/* Look for "in band" message in radio data. */
if(radio.pwm.impulse == PWM_IN_BAND_PREFIX) {
switch(radio.pwm.valley) {
if(stream.pwm.impulse == PWM_IN_BAND_PREFIX) {
switch(stream.pwm.valley) {
case PWM_TERM_DECODE_STOP: {
/*
* The receive controller has issued a decoder stop.
* This happens when a TX request is submitted or an service stop is requested.
* The PWM stop places an in-band message in the PWM stream if open.
* This happens when a service stop is submitted.
* Can be TX or a service stop as part of closing a service.
* PWM stop places an in-band message in the PWM stream if open.
* The decoder will then (eventually) process the in-band message.
* The decode result will be invalid due to being stopped.
* The decode result is invalid due to being aborted.
* The current AX25 buffer will not be dispatched.
* PWM and AX25 buffers and the stream manager object will be released in RESET.
* PWM and AX25 buffers and stream object are released in RESET.
*/
myDriver->decoder_state = DECODER_RESET;
continue; /* Continue in main loop. */
@ -865,7 +879,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
* It writes an in-band message in the open stream.
* Although we should never see that in-band.
* The decoder has already moved out of ACTIVE state and is no longer processing PWM.
* TODO: Deprecate these cases after checking they never happen.
* TODO: Deprecate these cases after confirming they never happen.
*/
pktAddEventFlags(myHandler, EVT_PWM_INVALID_INBAND);
myDriver->decoder_state = DECODER_RESET;
@ -873,7 +887,10 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
continue; /* Decoder state switch. */
} /* End case. */
/* If PWM reports a zero impulse or valley.
/* The next cases all fall through and set DECODER_RESET state. */
/*
* If PWM reports a zero impulse or valley.
* The PWM side has already posted a PWM_STREAM_CLOSE event.
*/
case PWM_TERM_ICU_ZERO:
@ -931,6 +948,8 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
*/
/* TODO: Need an EVT code freed up to add INVALID_SWAP. */
pktAddEventFlags(myHandler, EVT_PWM_INVALID_SWAP);
myDriver->active_demod_object->status |= STA_AFSK_INVALID_SWAP;
myDriver->decoder_state = DECODER_RESET;
}
continue; /* Decoder state switch. */
@ -940,6 +959,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
default: {
/* Unknown in-band message from PWM. */
pktAddEventFlags(myHandler, EVT_PWM_INVALID_INBAND);
myDriver->active_demod_object->status |= STA_AFSK_INVALID_INBAND;
myDriver->decoder_state = DECODER_RESET;
continue; /* Enclosing state switch. */
} /* End case default. */
@ -948,14 +968,14 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
} /* End if in-band. */
/*
* If not in-band the process the AFSK into an HDLC bit and AX25 data.
* If not in-band process the AFSK into an HDLC bit and AX25 data.
*/
if(!pktProcessAFSK(myDriver, radio.array)) {
if(!pktProcessAFSK(myDriver, stream.array)) {
/* AX25 character decoded but buffer is full.
* Status set and event sent by HDLC processor.
* Event sent by HDLC processor (common code for AFSK & 2FSK).
* Set error state and don't dispatch the AX25 buffer.
* TODO: Move status and event broadcast to here?
*/
myDriver->active_demod_object->status |= STA_PKT_BUFFER_FULL;
myDriver->decoder_state = DECODER_RESET;
break; /* From this case. */
}
@ -973,6 +993,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
/* HDLC reset after frame open and minimum valid data received. */
case FRAME_RESET:
myDriver->active_demod_object->status |= STA_AFSK_FRAME_RESET;
myDriver->decoder_state = DECODER_RESET;
continue;
@ -987,11 +1008,25 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
/*
* RESET readies the decoder for the next session.
* It frees any held buffers/objects.
* The DSP system is reset and then transition to IDLE.
* The DSP system is reset and then transitions to IDLE.
*/
case DECODER_RESET: {
#if AFSK_DEBUG_TYPE == AFSK_PACKET_RESET_STATUS
radio_pwm_fifo_t *demod_object = myDriver->active_demod_object;
char buf[120];
if(demod_object != NULL) {
int out = chsnprintf(buf, sizeof(buf),
"AFSK Reset demod status: %x\r\n",
demod_object->status);
pktWrite( (uint8_t *)buf, out);
} else {
int out = chsnprintf(buf, sizeof(buf),
"AFSK Reset has no demod object\r\n");
pktWrite( (uint8_t *)buf, out);
}
#endif
/* If there is a packet buffer object then handle it. */
if(myHandler->active_packet_object != NULL) {
#if AFSK_DEBUG_TYPE == AFSK_PWM_DATA_CAPTURE_DEBUG
char buf[80];
int out = chsnprintf(buf, sizeof(buf),
@ -1005,7 +1040,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
AX25_DUMP_RAW);
#endif
#if USE_CCM_HEAP_RX_BUFFERS == TRUE
/* Free the packet buffer in the heap now. */
/* Free the packet buffer referenced in the packet object. */
chHeapFree(myHandler->active_packet_object->buffer);
#endif
/* Release the AX25 receive packet buffer management object. */
@ -1024,6 +1059,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
* Return stream FIFO to pool if there is one active.
*/
radio_pwm_fifo_t *myFIFO = myDriver->active_demod_object;
/* There won't be a demod object if the decoder is just being reset. */
if(myFIFO != NULL) {
/*
* Lock the PWM queue to stop any further radio data being written.
@ -1090,7 +1126,7 @@ THD_FUNCTION(pktAFSKDecoder, arg) {
#endif
/*
* Indicate AFSK decode done.
* If PWM is still being captured the capture will terminate.
* PWM handler will terminate capture session if still active.
*/
myDriver->active_demod_object->status |= STA_AFSK_DECODE_DONE;

Wyświetl plik

@ -52,8 +52,9 @@
#define AFSK_QCORR_DEC_MFIL_DEBUG 6
#define AFSK_PWM_DATA_CAPTURE_DEBUG 7
#define AFSK_AX25_RAW_PACKET_DUMP 8
#define AFSK_PACKET_RESET_STATUS 9
#define AFSK_DEBUG_TYPE AFSK_NO_DEBUG
#define AFSK_DEBUG_TYPE AFSK_PACKET_RESET_STATUS
/* Error output type selection. */
#define AFSK_NO_ERROR 0

Wyświetl plik

@ -402,9 +402,6 @@ void pktOpenPWMChannelI(ICUDriver *myICU, eventflags_t evt) {
NULL, NULL);
#endif /* USE_HEAP_PWM_BUFFER == TRUE */
/* Clear event/status bits. */
myFIFO->status = 0;
/*
* Initialize FIFO release control semaphore.
* The decoder thread waits on the semaphore before releasing to pool.
@ -435,7 +432,9 @@ void pktOpenPWMChannelI(ICUDriver *myICU, eventflags_t evt) {
icuStartCaptureI(myICU);
icuEnableNotificationsI(myICU);
pktAddEventFlagsI(myHandler, evt);
myFIFO->status |= evt;
/* Clear status bits. */
myFIFO->status = 0;
myDemod->icustate = PKT_PWM_ACTIVE;
}

Wyświetl plik

@ -62,9 +62,9 @@ eventmask_t evt = chEvtGetAndClearEvents(EVENT_MASK(1));
if(flags & EVT_PKT_FAILED_CB_THD) {
TRACE_ERROR("PKT > Failed to create RX callback thread");
}
/* if(flags & EVT_ICU_OVERFLOW) {
TRACE_DEBUG("PKT > PWM ICU overflow");
}*/
if(flags & EVT_PWM_INVALID_SWAP) {
TRACE_DEBUG("PKT > Invalid in-band buffer swap");
}
if(flags & EVT_PWM_STREAM_TIMEOUT) {
TRACE_WARN("PKT > PWM stream timeout");
}

Wyświetl plik

@ -7,7 +7,7 @@
*/
#include "pktconf.h"
#include "portab.h"
/*===========================================================================*/
/* Module local definitions. */
@ -20,6 +20,18 @@
memory_heap_t *ccm_heap = NULL;
//guarded_memory_pool_t *ccm_pool = NULL;
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
#if PKT_SVC_USE_RADIO1 || defined(__DOXYGEN__)
packet_svc_t RPKTD1;
#endif
#if PKT_SVC_USE_RADIO2 || defined(__DOXYGEN__)
packet_svc_t RPKTD2;
#endif
/*===========================================================================*/
/* Module local types. */
/*===========================================================================*/
@ -57,8 +69,17 @@ static guarded_memory_pool_t _ccm_pool;*/
*/
bool pktSystemInit(void) {
//#define useCCM __attribute__((section(".ram4")))
//static int example useCCM;
/*
* The definition for CCM is in pktconf.h as follows...
* #define useCCM __attribute__((section(".ram4")))
* How to allocate a variable in CCM...
* int example useCCM;
*
* The remainder available in CCM is used to create a heap.
* This can be used for non-DMA access data only in the F413.
*/
/* Reference the linker created CCM variables to get the available heap area. */
extern uint8_t __ram4_free__[];
extern uint8_t __ram4_end__[];
@ -101,7 +122,7 @@ bool pktSystemDeinit(void) {
* Remove common packet buffer control.
*/
chDbgAssert(ccm_heap != NULL, "CCM heap does not exist");
chSysLock();
//chSysLock();
pktDeinitBufferControl();
@ -873,8 +894,9 @@ dyn_objects_fifo_t *pktIncomingBufferPoolCreate(radio_unit_t radio) {
dyn_semaphore_t *pktInitBufferControl() {
/* Check if the transmit packet buffer semaphore already exists.
* If so we get a pointer to it and just return that.
* Otherwise create the semaphore and return result.
* Calling this twice is an error so assert if enabled.
* Otherwise get a pointer to it and just return that.
* If it does not exist create the semaphore and return result.
*/
dyn_semaphore_t *dyn_sem =
chFactoryFindSemaphore(PKT_SEND_BUFFER_SEM_NAME);
@ -895,13 +917,13 @@ dyn_semaphore_t *pktInitBufferControl() {
}
/*
* Send and packet analysis share a common pool of buffers.
* Radio send and APRS packet analysis share a common pool of buffers.
*/
void pktDeinitBufferControl() {
/* Check if the transmit packet buffer semaphore already exists.
* If so we get a pointer to it and just return that.
* Otherwise create the semaphore and return result.
/* Check if the transmit packet buffer semaphore exists.
* If so wait for all references to be released.
* Then release the semaphore.
*/
dyn_semaphore_t *dyn_sem =
chFactoryFindSemaphore(PKT_SEND_BUFFER_SEM_NAME);

Wyświetl plik

@ -446,7 +446,7 @@ static inline void pktReleaseDataBuffer(pkt_data_object_t *object) {
* Free the object.
* Decrease the factory reference count.
* If the service is closed and all buffers freed then the FIFO is destroyed.
* Terminate this thread and have idle clean up memory.
* Terminate this thread and have idle thread sweeper clean up memory.
*/
object->handler->cb_count--;
chFifoReturnObject(pkt_fifo, object);
@ -562,20 +562,28 @@ static inline bool pktGetAX25FrameStatus(pkt_data_object_t *object) {
* @param[in] radio radio unit ID.
*
* @return pointer to the service object.
* @retval NULL If the radio ID is invalid.
* @retval NULL If the radio ID is invalid or no service object assigned.
*
* @api
*/
inline packet_svc_t *pktGetServiceObject(radio_unit_t radio) {
/*
* TODO: implement mapping from radio config to packet handler object.
* Get radio configuration object.
*/
packet_svc_t *handler = NULL;
if(radio == PKT_RADIO_1) {
handler = &RPKTD1;
}
const radio_config_t *data = pktGetRadioData(radio);
chDbgAssert(data != NULL, "invalid radio ID");
if(data == NULL)
return NULL;
/*
* Get packet handler object for this radio.
*/
packet_svc_t *handler = data->pkt;
chDbgAssert(handler != NULL, "invalid radio ID");
/* if(radio == PKT_RADIO_1) {
handler = &RPKTD1;
}*/
chDbgAssert(handler != NULL, "invalid radio packet driver");
return handler;
}

Wyświetl plik

@ -65,9 +65,9 @@
//#define EVT_AFSK_TERMINATED EVENT_MASK(EVT_PRIORITY_BASE + 4)
#define EVT_AFSK_START_FAIL EVENT_MASK(EVT_PRIORITY_BASE + 5)
//#define STA_AFSK_DECODE_RESET EVENT_MASK(EVT_PRIORITY_BASE + 6)
//#define STA_AFSK_DECODE_DONE EVENT_MASK(EVT_PRIORITY_BASE + 7)
#define EVT_PWM_INVALID_SWAP EVENT_MASK(EVT_PRIORITY_BASE + 7)
/* TODO: Create an AKSK event field in decoder for the PWM & radio events. */
/* TODO: Create an AKSK event field in decoder for the PWM & radio events? */
#define EVT_PWM_NO_DATA EVENT_MASK(EVT_PRIORITY_BASE + 8)
#define EVT_PWM_INVALID_INBAND EVENT_MASK(EVT_PRIORITY_BASE + 9)
#define EVT_PWM_FIFO_EMPTY EVENT_MASK(EVT_PRIORITY_BASE + 10)
@ -128,14 +128,22 @@ typedef uint32_t statusmask_t; /**< Mask of status identifiers. */
#define STATUS_MASK(sid) ((statusmask_t)1 << (statusmask_t)(sid))
/* TODO: Classify status by PKT, AFSK and 2FSK types. */
#define STA_PKT_FRAME_RDY STATUS_MASK(0)
#define STA_PKT_CRC_ERROR STATUS_MASK(1)
#define STA_PKT_INVALID_FRAME STATUS_MASK(2)
#define STA_AFSK_DECODE_RESET STATUS_MASK(3)
#define STA_AFSK_DECODE_DONE STATUS_MASK(4)
#define STA_PWM_STREAM_CLOSED STATUS_MASK(5)
#define STA_PKT_FRAME_RDY STATUS_MASK(0)
#define STA_PKT_CRC_ERROR STATUS_MASK(1)
#define STA_PKT_INVALID_FRAME STATUS_MASK(2)
#define STA_AFSK_DECODE_RESET STATUS_MASK(3)
#define STA_AFSK_DECODE_DONE STATUS_MASK(4)
#define STA_PWM_STREAM_CLOSED STATUS_MASK(5)
#define STA_AFSK_FRAME_RESET STATUS_MASK(6)
#define STA_PKT_BUFFER_FULL STATUS_MASK(7)
#define STA_AFSK_INVALID_INBAND STATUS_MASK(8)
#define STA_AFSK_INVALID_SWAP STATUS_MASK(9)
#define STA_PWM_STREAM_TIMEOUT STATUS_MASK(10)
#define STA_PKT_NO_BUFFER STATUS_MASK(11)
/**
* Use this attribute to put variables in CCM.
*/
#define useCCM __attribute__((section(".ram4")))
#ifdef PKT_IS_TEST_PROJECT
@ -176,12 +184,24 @@ typedef uint32_t statusmask_t; /**< Mask of status identifiers. */
#include "pktevt.h"
#include "debug.h"
extern packet_svc_t RPKTD1;
/*===========================================================================*/
/* Driver definitions. */
/*===========================================================================*/
#if !defined(PKT_SVC_USE_RADIO1)
#define PKT_SVC_USE_RADIO1 FALSE
#endif
#if !defined(PKT_SVC_USE_RADIO2)
#define PKT_SVC_USE_RADIO2 FALSE
#endif
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
//extern packet_svc_t RPKTD1;
#ifdef __cplusplus
extern "C" {
#endif

Wyświetl plik

@ -70,22 +70,25 @@ typedef enum radioMode {
/* Forward declaration. */
//typedef struct radioBand radio_band_t;
typedef struct packetHandlerData pkt_service_t;
typedef struct AFSK_data AFSKDemodDriver;
/* Type for a radio band. */
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 radioConfig {
radio_unit_t unit;
radio_type_t type;
void *cfg;
void *dat;
radio_freq_t def_aprs; /**< A frequency in one of the bands. */
radio_band_t **bands;
radio_unit_t unit;
radio_type_t type;
pkt_service_t *pkt;
AFSKDemodDriver *afsk;
void *cfg;
void *dat;
radio_freq_t def_aprs; /**< A frequency in one of the bands. */
radio_band_t **bands;
} radio_config_t;
typedef uint8_t ax25char_t;