mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Move port telemetry port configuration logic into common telemetry code.
Update software serial to support RX, TX or RX&TX modes. Update serial API to allow on-the-fly changing of serial port mode. Update HoTT to change serial port mode when transmitting.
This commit is contained in:
parent
1051cbcf52
commit
ac0f3e9186
12 changed files with 169 additions and 64 deletions
|
@ -216,9 +216,7 @@ void hottV4FormatAndSendEAMResponse(void) {
|
|||
|
||||
static void hottV4Respond(uint8_t *data, uint8_t size) {
|
||||
|
||||
if (serialTotalBytesWaiting(core.telemport) != 0 ) {
|
||||
return; // cannot respond since another request came in.
|
||||
}
|
||||
serialSetMode(core.telemport, MODE_TX);
|
||||
|
||||
uint16_t crc = 0;
|
||||
uint8_t i;
|
||||
|
@ -235,16 +233,29 @@ static void hottV4Respond(uint8_t *data, uint8_t size) {
|
|||
hottV4SerialWrite(crc & 0xFF);
|
||||
|
||||
delayMicroseconds(HOTTV4_TX_DELAY);
|
||||
|
||||
serialSetMode(core.telemport, MODE_RX);
|
||||
}
|
||||
|
||||
static void hottV4SerialWrite(uint8_t c) {
|
||||
serialWrite(core.telemport, c);
|
||||
}
|
||||
|
||||
void configureHoTTTelemetryPort(void) {
|
||||
// TODO set speed here to 19200
|
||||
serialSetMode(core.telemport, MODE_RX);
|
||||
}
|
||||
|
||||
void freeHoTTTelemetryPort(void) {
|
||||
serialSetMode(core.telemport, MODE_RXTX);
|
||||
}
|
||||
|
||||
void handleHoTTTelemetry(void)
|
||||
{
|
||||
while (serialTotalBytesWaiting(core.telemport)) {
|
||||
uint8_t c = serialRead(core.telemport);
|
||||
uint8_t c;
|
||||
|
||||
while (serialTotalBytesWaiting(core.telemport) > 0) {
|
||||
c = serialRead(core.telemport);
|
||||
|
||||
// Protocol specific waiting time
|
||||
// to avoid collisions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue