Commit c9349ce8 authored by Michael Hope's avatar Michael Hope
Browse files

msp: rework the different size encoders.



Tidy the encoders up.  Reduce the code size stacking the encoders for
different sizes.
Signed-off-by: default avatarMichael Hope <mlhx@google.com>
parent 31f933ac
......@@ -396,38 +396,22 @@ static mspPort_t mspPorts[MAX_MSP_PORT_COUNT];
static mspPort_t *currentPort;
static void serialize32(uint32_t a)
static void serialize8(uint8_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;
serialWrite(mspSerialPort, a);
currentPort->checksum ^= a;
}
static void serialize16(int16_t a)
static void serialize16(uint16_t a)
{
static uint8_t t;
t = a;
serialWrite(mspSerialPort, t);
currentPort->checksum ^= t;
t = a >> 8 & 0xff;
serialWrite(mspSerialPort, t);
currentPort->checksum ^= t;
serialize8((uint8_t)(a >> 0));
serialize8((uint8_t)(a >> 8));
}
static void serialize8(uint8_t a)
static void serialize32(uint32_t a)
{
serialWrite(mspSerialPort, a);
currentPort->checksum ^= a;
serialize16((uint16_t)(a >> 0));
serialize16((uint16_t)(a >> 16));
}
static uint8_t read8(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment