Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
The section describes the programming interface of the LPSCI HAL driver.
Files | |
file | fsl_lpsci_hal.h |
Enumerations | |
enum | lpsci_status_t |
Error codes for the LPSCI driver. More... | |
enum | lpsci_stop_bit_count_t { kLpsciOneStopBit = 0U, kLpsciTwoStopBit = 1U } |
LPSCI number of stop bits. More... | |
enum | lpsci_parity_mode_t { kLpsciParityDisabled = 0x0U, kLpsciParityEven = 0x2U, kLpsciParityOdd = 0x3U } |
LPSCI parity mode. More... | |
enum | lpsci_bit_count_per_char_t { kLpsci8BitsPerChar = 0U, kLpsci9BitsPerChar = 1U } |
LPSCI number of bits in a character. More... | |
enum | lpsci_operation_config_t { kLpsciOperates = 0U, kLpsciStops = 1U } |
LPSCI operation configuration constants. More... | |
enum | lpsci_receiver_source_t { kLpsciLoopBack = 0U, kLpsciSingleWire = 1U } |
LPSCI receiver source select mode. More... | |
enum | lpsci_wakeup_method_t { kLpsciIdleLineWake = 0U, kLpsciAddrMarkWake = 1U } |
LPSCI wakeup from standby method constants. More... | |
enum | lpsci_idle_line_select_t { kLpsciIdleLineAfterStartBit = 0U, kLpsciIdleLineAfterStopBit = 1U } |
LPSCI idle-line detect selection types. More... | |
enum | lpsci_break_char_length_t { kLpsciBreakChar10BitMinimum = 0U, kLpsciBreakChar13BitMinimum = 1U } |
LPSCI break character length settings for transmit/detect. More... | |
enum | lpsci_singlewire_txdir_t { kLpsciSinglewireTxdirIn = 0U, kLpsciSinglewireTxdirOut = 1U } |
LPSCI single-wire mode transmit direction. More... | |
enum | lpsci_ir_tx_pulsewidth_t { kLpsciIrThreeSixteenthsWidth = 0U, kLpsciIrOneSixteenthWidth = 1U, kLpsciIrOneThirtysecondsWidth = 2U, kLpsciIrOneFourthWidth = 3U } |
LPSCI infrared transmitter pulse width options. More... | |
enum | lpsci_status_flag_t { kLpsciTxDataRegEmpty = 0U << LPSCI_SHIFT | UART0_S1_TDRE_SHIFT, kLpsciTxComplete = 0U << LPSCI_SHIFT | UART0_S1_TC_SHIFT, kLpsciRxDataRegFull = 0U << LPSCI_SHIFT | UART0_S1_RDRF_SHIFT, kLpsciIdleLineDetect = 0U << LPSCI_SHIFT | UART0_S1_IDLE_SHIFT, kLpsciRxOverrun = 0U << LPSCI_SHIFT | UART0_S1_OR_SHIFT, kLpsciNoiseDetect = 0U << LPSCI_SHIFT | UART0_S1_NF_SHIFT, kLpsciFrameErr = 0U << LPSCI_SHIFT | UART0_S1_FE_SHIFT, kLpsciParityErr = 0U << LPSCI_SHIFT | UART0_S1_PF_SHIFT, kLpsciLineBreakDetect = 1U << LPSCI_SHIFT | UART0_S2_LBKDIF_SHIFT, kLpsciRxActiveEdgeDetect = 1U << LPSCI_SHIFT | UART0_S2_RXEDGIF_SHIFT, kLpsciRxActive = 1U << LPSCI_SHIFT | UART0_S2_RAF_SHIFT } |
LPSCI status flags. More... | |
enum | lpsci_interrupt_t { kLpsciIntLinBreakDetect = 0U << LPSCI_SHIFT | UART0_BDH_LBKDIE_SHIFT, kLpsciIntRxActiveEdge = 0U << LPSCI_SHIFT | UART0_BDH_RXEDGIE_SHIFT, kLpsciIntTxDataRegEmpty = 1U << LPSCI_SHIFT | UART0_C2_TIE_SHIFT, kLpsciIntTxComplete = 1U << LPSCI_SHIFT | UART0_C2_TCIE_SHIFT, kLpsciIntRxDataRegFull = 1U << LPSCI_SHIFT | UART0_C2_RIE_SHIFT, kLpsciIntIdleLine = 1U << LPSCI_SHIFT | UART0_C2_ILIE_SHIFT, kLpsciIntRxOverrun = 2U << LPSCI_SHIFT | UART0_C3_ORIE_SHIFT, kLpsciIntNoiseErrFlag = 2U << LPSCI_SHIFT | UART0_C3_NEIE_SHIFT, kLpsciIntFrameErrFlag = 2U << LPSCI_SHIFT | UART0_C3_FEIE_SHIFT, kLpsciIntParityErrFlag = 2U << LPSCI_SHIFT | UART0_C3_PEIE_SHIFT } |
LPSCI interrupt configuration structure; default settings are 0 (disabled). More... | |
LPSCI Common Configurations | |
void | LPSCI_HAL_Init (UART0_Type *base) |
Initializes the LPSCI controller. More... | |
static void | LPSCI_HAL_EnableTransmitter (UART0_Type *base) |
Enables the LPSCI transmitter. More... | |
static void | LPSCI_HAL_DisableTransmitter (UART0_Type *base) |
Disables the LPSCI transmitter. More... | |
static bool | LPSCI_HAL_IsTransmitterEnabled (UART0_Type *base) |
Gets the LPSCI transmitter enabled/disabled configuration setting. More... | |
static void | LPSCI_HAL_EnableReceiver (UART0_Type *base) |
Enables the LPSCI receiver. More... | |
static void | LPSCI_HAL_DisableReceiver (UART0_Type *base) |
Disables the LPSCI receiver. More... | |
static bool | LPSCI_HAL_IsReceiverEnabled (UART0_Type *base) |
Gets the LPSCI receiver enabled/disabled configuration setting. More... | |
lpsci_status_t | LPSCI_HAL_SetBaudRate (UART0_Type *base, uint32_t sourceClockInHz, uint32_t baudRate) |
Configures the LPSCI baud rate. More... | |
void | LPSCI_HAL_SetBaudRateDivisor (UART0_Type *base, uint16_t baudRateDivisor) |
Sets the LPSCI baud rate modulo divisor value. More... | |
static void | LPSCI_HAL_SetBitCountPerChar (UART0_Type *base, lpsci_bit_count_per_char_t bitCountPerChar) |
Configures the number of bits per character in the LPSCI controller. More... | |
void | LPSCI_HAL_SetParityMode (UART0_Type *base, lpsci_parity_mode_t parityMode) |
Configures the parity mode in the LPSCI controller. More... | |
LPSCI Interrupts and DMA | |
void | LPSCI_HAL_SetIntMode (UART0_Type *base, lpsci_interrupt_t interrupt, bool enable) |
Configures the LPSCI module interrupts to enable/disable various interrupt sources. More... | |
bool | LPSCI_HAL_GetIntMode (UART0_Type *base, lpsci_interrupt_t interrupt) |
Returns whether the LPSCI module interrupts are enabled/disabled. More... | |
static uint32_t | LPSCI_HAL_GetDataRegAddr (UART0_Type *base) |
Gets the LPSCI transmit/receive data register address. More... | |
LPSCI Transfer Functions | |
static void | LPSCI_HAL_Putchar (UART0_Type *base, uint8_t data) |
This function allows the user to send an 8-bit character from the LPSCI data register. More... | |
void | LPSCI_HAL_Putchar9 (UART0_Type *base, uint16_t data) |
This function allows the user to send a 9-bit character from the LPSCI data register. More... | |
void | LPSCI_HAL_Putchar10 (UART0_Type *base, uint16_t data) |
This function allows the user to send a 10-bit character from the LPSCI data register. More... | |
static void | LPSCI_HAL_Getchar (UART0_Type *base, uint8_t *readData) |
This function gets a received 8-bit character from the LPSCI data register. More... | |
void | LPSCI_HAL_Getchar9 (UART0_Type *base, uint16_t *readData) |
This function gets a received 9-bit character from the LPSCI data register. More... | |
void | LPSCI_HAL_Getchar10 (UART0_Type *base, uint16_t *readData) |
This function gets a received 10-bit character from the LPSCI data register. More... | |
void | LPSCI_HAL_SendDataPolling (UART0_Type *base, const uint8_t *txBuff, uint32_t txSize) |
Sends out multiple bytes of data using the polling method. More... | |
lpsci_status_t | LPSCI_HAL_ReceiveDataPolling (UART0_Type *base, uint8_t *rxBuff, uint32_t rxSize) |
Receives multiple bytes of data using the polling method. More... | |
LPSCI Status Flags | |
bool | LPSCI_HAL_GetStatusFlag (UART0_Type *base, lpsci_status_flag_t statusFlag) |
Gets all LPSCI status flag states. More... | |
lpsci_status_t | LPSCI_HAL_ClearStatusFlag (UART0_Type *base, lpsci_status_flag_t statusFlag) |
Clears an individual and specific LPSCI status flag. More... | |
LPSCI Special Feature Configurations | |
static void | LPSCI_HAL_SetWaitModeOperation (UART0_Type *base, lpsci_operation_config_t mode) |
Configures the LPSCI to either operate or cease to operate in wait mode. More... | |
static lpsci_operation_config_t | LPSCI_HAL_GetWaitModeOperation (UART0_Type *base) |
Determines if the LPSCI operates or ceases to operate in wait mode. More... | |
static void | LPSCI_HAL_SetLoopCmd (UART0_Type *base, bool enable) |
Configures the LPSCI loopback operation. More... | |
static void | LPSCI_HAL_SetReceiverSource (UART0_Type *base, lpsci_receiver_source_t source) |
Configures the LPSCI single-wire operation. More... | |
static void | LPSCI_HAL_SetTransmitterDir (UART0_Type *base, lpsci_singlewire_txdir_t direction) |
Configures the LPSCI transmit direction while in single-wire mode. More... | |
lpsci_status_t | LPSCI_HAL_PutReceiverInStandbyMode (UART0_Type *base) |
Places the LPSCI receiver in standby mode. More... | |
static void | LPSCI_HAL_PutReceiverInNormalMode (UART0_Type *base) |
Places the LPSCI receiver in normal mode (disable standby mode operation). More... | |
static bool | LPSCI_HAL_IsReceiverInStandby (UART0_Type *base) |
Determines if the LPSCI receiver is currently in standby mode. More... | |
static void | LPSCI_HAL_SetReceiverWakeupMethod (UART0_Type *base, lpsci_wakeup_method_t method) |
Selects the LPSCI receiver wakeup method (idle-line or address-mark) from standby mode. More... | |
static lpsci_wakeup_method_t | LPSCI_HAL_GetReceiverWakeupMethod (UART0_Type *base) |
Gets the LPSCI receiver wakeup method (idle-line or address-mark) from standby mode. More... | |
void | LPSCI_HAL_ConfigIdleLineDetect (UART0_Type *base, uint8_t idleLine, uint8_t rxWakeIdleDetect) |
Configures the operation options of the LPSCI idle line detect. More... | |
static void | LPSCI_HAL_SetBreakCharTransmitLength (UART0_Type *base, lpsci_break_char_length_t length) |
Configures the LPSCI break character transmit length. More... | |
static void | LPSCI_HAL_SetBreakCharDetectLength (UART0_Type *base, lpsci_break_char_length_t length) |
Configures the LPSCI break character detect length. More... | |
static void | LPSCI_HAL_SetBreakCharCmd (UART0_Type *base, bool enable) |
Configures the LPSCI transmit send break character operation. More... | |
void | LPSCI_HAL_SetMatchAddress (UART0_Type *base, bool matchAddrMode1, bool matchAddrMode2, uint8_t matchAddrValue1, uint8_t matchAddrValue2) |
Configures the LPSCI match address mode control operation. More... | |
enum lpsci_status_t |
enum lpsci_parity_mode_t |
These constants define the number of allowable data bits per LPSCI character. Note, check the LPSCI documentation to determine if the desired LPSCI base supports the desired number of data bits per LPSCI character.
Enumerator | |
---|---|
kLpsci8BitsPerChar |
8-bit data characters |
kLpsci9BitsPerChar |
9-bit data characters |
This provides constants for the LPSCI break character length for both transmission and detection purposes. Note that the actual maximum bit times may vary depending on the LPSCI base.
enum lpsci_status_flag_t |
This provides constants for the LPSCI status flags for use in the LPSCI functions.
enum lpsci_interrupt_t |
This structure contains the settings for all LPSCI interrupt configurations.
void LPSCI_HAL_Init | ( | UART0_Type * | base | ) |
This function initializes the module to a known state.
base | LPSCI module base pointer. |
|
inlinestatic |
This function allows the user to enable the LPSCI transmitter.
base | LPSCI module base pointer. |
|
inlinestatic |
This function allows the user to disable the LPSCI transmitter.
base | LPSCI module base pointer. |
|
inlinestatic |
This function allows the user to get the setting of the LPSCI transmitter.
base | LPSCI module base pointer. |
|
inlinestatic |
This function allows the user to enable the LPSCI receiver.
base | LPSCI module base pointer. |
|
inlinestatic |
This function allows the user to disable the LPSCI receiver.
base | LPSCI module base pointer. |
|
inlinestatic |
This function allows the user to get the setting of the LPSCI receiver.
base | LPSCI module base pointer. |
lpsci_status_t LPSCI_HAL_SetBaudRate | ( | UART0_Type * | base, |
uint32_t | sourceClockInHz, | ||
uint32_t | baudRate | ||
) |
This function programs the LPSCI 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 LPSCI bases it is required that the transmitter/receiver be disabled before calling this function. Generally this is applied to all LPSCIs to ensure safe operation.
base | LPSCI module base pointer. |
sourceClockInHz | LPSCI source input clock in Hz. |
baudRate | LPSCI desired baud rate. |
void LPSCI_HAL_SetBaudRateDivisor | ( | UART0_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 LPSCI_HAL_SetBaudRate() function because the divisor is already known.
base | LPSCI 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 lpsci_bit_count_per_char_t.
base | LPSCI module base pointer. |
bitCountPerChar | Number of bits per char (8, 9, or 10, depending on the LPSCI base). |
void LPSCI_HAL_SetParityMode | ( | UART0_Type * | base, |
lpsci_parity_mode_t | parityMode | ||
) |
This function allows the user to configure the parity mode of the LPSCI controller to disable or enable it for even parity or odd parity.
base | LPSCI module base pointer. |
parityMode | Parity mode setting (enabled, disable, odd, even - see parity_mode_t struct). |
void LPSCI_HAL_SetIntMode | ( | UART0_Type * | base, |
lpsci_interrupt_t | interrupt, | ||
bool | enable | ||
) |
base | LPSCI module base pointer. |
interrupt | LPSCI interrupt configuration data. |
enable | true: enable, false: disable. |
bool LPSCI_HAL_GetIntMode | ( | UART0_Type * | base, |
lpsci_interrupt_t | interrupt | ||
) |
base | LPSCI module base pointer. |
interrupt | LPSCI interrupt configuration data. |
|
inlinestatic |
This function is used for DMA transfer.
base | LPSCI module base address. |
|
inlinestatic |
base | LPSCI module base pointer. |
data | The data to send of size 8-bit. |
void LPSCI_HAL_Putchar9 | ( | UART0_Type * | base, |
uint16_t | data | ||
) |
base | LPSCI module base pointer. |
data | The data to send of size 9-bit. |
void LPSCI_HAL_Putchar10 | ( | UART0_Type * | base, |
uint16_t | data | ||
) |
base | LPSCI module base pointer. |
data | The data to send of size 10-bit. |
|
inlinestatic |
base | LPSCI module base pointer. |
readData | The received data read from data register of size 8-bit. |
void LPSCI_HAL_Getchar9 | ( | UART0_Type * | base, |
uint16_t * | readData | ||
) |
base | LPSCI module base pointer. |
readData | The received data read from data register of size 9-bit. |
void LPSCI_HAL_Getchar10 | ( | UART0_Type * | base, |
uint16_t * | readData | ||
) |
base | LPSCI module base pointer. |
readData | The received data read from data register of size 10-bit. |
void LPSCI_HAL_SendDataPolling | ( | UART0_Type * | base, |
const uint8_t * | txBuff, | ||
uint32_t | txSize | ||
) |
This function only supports 8-bit transaction.
base | LPSCI 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. |
lpsci_status_t LPSCI_HAL_ReceiveDataPolling | ( | UART0_Type * | base, |
uint8_t * | rxBuff, | ||
uint32_t | rxSize | ||
) |
This function only supports 8-bit transaction.
base | LPSCI 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 LPSCI_HAL_GetStatusFlag | ( | UART0_Type * | base, |
lpsci_status_flag_t | statusFlag | ||
) |
base | LPSCI module base pointer. |
statusFlag | Status flag name. |
lpsci_status_t LPSCI_HAL_ClearStatusFlag | ( | UART0_Type * | base, |
lpsci_status_flag_t | statusFlag | ||
) |
This function allows the user to clear an individual and specific LPSCI status flag. Refer to structure definition lpsci_status_flag_t for list of status bits.
base | LPSCI module base pointer. |
statusFlag | The desired LPSCI status flag to clear. |
|
inlinestatic |
The function configures the LPSCI to either operate or cease to operate when wait mode is entered.
base | LPSCI module base pointer. |
mode | The LPSCI wait mode operation - operates or ceases to operate in wait mode. |
|
inlinestatic |
This function returns kLpsciOperates if the LPSCI has been configured to operate in wait mode. Else it returns KLpsciStops if the LPSCI has been configured to cease-to-operate in wait mode.
base | LPSCI module base pointer. |
|
inlinestatic |
This function enables or disables the LPSCI loopback operation.
base | LPSCI module base pointer. |
enable | The LPSCI loopback mode configuration, either disabled (false) or enabled (true). |
|
inlinestatic |
This function enables or disables the LPSCI single-wire operation. In some LPSCI bases it is required that the transmitter/receiver be disabled before calling this function. This may be applied to all LPSCIs to ensure safe operation.
base | LPSCI module base pointer. |
source | The LPSCI single-wire mode configuration, either disabled (false) or enabled (true). |
|
inlinestatic |
This function configures the transmitter direction when the LPSCI is configured for single-wire operation.
base | LPSCI module base pointer. |
direction | The LPSCI single-wire mode transmit direction configuration of type lpsci_singlewire_txdir_t (either kLpsciSinglewireTxdirIn or kLpsciSinglewireTxdirOut. |
lpsci_status_t LPSCI_HAL_PutReceiverInStandbyMode | ( | UART0_Type * | base | ) |
This function, when called, places the LPSCI receiver into standby mode. In some LPSCI bases, there are conditions that must be met before placing the receive in standby mode. Before placing LPSCI 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 LPSCI 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 | LPSCI module base pointer. |
|
inlinestatic |
This function, when called, places the LPSCI receiver into normal mode and out of standby mode.
base | LPSCI module base pointer. |
|
inlinestatic |
This function determines the state of the LPSCI receiver. If it returns true, the LPSCI receiver is in standby mode. If it returns false, the LPSCI receiver is in normal mode.
base | LPSCI module base pointer. |
|
inlinestatic |
This function configures the wakeup method of the LPSCI receiver from standby mode. The options are idle-line wake or address-mark wake.
base | LPSCI module base pointer. |
method | The LPSCI receiver wakeup method options: kLpsciIdleLineWake - Idle-line wake or kLpsciAddrMarkWake - address-mark wake. |
|
inlinestatic |
This function returns how the LPSCI receiver is configured to wake from standby mode. The wake method options that can be returned are kLpsciIdleLineWake or kLpsciAddrMarkWake.
base | LPSCI module base pointer. |
void LPSCI_HAL_ConfigIdleLineDetect | ( | UART0_Type * | base, |
uint8_t | idleLine, | ||
uint8_t | rxWakeIdleDetect | ||
) |
This function allows the user to configure the LPSCI 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 lpsci_idle_line_config_t.
base | LPSCI 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 will also set 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 LPSCI break character transmit length. See the typedef lpsci_break_char_length_t for setting options. In some LPSCI bases it is required that the transmitter be disabled before calling this function. This may be applied to all LPSCIs to ensure safe operation.
base | LPSCI module base pointer. |
length | The LPSCI break character length setting of type lpsci_break_char_length_t, either a minimum 10-bit times or a minimum 13-bit times. |
|
inlinestatic |
This function allows the user to configure the LPSCI break character detect length. See the typedef lpsci_break_char_length_t for setting options.
base | LPSCI module base pointer. |
length | The LPSCI break character length setting of type lpsci_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 LPSCI break character to send. If true is passed into the function, a break character is queued for transmission. A break character is continuously be queued until this function is called again when a false is passed into this function.
base | LPSCI module base pointer. |
enable | If false, the LPSCI normal/queue break character setting is disabled, which configures the LPSCI for normal transmitter operation. If true, a break character is queued for transmission. |
void LPSCI_HAL_SetMatchAddress | ( | UART0_Type * | base, |
bool | matchAddrMode1, | ||
bool | matchAddrMode2, | ||
uint8_t | matchAddrValue1, | ||
uint8_t | matchAddrValue2 | ||
) |
Note that this feature is available on select LPSCI bases.
The function allows the user to configure the LPSCI 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 | LPSCI 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. |