1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Rebased onto super-abstracted msp

This commit is contained in:
jflyper 2016-10-20 23:21:32 +09:00
parent 01eab00fd7
commit 0249443862
8 changed files with 71 additions and 49 deletions

View file

@ -35,6 +35,7 @@
static mspProcessCommandFnPtr mspProcessCommandFn;
static mspPushCommandFnPtr mspPushCommandFn;
static mspPort_t mspPorts[MAX_MSP_PORT_COUNT];
bufWriter_t *writer;
@ -128,34 +129,6 @@ static mspPostProcessFnPtr mspSerialProcessReceivedCommand(mspPort_t *mspPort)
return mspPostProcessFn;
}
#ifdef USE_DPRINTF
#include "common/printf.h"
#define DPRINTF_SERIAL_PORT SERIAL_PORT_USART3
extern serialPort_t *debugSerialPort;
#define dprintf(x) if (debugSerialPort) printf x
#else
#define dprintf(x)
#endif
void mspSerialPush(int cmd, uint8_t *data, int buflen)
{
for (uint8_t portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
mspPort_t * const mspPort = &mspPorts[portIndex];
if (!mspPort->port) {
continue;
}
// Big enough for a OSD line
uint8_t buf[sizeof(bufWriter_t) + 30];
writer = bufWriterInit(buf, sizeof(buf), (bufWrite_t)serialWriteBufShim, mspPort->port);
mspServerPush(mspPort, cmd, data, buflen);
bufWriterFlush(writer);
}
}
/*
* Process MSP commands from serial ports configured as MSP ports.
*
@ -204,3 +177,27 @@ void mspSerialInit(mspProcessCommandFnPtr mspProcessCommandFnToUse)
memset(mspPorts, 0, sizeof(mspPorts));
mspSerialAllocatePorts();
}
void mspSerialPush(uint8_t cmd, uint8_t *data, int buflen)
{
for (uint8_t portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
mspPort_t * const mspPort = &mspPorts[portIndex];
if (!mspPort->port) {
continue;
}
// Big enough for a OSD line
uint8_t buf[sizeof(bufWriter_t) + 30];
writer = bufWriterInit(buf, sizeof(buf), (bufWrite_t)serialWriteBufShim, mspPort->port);
mspPushCommandFn(mspPort, cmd, data, buflen);
bufWriterFlush(writer);
}
}
void mspSerialPushInit(mspPushCommandFnPtr mspPushCommandFnToUse)
{
mspPushCommandFn = mspPushCommandFnToUse;
}