Implement full FHSS TX/RX, real AES key, button read, slot sync
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:
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* @file power.h
|
||||
* @brief Power management: DC/DC regulator, GPIOTE wakeup, SYSTEM_ON sleep.
|
||||
* @brief Power management: DC/DC regulator, GPIOTE wakeup, WFI sleep.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
|
||||
/** @brief Enable the DC/DC converter and configure GPIOTE wakeup on the PTT button. */
|
||||
/** @brief Enable the DC/DC converter, configure GPIO input and GPIOTE wakeup on the PTT button. */
|
||||
void power_init(void);
|
||||
|
||||
/**
|
||||
@@ -14,3 +15,9 @@ void power_init(void);
|
||||
* interrupt fires (button press) and resumes from here.
|
||||
*/
|
||||
void power_sleep_until_button(void);
|
||||
|
||||
/**
|
||||
* @brief Return the current state of the PTT button.
|
||||
* @return true when the button is pressed.
|
||||
*/
|
||||
bool power_button_pressed(void);
|
||||
|
||||
Reference in New Issue
Block a user