Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • e-24/public/ahoi/firmware
1 result
Show changes
Commits on Source (3)
  • Bernd-Christian Renner's avatar
    FIX: fixed hangs due to broken I2C caused by TXB (tx power setting) · c1aa52ac
    Bernd-Christian Renner authored
    - dropped support for OLD TXB with MCP4551 (see ERRATA)
    - added support for NEW TXB with AD5245
    - added timeout for busy-waiting peripheral (UART, I2C, SPI) interaction; on timeout, the MB indicates an error state through LEDs
    - updated AD5245 interface/driver to support two devices (distinguished through A0 bit)
    - tweaked TX/RX switch sequencing
    c1aa52ac
  • Bernd-Christian Renner's avatar
    FIX: updated and aligned IRQ priorities · a556b2a7
    Bernd-Christian Renner authored
    - moved I2C configuration to board_config.h
    - introduced constants in board_config.h for all IRQ priorities
    - aligned values of IRQ priorities
    a556b2a7
  • Bernd-Christian Renner's avatar
    refactoring · 2329c6b8
    Bernd-Christian Renner authored
    - removed obsolte txamp functions (re DAC enable sequence)
    - reorderd TX enable sequence
    - consolidated time keeping (ticks/time vs sample count)
      - added RX_ and TX_ prefixes for samples counts
      - added new data type rx_sample_cnt_t
      - renamed function to calc rx lag for more clarity
      - deactivated downsampling (locked feature, almost all steps made)
    2329c6b8
Showing
with 295 additions and 67 deletions
Mods:
- sampling freq is now for TX, RX is downsampled (1,2,4)
- SAMPLES_PER_SYMBOL -> RX_SAMPLES_PER_SYMBOL
- removed TX_FACTOR
- TX_FACTOR*SAMPLES_PER_SYMBOL -> TX_SAMPLES_PER_SYMBOL
- remved MOD_INDEX
Check:
-[ ] check proper timing and working of adda_activateTransmission
-[ ] SPI has been changed to run only after TX has been powered on
-[ ] sample_time_t has been renamed to rx_sample_cnt_t
-[ ] check all occurances of sample_time_t for proper use
-[ ] check all occurances of rx_sample_cnt_t for proper use
-[X] disable SPI / sampling when switching RX <-> TX
-[X] check calculations in receive.c (are they in ticks?)
-[X] removed occurances of
-[X] SAMPLES_PER_SYMBOL
-[X] TX_FACTOR
-[X] MS_TO_SYMBOLS
-[X] TX_SAMPLING_CLK_DIV
-[X] SYNC_MOD_INDEX
-[X] definition of
-[X] US_TO_TICKS
-[X] MS_TO_TICKS
should now be in **TX** samples
-[X] check time calculation (TX vs. slower RX speed)
-[X] TX_SAMPLING_CLK_DIV is now SAMPLING_CLK_DIV
-[X] correct use of
-[X] SAMPLING_CLK_DIV -> TX
-[X] RX_SAMPLING_CLK_DIV -> RX
-[X] which is used for clock only?
-[X] these must be in ticks now (200kHz)
-[X] TXOFF_OUTPUT_SETTLE_TICKS
-[X] TXOFF_SWITCH_DELAY_TICKS
-[X] adda_wait has been removed (replaced by adda_waitTimerTicks)
-[X] check, if all usages of adda_waitTimerTicks() use correct time units
-[X] TXRX_TURNAROUND_TICKS has correct unit?
-[X] mcu_adda.c
-[X] check all occurances of sampleCnt
-[X] check that adda_getTimerTicks() is used with proper type (return)
-[X] it looks as though this is not the case!
-[X] rename adda_getSampleLag -> adda_getRxSampleLagTicks
-[X] and check that is used with time/ticks properly!
-[X] check initialize_hardware.c and timings
-[X] check SPI baudrate!
-[X] check if ranging_getDelay() is in ticks
-[X] ranging_setDelay() correctly converting?
-[X] sync.c
-[X] dist, tMax, tFirst are sample counts, no time! > check all occurances
-[X] endOfPreambleCnt is a sample count
-[X] syncTime is in ticks!
-[X] sync_calcEndOfPreamble() is in sample count (not ticks)
-[X] variable stime is a sample count
-[X] rx_sample_longcnt_t is declared but never used ...
-[X] was sample_longtime_t ever used? it would be the proper replacement
-[X] agc.c: AGC_EVENT_MAX_DELAY_TICKS is used as ticks unit?
-[X] freq_setSignalWindowSize() takes ticks as parameter?
-[X] where is signal window size used? is it / does it have to be scaled with RX_DOWNSAMPLE?
-[X] where is freq_getRxThreshold() used? is it / does it have to be scaled with RX_DOWNSAMPLE?
-[X] dito freq_getRxThresholdSq ?
-[X] dito freq_getRxThresholdPerc ?
-[X] ranging_setDelay() uses ticks
-[X] SIGNAL_THRESHOLD_MAX defined correctly (based on RX_SAMPLES_PER_SYMBOL)?
-[X] SIGNAL_WINDOW_SIZE_MAX defined correctly (based on RX_SAMPLES_PER_SYMBOL)?
Todo
- agc.c
- define LP_NUM_SAMPLES per speed
- then divide by RX_SAMPLING_DIV (2^x) !
-[x] aci_config.c
- Ausgabe: SAMPLING_FREQ, RX_DOWNSAMPLE, inv freq band
=== GENERAL ===
- remove legacy board support!
=== AGC ===
- failed gain stage change cannot be identified in software due to DMA use
=== TX/RX switch sequencing ===
verify the following behavior
TX -> RX
- wait TXOFF_OUTPUT_SETTLE_NS = 500 us: wait for output to settle
- disconnect TX, connect RX
- wait TXOFF_SWITCH_DELAY_NS = 500 us:
- enable rx
- wait RX_ENABLE_TICKS = 2 ms
- set gain (if AGC disabled)
- disable tx
- disconnects TX (to ensure it's disconnected)
- switch to timer ISR
- send shutdown command to DAC (stupid, since DAC could be disabled!)
- wait until total delay is TXRX_TURNAROUND
- restore agc
- switch to ADC ISR
RX -> TX
- switch to DAC ISR
- disable RX
- enable TX
- wait until RXTX complete
- connect TX, disconnect RX
- TX timings should be part of TX-BOARD implementation/def., not generic (in freqsetup.h)!
=== DOWNSAMPLING ===
- code for using receiver downsampling has been added
- it is currently locked
- for unlocking requirements, see @freqsetup.h
- make sure that time cannot warp in the switchToxxxISR() functions
- check meta calculation in receive_finish() in @receive.c
=== HARDWARE SUPPORT ===
- check TXRX turnaround sequence:
=== UART ===
https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx
- enable DMA for UART
- process data in ISRs or main?
=== HAL ===
The HAL implementation needs to be redone, as it's a bit over-engineered and the mcu indirection is confusing.
=== PKTPIN ===
- if we change modes, the pin behavior may be corrupted until the next trigger!
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner,
* Jan Heitmann, and
......@@ -43,6 +43,8 @@
#include "types.h"
#include "acitypes.h"
#include "error.h"
#include <stdbool.h>
#include <stdint.h>
......@@ -68,14 +70,11 @@ aci_check(const mm_packet_t * pkt);
/**
* send a reply back to the host
*/
inline void
static inline void
__attribute__((__always_inline__))
aci_sendReply(const mm_packet_t * const pkt)
{
// TODO improve this, it sucks.
while (! host_sendPacket((uint8_t *)pkt, MM_HEADER_LEN + pkt->header.len)) {
/* busy wait */
}
WAIT_TIMED(! host_sendPacket((uint8_t *)pkt, MM_HEADER_LEN + pkt->header.len));
}
......
/**
* Copyright 2016-2020
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -36,6 +36,7 @@
#include "aci.h"
#include "aci/types/config_rsp.h"
#include "aci_config.h"
#include "freqsetup.h"
#include <string.h>
......@@ -59,6 +60,15 @@ extern char * RXAMP_NAME;
* private functions
*/
/**************************************************************************
* public functions
*/
#define xstr(s) str(s)
#define str(s) #s
uint8_t
aci_config_fillReply(uint8_t * payload)
{
......@@ -93,6 +103,12 @@ aci_config_fillReply(uint8_t * payload)
strcat((char *)payload, "majority,");
#endif
// sampling frequency
strcat((char *)payload, xstr(SAMPLING_FREQ));
strcat((char *)payload, ":");
strcat((char *)payload, xstr(RX_DOWNSAMPLE));
strcat((char *)payload, "Hz,");
// high speed option (shorter symbols)
#ifdef HIGHSPEED
strcat((char *)payload, "hi-sp,");
......@@ -109,6 +125,9 @@ aci_config_fillReply(uint8_t * payload)
// freq table origin
strcat((char *)payload, LUT_SRC);
#ifdef INVERT_FREQBAND
strcat((char *)payload, ",inv");
#endif
strcat((char *)payload, ",");
// tx amp board
......@@ -130,10 +149,6 @@ aci_config_fillReply(uint8_t * payload)
/**************************************************************************
* public functions
*/
void
aci_config_processCmd(__attribute__ ((unused)) const mm_packet_t * pkt)
{
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -57,7 +57,7 @@ aci_peakwinlen_fillReply(uint8_t * payload)
aci_peakwinlen_cmd_t * p = (aci_peakwinlen_cmd_t *)payload;
// TODO check length ...
p->winlen = HTONS( TICKS_TO_US( freq_getSignalWindowSize() ) );
p->winlen = HTONS( RXCNT_TO_US( freq_getSignalWindowSize() ) );
return sizeof(aci_peakwinlen_cmd_t);
}
......@@ -73,7 +73,7 @@ aci_peakwinlen_processCmd(const mm_packet_t * pkt)
{
if (pkt->header.len == sizeof(aci_peakwinlen_cmd_t)) {
aci_peakwinlen_cmd_t * p = (aci_peakwinlen_cmd_t *)(pkt->payload);
freq_setSignalWindowSize(US_TO_TICKS( NTOHS(p->winlen) ));
freq_setSignalWindowSize(US_TO_RXCNT( NTOHS(p->winlen) ));
}
}
......
/**
* Copyright 2021
* Copyright 2021-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......
/**
* Copyright 2021
* Copyright 2021-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -66,12 +66,12 @@ aci_powerlevel_fillReply(uint8_t * payload)
// @see channelquality.h/c for details on the method
Umean = 0;
Ueff = 0;
for (i = 0; i < SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < RX_SAMPLES_PER_SYMBOL; i++) {
while (! adda_getSample(&sample)) { ; }
Ueff += fp16_square(sample);
Umean += sample;
}
p->power = channelquality_calcPowerLevel(Ueff, Umean, SAMPLES_PER_SYMBOL, 1); // the reference is a simple sine (useful?)
p->power = channelquality_calcPowerLevel(Ueff, Umean, RX_SAMPLES_PER_SYMBOL, 1); // the reference is a simple sine (useful?)
return sizeof(aci_powerlevel_rsp_t);
}
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner,
* Jan Heitmann, and
......@@ -56,7 +56,7 @@ aci_rangingdelay_fillReply(uint8_t * payload)
aci_rangingdelay_cmd_t * p = (aci_rangingdelay_cmd_t *)payload;
// payload
p->rangingdelay = HTONL(TICKS_TO_MS(ranging_getDelay()));
p->rangingdelay = HTONL(TICKS_TO_MS(ranging_getDelayTicks()));
return sizeof(aci_rangingdelay_cmd_t);
}
......@@ -71,7 +71,7 @@ void
aci_rangingdelay_processCmd(const mm_packet_t * pkt)
{
if (pkt->header.len == sizeof(aci_rangingdelay_cmd_t)) {
ranging_setDelay(MS_TO_TICKS(NTOHL(((aci_rangingdelay_cmd_t *)pkt->payload)->rangingdelay)));
ranging_setDelayTicks(MS_TO_TICKS(NTOHL(((aci_rangingdelay_cmd_t *)pkt->payload)->rangingdelay)));
}
}
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -75,7 +75,7 @@ aci_rxlevel_fillReply(uint8_t * payload)
// calculate power
// @see sync.c for details on method
memset(integral, 0, sizeof(integral));
for (i = 0; i < SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < RX_SAMPLES_PER_SYMBOL; i++) {
while (! adda_getSample(&sample)) { ; }
for (symb = 0; symb < NUM_SYMBOLS; symb++) {
......
/**
* Copyright 2016-2018
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -86,7 +86,7 @@ aci_test_freq_processCmd(const mm_packet_t * pkt)
adda_activateTransmission();
// send out selected frequency
for (i = 0; i < TX_FACTOR*SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < TX_SAMPLES_PER_SYMBOL; i++) {
adda_setSample(fp16_mul(FREQ_TXLIST[idx][i], gain));
}
......
/**
* Copyright 2016-2018
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -60,7 +60,7 @@ aci_test_noise_processCmd(const mm_packet_t * pkt)
uint16_t i, j;
uint16_t idx; // prevent any wrap arounds when using uint8
fp32_t scale;
fp16_t testSig[TX_FACTOR*SAMPLES_PER_SYMBOL];
fp16_t testSig[TX_SAMPLES_PER_SYMBOL];
aci_test_noise_cmd_t * p = (aci_test_noise_cmd_t *)pkt->payload;
// sanity check
......@@ -87,7 +87,7 @@ aci_test_noise_processCmd(const mm_packet_t * pkt)
}
// prepare test signal
for (i = 0; i < TX_FACTOR*SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < TX_SAMPLES_PER_SYMBOL; i++) {
fp32_t tmp;
tmp = 0;
for (idx = 0; idx < FREQ_LIST_NUM; idx += p->step) {
......@@ -101,7 +101,7 @@ aci_test_noise_processCmd(const mm_packet_t * pkt)
for (j = 0; j < p->dur; j++) {
// send out next frequency
for (i = 0; i < TX_FACTOR*SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < TX_SAMPLES_PER_SYMBOL; i++) {
adda_setSample(testSig[i]);
}
}
......
......@@ -53,7 +53,7 @@
* This file was auto-generated by genFsk.py for the range 4500:1000:4500 Hz
*/
static const fp16_t FREQ_TEST_SOUND[TX_FACTOR * SAMPLES_PER_SYMBOL] = {
static const fp16_t FREQ_TEST_SOUND[TX_SAMPLES_PER_SYMBOL] = {
0x0000, 0x0964, 0x1294, 0x1b5d, 0x238e, 0x2afa, 0x3179, 0x36e5,
0x3b20, 0x3e14, 0x3fb1, 0x3fec, 0x3ec5, 0x3c42, 0x3871, 0x3367,
0x2d41, 0x261f, 0x1e2b, 0x158f, 0x0c7c, 0x0323, 0xf9bb, 0xf074,
......@@ -126,7 +126,7 @@ static const fp16_t FREQ_TEST_SOUND[TX_FACTOR * SAMPLES_PER_SYMBOL] = {
*/
// determine number of symbols from duration in ms, round to nearest
#define MS_TO_SYMBOLS(t) ((MS_TO_TICKS(t) + SAMPLES_PER_SYMBOL / 2) / SAMPLES_PER_SYMBOL)
#define MS_TO_TX_SYMBOLS(t) ((MS_TO_TICKS(t) + TX_SAMPLES_PER_SYMBOL / 2) / TX_SAMPLES_PER_SYMBOL)
/**************************************************************************
......@@ -146,11 +146,11 @@ aci_test_sound_processCmd(const mm_packet_t * pkt)
}
// obtain and check parameters
dur = MS_TO_SYMBOLS(10 * p->dur); // p->dur in 1/100 ms
if (dur < MS_TO_SYMBOLS(10)) {
dur = MS_TO_SYMBOLS(10);
} else if (dur > MS_TO_SYMBOLS(2500)) {
dur = MS_TO_SYMBOLS(2500);
dur = MS_TO_TX_SYMBOLS(10 * p->dur); // p->dur in 1/100 ms
if (dur < MS_TO_TX_SYMBOLS(10)) {
dur = MS_TO_TX_SYMBOLS(10);
} else if (dur > MS_TO_TX_SYMBOLS(2500)) {
dur = MS_TO_TX_SYMBOLS(2500);
}
// init tx mode
......@@ -158,7 +158,7 @@ aci_test_sound_processCmd(const mm_packet_t * pkt)
// repeat symbol to match duration
for (j = 0; j < dur; j++) {
for (i = 0; i < TX_FACTOR*SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < TX_SAMPLES_PER_SYMBOL; i++) {
adda_setSample(FREQ_TEST_SOUND[i]);
}
}
......
/**
* Copyright 2016-2018
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -77,7 +77,7 @@ aci_test_sweep_processCmd(const mm_packet_t * pkt)
for (idx = 0; idx < FREQ_LIST_NUM; idx++) {
// send out next frequency
for (i = 0; i < TX_FACTOR*SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < TX_SAMPLES_PER_SYMBOL; i++) {
fp16_t s;
s = FREQ_TXLIST[idx][i];
if (p->gc) {
......@@ -88,7 +88,7 @@ aci_test_sweep_processCmd(const mm_packet_t * pkt)
// add silence (multiple symbols)
// TODO sanity check (int overflow)
for (i = 0; i < p->gap * TX_FACTOR*SAMPLES_PER_SYMBOL; i++) {
for (i = 0; i < p->gap * TX_SAMPLES_PER_SYMBOL; i++) {
adda_setNeutralSample();
}
}
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -54,25 +54,22 @@ static uint8_t gainLvl = DEFAULT_GAIN_LEVEL;
//#define AGC_WAIT_INC ((uint16_t)(1 + (SAMPLES_PER_SYMBOL * 2))) // decay time
//#define AGC_WAIT_DEC ((uint16_t)(1 + (SAMPLES_PER_SYMBOL / 10))) // attack time
// FIXME it's very dangerous to make this dependent on symbol length rather than time!
#define AGC_WAIT_INC ((uint16_t)(1 + (SAMPLES_PER_SYMBOL * 1))) // decay time
#define AGC_WAIT_DEC ((uint16_t)(1 + (SAMPLES_PER_SYMBOL / 16))) // attack time
#define AGC_WAIT_INC ((uint16_t)(1 + (RX_SAMPLES_PER_SYMBOL * 1))) // decay time
#define AGC_WAIT_DEC ((uint16_t)(1 + (RX_SAMPLES_PER_SYMBOL / 16))) // attack time
static uint16_t waitInc = 0;
static uint16_t waitDec = 0;
// NOTE, ticks delivered (used) are raw (i.e., not scaled with to RX units (div. by TX factor))
// so we simply multiply our time with that rather than using slow division in the code
#define AGC_EVENT_MAX_DELAY (TX_FACTOR * US_TO_TICKS(100))
// NOTE time ticks are at SAMPLING_FREQ, not at (possible) RX down-sampled rate
#define AGC_EVENT_MAX_DELAY_TICKS US_TO_TICKS(100)
static sample_time_t agcEvTime;
static void (* agcEvHandler)(void) = NULL;
//#define FB_EWMA 64 // -> x_i = (FB_EWMA-1)/FB_EWMA* x_{i-1} + 1/FB_EWMA * x
#if SAMPLING_FREQ == 50000
# define LP_NUM_SAMPLES 16 // MUST be a power of two!
#elif SAMPLING_FREQ == 200000
// TODO add other frequencies and down samplings
#if SAMPLING_FREQ == FREQ_200kHz && RX_DOWNSAMPLE == RX_SAMPLING_DIV1
# define LP_NUM_SAMPLES 64 // MUST be a power of two!
#else
# error "sampling frequency not supported by AGC"
# error "sampling frequency or RX downsampling not supported by AGC"
#endif
#define LP_NUM_MASK (LP_NUM_SAMPLES-1)
......@@ -109,7 +106,7 @@ static void (* agcEvHandler)(void) = NULL;
#define CONTROL_THRESH_SIGNAL_LOW ((fp32_t)(FP32_INV(GAIN_STEP_SQR) * CONTROL_TARGET_SIGNAL * LP_NUM_SAMPLES))
// feedback value (sum inside window)
static fp32_t fb = 0; // use larger data type to avoid casts during calculation (EWMA)
static fp32_t fb = 0; // use larger data type to cope with larger sums of fp16_t
// current thresholds
static fp32_t threshHigh;
......@@ -309,7 +306,7 @@ agc_checkAction(sample_time_t ticks)
}
// call handler and reset
if (ticks - agcEvTime <= AGC_EVENT_MAX_DELAY) {
if (ticks - agcEvTime <= AGC_EVENT_MAX_DELAY_TICKS) {
agcEvHandler();
}
agcEvHandler = NULL;
......
/**
* Copyright 2016-2019
* Copyright 2016-2024
*
* Jan Heitmann,
* Bernd-Christian Renner, and
......@@ -49,16 +49,16 @@
#define BATVOL_FACTOR (((BATVOL_RL+BATVOL_RH)*BATVOL_VREF) / BATVOL_RL)
static uint16_t batteryVoltage = 0;
static uint16_t batteryVoltage = 0; // [mV]
static uint8_t batVolThreshState = 0;
static uint8_t batVolThreshState = 0; // index of BATVOL_THRESH
static bool batVolInit = false;
// values include 200mV diode drop
// FIXME this is HW specific, so move where it belongs
static const uint16_t
batvolThresh[] = {
BATVOL_THRESH[] = {
11040, // crit, ca 25% [mV]
11310, // low, ca 50% [mV]
11750, // good, ca 75% [mV]
......@@ -70,7 +70,7 @@ batvolThresh[] = {
// };
#define BATVOL_THRESH_NUM (sizeof(batvolThresh)/sizeof(batvolThresh[0]))
#define BATVOL_THRESH_NUM (sizeof(BATVOL_THRESH)/sizeof(BATVOL_THRESH[0]))
#define BATVOL_CYCLE_LEN 20 // must be larger than 2*(BATVOL_THRESH_NUM+1)
......@@ -106,7 +106,7 @@ adc_handler(uint16_t raw) {
// recharging battery or lab supply (whch might increase)
uint8_t i;
for (i = 0; i < BATVOL_THRESH_NUM; i++) {
if (batteryVoltage < batvolThresh[i]) {
if (batteryVoltage < BATVOL_THRESH[i]) {
break;
}
}
......@@ -118,9 +118,9 @@ adc_handler(uint16_t raw) {
// callback from MCU timer interface
// blinking pattern
// n blinks per cycle -> voltage below batvolThresh[n-1]
// n blinks per cycle -> voltage below BATVOL_THRESH[n-1]
// min is 1 blink (so that the user knows the device still works)
// if voltage exceeds maximum (last entry in batvolThresh), permanent blinking
// if voltage exceeds maximum (last entry in BATVOL_THRESH), permanent blinking
void
alivetimer_handler()
{
......
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -100,7 +100,7 @@ channelquality_calcSignalLevel(fp64_t rxLevel, uint32_t numBits, uint8_t numFreq
// relAmpl = 2 / N * mean
// relFreqs = relAmpl / (1 / numFreqs) = relAmpl * numFreqs
// TODO inefficient: possible to convert to (smaller) uints?
uint32_t res = fp64_toUint( 100 * fp64_sqrt( rxLevel / numBits ) * numFreqs * 2 / SAMPLES_PER_SYMBOL );
uint32_t res = fp64_toUint( 100 * fp64_sqrt( rxLevel / numBits ) * numFreqs * 2 / RX_SAMPLES_PER_SYMBOL );
return res > RSSI_MAX ? RSSI_MAX : res;
......
......@@ -44,12 +44,22 @@ aci/csrc
# enable debug pins
CFLAGS += -DPIN_DEBUG
# setup sampling rate (SAMPLING_FREQ) and RX downsampling sending
# (RX_DOWNSAMPLE), not all combinations are supported with every
# communication band
# CFLAGS += -DSAMPLING_FREQ=FREQ_200kHz
# CFLAGS += -DRX_DOWNSAMPLE=RX_SAMPLING_DIV1
# enable ACI sample command
CFLAGS += -DACI_SAMPLE_ENABLE
# enable TX gain compensation to equalize hydrophone levels
CFLAGS += -DTXGAIN_COMP
# set default transducer
# see TRANSDUCER_* in freq_setup.h for available options
# CFLAGS += -DTRANSDUCER_DFLT=TRANSDUCER_AS1_ORIG
# set spreading/despreading method
# - best bit: only use best bit (ignore all others)
# - majority: make a majority vote (useful only for odd number)
......@@ -68,6 +78,12 @@ CFLAGS += -DSYNC_AUTO_NOISE
# use wide band
# CFLAGS += -DWIDEBAND
# invert frequency band
# this option should be used in combination with
# non-wideband, if the hydrophone is much louder
# towards the higher end of the overall band
# CFLAGS += -DINVERT_FREQBAND
# frequency band definitions dir
LUT_SRC = os/fsk_25-60
......
/**
* Copyright 2023
*
* Bernd-Christian Renner and
* Hamburg University of Technology (TUHH).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hal_gpio.h>
#define TIMEOUT_MS 100
#define WAIT_TIMED(cond) \
do { \
uint32_t tickstart = HAL_GetTick(); \
while (cond) { \
if (TIMEOUT_MS == 0 || (HAL_GetTick() - tickstart) > TIMEOUT_MS) { \
led_on(LED_1); \
led_on(LED_2); \
led_on(LED_3); \
led_on(LED_4); \
led_on(LED_5); \
while (true) { /* dead */ } \
} \
} \
} while (false);
/**
* Copyright 2016-2019
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -592,7 +592,7 @@ freq_getTxGainByIndex(uint8_t i)
}
uint16_t
rx_sample_cnt_t
freq_getSignalWindowSize()
{
return signalWindowSize;
......@@ -600,7 +600,7 @@ freq_getSignalWindowSize()
void
freq_setSignalWindowSize(uint16_t newSize)
freq_setSignalWindowSize(rx_sample_cnt_t newSize)
{
if (newSize <= SIGNAL_WINDOW_SIZE_MAX) {
signalWindowSize = newSize;
......