| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_uart_hal.h
Go to the documentation of this file.
1 /*!
2 ********************************************************************************
3 * File: fsl_uart_hal.h
4 *
5 * Copyright (c) 2014, Freescale Semiconductor, Inc.
6 *
7 *******************************************************************************/
8 /*!
9 * @file fsl_uart_hal.h
10 * @brief \b fsl_uart_hal.h defines structures and types for the i2c master HAL layer.
11 */
12 #ifndef FSL_UART_HAL_H_
13 #define FSL_UART_HAL_H_
14 #include "isf_types.h"
15 #include <stdbool.h>
16 /*******************************************************************************
17 * Definitions
18 ******************************************************************************/
19
20 /*! @brief Error codes for the UART driver. */
21 typedef enum _uart_status
22 {
23 kStatus_UART_Success = 0,
24 kStatus_UART_BaudRateCalculationError,/*!< UART Baud Rate calculation error out of range. */
25 kStatus_UART_BaudRatePercentDiffExceeded, /*!< UART Baud Rate exceeds percentage difference */
26 kStatus_UART_BitCountNotSupported, /*!< UART bit count config not supported. */
27 kStatus_UART_StopBitCountNotSupported, /*!< UART stop bit count config not supported. */
28 kStatus_UART_RxStandbyModeError, /*!< UART unable to place receiver in standby mode. */
29 kStatus_UART_ClearStatusFlagError, /*!< UART clear status flag error. */
30 kStatus_UART_MSBFirstNotSupported, /*!< UART MSB first feature not supported. */
31 kStatus_UART_ResyncNotSupported, /*!< UART resync disable operation not supported. */
32 kStatus_UART_TxNotDisabled, /*!< UART Transmitter not disabled before enabling feature */
33 kStatus_UART_RxNotDisabled, /*!< UART Receiver not disabled before enabling feature */
34 kStatus_UART_TxOrRxNotDisabled, /*!< UART Transmitter or Receiver not disabled */
35 kStatus_UART_TxBusy, /*!< UART transmit still in progress. */
36 kStatus_UART_RxBusy, /*!< UART receive still in progress. */
37 kStatus_UART_NoTransmitInProgress, /*!< UART no transmit in progress. */
38 kStatus_UART_NoReceiveInProgress, /*!< UART no receive in progress. */
39 kStatus_UART_InvalidInstanceNumber, /*!< Invalid UART instance number. */
40 kStatus_UART_InvalidBitSetting, /*!< Invalid setting for desired UART register bit field. */
41 kStatus_UART_OverSamplingNotSupported, /*!< UART oversampling not supported. */
42 kStatus_UART_BothEdgeNotSupported, /*!< UART both edge sampling not supported. */
43 kStatus_UART_Timeout, /*!< UART transfer timed out.*/
44 kStatus_UART_Error, /*!< UART error.*/
45 } uart_status_t;
46 /*!
47 * @brief UART number of stop bits.
48 *
49 * These constants define the number of allowable stop bits to configure in a UART instance.
50 */
51 typedef enum _uart_stop_bit_count {
52 kUartOneStopBit = 0, /*!< one stop bit. */
53 kUartTwoStopBit = 1, /*!< two stop bits. */
54 } uart_stop_bit_count_t;
55
56 /*!
57 * @brief UART parity mode.
58 *
59 * These constants define the UART parity mode options: disabled or enabled of type even or odd.
60 */
61 typedef enum _uart_parity_mode {
62 kUartParityDisabled = 0x0, /*!< parity disabled */
63 kUartParityEven = 0x2, /*!< parity enabled, type even, bit setting: PE|PT = 10 */
64 kUartParityOdd = 0x3, /*!< parity enabled, type odd, bit setting: PE|PT = 11 */
65 } uart_parity_mode_t;
66
67 /*!
68 * @brief UART number of bits in a character.
69 *
70 * These constants define the number of allowable data bits per UART character. Note, check the
71 * UART documentation to determine if the desired UART instance supports the desired number
72 * of data bits per UART character.
73 */
74 typedef enum _uart_bit_count_per_char {
75 kUart8BitsPerChar = 0, /*!< 8-bit data characters */
76 kUart9BitsPerChar = 1, /*!< 9-bit data characters */
77 kUart10BitsPerChar = 2, /*!< 10-bit data characters */
78 } uart_bit_count_per_char_t;
79
80 /*!
81 * @brief UART operation configuration constants.
82 *
83 * This provides constants for UART operational states: "operates normally"
84 * or "stops/siezes to operation"
85 */
86 typedef enum _uart_operation_config {
87 kUartOperates = 0, /*!< UART continues to operate normally */
88 kUartStops = 1, /*!< UART siezes operation */
89 } uart_operation_config_t;
90
91 /*!
92 * @brief UART wakeup from standby method constants.
93 *
94 * This provides constants for the two UART wakeup methods: idle-line or address-mark.
95 */
96 typedef enum _uart_wakeup_method {
97 kUartIdleLineWake = 0, /*!< The idle-line wakes UART receiver from standby */
98 kUartAddrMarkWake = 1, /*!< The addr-mark wakes UART receiver from standby */
99 } uart_wakeup_method_t;
100
101 /*!
102 * @brief UART idle line detect selection types.
103 *
104 * This provides constants for the UART idle character bit-count start: either after start or
105 * stop bit.
106 */
107 typedef enum _uart_idle_line_select {
108 kUartIdleLineAfterStartBit = 0, /*!< UART idle character bit count start after start bit */
109 kUartIdleLineAfterStopBit = 1, /*!< UART idle character bit count start after stop bit */
110 } uart_idle_line_select_t;
111
112 /*!
113 * @brief UART break character length settings for transmit/detect.
114 *
115 * This provides constants for the UART break character length for both transmission and detection
116 * purposes. Note that the actual maximum bit times may vary depending on the UART instance.
117 */
118 typedef enum _uart_break_char_length {
119 kUartBreakChar10BitMinimum = 0, /*!< UART break char length 10 bit times (if M = 0, SBNS = 0) or
120 11 (if M = 1, SBNS = 0 or M = 0, SBNS = 1) or 12 (if M = 1,
121 SBNS = 1 or M10 = 1, SNBS = 0) or 13 (if M10 = 1, SNBS = 1) */
122 kUartBreakChar13BitMinimum = 1, /*!< UART break char length 13 bit times (if M = 0, SBNS = 0) or
123 14 (if M = 1, SBNS = 0 or M = 0, SBNS = 1) or 15 (if M = 1,
124 SBNS = 1 or M10 = 1, SNBS = 0) or 16 (if M10 = 1, SNBS = 1) */
125 } uart_break_char_length_t;
126
127
128 /*!
129 * @brief UART configuration structure.
130 *
131 * This structure contains the settings for the most common UART configurations including
132 * the UART module source clock, baud rate, parity mode, stop bit count, data bit count per
133 * character, and tx/rx inversion options (which is the least common of the configuration).
134 */
135 typedef struct UartConfig {
136 uint32 uartSourceClockInHz; /*!< UART module source clock in Hz */
137 uint32 baudRate; /*!< UART baud rate */
138 uart_parity_mode_t parityMode; /*!< Parity mode, disabled (default), even, or odd */
139 uart_stop_bit_count_t stopBitCount; /*!< Number of stop bits, 1 stop bit (default)
140 or 2 stop bits */
141 uart_bit_count_per_char_t bitCountPerChar; /*!< Number of bits, 8-bit (default) or 9-bit
142 in a word (up to 10-bits in
143 some UART instances) */
144 unsigned rxDataInvert : 1; /*!< Receive Data Inversion: 0 - not inverted (default),
145 1 - inverted */
146 unsigned txDataInvert : 1; /*!< Transmit Data Inversion: 0 - not inverted (default),
147 1 - inverted */
148 } uart_config_t;
149 /*!
150 * @brief Initialize the UART controller.
151 *
152 * This function will initialize the module to user defined settings and default settings.
153 * Here is an example demonstrating how to define the uart_config_t structure and call
154 * the uart_hal_init function:
155 @code
156 uart_config_t uartConfig;
157 uartConfig.uartSourceClockInHz = uartSourceClock;
158 uartConfig.baudRate = baudRate;
159 uartConfig.bitCountPerChar = kUart8BitsPerChar;
160 uartConfig.parityMode = kUartParityDisabled;
161 uartConfig.stopBitCount = kUartOneStopBit;
162 uartConfig.txDataInvert = 0;
163 uartConfig.rxDataInvert = 0;
164 uart_hal_init(uartInstance, &uartConfig);
165 @endcode
166 *
167 * @param uartInstance UART module instance number.
168 * @param config UART configuration data.
169 * @return An error code or kStatus_UART_Success.
170 */
171 uart_status_t uart_hal_init(uint32 uartInstance, const uart_config_t *config);
172
173 /*!
174 * @brief Enable the UART transmitter.
175 *
176 * This function allows the user to enable the UART transmitter.
177 *
178 * @param uartInstance UART module instance number.
179 */
180 void uart_hal_enable_transmitter(uint32 uartInstance);
181
182 /*!
183 * @brief Disable the UART transmitter.
184 *
185 * This function allows the user to disable the UART transmitter.
186 *
187 * @param uartInstance UART module instance number.
188 */
189 void uart_hal_disable_transmitter(uint32 uartInstance);
190
191
192 /*!
193 * @brief Enable the UART receiver.
194 *
195 * This function allows the user to enable the UART receiver.
196 *
197 * @param uartInstance UART module instance number.
198 */
199 void uart_hal_enable_receiver(uint32 uartInstance);
200
201 /*!
202 * @brief Disable the UART receiver.
203 *
204 * This function allows the user to disable the UART receiver.
205 *
206 * @param uartInstance UART module instance number.
207 */
208 void uart_hal_disable_receiver(uint32 uartInstance);
209
210
211 #endif /* FSL_I2C_HAL_H_ */
212
_uart_stop_bit_count
_uart_stop_bit_count
UART number of stop bits.
Definition: fsl_uart_hal.h:51
kStatus_UART_Success
Definition: fsl_uart_hal.h:23
kStatus_UART_NoReceiveInProgress
Definition: fsl_uart_hal.h:38
UartConfig::uartSourceClockInHz
uint32 uartSourceClockInHz
Definition: fsl_uart_hal.h:136
kStatus_UART_RxStandbyModeError
Definition: fsl_uart_hal.h:28
uart_hal_disable_transmitter
void uart_hal_disable_transmitter(uint32 uartInstance)
Disable the UART transmitter.
kStatus_UART_ClearStatusFlagError
Definition: fsl_uart_hal.h:29
_uart_parity_mode
_uart_parity_mode
UART parity mode.
Definition: fsl_uart_hal.h:61
uart_stop_bit_count_t
enum _uart_stop_bit_count uart_stop_bit_count_t
UART number of stop bits.
_uart_operation_config
_uart_operation_config
UART operation configuration constants.
Definition: fsl_uart_hal.h:86
kStatus_UART_BitCountNotSupported
Definition: fsl_uart_hal.h:26
kStatus_UART_TxBusy
Definition: fsl_uart_hal.h:35
kStatus_UART_StopBitCountNotSupported
Definition: fsl_uart_hal.h:27
uart_hal_disable_receiver
void uart_hal_disable_receiver(uint32 uartInstance)
Disable the UART receiver.
uart_parity_mode_t
enum _uart_parity_mode uart_parity_mode_t
UART parity mode.
kStatus_UART_BothEdgeNotSupported
Definition: fsl_uart_hal.h:42
kStatus_UART_NoTransmitInProgress
Definition: fsl_uart_hal.h:37
kStatus_UART_BaudRateCalculationError
Definition: fsl_uart_hal.h:24
_uart_bit_count_per_char
_uart_bit_count_per_char
UART number of bits in a character.
Definition: fsl_uart_hal.h:74
kUartParityOdd
Definition: fsl_uart_hal.h:64
kStatus_UART_TxNotDisabled
Definition: fsl_uart_hal.h:32
kStatus_UART_RxBusy
Definition: fsl_uart_hal.h:36
UartConfig
UART configuration structure.
Definition: fsl_uart_hal.h:135
UartConfig::stopBitCount
uart_stop_bit_count_t stopBitCount
Definition: fsl_uart_hal.h:139
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
uart_wakeup_method_t
enum _uart_wakeup_method uart_wakeup_method_t
UART wakeup from standby method constants.
kUartIdleLineWake
Definition: fsl_uart_hal.h:97
kStatus_UART_ResyncNotSupported
Definition: fsl_uart_hal.h:31
kUartAddrMarkWake
Definition: fsl_uart_hal.h:98
kUart9BitsPerChar
Definition: fsl_uart_hal.h:76
kUart10BitsPerChar
Definition: fsl_uart_hal.h:77
kStatus_UART_RxNotDisabled
Definition: fsl_uart_hal.h:33
kUartParityDisabled
Definition: fsl_uart_hal.h:62
isf_types.h
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
kUartOperates
Definition: fsl_uart_hal.h:87
UartConfig::parityMode
uart_parity_mode_t parityMode
Definition: fsl_uart_hal.h:138
UartConfig::baudRate
uint32 baudRate
Definition: fsl_uart_hal.h:137
_uart_wakeup_method
_uart_wakeup_method
UART wakeup from standby method constants.
Definition: fsl_uart_hal.h:96
uart_bit_count_per_char_t
enum _uart_bit_count_per_char uart_bit_count_per_char_t
UART number of bits in a character.
kStatus_UART_BaudRatePercentDiffExceeded
Definition: fsl_uart_hal.h:25
UartConfig::bitCountPerChar
uart_bit_count_per_char_t bitCountPerChar
Definition: fsl_uart_hal.h:141
kUartIdleLineAfterStopBit
Definition: fsl_uart_hal.h:109
kUartBreakChar13BitMinimum
Definition: fsl_uart_hal.h:122
uart_status_t
enum _uart_status uart_status_t
Error codes for the UART driver.
uart_break_char_length_t
enum _uart_break_char_length uart_break_char_length_t
UART break character length settings for transmit/detect.
kUartIdleLineAfterStartBit
Definition: fsl_uart_hal.h:108
kUartStops
Definition: fsl_uart_hal.h:88
UartConfig::rxDataInvert
unsigned rxDataInvert
Definition: fsl_uart_hal.h:144
uart_hal_enable_transmitter
void uart_hal_enable_transmitter(uint32 uartInstance)
Enable the UART transmitter.
_uart_idle_line_select
_uart_idle_line_select
UART idle line detect selection types.
Definition: fsl_uart_hal.h:107
_uart_break_char_length
_uart_break_char_length
UART break character length settings for transmit/detect.
Definition: fsl_uart_hal.h:118
kStatus_UART_Timeout
Definition: fsl_uart_hal.h:43
uart_idle_line_select_t
enum _uart_idle_line_select uart_idle_line_select_t
UART idle line detect selection types.
kStatus_UART_InvalidBitSetting
Definition: fsl_uart_hal.h:40
kStatus_UART_Error
Definition: fsl_uart_hal.h:44
UartConfig::txDataInvert
unsigned txDataInvert
Definition: fsl_uart_hal.h:146
_uart_status
_uart_status
Error codes for the UART driver.
Definition: fsl_uart_hal.h:21
uart_hal_init
uart_status_t uart_hal_init(uint32 uartInstance, const uart_config_t *config)
Initialize the UART controller.
kUartTwoStopBit
Definition: fsl_uart_hal.h:53
kStatus_UART_MSBFirstNotSupported
Definition: fsl_uart_hal.h:30
uart_operation_config_t
enum _uart_operation_config uart_operation_config_t
UART operation configuration constants.
kUartOneStopBit
Definition: fsl_uart_hal.h:52
kUartParityEven
Definition: fsl_uart_hal.h:63
kUart8BitsPerChar
Definition: fsl_uart_hal.h:75
kStatus_UART_OverSamplingNotSupported
Definition: fsl_uart_hal.h:41
uart_config_t
struct UartConfig uart_config_t
UART configuration structure.
kUartBreakChar10BitMinimum
Definition: fsl_uart_hal.h:119
uart_hal_enable_receiver
void uart_hal_enable_receiver(uint32 uartInstance)
Enable the UART receiver.
kStatus_UART_TxOrRxNotDisabled
Definition: fsl_uart_hal.h:34
kStatus_UART_InvalidInstanceNumber
Definition: fsl_uart_hal.h:39
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.