mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
msp: rework the different size encoders.
Tidy the encoders up. Reduce the code size stacking the encoders for different sizes. Signed-off-by: Michael Hope <mlhx@google.com>
This commit is contained in:
parent
31f933ac21
commit
c9349ce83b
1 changed files with 12 additions and 28 deletions
|
@ -396,40 +396,24 @@ static mspPort_t mspPorts[MAX_MSP_PORT_COUNT];
|
||||||
|
|
||||||
static mspPort_t *currentPort;
|
static mspPort_t *currentPort;
|
||||||
|
|
||||||
static void serialize32(uint32_t a)
|
|
||||||
{
|
|
||||||
static uint8_t t;
|
|
||||||
t = a;
|
|
||||||
serialWrite(mspSerialPort, t);
|
|
||||||
currentPort->checksum ^= t;
|
|
||||||
t = a >> 8;
|
|
||||||
serialWrite(mspSerialPort, t);
|
|
||||||
currentPort->checksum ^= t;
|
|
||||||
t = a >> 16;
|
|
||||||
serialWrite(mspSerialPort, t);
|
|
||||||
currentPort->checksum ^= t;
|
|
||||||
t = a >> 24;
|
|
||||||
serialWrite(mspSerialPort, t);
|
|
||||||
currentPort->checksum ^= t;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void serialize16(int16_t a)
|
|
||||||
{
|
|
||||||
static uint8_t t;
|
|
||||||
t = a;
|
|
||||||
serialWrite(mspSerialPort, t);
|
|
||||||
currentPort->checksum ^= t;
|
|
||||||
t = a >> 8 & 0xff;
|
|
||||||
serialWrite(mspSerialPort, t);
|
|
||||||
currentPort->checksum ^= t;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void serialize8(uint8_t a)
|
static void serialize8(uint8_t a)
|
||||||
{
|
{
|
||||||
serialWrite(mspSerialPort, a);
|
serialWrite(mspSerialPort, a);
|
||||||
currentPort->checksum ^= a;
|
currentPort->checksum ^= a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void serialize16(uint16_t a)
|
||||||
|
{
|
||||||
|
serialize8((uint8_t)(a >> 0));
|
||||||
|
serialize8((uint8_t)(a >> 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void serialize32(uint32_t a)
|
||||||
|
{
|
||||||
|
serialize16((uint16_t)(a >> 0));
|
||||||
|
serialize16((uint16_t)(a >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t read8(void)
|
static uint8_t read8(void)
|
||||||
{
|
{
|
||||||
return currentPort->inBuf[currentPort->indRX++] & 0xff;
|
return currentPort->inBuf[currentPort->indRX++] & 0xff;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue