1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 16:55:20 +03:00

PXX2 pulses now received on external module

This commit is contained in:
Bertrand Songis 2019-02-21 12:27:52 +01:00
parent 4b339bebbe
commit 9472fd2132
4 changed files with 21 additions and 8 deletions

View file

@ -88,9 +88,12 @@ class ModuleFifo : public Fifo<uint8_t, 32> {
ridx = nextIndex(next); ridx = nextIndex(next);
return true; return true;
} }
uint32_t errors;
}; };
extern ModuleFifo intmoduleFifo; extern ModuleFifo intmoduleFifo;
extern ModuleFifo extmoduleFifo;
class Pxx2CrcMixin { class Pxx2CrcMixin {
protected: protected:

View file

@ -21,7 +21,6 @@
#include "opentx.h" #include "opentx.h"
ModuleFifo intmoduleFifo; ModuleFifo intmoduleFifo;
uint8_t intmoduleErrors;
void intmoduleStop() void intmoduleStop()
{ {
@ -80,7 +79,7 @@ extern "C" void INTMODULE_USART_IRQHandler(void)
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) { while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
uint8_t data = INTMODULE_USART->DR; uint8_t data = INTMODULE_USART->DR;
if (status & USART_FLAG_ERRORS) { if (status & USART_FLAG_ERRORS) {
intmoduleErrors++; intmoduleFifo.errors++;
} }
else { else {
intmoduleFifo.push(data); intmoduleFifo.push(data);

View file

@ -110,6 +110,8 @@ void extmoduleSerialStart(uint32_t /*baudrate*/, uint32_t period_half_us)
} }
#if defined(EXTMODULE_USART) #if defined(EXTMODULE_USART)
ModuleFifo extmoduleFifo;
void extmoduleInvertedSerialStart(uint32_t baudrate) void extmoduleInvertedSerialStart(uint32_t baudrate)
{ {
EXTERNAL_MODULE_ON(); EXTERNAL_MODULE_ON();
@ -182,10 +184,10 @@ extern "C" void EXTMODULE_USART_IRQHandler(void)
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) { while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
uint8_t data = EXTMODULE_USART->DR; uint8_t data = EXTMODULE_USART->DR;
if (status & USART_FLAG_ERRORS) { if (status & USART_FLAG_ERRORS) {
// TODO later extmoduleErrors++; extmoduleFifo.errors++;
} }
else { else {
// TODO later extmoduleFifo.push(data); extmoduleFifo.push(data);
} }
status = EXTMODULE_USART->SR; status = EXTMODULE_USART->SR;
} }

View file

@ -211,11 +211,20 @@ void telemetryWakeup()
} }
#endif #endif
#if defined(INTMODULE_USART) #if defined(INTMODULE_USART) || defined(EXTMODULE_USART)
uint8_t frame[32]; uint8_t frame[32];
if (intmoduleFifo.getFrame(frame)) {
processModuleFrame(INTERNAL_MODULE, frame); #if defined(INTMODULE_USART)
} if (intmoduleFifo.getFrame(frame)) {
processModuleFrame(INTERNAL_MODULE, frame);
}
#endif
#if defined(EXTMODULE_USART)
if (extmoduleFifo.getFrame(frame)) {
processModuleFrame(EXTERNAL_MODULE, frame);
}
#endif
#endif #endif
#if defined(STM32) #if defined(STM32)