36#include "inc/hw_types.h"
37#include "inc/hw_memmap.h"
38#include "inc/hw_ints.h"
39#include "inc/hw_uart.h"
40#include "driverlib/rom.h"
41#include "driverlib/rom_map.h"
42#include "driverlib/interrupt.h"
43#include "driverlib/prcm.h"
44#include "driverlib/utils.h"
66 uint32_t baud, uint32_t mode,
bool hw_fifo,
67 TxEnableMethod tx_enable_assert,
68 TxEnableMethod tx_enable_deassert)
70 , txEnableAssert_(tx_enable_assert)
71 , txEnableDeassert_(tx_enable_deassert)
73 , interrupt_(interrupt)
75 , uartMode_(mode | UART_CONFIG_PAR_NONE)
81 UART_CONFIG_PAR_NONE == 0,
"driverlib changed against our assumptions");
83 UART_CONFIG_STOP_ONE == 0,
"driverlib changed against our assumptions");
91 MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
95 MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);
100 MAP_UARTConfigSetExpClk(
base_, cm3_cpu_clock_hz, baud,
uartMode_);
106 std::min(0xff, configKERNEL_INTERRUPT_PRIORITY + 0x20));
107 MAP_UARTIntEnable(
base_, UART_INT_RX | UART_INT_RT);
115 MAP_UARTEnable(
base_);
118 MAP_UARTFIFOEnable(
base_);
122 MAP_UARTFIFODisable(
base_);
131 MAP_UARTDisable(
base_);
147 MAP_UARTBreakCtl(
base_,
true);
149 MAP_UtilsDelay(100 * 26);
150 MAP_UARTBreakCtl(
base_,
false);
151 MAP_UtilsDelay(12 * 26);
156 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_NONE);
161 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_ODD);
166 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_EVEN);
171 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_ONE);
183 MAP_UARTParityModeSet(
base_, UART_CONFIG_PAR_ZERO);
242 MAP_UARTCharPutNonBlocking(
base_, data);
250 while (MAP_UARTSpaceAvail(
base_));
255 MAP_UARTTxIntModeSet(
base_, UART_TXINT_MODE_FIFO);
260 MAP_UARTTxIntModeSet(
base_, UART_TXINT_MODE_EOT);
261 MAP_UARTIntClear(
base_, UART_INT_TX);
279 MAP_UARTIntEnable(
base_, UART_INT_TX);
290 unsigned long status = MAP_UARTIntStatus(
base_,
true);
291 MAP_UARTIntClear(
base_, status);
297 while (MAP_UARTCharsAvail(
base_))
299 long data = MAP_UARTCharGetNonBlocking(
base_);
310 long bit9 = (data & 0x200) >> 1;
317 else if (data >= 0 && data <= 0xff)
325 unsigned char c = data;
342 HASSERT(MAP_UARTTxIntModeGet(
base_) == UART_TXINT_MODE_EOT);
352 t->notify_from_isr();
354 MAP_UARTIntDisable(
base_, UART_INT_TX);
357 os_isr_exit_yield_test(woken);
static CC32xxUart * instances[2]
Instance pointers help us get context from the interrupt handler(s)
void uart0_interrupt_handler(void)
UART0 interrupt handler.
static Atomic isr_lock
Critical section lock between ISR and ioctl.
void uart1_interrupt_handler(void)
UART1 interrupt handler.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
Specialization of Serial driver for CC32xx UART.
uint8_t txPending_
transmission currently pending
void disable() override
function to disable device
Notifiable * txComplete_
Notifiable to invoke when the transmit engine has finished operation.
void tx_char() override
Try and transmit a message.
uint8_t hwFIFO_
true if hardware fifo is to be enabled, else false
CC32xxUart()
Default constructor.
unsigned long base_
base address of this device
TxEnableMethod txEnableAssert_
function pointer to a method that asserts the transmit enable.
void send()
Send data until there is no more space left.
uint32_t interrupt_
interrupt of this device
uint32_t baud_
desired baud rate
void set_mode()
Sets the port baud rate and mode from the class variables.
uint8_t nineBit_
true if using 9-bit reception
uint32_t uartMode_
mode of the UART, 8 or 9 bit, 1 or 2 stop...
TxEnableMethod txEnableDeassert_
function pointer to a method that deasserts the transmit enable.
int ioctl(File *file, unsigned long int key, unsigned long data) override
Request an ioctl transaction.
void enable() override
function to enable device
void interrupt_handler()
handle an interrupt.
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
#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.