|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Namespaces | |
| namespace | anonymous_namespace{sx1262.cpp} |
| namespace | anonymous_namespace{sx1262_setup.cpp} |
| namespace | anonymous_namespace{arm_gate.cpp} |
| namespace | anonymous_namespace{frame.cpp} |
| namespace | anonymous_namespace{radio_fake.cpp} |
| namespace | fake |
Classes | |
| class | SpiBus |
| struct | PacketStatus |
| class | Sx1262 |
| class | RadioControl |
| struct | LoraConfig |
| class | Sx1262Setup |
| class | ArmGate |
| struct | Frame |
| class | Link |
| class | FakeAir |
| class | FakeChip |
Enumerations | |
| enum class | SetupStep : uint8_t { Ok = 0 , Standby , Regulator , Tcxo , Calibrate , RfSwitch , PacketType , Frequency , ImageCalibration , PaConfig , TxParams , BufferBase , Modulation , PacketParams , IrqMap , TxClamp , SyncWord , DeviceErrors , StartRx } |
| enum class | RxMode : uint8_t { Continuous , DutyCycle } |
| enum class | ArmAction : uint8_t { None = 0 , Pending , Arm , Disarm , RejectKey , RejectTarget , RejectStale } |
| enum class | FrameType : uint8_t { Heartbeat = 0x01 , SelfTest = 0x02 , Arm = 0x10 , UnArm = 0x11 } |
| enum class | FrameStatus : uint8_t { Ok = 0 , ErrTooShort , ErrVersion , ErrLength , ErrCrc , ErrType , ErrPayload , ErrArgs } |
| enum class | RadioStatus : uint8_t { Ok = 0 , ErrNotFound , ErrTooLong , NoData , ErrTimeout , NotImplemented } |
Functions | |
| bool | sx1262_status_ok (uint8_t status) |
| uint32_t | sx1262_frequency_word (uint32_t freq_hz) |
| uint32_t | lora_time_on_air_us (const LoraConfig &cfg, uint8_t payload_len) |
| void | put_u16 (uint8_t *p, uint16_t v) |
| void | put_u32 (uint8_t *p, uint32_t v) |
| uint16_t | get_u16 (const uint8_t *p) |
| uint32_t | get_u32 (const uint8_t *p) |
| uint16_t | crc16 (const uint8_t *data, size_t len) |
| CRC-16/CCITT-FALSE: poly 0x1021, init 0xFFFF, no reflection, no xorout. | |
| FrameStatus | decode_frame (const uint8_t *buf, size_t len, Frame &out) |
| Parse and validate a received packet. | |
| FrameStatus | encode_frame (FrameType type, uint16_t seq, const uint8_t *payload, uint8_t payload_len, uint8_t *out, size_t out_cap, size_t &out_len) |
| Build a frame into out[0..out_cap). | |
| RadioStatus | radio_probe () |
| RadioStatus | radio_receive (uint8_t *buf, uint8_t max_len, uint8_t &len) |
| RadioStatus | radio_send (const uint8_t *bytes, uint8_t len) |
Variables | |
| constexpr uint8_t | kOpClearIrqStatus = 0x02 |
| constexpr uint8_t | kOpGetIrqStatus = 0x12 |
| constexpr uint8_t | kOpGetRxBufferStatus = 0x13 |
| constexpr uint8_t | kOpGetPacketStatus = 0x14 |
| constexpr uint8_t | kOpReadBuffer = 0x1E |
| constexpr uint8_t | kOpSetRx = 0x82 |
| constexpr uint16_t | kIrqRxDone = 1u << 1 |
| constexpr uint16_t | kIrqHeaderErr = 1u << 5 |
| constexpr uint16_t | kIrqCrcErr = 1u << 6 |
| constexpr LoraConfig | kDefaultLora = {915000000u, 9, 0x04, 1, 8, 22, 0x1424} |
| constexpr uint32_t | kArmKey = 0xA5C3965Au |
| PLACEHOLDER: lead to choose the real key before flight. | |
| constexpr uint32_t | kArmConfirmWindowMs = 2000 |
| Max time between the two ARM frames. | |
| constexpr uint8_t | kFrameVersion = 0x01 |
| constexpr size_t | kFrameHeaderLen = 5 |
| constexpr size_t | kFrameCrcLen = 2 |
| constexpr size_t | kFrameOverhead = kFrameHeaderLen + kFrameCrcLen |
| constexpr size_t | kLoraMaxPacket = 255 |
| constexpr size_t | kFrameMaxPayload = kLoraMaxPacket - kFrameOverhead |
| constexpr size_t | kFrameMaxLen = kFrameOverhead + kFrameMaxPayload |
| constexpr uint8_t | kHeartbeatLen = 7 |
| Required payload length per type. | |
| constexpr uint8_t | kSelfTestLen = 4 |
| constexpr uint8_t | kArmLen = 9 |
| constexpr uint8_t | kUnArmLen = 0 |
|
strong |
| Enumerator | |
|---|---|
| None | |
| Pending | |
| Arm | |
| Disarm | |
| RejectKey | |
| RejectTarget | |
| RejectStale | |
Definition at line 40 of file arm_gate.h.
|
strong |
|
strong |
|
strong |
|
strong |
| Enumerator | |
|---|---|
| Continuous | |
| DutyCycle | |
Definition at line 72 of file sx1262_setup.h.
|
strong |
| Enumerator | |
|---|---|
| Ok | |
| Standby | |
| Regulator | |
| Tcxo | |
| Calibrate | |
| RfSwitch | |
| PacketType | |
| Frequency | |
| ImageCalibration | |
| PaConfig | |
| TxParams | |
| BufferBase | |
| Modulation | |
| PacketParams | |
| IrqMap | |
| TxClamp | |
| SyncWord | |
| DeviceErrors | |
| StartRx | |
Definition at line 50 of file sx1262_setup.h.
| uint16_t radio_link::crc16 | ( | const uint8_t * | data, |
| size_t | len ) |
CRC-16/CCITT-FALSE: poly 0x1021, init 0xFFFF, no reflection, no xorout.
Check value: crc16("123456789") == 0x29B1.
Definition at line 30 of file frame.cpp.
References b.
Referenced by decode_frame(), encode_frame(), raw_frame(), test_crc16_empty_is_init_value(), and test_crc16_standard_check_value().
| FrameStatus radio_link::decode_frame | ( | const uint8_t * | buf, |
| size_t | len, | ||
| Frame & | out ) |
Parse and validate a received packet.
On Ok, out is filled in. Checks, in order: size, version, length field, CRC, type, payload size. Nothing in out is valid unless Ok is returned.
Definition at line 63 of file frame.cpp.
References crc16(), ErrArgs, ErrCrc, ErrLength, ErrPayload, ErrTooShort, ErrType, ErrVersion, get_u16(), kFrameHeaderLen, kFrameMaxPayload, kFrameOverhead, kFrameVersion, and Ok.
Referenced by anonymous_namespace{idle_e2e.cpp}::beats(), radio_link::Link::poll(), test_decode_golden_heartbeat(), test_decode_rejects_any_single_bit_flip(), test_decode_rejects_extra_or_missing_bytes(), test_decode_rejects_null_buffer(), test_decode_rejects_oversize_length_field(), test_decode_rejects_too_short(), test_decode_rejects_unknown_type_with_valid_crc(), test_decode_rejects_wrong_payload_size_with_valid_crc(), test_decode_rejects_wrong_version(), test_roundtrip_every_type(), and test_send_goes_through_the_seam().
| FrameStatus radio_link::encode_frame | ( | FrameType | type, |
| uint16_t | seq, | ||
| const uint8_t * | payload, | ||
| uint8_t | payload_len, | ||
| uint8_t * | out, | ||
| size_t | out_cap, | ||
| size_t & | out_len ) |
Build a frame into out[0..out_cap).
On Ok, out_len is the byte count. Payload size is checked against the type, so a malformed frame can't be sent.
Definition at line 96 of file frame.cpp.
References crc16(), ErrArgs, ErrPayload, ErrType, kFrameHeaderLen, kFrameOverhead, kFrameVersion, Ok, and put_u16().
Referenced by anonymous_namespace{idle_e2e.cpp}::ground_arm(), inject_arm(), radio_task_send_frame(), anonymous_namespace{idle_e2e.cpp}::send_heartbeat(), test_bad_frame_does_not_replace_the_last_good_one(), test_encode_matches_golden_arm(), test_encode_matches_golden_un_arm(), test_encode_rejects_bad_inputs(), test_heartbeat_is_counted_but_not_acted_on(), test_roundtrip_every_type(), and test_send_goes_through_the_seam().
| uint16_t radio_link::get_u16 | ( | const uint8_t * | p | ) |
Definition at line 19 of file frame.cpp.
References p.
Referenced by anonymous_namespace{idle_e2e.cpp}::beats(), decode_frame(), test_decode_golden_heartbeat(), and test_little_endian_helpers().
| uint32_t radio_link::get_u32 | ( | const uint8_t * | p | ) |
Definition at line 24 of file frame.cpp.
References p.
Referenced by anonymous_namespace{idle_e2e.cpp}::beats(), radio_link::ArmGate::on_frame(), test_decode_golden_heartbeat(), and test_little_endian_helpers().
| uint32_t radio_link::lora_time_on_air_us | ( | const LoraConfig & | cfg, |
| uint8_t | payload_len ) |
Definition at line 73 of file sx1262_setup.cpp.
Referenced by radio_link::Sx1262Setup::send(), test_frequency_word_and_time_on_air(), and radio_link::FakeAir::transfer().
| void radio_link::put_u16 | ( | uint8_t * | p, |
| uint16_t | v ) |
Definition at line 7 of file frame.cpp.
References p.
Referenced by encode_frame(), raw_frame(), and test_little_endian_helpers().
| void radio_link::put_u32 | ( | uint8_t * | p, |
| uint32_t | v ) |
Definition at line 12 of file frame.cpp.
References p.
Referenced by arm_frame(), anonymous_namespace{idle_e2e.cpp}::ground_arm(), inject_arm(), test_encode_matches_golden_arm(), and test_little_endian_helpers().
| RadioStatus radio_link::radio_probe | ( | ) |
Definition at line 175 of file radio_task.cpp.
References ErrNotFound, and Ok.
Referenced by test_probe_ok_when_chip_present(), test_probe_reports_chip_presence(), and test_probe_reports_not_found_when_chip_missing().
| RadioStatus radio_link::radio_receive | ( | uint8_t * | buf, |
| uint8_t | max_len, | ||
| uint8_t & | len ) |
Definition at line 178 of file radio_task.cpp.
References radio_link::Sx1262::receive().
Referenced by radio_link::Link::poll(), test_inject_refuses_empty_packet(), test_inject_refuses_when_queue_full(), test_receive_drops_packet_bigger_than_buffer(), test_receive_is_first_in_first_out(), test_receive_keeps_working_after_queue_wraps(), test_receive_returns_injected_packet_with_its_length(), and test_receive_with_nothing_waiting_returns_no_data().
| RadioStatus radio_link::radio_send | ( | const uint8_t * | bytes, |
| uint8_t | len ) |
Definition at line 181 of file radio_task.cpp.
References setup().
Referenced by radio_task_send_frame(), anonymous_namespace{idle_e2e.cpp}::send_heartbeat(), test_reset_forgets_what_was_sent(), test_send_counts_each_packet(), test_send_fails_when_chip_missing(), test_send_gives_the_failure_the_test_asks_for(), test_send_goes_through_the_seam(), and test_send_is_visible_to_the_test().
| uint32_t radio_link::sx1262_frequency_word | ( | uint32_t | freq_hz | ) |
Definition at line 68 of file sx1262_setup.cpp.
Referenced by radio_link::Sx1262Setup::configure(), and test_frequency_word_and_time_on_air().
| bool radio_link::sx1262_status_ok | ( | uint8_t | status | ) |
Definition at line 27 of file sx1262.cpp.
Referenced by radio_link::Sx1262Setup::configure(), radio_link::Sx1262Setup::irq_status(), and radio_link::Sx1262Setup::read_register().
|
constexpr |
Max time between the two ARM frames.
PLACEHOLDER pending review.
Definition at line 38 of file arm_gate.h.
Referenced by test_confirm_after_window_does_not_arm(), test_confirm_exactly_at_window_edge_arms(), test_tick_expires_pending(), and radio_link::ArmGate::tick().
|
constexpr |
PLACEHOLDER: lead to choose the real key before flight.
Definition at line 36 of file arm_gate.h.
Referenced by good_arm(), anonymous_namespace{idle_e2e.cpp}::ground_arm(), inject_arm(), radio_link::ArmGate::on_frame(), test_rejected_key_cancels_pending(), test_rejected_target_cancels_pending(), test_wrong_inverse_rejected(), test_wrong_key_rejected(), and test_wrong_target_rejected().
|
constexpr |
Definition at line 56 of file frame.h.
Referenced by arm_frame(), and radio_link::anonymous_namespace{frame.cpp}::payload_len_for().
|
constexpr |
Definition at line 47 of file sx1262_setup.h.
Referenced by test_configure_follows_the_datasheet_order(), test_configure_names_the_failing_step(), test_duty_cycle_1ms_is_64_steps(), test_duty_cycle_sends_correct_opcode_and_periods(), test_frequency_word_and_time_on_air(), test_no_rearm_means_no_duty_cycle_command(), test_radio_rearmed_after_every_rxdone(), test_rearm_is_noop_in_continuous_mode(), test_rearm_restarts_duty_cycle_after_rxdone(), test_send_keeps_a_packet_that_just_arrived(), test_send_refuses_bad_input_and_dead_chip(), test_send_returns_to_duty_cycle_not_continuous(), test_send_times_out(), test_send_waits_for_tx_done_and_returns_to_rx(), test_start_continuous_after_duty_cycle(), and radio_link::FakeAir::transfer().
|
constexpr |
Definition at line 35 of file frame.h.
Referenced by decode_frame(), and encode_frame().
|
constexpr |
Definition at line 41 of file frame.h.
Referenced by inject_arm(), test_bad_frame_does_not_replace_the_last_good_one(), test_encode_matches_golden_arm(), test_encode_matches_golden_un_arm(), test_encode_rejects_bad_inputs(), test_heartbeat_is_counted_but_not_acted_on(), test_roundtrip_every_type(), and test_send_goes_through_the_seam().
|
constexpr |
Definition at line 40 of file frame.h.
Referenced by decode_frame().
|
constexpr |
Definition at line 37 of file frame.h.
Referenced by decode_frame(), and encode_frame().
|
constexpr |
Definition at line 34 of file frame.h.
Referenced by decode_frame(), encode_frame(), raw_frame(), and test_decode_rejects_oversize_length_field().
|
constexpr |
Required payload length per type.
Definition at line 54 of file frame.h.
Referenced by anonymous_namespace{idle_e2e.cpp}::beats(), and radio_link::anonymous_namespace{frame.cpp}::payload_len_for().
|
constexpr |
Definition at line 39 of file sx1262.h.
Referenced by radio_link::Sx1262::receive(), test_damaged_packets_are_counted(), and test_radio_crc_error_drops_the_packet().
|
constexpr |
Definition at line 38 of file sx1262.h.
Referenced by radio_link::Sx1262::receive(), test_damaged_packets_are_counted(), and test_header_error_drops_the_packet().
|
constexpr |
Definition at line 37 of file sx1262.h.
Referenced by radio_link::FakeAir::packet_arrives(), radio_link::FakeChip::packet_arrives(), radio_link::Sx1262::receive(), test_send_keeps_a_packet_that_just_arrived(), and test_zero_length_packet_is_dropped().
|
constexpr |
Definition at line 39 of file frame.h.
Referenced by test_pure_noise_never_arms().
|
constexpr |
Definition at line 28 of file sx1262.h.
Referenced by radio_link::Sx1262::clear_irq(), radio_link::Sx1262Setup::send(), test_packet_bigger_than_the_box_is_dropped(), test_the_four_exchanges_happen_in_order(), and radio_link::FakeChip::transfer().
|
constexpr |
Definition at line 29 of file sx1262.h.
Referenced by radio_link::Sx1262Setup::irq_status(), radio_link::Sx1262::receive(), test_no_flags_returns_no_data(), test_the_four_exchanges_happen_in_order(), and radio_link::FakeChip::transfer().
|
constexpr |
Definition at line 31 of file sx1262.h.
Referenced by radio_link::Sx1262::packet_status(), test_packet_status_sends_0x14_and_four_nops(), and radio_link::FakeChip::transfer().
|
constexpr |
Definition at line 30 of file sx1262.h.
Referenced by radio_link::Sx1262::receive(), test_the_four_exchanges_happen_in_order(), and radio_link::FakeChip::transfer().
|
constexpr |
Definition at line 32 of file sx1262.h.
Referenced by radio_link::Sx1262::receive(), test_the_four_exchanges_happen_in_order(), and radio_link::FakeChip::transfer().
|
constexpr |
Definition at line 33 of file sx1262.h.
Referenced by radio_link::Sx1262Setup::back_to_rx(), and radio_link::Sx1262::start_rx_continuous().
|
constexpr |
Definition at line 55 of file frame.h.
Referenced by radio_link::anonymous_namespace{frame.cpp}::payload_len_for().
|
constexpr |
Definition at line 57 of file frame.h.
Referenced by radio_link::anonymous_namespace{frame.cpp}::payload_len_for().