3131#include "RP2040_PWM.h" //Servo and oneshot
3232#include "../MF_I2C.h"
3333#include "../MF_Serial.h"
34- // #include "RP2040_SerialIRQ.h" //Replacement high performance serial driver (did not work very well...)
34+ #include "RP2040_SerialIRQ.h" //Replacement high performance serial driver (did not work very well...)
3535#include "MF_SerialUART_RP2040.h" //MF_Serial wrappers for SerialUART with task based TX buffer
3636#include "MF_SerialPIO_RP2040.h" //MF_Serial wrappers for SerialPIO with task based TX buffer
3737
@@ -166,8 +166,7 @@ void hal_print_pin_name(int pinnum) {
166166}
167167
168168
169-
170-
169+ //* MF_SerialUART version - works for sbus & ublox
171170
172171//create/get Serial bus (late binding)
173172//Serial BUS (&Serial, &Serial1, &Serial2) - ser0 &Serial is used for CLI via uart->USB converter
@@ -278,9 +277,11 @@ MF_Serial* hal_get_ser_bus(int bus_id, int baud, MF_SerialMode mode, bool invert
278277 return hal_ser [bus_id ];
279278}
280279
280+ //*/
281281
282282
283- /* //SerialUART version - works
283+
284+ /* //SerialUART version - works for sbus, not for gps because of lacking TX buffer
284285
285286//create/get Serial bus (late binding)
286287//Serial BUS (&Serial, &Serial1, &Serial2) - ser0 &Serial is used for CLI via uart->USB converter
@@ -344,23 +345,14 @@ MF_Serial* hal_get_ser_bus(int bus_id, int baud, MF_SerialMode mode, bool invert
344345}
345346
346347
347- */
348+ // */
348349
349350
350351
351352
352353
353- /*
354- //uncomment one: SerialIRQ, SerialUART or SerialPIO and use uart0 or uart1
355- auto *ser = new SerialIRQ(uart1, cfg.pin_ser1_tx, ser1_txbuf, sizeof(ser1_txbuf), cfg.pin_ser1_rx, ser1_rxbuf, sizeof(ser1_rxbuf));
356- //auto *ser = new SerialIRQ(uart1, cfg.pin_ser1_tx, pin_ser1_rx, 256, 256); //TODO
357- //auto *ser = new SerialDMA(uart1, cfg.pin_ser1_tx, pin_ser1_rx, 256, 256); //TODO
358- //auto *ser = new SerialUART(uart1, cfg.pin_ser1_tx, pin_ser1_rx); //SerialUART default Arduino impementation (had some problems with this)
359- //auto *ser = new SerialPIO(cfg.pin_ser1_tx, pin_ser1_rx, 32); //PIO uarts, any pin allowed (not tested, but expect same as SerialUART)
360- hal_ser[1] = new MF_SerialPtrWrapper<decltype(ser)>( ser );
361- */
362354
363- /*
355+ /* //SerialIRQ version - does not work for SBUS, works for UBLOX
364356
365357MF_Serial* hal_get_ser_bus(int bus_id, int baud, MF_SerialMode mode, bool invert) {
366358 if(bus_id < 0 || bus_id >= HAL_SER_NUM) return nullptr;
@@ -383,7 +375,7 @@ MF_Serial* hal_get_ser_bus(int bus_id, int baud, MF_SerialMode mode, bool invert
383375 break;
384376 }
385377
386- //using SerialIRQ - does not work correctly for sbus ...
378+ //using SerialIRQ - works for gps, does not work correctly for sbus ...
387379 switch(bus_id) {
388380 case 0: {
389381 int pin_tx = cfg.pin_ser0_tx;
@@ -394,8 +386,6 @@ MF_Serial* hal_get_ser_bus(int bus_id, int baud, MF_SerialMode mode, bool invert
394386 if(!hal_ser[bus_id]) hal_ser[bus_id] = new MF_SerialPtrWrapper<decltype(ser)>( ser );
395387 }
396388 break;
397- }
398- break;
399389 }
400390 case 1: {
401391 int pin_tx = cfg.pin_ser1_tx;
@@ -410,6 +400,20 @@ MF_Serial* hal_get_ser_bus(int bus_id, int baud, MF_SerialMode mode, bool invert
410400 default:
411401 return nullptr;
412402 }
413- */
403+
404+ return hal_ser[bus_id];
405+ }
406+
407+ //*/
414408
415409
410+
411+ /*
412+ //uncomment one: SerialIRQ, SerialUART or SerialPIO and use uart0 or uart1
413+ auto *ser = new SerialIRQ(uart1, cfg.pin_ser1_tx, ser1_txbuf, sizeof(ser1_txbuf), cfg.pin_ser1_rx, ser1_rxbuf, sizeof(ser1_rxbuf));
414+ //auto *ser = new SerialIRQ(uart1, cfg.pin_ser1_tx, pin_ser1_rx, 256, 256); //TODO
415+ //auto *ser = new SerialDMA(uart1, cfg.pin_ser1_tx, pin_ser1_rx, 256, 256); //TODO
416+ //auto *ser = new SerialUART(uart1, cfg.pin_ser1_tx, pin_ser1_rx); //SerialUART default Arduino impementation (had some problems with this)
417+ //auto *ser = new SerialPIO(cfg.pin_ser1_tx, pin_ser1_rx, 32); //PIO uarts, any pin allowed (not tested, but expect same as SerialUART)
418+ hal_ser[1] = new MF_SerialPtrWrapper<decltype(ser)>( ser );
419+ */
0 commit comments