1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

rewritten drv_uart to suck slightly less

tested w/o GPS

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@382 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop@gmail.com 2013-08-22 07:48:07 +00:00
parent 1ff0036dec
commit cbb580f753
10 changed files with 403 additions and 321 deletions

View file

@ -157,16 +157,16 @@ void serialize32(uint32_t a)
{
static uint8_t t;
t = a;
uartWrite(t);
uartWrite(core.mainport, t);
checksum ^= t;
t = a >> 8;
uartWrite(t);
uartWrite(core.mainport, t);
checksum ^= t;
t = a >> 16;
uartWrite(t);
uartWrite(core.mainport, t);
checksum ^= t;
t = a >> 24;
uartWrite(t);
uartWrite(core.mainport, t);
checksum ^= t;
}
@ -174,16 +174,16 @@ void serialize16(int16_t a)
{
static uint8_t t;
t = a;
uartWrite(t);
uartWrite(core.mainport, t);
checksum ^= t;
t = a >> 8 & 0xff;
uartWrite(t);
uartWrite(core.mainport, t);
checksum ^= t;
}
void serialize8(uint8_t a)
{
uartWrite(a);
uartWrite(core.mainport, a);
checksum ^= a;
}
@ -261,7 +261,9 @@ void serialInit(uint32_t baudrate)
{
int idx;
uartInit(baudrate);
core.mainport = uartOpen(USART1, NULL, baudrate, MODE_RXTX);
// TODO fix/hax
core.telemport = core.mainport;
// calculate used boxes based on features and fill availableBoxes[] array
memset(availableBoxes, 0xFF, sizeof(availableBoxes));
@ -670,8 +672,8 @@ void serialCom(void)
return;
}
while (isUartAvailable()) {
c = uartRead();
while (isUartAvailable(core.mainport)) {
c = uartRead(core.mainport);
if (c_state == IDLE) {
c_state = (c == '$') ? HEADER_START : IDLE;
@ -707,7 +709,7 @@ void serialCom(void)
c_state = IDLE;
}
}
if (!cliMode && !isUartAvailable() && feature(FEATURE_TELEMETRY) && f.ARMED) { // The first 2 conditions should never evaluate to true but I'm putting it here anyway - silpstream
if (!cliMode && !isUartAvailable(core.telemport) && feature(FEATURE_TELEMETRY) && f.ARMED) { // The first 2 conditions should never evaluate to true but I'm putting it here anyway - silpstream
sendTelemetry();
return;
}