BossHobby / QUICKSILVER

Flight Controller Firmware
MIT License
171 stars 40 forks source link

Unified Serial RX Map / Roadmap / Breakdown / Whatever #17

Closed Bobnova closed 3 years ago

Bobnova commented 5 years ago

Part 0: The USART Setup I don't really know how I'm going to do this for auto detecting a USART and assigning an ISR, we'll get to it. Once a USART is detected, this function ("ibus_init", "rx_init", "usart_rx_init" etc) will read the expected protocol ID from flash and set the USART up for it. It then sets a "RX ready to be read" flag.

Part 1: The ISR

In normal operation the ISR takes the protocol ID number (for the start byte value mostly), and puts out a uint8_t data[48] array (which needs a new name, raw_rx_data[48] maybe) with the radio frame int it, and a "OK time to get busy on this" flag and a flag for what protocol it is. In "What protocol is this anyway?" mode it takes in nothing, and outputs that same array. Maybe with a "I need an ID on this nonsense" flag, maybe not.

Part 2: The Decoder Input: the raw radio frame (rx_raw_data[48]), and a byte of protocol ID.

Checks to see if the data array is long enough to be a full frame of the given protocol. Checks CRC on the frame, if the protocol uses CRC. If those both pass, it then assembles the channels[16] array of uint16_t from the rx_raw_data array based on the protocol. If the rx_state is still in the safety/initialization phase it loops around a few times making sure it gets a full second of frames with throttle low, once it gets that, it's done. It outputs channels[16], protocol and rx_state.

Part 3: The Assignerizer Input Channels[16], protocol, rx_state, expo settings. If rx_state hasn't passed Part 2's tests, it does nothing. If it passes, it assembles the rx[4] array out of the first four channels, scaling based on protocol. It assembles the aux[] array based on channels and protocol. It applies expo to the rx[] array's channels based on the expo settings.

Output: rx[], aux[], protocol

Part 4: Safety

Input: rx[], protocol, rx_state, failsafe

Checks time since last frame, sets failsafe if it's too high. Checks that enough frames have arrived in a row to be considered safe, sets failsafe if not. Does FPS counting. Does other safety related stuff.

Output: rx_ready, failsafe, rx_state, rx[]'s throttle?

Note: Safety is called every loop! NOT just when a frame arrives.

This isn't exhaustive, it's the quick version beacause I have about 45 seconds to spare on this timeslot now.

NotFastEnuf commented 4 years ago

status update: crossfire missing uart pin controlled inverter handling missing smart port telemetry missing auto select of rc smoothing filter cut based on protocol

final step will be eliminating the individual rx files but still keeping a define based override for each protocol whill will bypass autodetect and hard set a protocol

bkleiner commented 4 years ago

auto select of rc smoothing filter cut based on protocol

this landed in c9aedf911e02d99ea5004fb5e30b41412eed8d3e

bkleiner commented 4 years ago

uart pin controlled inverter handling missing

we have this now in a branch https://github.com/NotFastEnuf/Guano/tree/feature-universial-serial-inversion

NotFastEnuf commented 4 years ago

At this point we are only missing integration of crossfire protocol and then we need to clean out all the old individual rx files. We should however at that point still support hard setting a rx protocol through config.h defines but it would just be selecting a protocol from within unified serial. We also still have inconsistent user behavior on saving a rx protocol/ bind state in unified serial vs other spi receivers. In unified - it is a two step process. UUU to toggle the save variable then DDD to save. In spi protocols it is just DDD. opinion warning - i think we should be consistent across the board and i lean towards the traditional 2 step process of olden days

bkleiner commented 3 years ago

At this point we are only missing integration of crossfire protocol and then we need to clean out all the old individual rx files. We should however at that point still support hard setting a rx protocol through config.h defines but it would just be selecting a protocol from within unified serial.

landed in this branch https://github.com/NotFastEnuf/Guano/tree/feature-redsky

NotFastEnuf commented 3 years ago

Excellent, once merged we can close this one down

bkleiner commented 3 years ago

CRSF support has been merged to master.

We also still have inconsistent user behavior on saving a rx protocol/ bind state in unified serial vs other spi receivers. In unified - it is a two step process. UUU to toggle the save variable then DDD to save. In spi protocols it is just DDD. opinion warning - i think we should be consistent across the board and i lean towards the traditional 2 step process of olden days

Fix for this is currently in a feature branch.

Closing this issue, as above is about spi-rx, not unified.