mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 00:35:34 +03:00
decouple cli/msp from each other. relocated non-msp code into
serial_common.c/h. decouple runtime_config from serial ports. decouple buzzer from serial ports. decouple opening of the main serial port from the msp code. decouple serial rx providers from runtime_config. rename core_t to serialPorts_t since it only contained serial ports. It's now clear which files use serial ports based on the header files they include.
This commit is contained in:
parent
2baf385b99
commit
a7e4c859bd
26 changed files with 209 additions and 135 deletions
|
@ -1,8 +1,10 @@
|
|||
#include "board.h"
|
||||
#include "mw.h"
|
||||
|
||||
#include "drivers/serial_common.h"
|
||||
#include "serial_common.h"
|
||||
|
||||
#include "gps_common.h"
|
||||
#include "serial_cli.h"
|
||||
#include "telemetry_common.h"
|
||||
#include "flight_common.h"
|
||||
#include "sensors_compass.h"
|
||||
|
@ -126,16 +128,16 @@ void serialize32(uint32_t a)
|
|||
{
|
||||
static uint8_t t;
|
||||
t = a;
|
||||
serialWrite(core.mainport, t);
|
||||
serialWrite(serialPorts.mainport, t);
|
||||
checksum ^= t;
|
||||
t = a >> 8;
|
||||
serialWrite(core.mainport, t);
|
||||
serialWrite(serialPorts.mainport, t);
|
||||
checksum ^= t;
|
||||
t = a >> 16;
|
||||
serialWrite(core.mainport, t);
|
||||
serialWrite(serialPorts.mainport, t);
|
||||
checksum ^= t;
|
||||
t = a >> 24;
|
||||
serialWrite(core.mainport, t);
|
||||
serialWrite(serialPorts.mainport, t);
|
||||
checksum ^= t;
|
||||
}
|
||||
|
||||
|
@ -143,16 +145,16 @@ void serialize16(int16_t a)
|
|||
{
|
||||
static uint8_t t;
|
||||
t = a;
|
||||
serialWrite(core.mainport, t);
|
||||
serialWrite(serialPorts.mainport, t);
|
||||
checksum ^= t;
|
||||
t = a >> 8 & 0xff;
|
||||
serialWrite(core.mainport, t);
|
||||
serialWrite(serialPorts.mainport, t);
|
||||
checksum ^= t;
|
||||
}
|
||||
|
||||
void serialize8(uint8_t a)
|
||||
{
|
||||
serialWrite(core.mainport, a);
|
||||
serialWrite(serialPorts.mainport, a);
|
||||
checksum ^= a;
|
||||
}
|
||||
|
||||
|
@ -239,12 +241,10 @@ reset:
|
|||
}
|
||||
}
|
||||
|
||||
void serialInit(uint32_t baudrate)
|
||||
void mspInit(void)
|
||||
{
|
||||
int idx;
|
||||
|
||||
core.mainport = uartOpen(USART1, NULL, baudrate, MODE_RXTX);
|
||||
|
||||
// calculate used boxes based on features and fill availableBoxes[] array
|
||||
memset(availableBoxes, 0xFF, sizeof(availableBoxes));
|
||||
|
||||
|
@ -655,16 +655,7 @@ static void evaluateCommand(void)
|
|||
tailSerialReply();
|
||||
}
|
||||
|
||||
// evaluate all other incoming serial data
|
||||
static void evaluateOtherData(uint8_t sr)
|
||||
{
|
||||
if (sr == '#')
|
||||
cliProcess();
|
||||
else if (sr == mcfg.reboot_character)
|
||||
systemReset(true); // reboot to bootloader
|
||||
}
|
||||
|
||||
void serialCom(void)
|
||||
void mspProcess(void)
|
||||
{
|
||||
uint8_t c;
|
||||
static uint8_t offset;
|
||||
|
@ -678,14 +669,8 @@ void serialCom(void)
|
|||
HEADER_CMD,
|
||||
} c_state = IDLE;
|
||||
|
||||
// in cli mode, all serial stuff goes to here. enter cli mode by sending #
|
||||
if (cliMode) {
|
||||
cliProcess();
|
||||
return;
|
||||
}
|
||||
|
||||
while (serialTotalBytesWaiting(core.mainport)) {
|
||||
c = serialRead(core.mainport);
|
||||
while (serialTotalBytesWaiting(serialPorts.mainport)) {
|
||||
c = serialRead(serialPorts.mainport);
|
||||
|
||||
if (c_state == IDLE) {
|
||||
c_state = (c == '$') ? HEADER_START : IDLE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue