1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00
This commit is contained in:
jflyper 2016-11-02 09:12:37 +09:00
parent 042096fbb7
commit f58f7f65b1
12 changed files with 94 additions and 91 deletions

View file

@ -211,8 +211,6 @@ void mspSerialInit(void)
mspSerialAllocatePorts();
}
mspPushCommandFnPtr mspPushCommandFn;
void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
{
static uint8_t pushBuf[30];
@ -234,7 +232,7 @@ void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
continue;
}
mspPushCommandFn(&push, data, datalen);
sbufWriteData(&push.buf, data, datalen);
sbufSwitchToReader(&push.buf, pushBuf);
@ -242,14 +240,9 @@ void mspSerialPush(uint8_t cmd, uint8_t *data, int datalen)
}
}
void mspSerialPushInit(mspPushCommandFnPtr mspPushCommandFnToUse)
uint32_t mspSerialTxBytesFree()
{
mspPushCommandFn = mspPushCommandFnToUse;
}
uint16_t mspSerialPushTxRoom()
{
uint16_t minroom = 50000;
uint32_t minroom = UINT16_MAX;
for (uint8_t portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
mspPort_t * const mspPort = &mspPorts[portIndex];
@ -262,7 +255,7 @@ uint16_t mspSerialPushTxRoom()
continue;
}
uint32_t room = mspPort->port->vTable->serialTotalTxFree(mspPort->port);
uint32_t room = serialTxBytesFree(mspPort->port);
if (room < minroom) {
minroom = room;