1use embedded_hal_async::delay::DelayNs;
2
3use crate::mod_params::*;
4
5pub trait InterfaceVariant {
8 async fn reset(&mut self, delay: &mut impl DelayNs) -> Result<(), RadioError>;
10 async fn wait_on_busy(&mut self) -> Result<(), RadioError>;
12 async fn await_irq(&mut self) -> Result<(), RadioError>;
14 async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError>;
16 async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError>;
18 async fn disable_rf_switch(&mut self) -> Result<(), RadioError>;
20}
21
22#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
24pub enum IrqState {
25 PreambleReceived,
27 Done,
29}
30
31pub trait RadioKind {
34 async fn init_lora(&mut self, is_public_network: bool) -> Result<(), RadioError>;
36 fn create_modulation_params(
38 &self,
39 spreading_factor: SpreadingFactor,
40 bandwidth: Bandwidth,
41 coding_rate: CodingRate,
42 frequency_in_hz: u32,
43 ) -> Result<ModulationParams, RadioError>;
44 fn create_packet_params(
46 &self,
47 preamble_length: u16,
48 implicit_header: bool,
49 payload_length: u8,
50 crc_on: bool,
51 iq_inverted: bool,
52 modulation_params: &ModulationParams,
53 ) -> Result<PacketParams, RadioError>;
54 async fn reset(&mut self, delay: &mut impl DelayNs) -> Result<(), RadioError>;
56 async fn ensure_ready(&mut self, mode: RadioMode) -> Result<(), RadioError>;
58 async fn set_standby(&mut self) -> Result<(), RadioError>;
60 async fn set_sleep(&mut self, warm_start_if_possible: bool, delay: &mut impl DelayNs) -> Result<(), RadioError>;
62 async fn set_tx_rx_buffer_base_address(
64 &mut self,
65 tx_base_addr: usize,
66 rx_base_addr: usize,
67 ) -> Result<(), RadioError>;
68 async fn set_tx_power_and_ramp_time(
70 &mut self,
71 output_power: i32,
72 mdltn_params: Option<&ModulationParams>,
73 is_tx_prep: bool,
74 ) -> Result<(), RadioError>;
75 async fn set_modulation_params(&mut self, mdltn_params: &ModulationParams) -> Result<(), RadioError>;
77 async fn set_packet_params(&mut self, pkt_params: &PacketParams) -> Result<(), RadioError>;
79 async fn calibrate_image(&mut self, frequency_in_hz: u32) -> Result<(), RadioError>;
81 async fn set_channel(&mut self, frequency_in_hz: u32) -> Result<(), RadioError>;
83 async fn set_payload(&mut self, payload: &[u8]) -> Result<(), RadioError>;
85 async fn do_tx(&mut self) -> Result<(), RadioError>;
87 async fn do_rx(&mut self, rx_mode: RxMode) -> Result<(), RadioError>;
89 async fn get_rx_payload(
91 &mut self,
92 rx_pkt_params: &PacketParams,
93 receiving_buffer: &mut [u8],
94 ) -> Result<u8, RadioError>;
95 async fn get_rx_packet_status(&mut self) -> Result<PacketStatus, RadioError>;
97 async fn do_cad(&mut self, mdltn_params: &ModulationParams) -> Result<(), RadioError>;
99 async fn set_irq_params(&mut self, radio_mode: Option<RadioMode>) -> Result<(), RadioError>;
101 async fn set_tx_continuous_wave_mode(&mut self) -> Result<(), RadioError>;
103
104 async fn await_irq(&mut self) -> Result<(), RadioError>;
106 async fn process_irq_event(
108 &mut self,
109 radio_mode: RadioMode,
110 cad_activity_detected: Option<&mut bool>,
111 clear_interrupts: bool,
112 ) -> Result<Option<IrqState>, RadioError>;
113}