Skip to content

Commit

Permalink
Add support for additional baud rates (#2217)
Browse files Browse the repository at this point in the history
* Add support for additional baud rates

* Addding check for existing baud rate

* Added missing include

---------

Co-authored-by: Simone Morettini <simone.morettini@redwirespaceeurope.com>
  • Loading branch information
SMorettini and Simone Morettini authored Aug 28, 2023
1 parent 9c335d0 commit a5c7aaa
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
32 changes: 32 additions & 0 deletions Drv/LinuxUartDriver/LinuxUartDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,38 @@ bool LinuxUartDriver::open(const char* const device,
case BAUD_921K:
relayRate = B921600;
break;
case BAUD_1000K:
relayRate = B1000000;
break;
case BAUD_1152K:
relayRate = B1152000;
break;
case BAUD_1500K:
relayRate = B1500000;
break;
case BAUD_2000K:
relayRate = B2000000;
break;
#ifdef B2500000
case BAUD_2500K:
relayRate = B2500000;
break;
#endif
#ifdef B3000000
case BAUD_3000K:
relayRate = B3000000;
break;
#endif
#ifdef B3500000
case BAUD_3500K:
relayRate = B3500000;
break;
#endif
#ifdef B4000000
case BAUD_4000K:
relayRate = B4000000;
break;
#endif
#endif
default:
FW_ASSERT(0, baud);
Expand Down
31 changes: 30 additions & 1 deletion Drv/LinuxUartDriver/LinuxUartDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <Os/Mutex.hpp>
#include <Os/Task.hpp>

#include <termios.h>

namespace Drv {

class LinuxUartDriver : public LinuxUartDriverComponentBase {
Expand All @@ -36,7 +38,34 @@ class LinuxUartDriver : public LinuxUartDriverComponentBase {
);

//! Configure UART parameters
enum UartBaudRate { BAUD_9600=9600, BAUD_19200=19200, BAUD_38400=38400, BAUD_57600=57600, BAUD_115K=115200, BAUD_230K=230400, BAUD_460K=460800, BAUD_921K=921600};
enum UartBaudRate {
BAUD_9600=9600,
BAUD_19200=19200,
BAUD_38400=38400,
BAUD_57600=57600,
BAUD_115K=115200,
BAUD_230K=230400,
#ifdef TGT_OS_TYPE_LINUX
BAUD_460K=460800,
BAUD_921K=921600,
BAUD_1000K=1000000000,
BAUD_1152K=1152000000,
BAUD_1500K=1500000000,
BAUD_2000K=2000000000,
#ifdef B2500000
BAUD_2500K=2500000000,
#endif
#ifdef B3000000
BAUD_3000K=3000000000,
#endif
#ifdef B3500000
BAUD_3500K=3500000000,
#endif
#ifdef B4000000
BAUD_4000K=4000000000
#endif
#endif
};

enum UartFlowControl { NO_FLOW, HW_FLOW };

Expand Down

0 comments on commit a5c7aaa

Please sign in to comment.