|
SmartSnippets DA1459x SDK
|
UART Controller. More...
Files | |
| file | hw_uart.h |
| Definition of API for the UART Low Level Driver. | |
Data Structures | |
| struct | uart_config |
| UART configuration structure definition. More... | |
Macros | |
| #define | HW_UART_REG_FIELD_MASK(instance, reg, field) (UART##instance##_UART##instance##_##reg##_REG_##field##_Msk) |
| Get the mask of a field of a UART register. More... | |
| #define | HW_UART_REG_FIELD_POS(instance, reg, field) (UART##instance##_UART##instance##_##reg##_REG_##field##_Pos) |
| Get the bit position of a field of a UART register. More... | |
| #define | HW_UART_REG_GETF(id, reg, field) ((UBA(id)->UART2_##reg##_REG & (UART2_UART2_##reg##_REG_##field##_Msk)) >> (UART2_UART2_##reg##_REG_##field##_Pos)) |
| Get the value of a field of a UART register. More... | |
| #define | HW_UART_REG_SETF(id, reg, field, new_val) |
| Set the value of a field of a UART register. More... | |
| #define | HW_UART_DMA_SUPPORT dg_configUART_DMA_SUPPORT |
| DMA support for UART. | |
Functions | |
| __STATIC_INLINE bool | hw_uart_is_busy (HW_UART_ID uart) |
| Check if a serial transfer is in progress. More... | |
| uint8_t | hw_uart_read (HW_UART_ID uart) |
| Read one byte from UART. More... | |
| void | hw_uart_write (HW_UART_ID uart, uint8_t data) |
| Write one byte to UART. More... | |
| uint16_t | hw_uart_abort_receive (HW_UART_ID uart) |
| Stop asynchronous read from UART. More... | |
| uint16_t | hw_uart_abort_send (HW_UART_ID uart) |
| Stop asynchronous transmit from UART. More... | |
| uint16_t | hw_uart_peek_received (HW_UART_ID uart) |
| Get number of bytes currently received by asynchronous read. More... | |
| uint16_t | hw_uart_peek_transmitted (HW_UART_ID uart) |
| Get number of bytes currently sent by asynchronous read. More... | |
| __STATIC_INLINE uint8_t | hw_uart_rxdata_getf (HW_UART_ID uart) |
| Read receive buffer register. More... | |
| __STATIC_INLINE void | hw_uart_txdata_setf (HW_UART_ID uart, uint8_t data) |
| Write byte to the transmit holding register. More... | |
| void | hw_uart_write_buffer (HW_UART_ID uart, const void *data, uint16_t len) |
| Writes number of bytes to UART synchronously. More... | |
| HW_UART_CONFIG_ERR | hw_uart_send (HW_UART_ID uart, const void *data, uint16_t len, hw_uart_tx_callback cb, void *user_data) |
| Write number of bytes to UART. More... | |
| HW_UART_CONFIG_ERR | hw_uart_receive (HW_UART_ID uart, void *data, uint16_t len, hw_uart_rx_callback cb, void *user_data) |
| Read number of bytes from UART. More... | |
| void | hw_uart_receive_error_checking (HW_UART_ID uart, void *data, uint16_t len, hw_uart_rx_callback cb, void *user_data, hw_uart_err_callback err_cb, void *error_data) |
| Read number of bytes from UART with error checking. More... | |
| __STATIC_INLINE void | hw_uart_rec_data_int_set (HW_UART_ID uart, uint8_t recdataavail) |
| Set the Received Data Available interrupt. More... | |
| __STATIC_INLINE void | hw_uart_tx_empty_int_set (HW_UART_ID uart, uint8_t txempty) |
| Set the Transmit Holding Register empty interrupt. More... | |
| __STATIC_INLINE void | hw_uart_linestat_int_set (HW_UART_ID uart, uint8_t linestat) |
| Set the Line Status interrupt. More... | |
| __STATIC_INLINE void | hw_uart_pthre_int_set (HW_UART_ID uart, uint8_t pthre) |
| Set the Programmable THRE interrupt. More... | |
| __STATIC_INLINE HW_UART_INT | hw_uart_get_interrupt_id (HW_UART_ID uart) |
| Get the Interrupt ID. More... | |
| __STATIC_INLINE void | hw_uart_write_scr (const HW_UART_ID uart, uint8_t value) |
| Write Scratch pad register. More... | |
| __STATIC_INLINE uint8_t | hw_uart_read_scr (const HW_UART_ID uart) |
| Read Scratch pad register. More... | |
| void | hw_uart_set_sclk (const HW_UART_ID uart, bool sclk) |
| Configure the serial clock input of the UART (divN or div1) More... | |
| HW_UART_BAUDRATE | hw_uart_baudrate_get (HW_UART_ID uart) |
| Get the baud rate setting. More... | |
| void | hw_uart_baudrate_set (HW_UART_ID uart, HW_UART_BAUDRATE baud_rate) |
| Set the baud rate. More... | |
| __STATIC_INLINE bool | hw_uart_is_data_ready (HW_UART_ID uart) |
| Check if there is data available for read. More... | |
| __STATIC_INLINE bool | hw_uart_is_fifo_enabled (HW_UART_ID uart) |
| Get the FIFO mode setting. More... | |
| __STATIC_INLINE void | hw_uart_disable_fifo (HW_UART_ID uart) |
| Disable both FIFOs. More... | |
| __STATIC_INLINE void | hw_uart_enable_fifo (HW_UART_ID uart) |
| Enable both FIFOs. More... | |
| __STATIC_INLINE bool | hw_uart_receive_fifo_not_empty (HW_UART_ID uart) |
| Check if receive FIFO is not empty. More... | |
| __STATIC_INLINE bool | hw_uart_transmit_fifo_not_full (HW_UART_ID uart) |
| Check if transmit FIFO is not full. More... | |
| __STATIC_INLINE bool | hw_uart_transmit_fifo_empty (HW_UART_ID uart) |
| Check if transmit FIFO is empty. More... | |
| __STATIC_INLINE uint16_t | hw_uart_receive_fifo_count (HW_UART_ID uart) |
| Read number of bytes in receive FIFO. More... | |
| __STATIC_INLINE uint16_t | hw_uart_transmit_fifo_count (HW_UART_ID uart) |
| Read number of bytes in transmit FIFO. More... | |
| __STATIC_INLINE void | hw_uart_enable_loopback (HW_UART_ID uart) |
| Enable loopback. More... | |
| __STATIC_INLINE void | hw_uart_disable_loopback (HW_UART_ID uart) |
| Disable loopback. More... | |
| uint8_t | hw_uart_fifo_en_getf (HW_UART_ID uart) |
| Get the FIFO mode setting. More... | |
| __STATIC_INLINE void | hw_uart_fifo_en_setf (HW_UART_ID uart, uint8_t en) |
| Enable or disable the UART FIFO mode. More... | |
| __STATIC_INLINE uint8_t | hw_uart_rx_fifo_tr_lvl_getf (HW_UART_ID uart) |
| Get the receive FIFO trigger level at which the Received Data Available Interrupt is generated. More... | |
| __STATIC_INLINE void | hw_uart_rx_fifo_tr_lvl_setf (HW_UART_ID uart, uint8_t tr_lvl) |
| Set the receive FIFO trigger level at which the Received Data Available Interrupt is generated. More... | |
| uint8_t | hw_uart_tx_fifo_tr_lvl_getf (HW_UART_ID uart) |
| Get the transmit FIFO trigger level at which the Transmit Holding Register Empty (THRE) Interrupt is generated. More... | |
| __STATIC_INLINE void | hw_uart_tx_fifo_tr_lvl_setf (HW_UART_ID uart, uint8_t tr_lvl) |
| Set the transmit FIFO trigger level at which the Transmit Holding Register Empty (THRE) Interrupt is generated. More... | |
| __STATIC_INLINE void | hw_uart_tx_fifo_flush (HW_UART_ID uart) |
| Reset UART transmit FIFO. More... | |
| __STATIC_INLINE void | hw_uart_rx_fifo_flush (HW_UART_ID uart) |
| Reset UART receive FIFO. More... | |
| __STATIC_INLINE bool | hw_uart_read_buf_empty (HW_UART_ID uart) |
| Check whether reading buffer is empty. More... | |
| __STATIC_INLINE bool | hw_uart_write_buf_full (HW_UART_ID uart) |
| Check whether writing buffer is full. More... | |
| __STATIC_INLINE bool | hw_uart_transmit_empty (HW_UART_ID uart) |
| Check whether transmitter is empty. More... | |
| HW_UART_CONFIG_ERR | hw_uart_init (HW_UART_ID uart, const uart_config *cfg) |
| Set UART line settings. More... | |
| void | hw_uart_deinit (HW_UART_ID uart) |
| Disables UART controller. More... | |
| void | hw_uart_reinit (HW_UART_ID uart, const uart_config *cfg) |
| Re-initialize UART registers. More... | |
| void | hw_uart_cfg_get (HW_UART_ID uart, uart_config *cfg) |
| Get UART line settings. More... | |
| uint8_t | hw_uart_afce_getf (HW_UART_ID uart) |
| Get the Auto Flow Control Enable (AFCE) setting. More... | |
| void | hw_uart_afce_setf (HW_UART_ID uart, uint8_t afce) |
| Enable or disable Auto Flow Control. More... | |
| uint8_t | hw_uart_loopback_getf (HW_UART_ID uart) |
| Get UART diagnostic mode status. More... | |
| void | hw_uart_loopback_setf (HW_UART_ID uart, uint8_t lb) |
| Set UART in diagnostic mode. More... | |
| uint8_t | hw_uart_rts_getf (HW_UART_ID uart) |
| Get RTS output value. More... | |
| void | hw_uart_rts_setf (HW_UART_ID uart, uint8_t rtsn) |
| Set RTS output value. More... | |
| HW_UART_ERROR | hw_uart_error_getf (HW_UART_ID uart) |
| Get the line status register error. More... | |
| uint8_t | hw_uart_rx_fifo_err_getf (HW_UART_ID uart) |
| Get the value of the Receiver FIFO Error bit. More... | |
| uint8_t | hw_uart_is_tx_fifo_empty (HW_UART_ID uart) |
| Get the value of the Transmitter Empty bit. More... | |
| uint8_t | hw_uart_thr_empty_getf (HW_UART_ID uart) |
| Get the value of the Transmit Holding Register Empty bit. More... | |
| uint8_t | hw_uart_break_int_getf (HW_UART_ID uart) |
| Get the value of the Break Interrupt bit. More... | |
| uint8_t | hw_uart_frame_err_getf (HW_UART_ID uart) |
| Get the value of the Framing Error bit. More... | |
| uint8_t | hw_uart_parity_err_getf (HW_UART_ID uart) |
| Get the value of the Parity Error bit. More... | |
| uint8_t | hw_uart_overrun_err_getf (HW_UART_ID uart) |
| Get the value of the Overrun Error bit. More... | |
| uint8_t | hw_uart_cts_getf (HW_UART_ID uart) |
| Get CTS input status. More... | |
| uint8_t | hw_uart_delta_cts_getf (HW_UART_ID uart) |
| Get Delta CTS. More... | |
| bool | hw_uart_tx_in_progress (const HW_UART_ID uart) |
| Check if buffered write is in progress. More... | |
| bool | hw_uart_rx_in_progress (const HW_UART_ID uart) |
| Check if buffered read is in progress. More... | |
Variables | |
| const uint32_t | hw_uart_divisor [HW_UART_BAUDRATE_MAX] |
| Baud rates dividers. More... | |
UART Controller.
| #define HW_UART_REG_FIELD_MASK | ( | instance, | |
| reg, | |||
| field | |||
| ) | (UART##instance##_UART##instance##_##reg##_REG_##field##_Msk) |
Get the mask of a field of a UART register.
| [in] | instance | identifies the UART instance to use (empty: UART, 2: UART2) |
| [in] | reg | is the register to access |
| [in] | field | is the register field to access |
| #define HW_UART_REG_FIELD_POS | ( | instance, | |
| reg, | |||
| field | |||
| ) | (UART##instance##_UART##instance##_##reg##_REG_##field##_Pos) |
Get the bit position of a field of a UART register.
| [in] | instance | identifies the UART instance to use (empty: UART, 2: UART2) |
| [in] | reg | is the register to access |
| [in] | field | is the register field to access |
| #define HW_UART_REG_GETF | ( | id, | |
| reg, | |||
| field | |||
| ) | ((UBA(id)->UART2_##reg##_REG & (UART2_UART2_##reg##_REG_##field##_Msk)) >> (UART2_UART2_##reg##_REG_##field##_Pos)) |
Get the value of a field of a UART register.
| [in] | id | identifies UART to use |
| [in] | reg | is the register to access |
| [in] | field | is the register field to write |
| #define HW_UART_REG_SETF | ( | id, | |
| reg, | |||
| field, | |||
| new_val | |||
| ) |
Set the value of a field of a UART register.
| [in] | id | identifies UART to use |
| [in] | reg | is the register to access |
| [in] | field | is the register field to write |
| [in] | new_val | is the value to write |
| enum HW_UART_BAUDRATE |
Baud rates.
| enum HW_UART_CONFIG_ERR |
Configuration errors.
| enum HW_UART_DATABITS |
Character format.
| enum HW_UART_ERROR |
| enum HW_UART_INT |
Interrupt Identification codes.
| enum HW_UART_PARITY |
Parity.
| enum HW_UART_STOPBITS |
| uint16_t hw_uart_abort_receive | ( | HW_UART_ID | uart | ) |
Stop asynchronous read from UART.
If there is outstanding reception on given UART, it will be stopped. The callback function will be fired with the number of bytes already present in rx buffer. If DMA is used, the DMA channel will be stopped.
| [in] | uart | identifies UART to use |
| uint16_t hw_uart_abort_send | ( | HW_UART_ID | uart | ) |
Stop asynchronous transmit from UART.
If there is outstanding transmission from given UART, it will be stopped. The callback function will be fired with the least number of bytes that have been transmitted.
| [in] | uart | identifies UART to use |
| uint8_t hw_uart_afce_getf | ( | HW_UART_ID | uart | ) |
Get the Auto Flow Control Enable (AFCE) setting.
| [in] | uart | identifies UART to use |
| void hw_uart_afce_setf | ( | HW_UART_ID | uart, |
| uint8_t | afce | ||
| ) |
Enable or disable Auto Flow Control.
| [in] | uart | identifies UART to use |
| [in] | afce | Auto Flow Control Enable (AFCE): 0 = disable Auto Flow Control Mode, 1 = enable Auto Flow Control Mode |
| HW_UART_BAUDRATE hw_uart_baudrate_get | ( | HW_UART_ID | uart | ) |
Get the baud rate setting.
This functions returns the HW_UART_BAUDRATE value that corresponds to the baud rate that has been set. This value is basically the settings of the baud rate divider registers (DLH|DLH|DLF)), unless a high baud rate has been set that is part of the HW_UART_BAUDRATE enum.
| [in] | uart | identifies UART to use |
| void hw_uart_baudrate_set | ( | HW_UART_ID | uart, |
| HW_UART_BAUDRATE | baud_rate | ||
| ) |
Set the baud rate.
| [in] | uart | identifies UART to use |
| [in] | baud_rate | uart baud rate |
| uint8_t hw_uart_break_int_getf | ( | HW_UART_ID | uart | ) |
Get the value of the Break Interrupt bit.
| [in] | uart | identifies UART to use |
| void hw_uart_cfg_get | ( | HW_UART_ID | uart, |
| uart_config * | cfg | ||
| ) |
Get UART line settings.
| [in] | uart | identifies UART to use |
| [in] | cfg | pointer to the UART configuration structure |
| uint8_t hw_uart_cts_getf | ( | HW_UART_ID | uart | ) |
Get CTS input status.
| [in] | uart | identifies UART to use |
| void hw_uart_deinit | ( | HW_UART_ID | uart | ) |
Disables UART controller.
| [in] | uart | UART controller instance |
| uint8_t hw_uart_delta_cts_getf | ( | HW_UART_ID | uart | ) |
Get Delta CTS.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_disable_fifo | ( | HW_UART_ID | uart | ) |
Disable both FIFOs.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_disable_loopback | ( | HW_UART_ID | uart | ) |
Disable loopback.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_enable_fifo | ( | HW_UART_ID | uart | ) |
Enable both FIFOs.
Thresholds should be set before for predictable results.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_enable_loopback | ( | HW_UART_ID | uart | ) |
Enable loopback.
| [in] | uart | identifies UART to use |
| HW_UART_ERROR hw_uart_error_getf | ( | HW_UART_ID | uart | ) |
Get the line status register error.
| [in] | uart | identifies UART to use |
| uint8_t hw_uart_fifo_en_getf | ( | HW_UART_ID | uart | ) |
Get the FIFO mode setting.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_fifo_en_setf | ( | HW_UART_ID | uart, |
| uint8_t | en | ||
| ) |
Enable or disable the UART FIFO mode.
| [in] | uart | identifies UART to use |
| [in] | en | should be 0 to disable and 1 to enable FIFO mode |
| uint8_t hw_uart_frame_err_getf | ( | HW_UART_ID | uart | ) |
Get the value of the Framing Error bit.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE HW_UART_INT hw_uart_get_interrupt_id | ( | HW_UART_ID | uart | ) |
Get the Interrupt ID.
| [in] | uart | identifies UART to use |
| HW_UART_CONFIG_ERR hw_uart_init | ( | HW_UART_ID | uart, |
| const uart_config * | cfg | ||
| ) |
Set UART line settings.
This function initializes UART registers with given configuration, including tx and rx FIFO trigger levels. It also initializes all internal software variables for buffered transmissions. Extra care is needed when configuring DMA burst mode and FIFO trigger level: If DMA burst mode is 4x, then the TX or RX trigger level should be 1/4 full. If DMA burst mode is 8x, then the TX or RX trigger level should be 1/2 full.
| [in] | uart | identifies UART to use |
| [in] | cfg | pointer to the UART configuration structure |
| __STATIC_INLINE bool hw_uart_is_busy | ( | HW_UART_ID | uart | ) |
Check if a serial transfer is in progress.
| __STATIC_INLINE bool hw_uart_is_data_ready | ( | HW_UART_ID | uart | ) |
Check if there is data available for read.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE bool hw_uart_is_fifo_enabled | ( | HW_UART_ID | uart | ) |
Get the FIFO mode setting.
| [in] | uart | identifies UART to use |
| uint8_t hw_uart_is_tx_fifo_empty | ( | HW_UART_ID | uart | ) |
Get the value of the Transmitter Empty bit.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_linestat_int_set | ( | HW_UART_ID | uart, |
| uint8_t | linestat | ||
| ) |
Set the Line Status interrupt.
| [in] | uart | identifies UART to use |
| [in] | linestat | should be 0 to disable and 1 to enable |
| uint8_t hw_uart_loopback_getf | ( | HW_UART_ID | uart | ) |
Get UART diagnostic mode status.
| [in] | uart | identifies UART to use |
| void hw_uart_loopback_setf | ( | HW_UART_ID | uart, |
| uint8_t | lb | ||
| ) |
Set UART in diagnostic mode.
| [in] | uart | identifies UART to use |
| [in] | lb | loop back bit value |
| uint8_t hw_uart_overrun_err_getf | ( | HW_UART_ID | uart | ) |
Get the value of the Overrun Error bit.
| [in] | uart | identifies UART to use |
| uint8_t hw_uart_parity_err_getf | ( | HW_UART_ID | uart | ) |
Get the value of the Parity Error bit.
| [in] | uart | identifies UART to use |
| uint16_t hw_uart_peek_received | ( | HW_UART_ID | uart | ) |
Get number of bytes currently received by asynchronous read.
If there is outstanding read on given UART, the function returns the number of bytes currently received.
| [in] | uart | identifies UART to use |
| uint16_t hw_uart_peek_transmitted | ( | HW_UART_ID | uart | ) |
Get number of bytes currently sent by asynchronous read.
If there is outstanding sending on given UART, the function returns the number of bytes currently sent.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_pthre_int_set | ( | HW_UART_ID | uart, |
| uint8_t | pthre | ||
| ) |
Set the Programmable THRE interrupt.
| [in] | uart | identifies UART to use |
| [in] | pthre | should be 0 to disable and 1 to enable |
| uint8_t hw_uart_read | ( | HW_UART_ID | uart | ) |
Read one byte from UART.
This is a blocking function to read single byte from UART. UART must be enabled before.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE bool hw_uart_read_buf_empty | ( | HW_UART_ID | uart | ) |
Check whether reading buffer is empty.
Works for both when Rx FIFO is enabled or not.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE uint8_t hw_uart_read_scr | ( | const HW_UART_ID | uart | ) |
Read Scratch pad register.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_rec_data_int_set | ( | HW_UART_ID | uart, |
| uint8_t | recdataavail | ||
| ) |
Set the Received Data Available interrupt.
| [in] | uart | identifies UART to use |
| [in] | recdataavail | should be 0 to disable and 1 to enable |
| HW_UART_CONFIG_ERR hw_uart_receive | ( | HW_UART_ID | uart, |
| void * | data, | ||
| uint16_t | len, | ||
| hw_uart_rx_callback | cb, | ||
| void * | user_data | ||
| ) |
Read number of bytes from UART.
This function initializes UART for receiving data. When len data is received or timeout occurs, user provided callback function will be fired with number of bytes read so far.
| [in] | uart | identifies UART to use |
| [out] | data | buffer for incoming data |
| [in] | len | max number of bytes to read |
| [in] | cb | function to call from interrupt when data is received |
| [in] | user_data | parameter passed to cb function |
| void hw_uart_receive_error_checking | ( | HW_UART_ID | uart, |
| void * | data, | ||
| uint16_t | len, | ||
| hw_uart_rx_callback | cb, | ||
| void * | user_data, | ||
| hw_uart_err_callback | err_cb, | ||
| void * | error_data | ||
| ) |
Read number of bytes from UART with error checking.
Function initializes UART for receiving data. It is a superset of the hw_uart_receive and provides information about the receiving errors. When len data is received or timeout occurs user provided callback will be fired with number of bytes read so far. If an error occurrs during reception, the err_cb will be called providing info about the error type.
| [in] | uart | identifies UART to use |
| [out] | data | buffer for incoming data |
| [in] | len | max number of bytes to read |
| [in] | cb | function to call from interrupt when data is received |
| [in] | user_data | parameter passed to cb function |
| [in] | err_cb | function to call from interrupt when an error is detected |
| [in] | error_data | parameter passed to err_cb function |
| __STATIC_INLINE uint16_t hw_uart_receive_fifo_count | ( | HW_UART_ID | uart | ) |
Read number of bytes in receive FIFO.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE bool hw_uart_receive_fifo_not_empty | ( | HW_UART_ID | uart | ) |
Check if receive FIFO is not empty.
| [in] | uart | identifies UART to use |
| void hw_uart_reinit | ( | HW_UART_ID | uart, |
| const uart_config * | cfg | ||
| ) |
Re-initialize UART registers.
Call this function with the configuration that should be re-applied. It should be called after platform exits power sleep mode. This function is similar to uart_init_ex, but it does not initialize software variables used for transmission control; it just re-applies hardware configuration. It will turn on interrupts if transmission is in progress.
| [in] | uart | identifies UART to use |
| [in] | cfg | pointer to the UART configuration structure |
| uint8_t hw_uart_rts_getf | ( | HW_UART_ID | uart | ) |
Get RTS output value.
| [in] | uart | identifies UART to use |
| void hw_uart_rts_setf | ( | HW_UART_ID | uart, |
| uint8_t | rtsn | ||
| ) |
Set RTS output value.
| [in] | uart | identifies UART to use |
| [in] | rtsn | Value for the RTS output (asserted low) |
| uint8_t hw_uart_rx_fifo_err_getf | ( | HW_UART_ID | uart | ) |
Get the value of the Receiver FIFO Error bit.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_rx_fifo_flush | ( | HW_UART_ID | uart | ) |
Reset UART receive FIFO.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE uint8_t hw_uart_rx_fifo_tr_lvl_getf | ( | HW_UART_ID | uart | ) |
Get the receive FIFO trigger level at which the Received Data Available Interrupt is generated.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_rx_fifo_tr_lvl_setf | ( | HW_UART_ID | uart, |
| uint8_t | tr_lvl | ||
| ) |
Set the receive FIFO trigger level at which the Received Data Available Interrupt is generated.
| [in] | uart | identifies UART to use |
| [in] | tr_lvl | the receive FIFO trigger level: 0 = 1 character in the FIFO, 1 = FIFO 1/4 full, 2 = FIFO 1/2 full, 3 = FIFO 2 less than full |
| bool hw_uart_rx_in_progress | ( | const HW_UART_ID | uart | ) |
Check if buffered read is in progress.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE uint8_t hw_uart_rxdata_getf | ( | HW_UART_ID | uart | ) |
Read receive buffer register.
| [in] | uart | identifies UART to use |
| HW_UART_CONFIG_ERR hw_uart_send | ( | HW_UART_ID | uart, |
| const void * | data, | ||
| uint16_t | len, | ||
| hw_uart_tx_callback | cb, | ||
| void * | user_data | ||
| ) |
Write number of bytes to UART.
| [in] | uart | identifies UART to use |
| [in] | data | data to be written |
| [in] | len | number of bytes to be written |
| [in] | cb | function to call from interrupt when transmission ends |
| [in] | user_data | parameter passed to cb function |
| void hw_uart_set_sclk | ( | const HW_UART_ID | uart, |
| bool | sclk | ||
| ) |
Configure the serial clock input of the UART (divN or div1)
This function allows the user to use custom high baud rates. The baud rates that can be used are not only the ones that are part of the HW_UART_BAUDRATE enum.
| [in] | uart | identifies UART to use |
| [in] | sclk | Serial clock, if true then DIV1 is used otherwise DIVN. |
| uint8_t hw_uart_thr_empty_getf | ( | HW_UART_ID | uart | ) |
Get the value of the Transmit Holding Register Empty bit.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE bool hw_uart_transmit_empty | ( | HW_UART_ID | uart | ) |
Check whether transmitter is empty.
If FIFOs are enabled (FCR[0] set to one), this bit is set whenever the Transmitter Shift Register and the FIFO are both empty. If FIFOs are disabled, this bit is set whenever the Transmitter Holding Register and the Transmitter Shift Register are both empty.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE uint16_t hw_uart_transmit_fifo_count | ( | HW_UART_ID | uart | ) |
Read number of bytes in transmit FIFO.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE bool hw_uart_transmit_fifo_empty | ( | HW_UART_ID | uart | ) |
Check if transmit FIFO is empty.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE bool hw_uart_transmit_fifo_not_full | ( | HW_UART_ID | uart | ) |
Check if transmit FIFO is not full.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_tx_empty_int_set | ( | HW_UART_ID | uart, |
| uint8_t | txempty | ||
| ) |
Set the Transmit Holding Register empty interrupt.
| [in] | uart | identifies UART to use |
| [in] | txempty | should be 0 to disable and 1 to enable |
| __STATIC_INLINE void hw_uart_tx_fifo_flush | ( | HW_UART_ID | uart | ) |
Reset UART transmit FIFO.
| [in] | uart | identifies UART to use |
| uint8_t hw_uart_tx_fifo_tr_lvl_getf | ( | HW_UART_ID | uart | ) |
Get the transmit FIFO trigger level at which the Transmit Holding Register Empty (THRE) Interrupt is generated.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_tx_fifo_tr_lvl_setf | ( | HW_UART_ID | uart, |
| uint8_t | tr_lvl | ||
| ) |
Set the transmit FIFO trigger level at which the Transmit Holding Register Empty (THRE) Interrupt is generated.
| [in] | uart | identifies UART to use |
| [in] | tr_lvl | the transmit FIFO trigger level: 0 = FIFO empty, 1 = 2 characters in the FIFO, 2 = FIFO 1/4 full, 3 = FIFO 1/2 full |
| bool hw_uart_tx_in_progress | ( | const HW_UART_ID | uart | ) |
Check if buffered write is in progress.
| [in] | uart | identifies UART to use |
| __STATIC_INLINE void hw_uart_txdata_setf | ( | HW_UART_ID | uart, |
| uint8_t | data | ||
| ) |
Write byte to the transmit holding register.
| [in] | uart | identifies UART to use |
| [in] | data | byte to be written |
| void hw_uart_write | ( | HW_UART_ID | uart, |
| uint8_t | data | ||
| ) |
Write one byte to UART.
This function waits till output FIFO has empty space according to threshold level, and puts byte to be transmitted.
| [in] | uart | identifies UART to use |
| [in] | data | byte to be written |
| __STATIC_INLINE bool hw_uart_write_buf_full | ( | HW_UART_ID | uart | ) |
Check whether writing buffer is full.
Works for both when Tx FIFO is enabled or not.
| [in] | uart | identifies UART to use |
| void hw_uart_write_buffer | ( | HW_UART_ID | uart, |
| const void * | data, | ||
| uint16_t | len | ||
| ) |
Writes number of bytes to UART synchronously.
This function finishes when all data is put in FIFO. It does not wait for data to be transmitted out from UART. Call
| [in] | uart | identifies UART to use |
| [in] | data | data to be written |
| [in] | len | number of bytes to be written |
| __STATIC_INLINE void hw_uart_write_scr | ( | const HW_UART_ID | uart, |
| uint8_t | value | ||
| ) |
Write Scratch pad register.
| [in] | uart | identifies UART to use |
| [in] | value | the value to be written |
| const uint32_t hw_uart_divisor[HW_UART_BAUDRATE_MAX] |
Baud rates dividers.
The defined values comprise the values of 3 registers: DLH, DLL, DLF. The encoding of the values for each register is:
+-----—+-----—+-----—+-----—+ | unused | DLH | DLL | DLF | +-----—+-----—+-----—+-----—+
1.8.16