1use crate::{
2 comm::messages::messages::DownlinkMessage, errors, math::FlightFloat, params::Params,
3 sensors::SensorBus,
4};
5pub mod dummy;
6
7#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
8pub struct BackupData {
9 pub error_code: u32,
10 pub pc: u32,
11 pub reset_count: u32,
12 pub do_rearm: u32,
13}
14
15#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord)]
16pub struct SerialTxPriority(pub u8);
17
18impl SerialTxPriority {
19 pub const REPLACEABLE_TELEMETRY: Self = Self(32);
20 pub const DEFAULT: Self = Self(128);
21 pub const CRITICAL: Self = Self(224);
22}
23
24pub type SerialRxPriority = SerialTxPriority;
25
26pub const SERIAL_RX_FRAME_MAX_BYTES: usize = 280;
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq)]
29pub struct SerialRxFrame {
30 pub data: [u8; SERIAL_RX_FRAME_MAX_BYTES],
31 pub len: usize,
32}
33
34impl SerialRxFrame {
35 pub const fn empty() -> Self {
36 Self {
37 data: [0; SERIAL_RX_FRAME_MAX_BYTES],
38 len: 0,
39 }
40 }
41}
42
43impl Default for SerialRxFrame {
44 fn default() -> Self {
45 Self::empty()
46 }
47}
48
49pub trait BoardIo {
50 fn update_sensor_bus<R: FlightFloat>(&mut self, sensors: &mut SensorBus<R>) {
51 sensors.clear();
52 }
53 fn imu_pending(&self) -> bool {
54 false
55 }
56 fn update_imu_sensor<R: FlightFloat>(&mut self, sensors: &mut SensorBus<R>) {
57 self.update_sensor_bus(sensors);
58 }
59 fn update_service_sensor_bus<R: FlightFloat>(&mut self, sensors: &mut SensorBus<R>) {
60 self.update_sensor_bus(sensors);
61 }
62 fn serial_rx_read(&mut self, buf: &mut [u8]) -> Option<Result<usize, errors::TelemError>>;
63 fn serial_tx_write(&mut self, bytes: &[u8]) -> Option<Result<usize, errors::TelemError>>;
64 fn serial_tx_write_priority(
65 &mut self,
66 bytes: &[u8],
67 _priority: SerialTxPriority,
68 ) -> Option<Result<usize, errors::TelemError>> {
69 self.serial_tx_write(bytes)
70 }
71 fn serial_tx_enqueue_downlink(
72 &mut self,
73 _system_id: u8,
74 _msg: DownlinkMessage,
75 _priority: SerialTxPriority,
76 ) -> Option<Result<usize, errors::TelemError>> {
77 None
78 }
79 fn serial_rx_frame_read(&mut self) -> Option<Result<SerialRxFrame, errors::TelemError>> {
80 None
81 }
82 fn serial_rx_pending(&self) -> bool {
83 false
84 }
85
86 fn clock_millis(&self) -> u32;
87 fn clock_micros(&self) -> u64;
88 fn set_test_pin_1(&mut self, _high: bool) {}
89 fn set_test_pin_2(&mut self, _high: bool) {}
90 fn set_test_pin_3(&mut self, _high: bool) {}
91 fn read_params(&mut self, _params: &mut Params) -> bool {
92 false
93 }
94 fn write_params(&mut self, _params: &Params) -> bool {
95 false
96 }
97 fn sensors_errors_count(&self) -> u16 {
98 0
99 }
100 fn sensors_errors_message(&self, _index: u16) -> Option<[u8; 50]> {
101 None
102 }
103 fn serial_flush(&mut self) {}
104 fn serial_flush_budgeted(&mut self, _max_units: usize) {
105 self.serial_flush();
106 }
107 fn led0_on(&mut self) {}
108 fn led0_off(&mut self) {}
109 fn led0_toggle(&mut self) {}
110 fn led1_on(&mut self) {}
111 fn led1_off(&mut self) {}
112 fn led1_toggle(&mut self) {}
113 fn backup_memory_read(&mut self) -> Option<BackupData> {
114 None
115 }
116 fn backup_memory_write(&mut self, _data: BackupData) -> bool {
117 false
118 }
119 fn backup_memory_clear(&mut self) -> bool {
120 false
121 }
122 fn reboot(&mut self) -> bool {
123 false
124 }
125 fn reboot_to_bootloader(&mut self) -> bool {
126 false
127 }
128 fn run_deferred_board_actions(&mut self) {}
129}