39#include "inc/hw_types.h"
40#include "inc/hw_memmap.h"
41#include "inc/hw_ints.h"
42#include "inc/hw_uart.h"
43#include "driverlib/rom.h"
44#include "driverlib/rom_map.h"
45#include "driverlib/uart.h"
46#include "driverlib/interrupt.h"
47#include "driverlib/sysctl.h"
63 uint32_t baud, uint32_t mode,
bool hw_fifo, TxEnableMethod tx_enable_assert,
64 TxEnableMethod tx_enable_deassert)
66 , txEnableAssert_(tx_enable_assert)
67 , txEnableDeassert_(tx_enable_deassert)
69 , interrupt_(interrupt)
77 UART_CONFIG_PAR_NONE == 0,
"driverlib changed against our assumptions");
79 UART_CONFIG_STOP_ONE == 0,
"driverlib changed against our assumptions");
87 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
91 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
95 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
99 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
103 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);
107 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5);
111 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
115 MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
121 MAP_UARTTxIntModeSet(
base_, UART_TXINT_MODE_EOT);
127 std::min(0xff, configKERNEL_INTERRUPT_PRIORITY + 0x20));
128 MAP_UARTIntEnable(
base_, UART_INT_RX | UART_INT_RT);
136 MAP_UARTEnable(
base_);
139 MAP_UARTFIFOEnable(
base_);
143 MAP_UARTFIFODisable(
base_);
152 MAP_UARTDisable(
base_);
164 MAP_UARTCharPutNonBlocking(
base_, data);
172 while (MAP_UARTSpaceAvail(
base_));
177 MAP_UARTTxIntModeSet(
base_, UART_TXINT_MODE_FIFO);
182 MAP_UARTTxIntModeSet(
base_, UART_TXINT_MODE_EOT);
183 MAP_UARTIntClear(
base_, UART_INT_TX);
201 MAP_UARTIntEnable(
base_, UART_INT_TX);
212 unsigned long status = MAP_UARTIntStatus(
base_,
true);
213 MAP_UARTIntClear(
base_, status);
219 while (MAP_UARTCharsAvail(
base_))
221 long data = MAP_UARTCharGetNonBlocking(
base_);
232 long bit9 = (data & 0x200) >> 1;
239 else if (data >= 0 && data <= 0xff)
247 unsigned char c = data;
264 HASSERT(MAP_UARTTxIntModeGet(
base_) == UART_TXINT_MODE_EOT);
274 t->notify_from_isr();
276 MAP_UARTIntDisable(
base_, UART_INT_TX);
279 os_isr_exit_yield_test(woken);
301 MAP_UARTBreakCtl(
base_,
true);
303 MAP_SysCtlDelay(100 * 26);
304 MAP_UARTBreakCtl(
base_,
false);
305 MAP_SysCtlDelay(12 * 26);
310 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_NONE);
315 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_ODD);
320 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_EVEN);
325 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_ONE);
337 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_ZERO);
static CC32xxUart * instances[2]
Instance pointers help us get context from the interrupt handler(s)
static Atomic isr_lock
Critical section lock between ISR and ioctl.
void uart2_interrupt_handler(void)
UART2 interrupt handler.
void uart0_interrupt_handler(void)
UART0 interrupt handler.
void uart6_interrupt_handler(void)
UART6 interrupt handler.
void uart3_interrupt_handler(void)
UART3 interrupt handler.
static Atomic isr_lock
Critical section lock between ISR and ioctl.
void uart7_interrupt_handler(void)
UART7 interrupt handler.
void uart1_interrupt_handler(void)
UART1 interrupt handler.
void uart4_interrupt_handler(void)
UART4 interrupt handler.
static TivaUart * instances[8]
Instance pointers help us get context from the interrupt handler(s)
void uart5_interrupt_handler(void)
UART5 interrupt handler.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
size_t space()
Return the number of items for which space is available.
void signal_condition()
Signal the wakeup condition.
size_t pending()
Return the number of items in the queue.
void signal_condition_from_isr()
Signal the wakeup condition from an ISR context.
size_t get(T *buf, size_t items)
remove a number of items from the buffer.
size_t put(const T *buf, size_t items)
Insert a number of items to the buffer.
An object that can schedule itself on an executor to run.
virtual void notify()=0
Generic callback.
Private data for a serial device.
DeviceBuffer< uint8_t > * rxBuf
receive buffer
DeviceBuffer< uint8_t > * txBuf
transmit buffer
unsigned int overrunCount
overrun count
Specialization of Serial driver for Tiva UART.
uint8_t nineBit_
true if using 9-bit reception
uint8_t hwFIFO_
enable HW FIFO
void tx_char() override
Try and transmit a message.
void disable() override
function to disable device
void interrupt_handler()
handle an interrupt.
void send()
Send data until there is no more space left.
uint8_t uartMode_
uart config (mode) flags
void set_mode()
Sets the port baud rate and mode from the class variables.
void enable() override
function to enable device
uint32_t baud_
desired baud rate
TxEnableMethod txEnableAssert_
function pointer to a method that asserts the transmit enable.
uint32_t interrupt_
interrupt of this device
TxEnableMethod txEnableDeassert_
function pointer to a method that deasserts the transmit enable.
uint32_t base_
base address of this device
TivaUart()
Default constructor.
int ioctl(File *file, unsigned long int key, unsigned long data) override
Request an ioctl transaction.
Notifiable * txComplete_
Notifiable to invoke when the transmit engine has finished operation.
uint8_t txPending_
transmission currently pending
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define TCBAUDRATE
Argument is the desired baud rate for the port.
#define TCDRAINNOTIFY
Argument is a Notifiable* pointer.
#define TCNINEBITRX
Use 9-bit reception mode.
#define TCSTOPTWO
Two stop bits.
#define TCSTOPONE
One stop bit.