Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
fsl_uart_hal.h File Reference
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include "fsl_device_registers.h"

Macros

#define UART_SHIFT   (8U)
 

Enumerations

enum  uart_status_t {
  kStatus_UART_Success = 0x00U,
  kStatus_UART_Fail = 0x01U,
  kStatus_UART_BaudRateCalculationError = 0x02U,
  kStatus_UART_RxStandbyModeError = 0x03U,
  kStatus_UART_ClearStatusFlagError = 0x04U,
  kStatus_UART_TxNotDisabled = 0x05U,
  kStatus_UART_RxNotDisabled = 0x06U,
  kStatus_UART_TxOrRxNotDisabled = 0x07U,
  kStatus_UART_TxBusy = 0x08U,
  kStatus_UART_RxBusy = 0x09U,
  kStatus_UART_NoTransmitInProgress = 0x0AU,
  kStatus_UART_NoReceiveInProgress = 0x0BU,
  kStatus_UART_Timeout = 0x0CU,
  kStatus_UART_Initialized = 0x0DU,
  kStatus_UART_NoDataToDeal = 0x0EU,
  kStatus_UART_RxOverRun = 0x0FU
}
 Error codes for the UART driver. More...
 
enum  uart_stop_bit_count_t {
  kUartOneStopBit = 0U,
  kUartTwoStopBit = 1U
}
 UART number of stop bits. More...
 
enum  uart_parity_mode_t {
  kUartParityDisabled = 0x0U,
  kUartParityEven = 0x2U,
  kUartParityOdd = 0x3U
}
 UART parity mode. More...
 
enum  uart_bit_count_per_char_t {
  kUart8BitsPerChar = 0U,
  kUart9BitsPerChar = 1U
}
 UART number of bits in a character. More...
 
enum  uart_operation_config_t {
  kUartOperates = 0U,
  kUartStops = 1U
}
 UART operation configuration constants. More...
 
enum  uart_receiver_source_t {
  kUartLoopBack = 0U,
  kUartSingleWire = 1U
}
 UART receiver source select mode. More...
 
enum  uart_wakeup_method_t {
  kUartIdleLineWake = 0U,
  kUartAddrMarkWake = 1U
}
 UART wakeup from standby method constants. More...
 
enum  uart_idle_line_select_t {
  kUartIdleLineAfterStartBit = 0U,
  kUartIdleLineAfterStopBit = 1U
}
 UART idle-line detect selection types. More...
 
enum  uart_break_char_length_t {
  kUartBreakChar10BitMinimum = 0U,
  kUartBreakChar13BitMinimum = 1U
}
 UART break character length settings for transmit/detect. More...
 
enum  uart_singlewire_txdir_t {
  kUartSinglewireTxdirIn = 0U,
  kUartSinglewireTxdirOut = 1U
}
 UART single-wire mode transmit direction. More...
 
enum  uart_ir_tx_pulsewidth_t {
  kUartIrThreeSixteenthsWidth = 0U,
  kUartIrOneSixteenthWidth = 1U,
  kUartIrOneThirtysecondsWidth = 2U,
  kUartIrOneFourthWidth = 3U
}
 UART infrared transmitter pulse width options. More...
 
enum  uart_iso7816_transfer_protocoltype_t {
  kUartIso7816TransfertType0 = 0U,
  kUartIso7816TransfertType1 = 1U
}
 UART ISO7816 transport protocol type options. More...
 
enum  uart_iso7816_onack_config_t {
  kUartIso7816OnackEnable = 0U,
  kUartIso7816OnackDisable = 1U
}
 UART ISO7816 ONACK generation. More...
 
enum  uart_iso7816_anack_config_t {
  kUartIso7816AnackDisable = 0U,
  kUartIso7816AnackEnable = 1U
}
 UART ISO7816 ANACK generation. More...
 
enum  uart_iso7816_initd_config_t {
  kUartIso7816InitdDisable = 0U,
  kUartIso7816InitdEnable = 1U
}
 UART ISO7816 Initial Character detection. More...
 
enum  uart_status_flag_t {
  kUartTxDataRegEmpty = 0U << UART_SHIFT | UART_S1_TDRE_SHIFT,
  kUartTxComplete = 0U << UART_SHIFT | UART_S1_TC_SHIFT,
  kUartRxDataRegFull = 0U << UART_SHIFT | UART_S1_RDRF_SHIFT,
  kUartIdleLineDetect = 0U << UART_SHIFT | UART_S1_IDLE_SHIFT,
  kUartRxOverrun = 0U << UART_SHIFT | UART_S1_OR_SHIFT,
  kUartNoiseDetect = 0U << UART_SHIFT | UART_S1_NF_SHIFT,
  kUartFrameErr = 0U << UART_SHIFT | UART_S1_FE_SHIFT,
  kUartParityErr = 0U << UART_SHIFT | UART_S1_PF_SHIFT,
  kUartRxActiveEdgeDetect = 1U << UART_SHIFT | UART_S2_RXEDGIF_SHIFT,
  kUartRxActive = 1U << UART_SHIFT | UART_S2_RAF_SHIFT
}
 UART status flags. More...
 
enum  uart_interrupt_t {
  kUartIntRxActiveEdge = 0U << UART_SHIFT | UART_BDH_RXEDGIE_SHIFT,
  kUartIntTxDataRegEmpty = 1U << UART_SHIFT | UART_C2_TIE_SHIFT,
  kUartIntTxComplete = 1U << UART_SHIFT | UART_C2_TCIE_SHIFT,
  kUartIntRxDataRegFull = 1U << UART_SHIFT | UART_C2_RIE_SHIFT,
  kUartIntIdleLine = 1U << UART_SHIFT | UART_C2_ILIE_SHIFT,
  kUartIntRxOverrun = 2U << UART_SHIFT | UART_C3_ORIE_SHIFT,
  kUartIntNoiseErrFlag = 2U << UART_SHIFT | UART_C3_NEIE_SHIFT,
  kUartIntFrameErrFlag = 2U << UART_SHIFT | UART_C3_FEIE_SHIFT,
  kUartIntParityErrFlag = 2U << UART_SHIFT | UART_C3_PEIE_SHIFT
}
 UART interrupt configuration structure, default settings are 0 (disabled). More...
 
enum  uart_iso7816_interrupt_t {
  kUartIntIso7816RxThreasholdExceeded = 0U,
  kUartIntIso7816TxThresholdExceeded = 1U,
  kUartIntIso7816GuardTimerViolated = 2U,
  kUartIntIso7816AtrDurationTimer = 3U,
  kUartIntIso7816InitialCharDetected = 4U,
  kUartIntIso7816BlockWaitTimer = 5U,
  kUartIntIso7816CharWaitTimer = 6U,
  kUartIntIso7816WaitTimer = 7U,
  kUartIntIso7816All = 8U
}
 UART ISO7816-specific interrupt configuration. More...
 

Functions

UART Common Configurations
void UART_HAL_Init (UART_Type *base)
 Initializes the UART controller. More...
 
static void UART_HAL_EnableTransmitter (UART_Type *base)
 Enables the UART transmitter. More...
 
static void UART_HAL_DisableTransmitter (UART_Type *base)
 Disables the UART transmitter. More...
 
static bool UART_HAL_IsTransmitterEnabled (UART_Type *base)
 Gets the UART transmitter enabled/disabled configuration setting. More...
 
static void UART_HAL_EnableReceiver (UART_Type *base)
 Enables the UART receiver. More...
 
static void UART_HAL_DisableReceiver (UART_Type *base)
 Disables the UART receiver. More...
 
static bool UART_HAL_IsReceiverEnabled (UART_Type *base)
 Gets the UART receiver enabled/disabled configuration setting. More...
 
uart_status_t UART_HAL_SetBaudRate (UART_Type *base, uint32_t sourceClockInHz, uint32_t baudRate)
 Configures the UART baud rate. More...
 
void UART_HAL_SetBaudRateDivisor (UART_Type *base, uint16_t baudRateDivisor)
 Sets the UART baud rate modulo divisor value. More...
 
static void UART_HAL_SetBitCountPerChar (UART_Type *base, uart_bit_count_per_char_t bitCountPerChar)
 Configures the number of bits per character in the UART controller. More...
 
void UART_HAL_SetParityMode (UART_Type *base, uart_parity_mode_t parityMode)
 Configures the parity mode in the UART controller. More...
 
static uint32_t UART_HAL_GetDataRegAddr (UART_Type *base)
 Get UART transmit/receive data register address. More...
 
UART Interrupts and DMA
void UART_HAL_SetIntMode (UART_Type *base, uart_interrupt_t interrupt, bool enable)
 Configures the UART module interrupts to enable/disable various interrupt sources. More...
 
bool UART_HAL_GetIntMode (UART_Type *base, uart_interrupt_t interrupt)
 Returns whether the UART module interrupts is enabled/disabled. More...
 
UART Transfer Functions
void UART_HAL_Putchar (UART_Type *base, uint8_t data)
 This function allows the user to send an 8-bit character from the UART data register. More...
 
void UART_HAL_Putchar9 (UART_Type *base, uint16_t data)
 This function allows the user to send a 9-bit character from the UART data register. More...
 
void UART_HAL_Getchar (UART_Type *base, uint8_t *readData)
 This function gets a received 8-bit character from the UART data register. More...
 
void UART_HAL_Getchar9 (UART_Type *base, uint16_t *readData)
 This function gets a received 9-bit character from the UART data register. More...
 
void UART_HAL_SendDataPolling (UART_Type *base, const uint8_t *txBuff, uint32_t txSize)
 Sends out multiple bytes of data using polling method. More...
 
uart_status_t UART_HAL_ReceiveDataPolling (UART_Type *base, uint8_t *rxBuff, uint32_t rxSize)
 Receives multiple bytes of data using polling method. More...
 
UART Status Flags
bool UART_HAL_GetStatusFlag (UART_Type *base, uart_status_flag_t statusFlag)
 Gets all UART status flag states. More...
 
uart_status_t UART_HAL_ClearStatusFlag (UART_Type *base, uart_status_flag_t statusFlag)
 Clears an individual and specific UART status flag. More...
 
UART Special Feature Configurations
static void UART_HAL_SetLoopCmd (UART_Type *base, bool enable)
 Configures the UART loopback operation. More...
 
static void UART_HAL_SetReceiverSource (UART_Type *base, uart_receiver_source_t source)
 Configures the UART single-wire operation. More...
 
static void UART_HAL_SetTransmitterDir (UART_Type *base, uart_singlewire_txdir_t direction)
 Configures the UART transmit direction while in single-wire mode. More...
 
uart_status_t UART_HAL_PutReceiverInStandbyMode (UART_Type *base)
 Places the UART receiver in standby mode. More...
 
static void UART_HAL_PutReceiverInNormalMode (UART_Type *base)
 Places the UART receiver in normal mode (disable standby mode operation). More...
 
static bool UART_HAL_IsReceiverInStandby (UART_Type *base)
 Determines if the UART receiver is currently in standby mode. More...
 
static void UART_HAL_SetReceiverWakeupMethod (UART_Type *base, uart_wakeup_method_t method)
 Selects the UART receiver wakeup method (idle-line or address-mark) from standby mode. More...
 
static uart_wakeup_method_t UART_HAL_GetReceiverWakeupMethod (UART_Type *base)
 Gets the UART receiver wakeup method (idle-line or address-mark) from standby mode. More...
 
void UART_HAL_ConfigIdleLineDetect (UART_Type *base, uint8_t idleLine, uint8_t rxWakeIdleDetect)
 Configures the operation options of the UART idle line detect. More...
 
static void UART_HAL_SetBreakCharTransmitLength (UART_Type *base, uart_break_char_length_t length)
 Configures the UART break character transmit length. More...
 
static void UART_HAL_SetBreakCharCmd (UART_Type *base, bool enable)
 Configures the UART transmit send break character operation. More...
 
void UART_HAL_SetMatchAddress (UART_Type *base, bool matchAddrMode1, bool matchAddrMode2, uint8_t matchAddrValue1, uint8_t matchAddrValue2)
 Configures the UART match address mode control operation. More...