Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the UART-ISO7816 HAL driver.
Files | |
file | fsl_uart_hal.h |
Enumerations | |
enum | uart_status_t |
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 } |
UART ISO7816-specific interrupt configuration. More... | |
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... | |
enum uart_status_t |
enum uart_parity_mode_t |
These constants define the number of allowable data bits per UART character. Note, check the UART documentation to determine if the desired UART base supports the desired number of data bits per UART character.
Enumerator | |
---|---|
kUart8BitsPerChar |
8-bit data characters |
kUart9BitsPerChar |
9-bit data characters |
enum uart_wakeup_method_t |
This provides constants for the UART break character length for both transmission and detection purposes. Note that the actual maximum bit times may vary depending on the UART base.
enum uart_status_flag_t |
This provides constants for the UART status flags for use in the UART functions.
enum uart_interrupt_t |
This structure contains the settings for all of the UART interrupt configurations.
This enumeration contains the settings for all of the UART ISO7816 feature-specific interrupt configurations.
void UART_HAL_Init | ( | UART_Type * | base | ) |
This function initializes the module to a known state.
base | UART module base pointer. |
|
inlinestatic |
This function allows the user to enable the UART transmitter.
base | UART module base pointer. |
|
inlinestatic |
This function allows the user to disable the UART transmitter.
base | UART module base pointer. |
|
inlinestatic |
This function allows the user to get the setting of the UART transmitter.
base | UART module base pointer. |
|
inlinestatic |
This function allows the user to enable the UART receiver.
base | UART module base pointer. |
|
inlinestatic |
This function allows the user to disable the UART receiver.
base | UART module base pointer. |
|
inlinestatic |
This function allows the user to get the setting of the UART receiver.
base | UART module base pointer. |
uart_status_t UART_HAL_SetBaudRate | ( | UART_Type * | base, |
uint32_t | sourceClockInHz, | ||
uint32_t | baudRate | ||
) |
This function programs the UART baud rate to the desired value passed in by the user. The user must also pass in the module source clock so that the function can calculate the baud rate divisors to their appropriate values. In some UART bases it is required that the transmitter/receiver be disabled before calling this function. Generally this is applied to all UARTs to ensure safe operation.
base | UART module base pointer. |
sourceClockInHz | UART source input clock in Hz. |
baudRate | UART desired baud rate. |
void UART_HAL_SetBaudRateDivisor | ( | UART_Type * | base, |
uint16_t | baudRateDivisor | ||
) |
This function allows the user to program the baud rate divisor directly in situations where the divisor value is known. In this case, the user may not want to call the UART_HAL_SetBaudRate() function, because the divisor is already known.
base | UART module base pointer. |
baudRateDivisor | The baud rate modulo division "SBR" value. |
|
inlinestatic |
This function allows the user to configure the number of bits per character according to the typedef uart_bit_count_per_char_t.
base | UART module base pointer. |
bitCountPerChar | Number of bits per char (8, 9, or 10, depending on the UART base). |
void UART_HAL_SetParityMode | ( | UART_Type * | base, |
uart_parity_mode_t | parityMode | ||
) |
This function allows the user to configure the parity mode of the UART controller to disable it or enable it for even parity or for odd parity.
base | UART module base pointer. |
parityMode | Parity mode setting (enabled, disable, odd, even - see parity_mode_t struct). |
|
inlinestatic |
base | UART module base pointer. |
void UART_HAL_SetIntMode | ( | UART_Type * | base, |
uart_interrupt_t | interrupt, | ||
bool | enable | ||
) |
base | UART module base pointer. |
interrupt | UART interrupt configuration data. |
enable | true: enable, false: disable. |
bool UART_HAL_GetIntMode | ( | UART_Type * | base, |
uart_interrupt_t | interrupt | ||
) |
base | UART module base pointer. |
interrupt | UART interrupt configuration data. |
void UART_HAL_Putchar | ( | UART_Type * | base, |
uint8_t | data | ||
) |
base | UART module base pointer. |
data | The data to send of size 8-bit. |
void UART_HAL_Putchar9 | ( | UART_Type * | base, |
uint16_t | data | ||
) |
base | UART module base pointer. |
data | The data to send of size 9-bit. |
void UART_HAL_Getchar | ( | UART_Type * | base, |
uint8_t * | readData | ||
) |
base | UART module base pointer. |
readData | The received data read from data register of size 8-bit. |
void UART_HAL_Getchar9 | ( | UART_Type * | base, |
uint16_t * | readData | ||
) |
base | UART module base pointer. |
readData | The received data read from data register of size 9-bit. |
void UART_HAL_SendDataPolling | ( | UART_Type * | base, |
const uint8_t * | txBuff, | ||
uint32_t | txSize | ||
) |
This function only supports 8-bit transaction.
base | UART module base pointer. |
txBuff | The buffer pointer which saves the data to be sent. |
txSize | Size of data to be sent in unit of byte. |
uart_status_t UART_HAL_ReceiveDataPolling | ( | UART_Type * | base, |
uint8_t * | rxBuff, | ||
uint32_t | rxSize | ||
) |
This function only supports 8-bit transaction.
base | UART module base pointer. |
rxBuff | The buffer pointer which saves the data to be received. |
rxSize | Size of data need to be received in unit of byte. |
bool UART_HAL_GetStatusFlag | ( | UART_Type * | base, |
uart_status_flag_t | statusFlag | ||
) |
base | UART module base pointer. |
statusFlag | Status flag name. |
uart_status_t UART_HAL_ClearStatusFlag | ( | UART_Type * | base, |
uart_status_flag_t | statusFlag | ||
) |
This function allows the user to clear an individual and specific UART status flag. Refer to structure definition uart_status_flag_t for list of status bits.
base | UART module base pointer. |
statusFlag | The desired UART status flag to clear. |
|
inlinestatic |
This function enables or disables the UART loopback operation.
base | UART module base pointer. |
enable | The UART loopback mode configuration, either disabled (false) or enabled (true). |
|
inlinestatic |
This function enables or disables the UART single-wire operation. In some UART bases it is required that the transmitter/receiver be disabled before calling this function. This may be applied to all UARTs to ensure safe operation.
base | UART module base pointer. |
source | The UART single-wire mode configuration. |
|
inlinestatic |
This function configures the transmitter direction when the UART is configured for single-wire operation.
base | UART module base pointer. |
direction | The UART single-wire mode transmit direction configuration of type uart_singlewire_txdir_t (either kUartSinglewireTxdirIn or kUartSinglewireTxdirOut. |
uart_status_t UART_HAL_PutReceiverInStandbyMode | ( | UART_Type * | base | ) |
This function, when called, places the UART receiver into standby mode. In some UART bases, there are conditions that must be met before placing Rx in standby mode. Before placing UART in standby, determine if receiver is set to wake on idle, and if receiver is already in idle state. NOTE: RWU should only be set with C1[WAKE] = 0 (wakeup on idle) if the channel is currently not idle. This can be determined by the S2[RAF] flag. If set to wake up FROM an IDLE event and the channel is already idle, it is possible that the UART discards data because data must be received (or a LIN break detect) after an IDLE is detected before IDLE is allowed to be reasserted.
base | UART module base pointer. |
|
inlinestatic |
This function, when called, places the UART receiver into normal mode and out of standby mode.
base | UART module base pointer. |
|
inlinestatic |
This function determines the state of the UART receiver. If it returns true, this means that the UART receiver is in standby mode; if it returns false, the UART receiver is in normal mode.
base | UART module base pointer. |
|
inlinestatic |
This function configures the wakeup method of the UART receiver from standby mode. The options are idle-line wake or address-mark wake.
base | UART module base pointer. |
method | The UART receiver wakeup method options: kUartIdleLineWake - Idle-line wake or kUartAddrMarkWake - address-mark wake. |
|
inlinestatic |
This function returns how the UART receiver is configured to wake from standby mode. The wake method options that can be returned are kUartIdleLineWake or kUartAddrMarkWake.
base | UART module base pointer. |
void UART_HAL_ConfigIdleLineDetect | ( | UART_Type * | base, |
uint8_t | idleLine, | ||
uint8_t | rxWakeIdleDetect | ||
) |
This function allows the user to configure the UART idle-line detect operation. There are two separate operations for the user to configure, the idle line bit-count start and the receive wake up affect on IDLE status bit. The user passes in a structure of type uart_idle_line_config_t.
base | UART module base pointer. |
idleLine | Idle bit count start: 0 - after start bit (default), 1 - after stop bit |
rxWakeIdleDetect | Receiver Wake Up Idle Detect. IDLE status bit operation during receive standby. Controls whether idle character that wakes up receiver also sets IDLE status bit. 0 - IDLE status bit doesn't get set (default), 1 - IDLE status bit gets set |
|
inlinestatic |
This function allows the user to configure the UART break character transmit length. Refer to the typedef uart_break_char_length_t for setting options. In some UART bases it is required that the transmitter be disabled before calling this function. This may be applied to all UARTs to ensure safe operation.
base | UART module base pointer. |
length | The UART break character length setting of type uart_break_char_length_t, either a minimum 10-bit times or a minimum 13-bit times. |
|
inlinestatic |
This function allows the user to queue a UART break character to send. If true is passed into the function, then a break character is queued for transmission. A break character is continuously queued until this function is called again when a false is passed into this function.
base | UART module base pointer. |
enable | If false, the UART normal/queue break character setting is disabled, which configures the UART for normal transmitter operation. If true, a break character is queued for transmission. |
void UART_HAL_SetMatchAddress | ( | UART_Type * | base, |
bool | matchAddrMode1, | ||
bool | matchAddrMode2, | ||
uint8_t | matchAddrValue1, | ||
uint8_t | matchAddrValue2 | ||
) |
(Note: Feature available on select UART bases)
The function allows the user to configure the UART match address control operation. The user has the option to enable the match address mode and to program the match address value. There are two match address modes, each with its own enable and programmable match address value.
base | UART module base pointer. |
matchAddrMode1 | If true, this enables match address mode 1 (MAEN1), where false disables. |
matchAddrMode2 | If true, this enables match address mode 2 (MAEN2), where false disables. |
matchAddrValue1 | The match address value to program for match address mode 1. |
matchAddrValue2 | The match address value to program for match address mode 2. |