Implement full FHSS TX/RX, real AES key, button read, slot sync
All checks were successful
CI / Build firmware (push) Successful in 36s
CI / Check formatting (push) Successful in 12s
CI / Static analysis (push) Successful in 12s
CI / Build documentation (push) Successful in 15s

radio_tx_burst(): captures current slot, calls fhss_next_channel() to
advance the sequence, sets channel, transmits ptt_frame_t, then holds
the dwell window via TIMER0 so the receiver has the full 2 ms to listen.

radio_rx_burst(): advances to the same channel, enables RX, waits for
EVENTS_END or TIMER0 COMPARE0 expiry. On a valid CRC the ptt_frame_t
is returned; caller syncs FHSS with fhss_set_slot(frame.slot + 1).

TIMER0: configured once in radio_init() (MODE=Timer, BITMODE=16-bit,
PRESCALER=4 -> 1 MHz tick, CC[0]=2000 -> 2 ms, COMPARE0_STOP shortcut).

fhss.c: replace zero key with a non-trivial 128-bit value; add
fhss_set_slot() and fhss_get_slot() for RX synchronisation.

power.c: add BUTTON_ACTIVE_LOW flag (default 1 = pull-up + GND button);
configure PIN_CNF accordingly; implement power_button_pressed() via
NRF_P0->IN.

regs.h: add gpio_pin_cnf_t with GPIO_PULL_* constants.

main.c: tight PTT loop -- radio_tx_burst() while button held, otherwise
radio_rx_burst() with slot sync on reception. No WFI in RX mode.
This commit is contained in:
Krzysztof Cieślik
2026-05-22 00:40:49 +02:00
parent dca80c7821
commit c9320eb9db
8 changed files with 232 additions and 42 deletions

View File

@@ -153,3 +153,24 @@ typedef union {
} bit;
uint32_t reg;
} radio_shorts_t;
/* GPIO */
/** @brief GPIO PIN_CNF[n]: pin configuration register. */
typedef union {
struct {
uint32_t DIR : 1; /* [0] 0=Input 1=Output */
uint32_t INPUT : 1; /* [1] 0=Connect 1=Disconnect */
uint32_t PULL : 2; /* [3:2] 0=Disabled 1=Pulldown 3=Pullup */
uint32_t : 4; /* [7:4] reserved */
uint32_t DRIVE : 3; /* [10:8] 0=S0S1 standard drive */
uint32_t : 5; /* [15:11] reserved */
uint32_t SENSE : 2; /* [17:16] 0=Disabled 2=SenseHigh 3=SenseLow */
uint32_t : 14; /* [31:18] reserved */
} bit;
uint32_t reg;
} gpio_pin_cnf_t;
#define GPIO_PULL_DISABLED 0u
#define GPIO_PULL_PULLDOWN 1u
#define GPIO_PULL_PULLUP 3u