rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
fsl_lpuart.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "hal.h"
10#include "fsl_lpuart.h"
11
12/*******************************************************************************
13 * Definitions
14 ******************************************************************************/
15
16/* Component ID definition, used by tools. */
17#ifndef FSL_COMPONENT_ID
18#define FSL_COMPONENT_ID "platform.drivers.lpuart"
19#endif
20
21/* LPUART transfer state. */
23{
24 kLPUART_TxIdle, /*!< TX idle. */
25 kLPUART_TxBusy, /*!< TX busy. */
26 kLPUART_RxIdle, /*!< RX idle. */
27 kLPUART_RxBusy /*!< RX busy. */
28};
29
30/* Typedef for interrupt handler. */
31typedef void (*lpuart_isr_t)(LPUART_Type *base, lpuart_handle_t *handle);
32
33/*******************************************************************************
34 * Prototypes
35 ******************************************************************************/
36/*!
37 * @brief Check whether the RX ring buffer is full.
38 *
39 * @userData handle LPUART handle pointer.
40 * @retval true RX ring buffer is full.
41 * @retval false RX ring buffer is not full.
42 */
43static bool LPUART_TransferIsRxRingBufferFull(LPUART_Type *base, lpuart_handle_t *handle);
44
45/*!
46 * @brief Write to TX register using non-blocking method.
47 *
48 * This function writes data to the TX register directly, upper layer must make
49 * sure the TX register is empty or TX FIFO has empty room before calling this function.
50 *
51 * @note This function does not check whether all the data has been sent out to bus,
52 * so before disable TX, check kLPUART_TransmissionCompleteFlag to ensure the TX is
53 * finished.
54 *
55 * @param base LPUART peripheral base address.
56 * @param data Start address of the data to write.
57 * @param length Size of the buffer to be sent.
58 */
59//!!!!!!!!!!!!!!!!!!!!!!!!
60/*static */void LPUART_WriteNonBlocking(LPUART_Type *base, const uint8_t *data, size_t length);
61
62/*!
63 * @brief Read RX register using non-blocking method.
64 *
65 * This function reads data from the TX register directly, upper layer must make
66 * sure the RX register is full or TX FIFO has data before calling this function.
67 *
68 * @param base LPUART peripheral base address.
69 * @param data Start address of the buffer to store the received data.
70 * @param length Size of the buffer.
71 */
72static void LPUART_ReadNonBlocking(LPUART_Type *base, uint8_t *data, size_t length);
73
74/*******************************************************************************
75 * Variables
76 ******************************************************************************/
77/* Array of LPUART peripheral base address. */
78static LPUART_Type *const s_lpuartBases[] = LPUART_BASE_PTRS;
79/* Array of LPUART handle. */
81/* Array of LPUART IRQ number. */
82#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
83static const IRQn_Type s_lpuartRxIRQ[] = LPUART_RX_IRQS;
84static const IRQn_Type s_lpuartTxIRQ[] = LPUART_TX_IRQS;
85#else
86static const IRQn_Type s_lpuartIRQ[] = LPUART_RX_TX_IRQS;
87#endif
88#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
89/* Array of LPUART clock name. */
90static const clock_ip_name_t s_lpuartClock[] = LPUART_CLOCKS;
91
92#if defined(LPUART_PERIPH_CLOCKS)
93/* Array of LPUART functional clock name. */
94static const clock_ip_name_t s_lpuartPeriphClocks[] = LPUART_PERIPH_CLOCKS;
95#endif
96
97#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
98
99/* LPUART ISR for transactional APIs. */
101
102/*******************************************************************************
103 * Code
104 ******************************************************************************/
105/*!
106 * brief Get the LPUART instance from peripheral base address.
107 *
108 * param base LPUART peripheral base address.
109 * return LPUART instance.
110 */
111uint32_t LPUART_GetInstance(LPUART_Type *base)
112{
113 uint32_t instance;
114
115 /* Find the instance index from base address mappings. */
116 for (instance = 0; instance < ARRAY_SIZE(s_lpuartBases); instance++)
117 {
118 if (s_lpuartBases[instance] == base)
119 {
120 break;
121 }
122 }
123
124 assert(instance < ARRAY_SIZE(s_lpuartBases));
125
126 return instance;
127}
128
129/*!
130 * brief Get the length of received data in RX ring buffer.
131 *
132 * userData handle LPUART handle pointer.
133 * return Length of received data in RX ring buffer.
134 */
136{
137 assert(handle);
138
139 size_t size;
140
141 if (handle->rxRingBufferTail > handle->rxRingBufferHead)
142 {
143 size = (size_t)(handle->rxRingBufferHead + handle->rxRingBufferSize - handle->rxRingBufferTail);
144 }
145 else
146 {
147 size = (size_t)(handle->rxRingBufferHead - handle->rxRingBufferTail);
148 }
149
150 return size;
151}
152
153static bool LPUART_TransferIsRxRingBufferFull(LPUART_Type *base, lpuart_handle_t *handle)
154{
155 assert(handle);
156
157 bool full;
158
159 if (LPUART_TransferGetRxRingBufferLength(base, handle) == (handle->rxRingBufferSize - 1U))
160 {
161 full = true;
162 }
163 else
164 {
165 full = false;
166 }
167 return full;
168}
169
170//!!!!!!!!!!!!!!!!
171/*static */void LPUART_WriteNonBlocking(LPUART_Type *base, const uint8_t *data, size_t length)
172{
173 assert(data);
174
175 size_t i;
176
177 /* The Non Blocking write data API assume user have ensured there is enough space in
178 peripheral to write. */
179 for (i = 0; i < length; i++)
180 {
181 base->DATA = data[i];
182 }
183}
184
185static void LPUART_ReadNonBlocking(LPUART_Type *base, uint8_t *data, size_t length)
186{
187 assert(data);
188
189 size_t i;
190#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
191 uint32_t ctrl = base->CTRL;
192 bool isSevenDataBits =
193 ((ctrl & LPUART_CTRL_M7_MASK) || ((!(ctrl & LPUART_CTRL_M_MASK)) && (ctrl & LPUART_CTRL_PE_MASK)));
194#endif
195
196 /* The Non Blocking read data API assume user have ensured there is enough space in
197 peripheral to write. */
198 for (i = 0; i < length; i++)
199 {
200#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
201 if (isSevenDataBits)
202 {
203 data[i] = (base->DATA & 0x7F);
204 }
205 else
206 {
207 data[i] = base->DATA;
208 }
209#else
210 data[i] = base->DATA;
211#endif
212 }
213}
214
215/*!
216 * brief Initializes an LPUART instance with the user configuration structure and the peripheral clock.
217 *
218 * This function configures the LPUART module with user-defined settings. Call the LPUART_GetDefaultConfig() function
219 * to configure the configuration structure and get the default configuration.
220 * The example below shows how to use this API to configure the LPUART.
221 * code
222 * lpuart_config_t lpuartConfig;
223 * lpuartConfig.baudRate_Bps = 115200U;
224 * lpuartConfig.parityMode = kLPUART_ParityDisabled;
225 * lpuartConfig.dataBitsCount = kLPUART_EightDataBits;
226 * lpuartConfig.isMsb = false;
227 * lpuartConfig.stopBitCount = kLPUART_OneStopBit;
228 * lpuartConfig.txFifoWatermark = 0;
229 * lpuartConfig.rxFifoWatermark = 1;
230 * LPUART_Init(LPUART1, &lpuartConfig, 20000000U);
231 * endcode
232 *
233 * param base LPUART peripheral base address.
234 * param config Pointer to a user-defined configuration structure.
235 * param srcClock_Hz LPUART clock source frequency in HZ.
236 * retval kStatus_LPUART_BaudrateNotSupport Baudrate is not support in current clock source.
237 * retval kStatus_Success LPUART initialize succeed
238 */
239status_t LPUART_Init(LPUART_Type *base, const lpuart_config_t *config, uint32_t srcClock_Hz)
240{
241 assert(config);
242 assert(config->baudRate_Bps);
243#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
244 assert(FSL_FEATURE_LPUART_FIFO_SIZEn(base) >= config->txFifoWatermark);
245 assert(FSL_FEATURE_LPUART_FIFO_SIZEn(base) >= config->rxFifoWatermark);
246#endif
247
248 uint32_t temp;
249 uint16_t sbr, sbrTemp;
250 uint32_t osr, osrTemp, tempDiff, calculatedBaud, baudDiff;
251
252 /* This LPUART instantiation uses a slightly different baud rate calculation
253 * The idea is to use the best OSR (over-sampling rate) possible
254 * Note, OSR is typically hard-set to 16 in other LPUART instantiations
255 * loop to find the best OSR value possible, one that generates minimum baudDiff
256 * iterate through the rest of the supported values of OSR */
257
258 baudDiff = config->baudRate_Bps;
259 osr = 0;
260 sbr = 0;
261 for (osrTemp = 4; osrTemp <= 32; osrTemp++)
262 {
263 /* calculate the temporary sbr value */
264 sbrTemp = (srcClock_Hz / (config->baudRate_Bps * osrTemp));
265 /*set sbrTemp to 1 if the sourceClockInHz can not satisfy the desired baud rate*/
266 if (sbrTemp == 0)
267 {
268 sbrTemp = 1;
269 }
270 /* Calculate the baud rate based on the temporary OSR and SBR values */
271 calculatedBaud = (srcClock_Hz / (osrTemp * sbrTemp));
272
273 tempDiff = calculatedBaud - config->baudRate_Bps;
274
275 /* Select the better value between srb and (sbr + 1) */
276 if (tempDiff > (config->baudRate_Bps - (srcClock_Hz / (osrTemp * (sbrTemp + 1)))))
277 {
278 tempDiff = config->baudRate_Bps - (srcClock_Hz / (osrTemp * (sbrTemp + 1)));
279 sbrTemp++;
280 }
281
282 if (tempDiff <= baudDiff)
283 {
284 baudDiff = tempDiff;
285 osr = osrTemp; /* update and store the best OSR value calculated */
286 sbr = sbrTemp; /* update store the best SBR value calculated */
287 }
288 }
289
290 /* Check to see if actual baud rate is within 3% of desired baud rate
291 * based on the best calculate OSR value */
292 if (baudDiff > ((config->baudRate_Bps / 100) * 3))
293 {
294 /* Unacceptable baud rate difference of more than 3%*/
296 }
297
298#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
299
300 uint32_t instance = LPUART_GetInstance(base);
301
302 /* Enable lpuart clock */
304#if defined(LPUART_PERIPH_CLOCKS)
306#endif
307
308#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
309
310#if defined(FSL_FEATURE_LPUART_HAS_GLOBAL) && FSL_FEATURE_LPUART_HAS_GLOBAL
311 /*Reset all internal logic and registers, except the Global Register */
313#else
314 /* Disable LPUART TX RX before setting. */
315 base->CTRL &= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);
316#endif
317
318 temp = base->BAUD;
319
320 /* Acceptable baud rate, check if OSR is between 4x and 7x oversampling.
321 * If so, then "BOTHEDGE" sampling must be turned on */
322 if ((osr > 3) && (osr < 8))
323 {
324 temp |= LPUART_BAUD_BOTHEDGE_MASK;
325 }
326
327 /* program the osr value (bit value is one less than actual value) */
328 temp &= ~LPUART_BAUD_OSR_MASK;
329 temp |= LPUART_BAUD_OSR(osr - 1);
330
331 /* write the sbr value to the BAUD registers */
332 temp &= ~LPUART_BAUD_SBR_MASK;
333 base->BAUD = temp | LPUART_BAUD_SBR(sbr);
334
335 /* Set bit count and parity mode. */
336 base->BAUD &= ~LPUART_BAUD_M10_MASK;
337
338 temp = base->CTRL &
339 ~(LPUART_CTRL_PE_MASK | LPUART_CTRL_PT_MASK | LPUART_CTRL_M_MASK | LPUART_CTRL_ILT_MASK |
340 LPUART_CTRL_IDLECFG_MASK);
341
342 temp |=
343 (uint8_t)config->parityMode | LPUART_CTRL_IDLECFG(config->rxIdleConfig) | LPUART_CTRL_ILT(config->rxIdleType);
344
345#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
346 if (kLPUART_SevenDataBits == config->dataBitsCount)
347 {
348 if (kLPUART_ParityDisabled != config->parityMode)
349 {
350 temp &= ~LPUART_CTRL_M7_MASK; /* Seven data bits and one parity bit */
351 }
352 else
353 {
354 temp |= LPUART_CTRL_M7_MASK;
355 }
356 }
357 else
358#endif
359 {
360 if (kLPUART_ParityDisabled != config->parityMode)
361 {
362 temp |= LPUART_CTRL_M_MASK; /* Eight data bits and one parity bit */
363 }
364 }
365
366 base->CTRL = temp;
367
368#if defined(FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT
369 /* set stop bit per char */
370 temp = base->BAUD & ~LPUART_BAUD_SBNS_MASK;
371 base->BAUD = temp | LPUART_BAUD_SBNS((uint8_t)config->stopBitCount);
372#endif
373
374#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
375 /* Set tx/rx WATER watermark
376 Note:
377 Take care of the RX FIFO, RX interrupt request only assert when received bytes
378 equal or more than RX water mark, there is potential issue if RX water
379 mark larger than 1.
380 For example, if RX FIFO water mark is 2, upper layer needs 5 bytes and
381 5 bytes are received. the last byte will be saved in FIFO but not trigger
382 RX interrupt because the water mark is 2.
383 */
384 base->WATER = (((uint32_t)(config->rxFifoWatermark) << 16) | config->txFifoWatermark);
385
386 /* Enable tx/rx FIFO */
387 base->FIFO |= (LPUART_FIFO_TXFE_MASK | LPUART_FIFO_RXFE_MASK);
388
389 /* Flush FIFO */
390 base->FIFO |= (LPUART_FIFO_TXFLUSH_MASK | LPUART_FIFO_RXFLUSH_MASK);
391#endif
392
393 /* Clear all status flags */
394 temp = (LPUART_STAT_RXEDGIF_MASK | LPUART_STAT_IDLE_MASK | LPUART_STAT_OR_MASK | LPUART_STAT_NF_MASK |
395 LPUART_STAT_FE_MASK | LPUART_STAT_PF_MASK);
396
397#if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT
398 temp |= LPUART_STAT_LBKDIF_MASK;
399#endif
400
401#if defined(FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING) && FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING
402 temp |= (LPUART_STAT_MA1F_MASK | LPUART_STAT_MA2F_MASK);
403#endif
404
405#if defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
406 /* Set the CTS configuration/TX CTS source. */
407 base->MODIR |= LPUART_MODIR_TXCTSC(config->txCtsConfig) | LPUART_MODIR_TXCTSSRC(config->txCtsSource);
408 if (config->enableRxRTS)
409 {
410 /* Enable the receiver RTS(request-to-send) function. */
411 base->MODIR |= LPUART_MODIR_RXRTSE_MASK;
412 }
413 if (config->enableTxCTS)
414 {
415 /* Enable the CTS(clear-to-send) function. */
416 base->MODIR |= LPUART_MODIR_TXCTSE_MASK;
417 }
418#endif
419
420 /* Set data bits order. */
421 if (config->isMsb)
422 {
423 temp |= LPUART_STAT_MSBF_MASK;
424 }
425 else
426 {
427 temp &= ~LPUART_STAT_MSBF_MASK;
428 }
429
430 base->STAT |= temp;
431
432 /* Enable TX/RX base on configure structure. */
433 temp = base->CTRL;
434 if (config->enableTx)
435 {
436 temp |= LPUART_CTRL_TE_MASK;
437 }
438
439 if (config->enableRx)
440 {
441 temp |= LPUART_CTRL_RE_MASK;
442 }
443
444 base->CTRL = temp;
445
446 return kStatus_Success;
447}
448/*!
449 * brief Deinitializes a LPUART instance.
450 *
451 * This function waits for transmit to complete, disables TX and RX, and disables the LPUART clock.
452 *
453 * param base LPUART peripheral base address.
454 */
455void LPUART_Deinit(LPUART_Type *base)
456{
457 uint32_t temp;
458
459#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
460 /* Wait tx FIFO send out*/
461 while (0 != ((base->WATER & LPUART_WATER_TXCOUNT_MASK) >> LPUART_WATER_TXWATER_SHIFT))
462 {
463 }
464#endif
465 /* Wait last char shift out */
466 while (0 == (base->STAT & LPUART_STAT_TC_MASK))
467 {
468 }
469
470 /* Clear all status flags */
471 temp = (LPUART_STAT_RXEDGIF_MASK | LPUART_STAT_IDLE_MASK | LPUART_STAT_OR_MASK | LPUART_STAT_NF_MASK |
472 LPUART_STAT_FE_MASK | LPUART_STAT_PF_MASK);
473
474#if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT
475 temp |= LPUART_STAT_LBKDIF_MASK;
476#endif
477
478#if defined(FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING) && FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING
479 temp |= (LPUART_STAT_MA1F_MASK | LPUART_STAT_MA2F_MASK);
480#endif
481
482 base->STAT |= temp;
483
484 /* Disable the module. */
485 base->CTRL = 0;
486
487#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
488 uint32_t instance = LPUART_GetInstance(base);
489
490 /* Disable lpuart clock */
492
493#if defined(LPUART_PERIPH_CLOCKS)
495#endif
496
497#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
498}
499
500/*!
501 * brief Gets the default configuration structure.
502 *
503 * This function initializes the LPUART configuration structure to a default value. The default
504 * values are:
505 * lpuartConfig->baudRate_Bps = 115200U;
506 * lpuartConfig->parityMode = kLPUART_ParityDisabled;
507 * lpuartConfig->dataBitsCount = kLPUART_EightDataBits;
508 * lpuartConfig->isMsb = false;
509 * lpuartConfig->stopBitCount = kLPUART_OneStopBit;
510 * lpuartConfig->txFifoWatermark = 0;
511 * lpuartConfig->rxFifoWatermark = 1;
512 * lpuartConfig->rxIdleType = kLPUART_IdleTypeStartBit;
513 * lpuartConfig->rxIdleConfig = kLPUART_IdleCharacter1;
514 * lpuartConfig->enableTx = false;
515 * lpuartConfig->enableRx = false;
516 *
517 * param config Pointer to a configuration structure.
518 */
520{
521 assert(config);
522
523 /* Initializes the configure structure to zero. */
524 memset(config, 0, sizeof(*config));
525
526 config->baudRate_Bps = 115200U;
527 config->parityMode = kLPUART_ParityDisabled;
528 config->dataBitsCount = kLPUART_EightDataBits;
529 config->isMsb = false;
530#if defined(FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT
531 config->stopBitCount = kLPUART_OneStopBit;
532#endif
533#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
534 config->txFifoWatermark = 0;
535 config->rxFifoWatermark = 0;
536#endif
537#if defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
538 config->enableRxRTS = false;
539 config->enableTxCTS = false;
540 config->txCtsConfig = kLPUART_CtsSampleAtStart;
541 config->txCtsSource = kLPUART_CtsSourcePin;
542#endif
543 config->rxIdleType = kLPUART_IdleTypeStartBit;
544 config->rxIdleConfig = kLPUART_IdleCharacter1;
545 config->enableTx = false;
546 config->enableRx = false;
547}
548
549/*!
550 * brief Sets the LPUART instance baudrate.
551 *
552 * This function configures the LPUART module baudrate. This function is used to update
553 * the LPUART module baudrate after the LPUART module is initialized by the LPUART_Init.
554 * code
555 * LPUART_SetBaudRate(LPUART1, 115200U, 20000000U);
556 * endcode
557 *
558 * param base LPUART peripheral base address.
559 * param baudRate_Bps LPUART baudrate to be set.
560 * param srcClock_Hz LPUART clock source frequency in HZ.
561 * retval kStatus_LPUART_BaudrateNotSupport Baudrate is not supported in the current clock source.
562 * retval kStatus_Success Set baudrate succeeded.
563 */
564status_t LPUART_SetBaudRate(LPUART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz)
565{
566 assert(baudRate_Bps);
567
568 uint32_t temp, oldCtrl;
569 uint16_t sbr, sbrTemp;
570 uint32_t osr, osrTemp, tempDiff, calculatedBaud, baudDiff;
571
572 /* This LPUART instantiation uses a slightly different baud rate calculation
573 * The idea is to use the best OSR (over-sampling rate) possible
574 * Note, OSR is typically hard-set to 16 in other LPUART instantiations
575 * loop to find the best OSR value possible, one that generates minimum baudDiff
576 * iterate through the rest of the supported values of OSR */
577
578 baudDiff = baudRate_Bps;
579 osr = 0;
580 sbr = 0;
581 for (osrTemp = 4; osrTemp <= 32; osrTemp++)
582 {
583 /* calculate the temporary sbr value */
584 sbrTemp = (srcClock_Hz / (baudRate_Bps * osrTemp));
585 /*set sbrTemp to 1 if the sourceClockInHz can not satisfy the desired baud rate*/
586 if (sbrTemp == 0)
587 {
588 sbrTemp = 1;
589 }
590 /* Calculate the baud rate based on the temporary OSR and SBR values */
591 calculatedBaud = (srcClock_Hz / (osrTemp * sbrTemp));
592
593 tempDiff = calculatedBaud - baudRate_Bps;
594
595 /* Select the better value between srb and (sbr + 1) */
596 if (tempDiff > (baudRate_Bps - (srcClock_Hz / (osrTemp * (sbrTemp + 1)))))
597 {
598 tempDiff = baudRate_Bps - (srcClock_Hz / (osrTemp * (sbrTemp + 1)));
599 sbrTemp++;
600 }
601
602 if (tempDiff <= baudDiff)
603 {
604 baudDiff = tempDiff;
605 osr = osrTemp; /* update and store the best OSR value calculated */
606 sbr = sbrTemp; /* update store the best SBR value calculated */
607 }
608 }
609
610 /* Check to see if actual baud rate is within 3% of desired baud rate
611 * based on the best calculate OSR value */
612 if (baudDiff < ((baudRate_Bps / 100) * 3))
613 {
614 /* Store CTRL before disable Tx and Rx */
615 oldCtrl = base->CTRL;
616
617 /* Disable LPUART TX RX before setting. */
618 base->CTRL &= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);
619
620 temp = base->BAUD;
621
622 /* Acceptable baud rate, check if OSR is between 4x and 7x oversampling.
623 * If so, then "BOTHEDGE" sampling must be turned on */
624 if ((osr > 3) && (osr < 8))
625 {
626 temp |= LPUART_BAUD_BOTHEDGE_MASK;
627 }
628
629 /* program the osr value (bit value is one less than actual value) */
630 temp &= ~LPUART_BAUD_OSR_MASK;
631 temp |= LPUART_BAUD_OSR(osr - 1);
632
633 /* write the sbr value to the BAUD registers */
634 temp &= ~LPUART_BAUD_SBR_MASK;
635 base->BAUD = temp | LPUART_BAUD_SBR(sbr);
636
637 /* Restore CTRL. */
638 base->CTRL = oldCtrl;
639
640 return kStatus_Success;
641 }
642 else
643 {
644 /* Unacceptable baud rate difference of more than 3%*/
646 }
647}
648
649/*!
650 * brief Enables LPUART interrupts according to a provided mask.
651 *
652 * This function enables the LPUART interrupts according to a provided mask. The mask
653 * is a logical OR of enumeration members. See the ref _lpuart_interrupt_enable.
654 * This examples shows how to enable TX empty interrupt and RX full interrupt:
655 * code
656 * LPUART_EnableInterrupts(LPUART1,kLPUART_TxDataRegEmptyInterruptEnable | kLPUART_RxDataRegFullInterruptEnable);
657 * endcode
658 *
659 * param base LPUART peripheral base address.
660 * param mask The interrupts to enable. Logical OR of ref _uart_interrupt_enable.
661 */
662void LPUART_EnableInterrupts(LPUART_Type *base, uint32_t mask)
663{
664 base->BAUD |= ((mask << 8) & (LPUART_BAUD_LBKDIE_MASK | LPUART_BAUD_RXEDGIE_MASK));
665#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
666 base->FIFO = (base->FIFO & ~(LPUART_FIFO_TXOF_MASK | LPUART_FIFO_RXUF_MASK)) |
667 ((mask << 8) & (LPUART_FIFO_TXOFE_MASK | LPUART_FIFO_RXUFE_MASK));
668#endif
669 mask &= 0xFFFFFF00U;
670 base->CTRL |= mask;
671}
672
673/*!
674 * brief Disables LPUART interrupts according to a provided mask.
675 *
676 * This function disables the LPUART interrupts according to a provided mask. The mask
677 * is a logical OR of enumeration members. See ref _lpuart_interrupt_enable.
678 * This example shows how to disable the TX empty interrupt and RX full interrupt:
679 * code
680 * LPUART_DisableInterrupts(LPUART1,kLPUART_TxDataRegEmptyInterruptEnable | kLPUART_RxDataRegFullInterruptEnable);
681 * endcode
682 *
683 * param base LPUART peripheral base address.
684 * param mask The interrupts to disable. Logical OR of ref _lpuart_interrupt_enable.
685 */
686void LPUART_DisableInterrupts(LPUART_Type *base, uint32_t mask)
687{
688 base->BAUD &= ~((mask << 8) & (LPUART_BAUD_LBKDIE_MASK | LPUART_BAUD_RXEDGIE_MASK));
689#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
690 base->FIFO = (base->FIFO & ~(LPUART_FIFO_TXOF_MASK | LPUART_FIFO_RXUF_MASK)) &
691 ~((mask << 8) & (LPUART_FIFO_TXOFE_MASK | LPUART_FIFO_RXUFE_MASK));
692#endif
693 mask &= 0xFFFFFF00U;
694 base->CTRL &= ~mask;
695}
696
697/*!
698 * brief Gets enabled LPUART interrupts.
699 *
700 * This function gets the enabled LPUART interrupts. The enabled interrupts are returned
701 * as the logical OR value of the enumerators ref _lpuart_interrupt_enable. To check
702 * a specific interrupt enable status, compare the return value with enumerators
703 * in ref _lpuart_interrupt_enable.
704 * For example, to check whether the TX empty interrupt is enabled:
705 * code
706 * uint32_t enabledInterrupts = LPUART_GetEnabledInterrupts(LPUART1);
707 *
708 * if (kLPUART_TxDataRegEmptyInterruptEnable & enabledInterrupts)
709 * {
710 * ...
711 * }
712 * endcode
713 *
714 * param base LPUART peripheral base address.
715 * return LPUART interrupt flags which are logical OR of the enumerators in ref _lpuart_interrupt_enable.
716 */
717uint32_t LPUART_GetEnabledInterrupts(LPUART_Type *base)
718{
719 uint32_t temp;
720 temp = (base->BAUD & (LPUART_BAUD_LBKDIE_MASK | LPUART_BAUD_RXEDGIE_MASK)) >> 8;
721#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
722 temp |= (base->FIFO & (LPUART_FIFO_TXOFE_MASK | LPUART_FIFO_RXUFE_MASK)) >> 8;
723#endif
724 temp |= (base->CTRL & 0xFF0C000);
725
726 return temp;
727}
728
729/*!
730 * brief Gets LPUART status flags.
731 *
732 * This function gets all LPUART status flags. The flags are returned as the logical
733 * OR value of the enumerators ref _lpuart_flags. To check for a specific status,
734 * compare the return value with enumerators in the ref _lpuart_flags.
735 * For example, to check whether the TX is empty:
736 * code
737 * if (kLPUART_TxDataRegEmptyFlag & LPUART_GetStatusFlags(LPUART1))
738 * {
739 * ...
740 * }
741 * endcode
742 *
743 * param base LPUART peripheral base address.
744 * return LPUART status flags which are ORed by the enumerators in the _lpuart_flags.
745 */
746uint32_t LPUART_GetStatusFlags(LPUART_Type *base)
747{
748 uint32_t temp;
749 temp = base->STAT;
750#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
751 temp |= (base->FIFO &
752 (LPUART_FIFO_TXEMPT_MASK | LPUART_FIFO_RXEMPT_MASK | LPUART_FIFO_TXOF_MASK | LPUART_FIFO_RXUF_MASK)) >>
753 16;
754#endif
755 return temp;
756}
757
758/*!
759 * brief Clears status flags with a provided mask.
760 *
761 * This function clears LPUART status flags with a provided mask. Automatically cleared flags
762 * can't be cleared by this function.
763 * Flags that can only cleared or set by hardware are:
764 * kLPUART_TxDataRegEmptyFlag, kLPUART_TransmissionCompleteFlag, kLPUART_RxDataRegFullFlag,
765 * kLPUART_RxActiveFlag, kLPUART_NoiseErrorInRxDataRegFlag, kLPUART_ParityErrorInRxDataRegFlag,
766 * kLPUART_TxFifoEmptyFlag,kLPUART_RxFifoEmptyFlag
767 * Note: This API should be called when the Tx/Rx is idle, otherwise it takes no effects.
768 *
769 * param base LPUART peripheral base address.
770 * param mask the status flags to be cleared. The user can use the enumerators in the
771 * _lpuart_status_flag_t to do the OR operation and get the mask.
772 * return 0 succeed, others failed.
773 * retval kStatus_LPUART_FlagCannotClearManually The flag can't be cleared by this function but
774 * it is cleared automatically by hardware.
775 * retval kStatus_Success Status in the mask are cleared.
776 */
777status_t LPUART_ClearStatusFlags(LPUART_Type *base, uint32_t mask)
778{
779 uint32_t temp;
780 status_t status;
781#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
782 temp = (uint32_t)base->FIFO;
783 temp &= (uint32_t)(~(LPUART_FIFO_TXOF_MASK | LPUART_FIFO_RXUF_MASK));
784 temp |= (mask << 16) & (LPUART_FIFO_TXOF_MASK | LPUART_FIFO_RXUF_MASK);
785 base->FIFO = temp;
786#endif
787 temp = (uint32_t)base->STAT;
788#if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT
789 temp &= (uint32_t)(~(LPUART_STAT_LBKDIF_MASK));
790 temp |= mask & LPUART_STAT_LBKDIF_MASK;
791#endif
792 temp &= (uint32_t)(~(LPUART_STAT_RXEDGIF_MASK | LPUART_STAT_IDLE_MASK | LPUART_STAT_OR_MASK | LPUART_STAT_NF_MASK |
793 LPUART_STAT_FE_MASK | LPUART_STAT_PF_MASK));
794 temp |= mask & (LPUART_STAT_RXEDGIF_MASK | LPUART_STAT_IDLE_MASK | LPUART_STAT_OR_MASK | LPUART_STAT_NF_MASK |
795 LPUART_STAT_FE_MASK | LPUART_STAT_PF_MASK);
796#if defined(FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING) && FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING
797 temp &= (uint32_t)(~(LPUART_STAT_MA2F_MASK | LPUART_STAT_MA1F_MASK));
798 temp |= mask & (LPUART_STAT_MA2F_MASK | LPUART_STAT_MA1F_MASK);
799#endif
800 base->STAT = temp;
801 /* If some flags still pending. */
802 if (mask & LPUART_GetStatusFlags(base))
803 {
804 /* Some flags can only clear or set by the hardware itself, these flags are: kLPUART_TxDataRegEmptyFlag,
805 kLPUART_TransmissionCompleteFlag, kLPUART_RxDataRegFullFlag, kLPUART_RxActiveFlag,
806 kLPUART_NoiseErrorInRxDataRegFlag, kLPUART_ParityErrorInRxDataRegFlag,
807 kLPUART_TxFifoEmptyFlag, kLPUART_RxFifoEmptyFlag. */
808 status = kStatus_LPUART_FlagCannotClearManually; /* flags can not clear manually */
809 }
810 else
811 {
812 status = kStatus_Success;
813 }
814
815 return status;
816}
817
818/*!
819 * brief Writes to the transmitter register using a blocking method.
820 *
821 * This function polls the transmitter register, waits for the register to be empty or for TX FIFO to have
822 * room, and writes data to the transmitter buffer.
823 *
824 * note This function does not check whether all data has been sent out to the bus.
825 * Before disabling the transmitter, check the kLPUART_TransmissionCompleteFlag to ensure that the transmit is
826 * finished.
827 *
828 * param base LPUART peripheral base address.
829 * param data Start address of the data to write.
830 * param length Size of the data to write.
831 */
832void LPUART_WriteBlocking(LPUART_Type *base, const uint8_t *data, size_t length)
833{
834 assert(data);
835
836 /* This API can only ensure that the data is written into the data buffer but can't
837 ensure all data in the data buffer are sent into the transmit shift buffer. */
838 while (length--)
839 {
840 while (!(base->STAT & LPUART_STAT_TDRE_MASK))
841 {
842 }
843 base->DATA = *(data++);
844 }
845}
846
847/*!
848* brief Reads the receiver data register using a blocking method.
849 *
850 * This function polls the receiver register, waits for the receiver register full or receiver FIFO
851 * has data, and reads data from the TX register.
852 *
853 * param base LPUART peripheral base address.
854 * param data Start address of the buffer to store the received data.
855 * param length Size of the buffer.
856 * retval kStatus_LPUART_RxHardwareOverrun Receiver overrun happened while receiving data.
857 * retval kStatus_LPUART_NoiseError Noise error happened while receiving data.
858 * retval kStatus_LPUART_FramingError Framing error happened while receiving data.
859 * retval kStatus_LPUART_ParityError Parity error happened while receiving data.
860 * retval kStatus_Success Successfully received all data.
861 */
862status_t LPUART_ReadBlocking(LPUART_Type *base, uint8_t *data, size_t length)
863{
864 assert(data);
865
866 uint32_t statusFlag;
867#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
868 uint32_t ctrl = base->CTRL;
869 bool isSevenDataBits =
870 ((ctrl & LPUART_CTRL_M7_MASK) || ((!(ctrl & LPUART_CTRL_M_MASK)) && (ctrl & LPUART_CTRL_PE_MASK)));
871#endif
872
873 while (length--)
874 {
875#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
876 while (0 == ((base->WATER & LPUART_WATER_RXCOUNT_MASK) >> LPUART_WATER_RXCOUNT_SHIFT))
877#else
878 while (!(base->STAT & LPUART_STAT_RDRF_MASK))
879#endif
880 {
881 statusFlag = LPUART_GetStatusFlags(base);
882
883 if (statusFlag & kLPUART_RxOverrunFlag)
884 {
887 }
888
889 if (statusFlag & kLPUART_NoiseErrorFlag)
890 {
893 }
894
895 if (statusFlag & kLPUART_FramingErrorFlag)
896 {
899 }
900
901 if (statusFlag & kLPUART_ParityErrorFlag)
902 {
905 }
906 }
907#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
908 if (isSevenDataBits)
909 {
910 *(data++) = (base->DATA & 0x7F);
911 }
912 else
913 {
914 *(data++) = base->DATA;
915 }
916#else
917 *(data++) = base->DATA;
918#endif
919 }
920
921 return kStatus_Success;
922}
923
924/*!
925 * brief Initializes the LPUART handle.
926 *
927 * This function initializes the LPUART handle, which can be used for other LPUART
928 * transactional APIs. Usually, for a specified LPUART instance,
929 * call this API once to get the initialized handle.
930 *
931 * The LPUART driver supports the "background" receiving, which means that user can set up
932 * an RX ring buffer optionally. Data received is stored into the ring buffer even when the
933 * user doesn't call the LPUART_TransferReceiveNonBlocking() API. If there is already data received
934 * in the ring buffer, the user can get the received data from the ring buffer directly.
935 * The ring buffer is disabled if passing NULL as p ringBuffer.
936 *
937 * param base LPUART peripheral base address.
938 * param handle LPUART handle pointer.
939 * param callback Callback function.
940 * param userData User data.
941 */
942void LPUART_TransferCreateHandle(LPUART_Type *base,
943 lpuart_handle_t *handle,
945 void *userData)
946{
947 assert(handle);
948
949 uint32_t instance;
950#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
951 uint32_t ctrl = base->CTRL;
952 bool isSevenDataBits =
953 ((ctrl & LPUART_CTRL_M7_MASK) || ((!(ctrl & LPUART_CTRL_M_MASK)) && (ctrl & LPUART_CTRL_PE_MASK)));
954#endif
955
956 /* Zero the handle. */
957 memset(handle, 0, sizeof(lpuart_handle_t));
958
959 /* Set the TX/RX state. */
960 handle->rxState = kLPUART_RxIdle;
961 handle->txState = kLPUART_TxIdle;
962
963 /* Set the callback and user data. */
964 handle->callback = callback;
965 handle->userData = userData;
966
967#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
968 /* Initial seven data bits flag */
969 handle->isSevenDataBits = isSevenDataBits;
970#endif
971
972 /* Get instance from peripheral base address. */
974
975 /* Save the handle in global variables to support the double weak mechanism. */
976 s_lpuartHandle[instance] = handle;
977
979
980/* Enable interrupt in NVIC. */
981#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
982 EnableIRQ(s_lpuartRxIRQ[instance]);
983 EnableIRQ(s_lpuartTxIRQ[instance]);
984#else
985 EnableIRQ(s_lpuartIRQ[instance]);
986#endif
987}
988
989/*!
990 * brief Sets up the RX ring buffer.
991 *
992 * This function sets up the RX ring buffer to a specific UART handle.
993 *
994 * When the RX ring buffer is used, data received is stored into the ring buffer even when
995 * the user doesn't call the UART_TransferReceiveNonBlocking() API. If there is already data received
996 * in the ring buffer, the user can get the received data from the ring buffer directly.
997 *
998 * note When using RX ring buffer, one byte is reserved for internal use. In other
999 * words, if p ringBufferSize is 32, then only 31 bytes are used for saving data.
1000 *
1001 * param base LPUART peripheral base address.
1002 * param handle LPUART handle pointer.
1003 * param ringBuffer Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer.
1004 * param ringBufferSize size of the ring buffer.
1005 */
1006void LPUART_TransferStartRingBuffer(LPUART_Type *base,
1007 lpuart_handle_t *handle,
1008 uint8_t *ringBuffer,
1009 size_t ringBufferSize)
1010{
1011 assert(handle);
1012 assert(ringBuffer);
1013
1014 /* Setup the ring buffer address */
1015 handle->rxRingBuffer = ringBuffer;
1016 handle->rxRingBufferSize = ringBufferSize;
1017 handle->rxRingBufferHead = 0U;
1018 handle->rxRingBufferTail = 0U;
1019
1020 /* Enable the interrupt to accept the data when user need the ring buffer. */
1022}
1023
1024/*!
1025 * brief Aborts the background transfer and uninstalls the ring buffer.
1026 *
1027 * This function aborts the background transfer and uninstalls the ring buffer.
1028 *
1029 * param base LPUART peripheral base address.
1030 * param handle LPUART handle pointer.
1031 */
1032void LPUART_TransferStopRingBuffer(LPUART_Type *base, lpuart_handle_t *handle)
1033{
1034 assert(handle);
1035
1036 if (handle->rxState == kLPUART_RxIdle)
1037 {
1039 }
1040
1041 handle->rxRingBuffer = NULL;
1042 handle->rxRingBufferSize = 0U;
1043 handle->rxRingBufferHead = 0U;
1044 handle->rxRingBufferTail = 0U;
1045}
1046
1047/*!
1048 * brief Transmits a buffer of data using the interrupt method.
1049 *
1050 * This function send data using an interrupt method. This is a non-blocking function, which
1051 * returns directly without waiting for all data written to the transmitter register. When
1052 * all data is written to the TX register in the ISR, the LPUART driver calls the callback
1053 * function and passes the ref kStatus_LPUART_TxIdle as status parameter.
1054 *
1055 * note The kStatus_LPUART_TxIdle is passed to the upper layer when all data are written
1056 * to the TX register. However, there is no check to ensure that all the data sent out. Before disabling the TX,
1057 * check the kLPUART_TransmissionCompleteFlag to ensure that the transmit is finished.
1058 *
1059 * param base LPUART peripheral base address.
1060 * param handle LPUART handle pointer.
1061 * param xfer LPUART transfer structure, see #lpuart_transfer_t.
1062 * retval kStatus_Success Successfully start the data transmission.
1063 * retval kStatus_LPUART_TxBusy Previous transmission still not finished, data not all written to the TX register.
1064 * retval kStatus_InvalidArgument Invalid argument.
1065 */
1067{
1068 assert(handle);
1069 assert(xfer);
1070 assert(xfer->data);
1071 assert(xfer->dataSize);
1072
1073 status_t status;
1074
1075 /* Return error if current TX busy. */
1076 if (kLPUART_TxBusy == handle->txState)
1077 {
1078 status = kStatus_LPUART_TxBusy;
1079 }
1080 else
1081 {
1082 handle->txData = xfer->data;
1083 handle->txDataSize = xfer->dataSize;
1084 handle->txDataSizeAll = xfer->dataSize;
1085 handle->txState = kLPUART_TxBusy;
1086
1087 /* Enable transmitter interrupt. */
1089
1090 status = kStatus_Success;
1091 }
1092
1093 return status;
1094}
1095
1096/*!
1097 * brief Aborts the interrupt-driven data transmit.
1098 *
1099 * This function aborts the interrupt driven data sending. The user can get the remainBtyes to find out
1100 * how many bytes are not sent out.
1101 *
1102 * param base LPUART peripheral base address.
1103 * param handle LPUART handle pointer.
1104 */
1105void LPUART_TransferAbortSend(LPUART_Type *base, lpuart_handle_t *handle)
1106{
1107 assert(handle);
1108
1110
1111 handle->txDataSize = 0;
1112 handle->txState = kLPUART_TxIdle;
1113}
1114
1115/*!
1116 * brief Gets the number of bytes that have been written to the LPUART transmitter register.
1117 *
1118 * This function gets the number of bytes that have been written to LPUART TX
1119 * register by an interrupt method.
1120 *
1121 * param base LPUART peripheral base address.
1122 * param handle LPUART handle pointer.
1123 * param count Send bytes count.
1124 * retval kStatus_NoTransferInProgress No send in progress.
1125 * retval kStatus_InvalidArgument Parameter is invalid.
1126 * retval kStatus_Success Get successfully through the parameter \p count;
1127 */
1128status_t LPUART_TransferGetSendCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
1129{
1130 assert(handle);
1131 assert(count);
1132
1133 if (kLPUART_TxIdle == handle->txState)
1134 {
1136 }
1137
1138 *count = handle->txDataSizeAll - handle->txDataSize;
1139
1140 return kStatus_Success;
1141}
1142
1143/*!
1144 * brief Receives a buffer of data using the interrupt method.
1145 *
1146 * This function receives data using an interrupt method. This is a non-blocking function
1147 * which returns without waiting to ensure that all data are received.
1148 * If the RX ring buffer is used and not empty, the data in the ring buffer is copied and
1149 * the parameter p receivedBytes shows how many bytes are copied from the ring buffer.
1150 * After copying, if the data in the ring buffer is not enough for read, the receive
1151 * request is saved by the LPUART driver. When the new data arrives, the receive request
1152 * is serviced first. When all data is received, the LPUART driver notifies the upper layer
1153 * through a callback function and passes a status parameter ref kStatus_UART_RxIdle.
1154 * For example, the upper layer needs 10 bytes but there are only 5 bytes in ring buffer.
1155 * The 5 bytes are copied to xfer->data, which returns with the
1156 * parameter p receivedBytes set to 5. For the remaining 5 bytes, the newly arrived data is
1157 * saved from xfer->data[5]. When 5 bytes are received, the LPUART driver notifies the upper layer.
1158 * If the RX ring buffer is not enabled, this function enables the RX and RX interrupt
1159 * to receive data to xfer->data. When all data is received, the upper layer is notified.
1160 *
1161 * param base LPUART peripheral base address.
1162 * param handle LPUART handle pointer.
1163 * param xfer LPUART transfer structure, see #uart_transfer_t.
1164 * param receivedBytes Bytes received from the ring buffer directly.
1165 * retval kStatus_Success Successfully queue the transfer into the transmit queue.
1166 * retval kStatus_LPUART_RxBusy Previous receive request is not finished.
1167 * retval kStatus_InvalidArgument Invalid argument.
1168 */
1170 lpuart_handle_t *handle,
1171 lpuart_transfer_t *xfer,
1172 size_t *receivedBytes)
1173{
1174 assert(handle);
1175 assert(xfer);
1176 assert(xfer->data);
1177 assert(xfer->dataSize);
1178
1179 uint32_t i;
1180 status_t status;
1181 /* How many bytes to copy from ring buffer to user memory. */
1182 size_t bytesToCopy = 0U;
1183 /* How many bytes to receive. */
1184 size_t bytesToReceive;
1185 /* How many bytes currently have received. */
1186 size_t bytesCurrentReceived;
1187
1188 /* How to get data:
1189 1. If RX ring buffer is not enabled, then save xfer->data and xfer->dataSize
1190 to lpuart handle, enable interrupt to store received data to xfer->data. When
1191 all data received, trigger callback.
1192 2. If RX ring buffer is enabled and not empty, get data from ring buffer first.
1193 If there are enough data in ring buffer, copy them to xfer->data and return.
1194 If there are not enough data in ring buffer, copy all of them to xfer->data,
1195 save the xfer->data remained empty space to lpuart handle, receive data
1196 to this empty space and trigger callback when finished. */
1197
1198 if (kLPUART_RxBusy == handle->rxState)
1199 {
1200 status = kStatus_LPUART_RxBusy;
1201 }
1202 else
1203 {
1204 bytesToReceive = xfer->dataSize;
1205 bytesCurrentReceived = 0;
1206
1207 /* If RX ring buffer is used. */
1208 if (handle->rxRingBuffer)
1209 {
1210 /* Disable LPUART RX IRQ, protect ring buffer. */
1212
1213 /* How many bytes in RX ring buffer currently. */
1214 bytesToCopy = LPUART_TransferGetRxRingBufferLength(base, handle);
1215
1216 if (bytesToCopy)
1217 {
1218 bytesToCopy = MIN(bytesToReceive, bytesToCopy);
1219
1220 bytesToReceive -= bytesToCopy;
1221
1222 /* Copy data from ring buffer to user memory. */
1223 for (i = 0U; i < bytesToCopy; i++)
1224 {
1225 xfer->data[bytesCurrentReceived++] = handle->rxRingBuffer[handle->rxRingBufferTail];
1226
1227 /* Wrap to 0. Not use modulo (%) because it might be large and slow. */
1228 if (handle->rxRingBufferTail + 1U == handle->rxRingBufferSize)
1229 {
1230 handle->rxRingBufferTail = 0U;
1231 }
1232 else
1233 {
1234 handle->rxRingBufferTail++;
1235 }
1236 }
1237 }
1238
1239 /* If ring buffer does not have enough data, still need to read more data. */
1240 if (bytesToReceive)
1241 {
1242 /* No data in ring buffer, save the request to LPUART handle. */
1243 handle->rxData = xfer->data + bytesCurrentReceived;
1244 handle->rxDataSize = bytesToReceive;
1245 handle->rxDataSizeAll = bytesToReceive;
1246 handle->rxState = kLPUART_RxBusy;
1247 }
1248 /* Enable LPUART RX IRQ if previously enabled. */
1250
1251 /* Call user callback since all data are received. */
1252 if (0 == bytesToReceive)
1253 {
1254 if (handle->callback)
1255 {
1256 handle->callback(base, handle, kStatus_LPUART_RxIdle, handle->userData);
1257 }
1258 }
1259 }
1260 /* Ring buffer not used. */
1261 else
1262 {
1263 handle->rxData = xfer->data + bytesCurrentReceived;
1264 handle->rxDataSize = bytesToReceive;
1265 handle->rxDataSizeAll = bytesToReceive;
1266 handle->rxState = kLPUART_RxBusy;
1267
1268 /* Enable RX interrupt. */
1271 }
1272
1273 /* Return the how many bytes have read. */
1274 if (receivedBytes)
1275 {
1276 *receivedBytes = bytesCurrentReceived;
1277 }
1278
1279 status = kStatus_Success;
1280 }
1281
1282 return status;
1283}
1284
1285/*!
1286 * brief Aborts the interrupt-driven data receiving.
1287 *
1288 * This function aborts the interrupt-driven data receiving. The user can get the remainBytes to find out
1289 * how many bytes not received yet.
1290 *
1291 * param base LPUART peripheral base address.
1292 * param handle LPUART handle pointer.
1293 */
1294void LPUART_TransferAbortReceive(LPUART_Type *base, lpuart_handle_t *handle)
1295{
1296 assert(handle);
1297
1298 /* Only abort the receive to handle->rxData, the RX ring buffer is still working. */
1299 if (!handle->rxRingBuffer)
1300 {
1301 /* Disable RX interrupt. */
1304 }
1305
1306 handle->rxDataSize = 0U;
1307 handle->rxState = kLPUART_RxIdle;
1308}
1309
1310/*!
1311 * brief Gets the number of bytes that have been received.
1312 *
1313 * This function gets the number of bytes that have been received.
1314 *
1315 * param base LPUART peripheral base address.
1316 * param handle LPUART handle pointer.
1317 * param count Receive bytes count.
1318 * retval kStatus_NoTransferInProgress No receive in progress.
1319 * retval kStatus_InvalidArgument Parameter is invalid.
1320 * retval kStatus_Success Get successfully through the parameter \p count;
1321 */
1322status_t LPUART_TransferGetReceiveCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
1323{
1324 assert(handle);
1325 assert(count);
1326
1327 if (kLPUART_RxIdle == handle->rxState)
1328 {
1330 }
1331
1332 *count = handle->rxDataSizeAll - handle->rxDataSize;
1333
1334 return kStatus_Success;
1335}
1336
1337/*!
1338 * brief LPUART IRQ handle function.
1339 *
1340 * This function handles the LPUART transmit and receive IRQ request.
1341 *
1342 * param base LPUART peripheral base address.
1343 * param handle LPUART handle pointer.
1344 */
1345void LPUART_TransferHandleIRQ(LPUART_Type *base, lpuart_handle_t *handle)
1346{
1347 assert(handle);
1348
1349 uint8_t count;
1350 uint8_t tempCount;
1351 uint32_t status = LPUART_GetStatusFlags(base);
1352 uint32_t enabledInterrupts = LPUART_GetEnabledInterrupts(base);
1353
1354 /////////////////////////////////////////////////////////////////////////////////////////
1355 // [andreika][rusefi]: we use this 'fake' unused status to trigger the callback via IRQ in software
1356 if (LPUART_STAT_RXINV_MASK & status)
1357 {
1358 base->STAT &= ~LPUART_STAT_RXINV_MASK;
1359 if (handle->callback)
1360 {
1361 handle->callback(base, handle, kStatus_LPUART_RxIdle, handle->userData);
1362 }
1363 }
1364 /////////////////////////////////////////////////////////////////////////////////////////
1365
1366 /* If RX overrun. */
1367 if (kLPUART_RxOverrunFlag & status)
1368 {
1369 /* Clear overrun flag, otherwise the RX does not work. */
1370 base->STAT = ((base->STAT & 0x3FE00000U) | LPUART_STAT_OR_MASK);
1371
1372 /* Trigger callback. */
1373 if (handle->callback)
1374 {
1375 handle->callback(base, handle, kStatus_LPUART_RxHardwareOverrun, handle->userData);
1376 }
1377 }
1378
1379 /* If IDLE flag is set and the IDLE interrupt is enabled. */
1380 if ((kLPUART_IdleLineFlag & status) && (kLPUART_IdleLineInterruptEnable & enabledInterrupts))
1381 {
1382#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
1383 count = ((uint8_t)((base->WATER & LPUART_WATER_RXCOUNT_MASK) >> LPUART_WATER_RXCOUNT_SHIFT));
1384
1385 while ((count) && (handle->rxDataSize))
1386 {
1387 tempCount = MIN(handle->rxDataSize, count);
1388
1389 /* Using non block API to read the data from the registers. */
1390 LPUART_ReadNonBlocking(base, handle->rxData, tempCount);
1391 handle->rxData += tempCount;
1392 handle->rxDataSize -= tempCount;
1393 count -= tempCount;
1394
1395 /* If rxDataSize is 0, disable idle line interrupt.*/
1396 if (!(handle->rxDataSize))
1397 {
1398 handle->rxState = kLPUART_RxIdle;
1399
1401 if (handle->callback)
1402 {
1403 handle->callback(base, handle, kStatus_LPUART_RxIdle, handle->userData);
1404 }
1405 }
1406 }
1407#endif
1408 /* Clear IDLE flag.*/
1409 base->STAT |= LPUART_STAT_IDLE_MASK;
1410
1411 /* If rxDataSize is 0, disable idle line interrupt.*/
1412 if (!(handle->rxDataSize))
1413 {
1415 }
1416 /* If callback is not NULL and rxDataSize is not 0. */
1417 if ((handle->callback) && (handle->rxDataSize))
1418 {
1419 handle->callback(base, handle, kStatus_LPUART_IdleLineDetected, handle->userData);
1420 }
1421 }
1422 /* Receive data register full */
1423 if ((kLPUART_RxDataRegFullFlag & status) && (kLPUART_RxDataRegFullInterruptEnable & enabledInterrupts))
1424 {
1425/* Get the size that can be stored into buffer for this interrupt. */
1426#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
1427 count = ((uint8_t)((base->WATER & LPUART_WATER_RXCOUNT_MASK) >> LPUART_WATER_RXCOUNT_SHIFT));
1428#else
1429 count = 1;
1430#endif
1431
1432 /* If handle->rxDataSize is not 0, first save data to handle->rxData. */
1433 while ((count) && (handle->rxDataSize))
1434 {
1435#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
1436 tempCount = MIN(handle->rxDataSize, count);
1437#else
1438 tempCount = 1;
1439#endif
1440
1441 /* Using non block API to read the data from the registers. */
1442 LPUART_ReadNonBlocking(base, handle->rxData, tempCount);
1443 handle->rxData += tempCount;
1444 handle->rxDataSize -= tempCount;
1445 count -= tempCount;
1446
1447 /* If all the data required for upper layer is ready, trigger callback. */
1448 if (!handle->rxDataSize)
1449 {
1450 handle->rxState = kLPUART_RxIdle;
1451
1452 if (handle->callback)
1453 {
1454 handle->callback(base, handle, kStatus_LPUART_RxIdle, handle->userData);
1455 }
1456 }
1457 }
1458
1459 /* If use RX ring buffer, receive data to ring buffer. */
1460 if (handle->rxRingBuffer)
1461 {
1462 while (count--)
1463 {
1464 /* If RX ring buffer is full, trigger callback to notify over run. */
1465 if (LPUART_TransferIsRxRingBufferFull(base, handle))
1466 {
1467 if (handle->callback)
1468 {
1469 handle->callback(base, handle, kStatus_LPUART_RxRingBufferOverrun, handle->userData);
1470 }
1471 }
1472
1473 /* If ring buffer is still full after callback function, the oldest data is overrided. */
1474 if (LPUART_TransferIsRxRingBufferFull(base, handle))
1475 {
1476 /* Increase handle->rxRingBufferTail to make room for new data. */
1477 if (handle->rxRingBufferTail + 1U == handle->rxRingBufferSize)
1478 {
1479 handle->rxRingBufferTail = 0U;
1480 }
1481 else
1482 {
1483 handle->rxRingBufferTail++;
1484 }
1485 }
1486
1487/* Read data. */
1488#if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
1489 if (handle->isSevenDataBits)
1490 {
1491 handle->rxRingBuffer[handle->rxRingBufferHead] = (base->DATA & 0x7F);
1492 }
1493 else
1494 {
1495 handle->rxRingBuffer[handle->rxRingBufferHead] = base->DATA;
1496 }
1497#else
1498 handle->rxRingBuffer[handle->rxRingBufferHead] = base->DATA;
1499#endif
1500
1501 /* Increase handle->rxRingBufferHead. */
1502 if (handle->rxRingBufferHead + 1U == handle->rxRingBufferSize)
1503 {
1504 handle->rxRingBufferHead = 0U;
1505 }
1506 else
1507 {
1508 handle->rxRingBufferHead++;
1509 }
1510 }
1511 }
1512 /* If no receive requst pending, stop RX interrupt. */
1513 else if (!handle->rxDataSize)
1514 {
1516 }
1517 else
1518 {
1519 }
1520 }
1521
1522 /* Send data register empty and the interrupt is enabled. */
1523 if ((kLPUART_TxDataRegEmptyFlag & status) && (kLPUART_TxDataRegEmptyInterruptEnable & enabledInterrupts))
1524 {
1525/* Get the bytes that available at this moment. */
1526#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
1527 count = FSL_FEATURE_LPUART_FIFO_SIZEn(base) -
1528 ((base->WATER & LPUART_WATER_TXCOUNT_MASK) >> LPUART_WATER_TXCOUNT_SHIFT);
1529#else
1530 count = 1;
1531#endif
1532
1533 while ((count) && (handle->txDataSize))
1534 {
1535#if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
1536 tempCount = MIN(handle->txDataSize, count);
1537#else
1538 tempCount = 1;
1539#endif
1540
1541 /* Using non block API to write the data to the registers. */
1542 LPUART_WriteNonBlocking(base, handle->txData, tempCount);
1543 handle->txData += tempCount;
1544 handle->txDataSize -= tempCount;
1545 count -= tempCount;
1546
1547 /* If all the data are written to data register, notify user with the callback, then TX finished. */
1548 if (!handle->txDataSize)
1549 {
1550 handle->txState = kLPUART_TxIdle;
1551
1552 /* Disable TX register empty interrupt. */
1553 base->CTRL = (base->CTRL & ~LPUART_CTRL_TIE_MASK);
1554
1555 /* Trigger callback. */
1556 if (handle->callback)
1557 {
1558 handle->callback(base, handle, kStatus_LPUART_TxIdle, handle->userData);
1559 }
1560 }
1561 }
1562 }
1563}
1564
1565/*!
1566 * brief LPUART Error IRQ handle function.
1567 *
1568 * This function handles the LPUART error IRQ request.
1569 *
1570 * param base LPUART peripheral base address.
1571 * param handle LPUART handle pointer.
1572 */
1573void LPUART_TransferHandleErrorIRQ(LPUART_Type *base, lpuart_handle_t *handle)
1574{
1575 /* To be implemented by User. */
1576}
1577#if defined(FSL_FEATURE_LPUART_HAS_SHARED_IRQ0_IRQ1) && FSL_FEATURE_LPUART_HAS_SHARED_IRQ0_IRQ1
1578#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1580{
1581 if (CLOCK_isEnabledClock(s_lpuartClock[0]))
1582 {
1583 if ((LPUART_STAT_OR_MASK & LPUART0->STAT) ||
1584 ((LPUART_STAT_RDRF_MASK & LPUART0->STAT) && (LPUART_CTRL_RIE_MASK & LPUART0->CTRL)))
1585 {
1586 s_lpuartIsr(LPUART0, s_lpuartHandle[0]);
1587 }
1588 }
1589 if (CLOCK_isEnabledClock(s_lpuartClock[1]))
1590 {
1591 if ((LPUART_STAT_OR_MASK & LPUART1->STAT) ||
1592 ((LPUART_STAT_RDRF_MASK & LPUART1->STAT) && (LPUART_CTRL_RIE_MASK & LPUART1->CTRL)))
1593 {
1594 s_lpuartIsr(LPUART1, s_lpuartHandle[1]);
1595 }
1596 }
1597/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1598 exception return operation might vector to incorrect interrupt */
1599#if defined __CORTEX_M && (__CORTEX_M == 4U)
1600 __DSB();
1601#endif
1602}
1604{
1605 if (CLOCK_isEnabledClock(s_lpuartClock[0]))
1606 {
1607 if ((LPUART_STAT_OR_MASK & LPUART0->STAT) ||
1608 ((LPUART0->STAT & LPUART_STAT_TDRE_MASK) && (LPUART0->CTRL & LPUART_CTRL_TIE_MASK)))
1609 {
1610 s_lpuartIsr(LPUART0, s_lpuartHandle[0]);
1611 }
1612 }
1613 if (CLOCK_isEnabledClock(s_lpuartClock[1]))
1614 {
1615 if ((LPUART_STAT_OR_MASK & LPUART1->STAT) ||
1616 ((LPUART1->STAT & LPUART_STAT_TDRE_MASK) && (LPUART1->CTRL & LPUART_CTRL_TIE_MASK)))
1617 {
1618 s_lpuartIsr(LPUART1, s_lpuartHandle[1]);
1619 }
1620 }
1621/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1622 exception return operation might vector to incorrect interrupt */
1623#if defined __CORTEX_M && (__CORTEX_M == 4U)
1624 __DSB();
1625#endif
1626}
1627#else
1629{
1630 if (CLOCK_isEnabledClock(s_lpuartClock[0]))
1631 {
1632 if ((LPUART_STAT_OR_MASK & LPUART0->STAT) ||
1633 ((LPUART_STAT_RDRF_MASK & LPUART0->STAT) && (LPUART_CTRL_RIE_MASK & LPUART0->CTRL)) ||
1634 ((LPUART0->STAT & LPUART_STAT_TDRE_MASK) && (LPUART0->CTRL & LPUART_CTRL_TIE_MASK)))
1635 {
1636 s_lpuartIsr(LPUART0, s_lpuartHandle[0]);
1637 }
1638 }
1639 if (CLOCK_isEnabledClock(s_lpuartClock[1]))
1640 {
1641 if ((LPUART_STAT_OR_MASK & LPUART1->STAT) ||
1642 ((LPUART_STAT_RDRF_MASK & LPUART1->STAT) && (LPUART_CTRL_RIE_MASK & LPUART1->CTRL)) ||
1643 ((LPUART1->STAT & LPUART_STAT_TDRE_MASK) && (LPUART1->CTRL & LPUART_CTRL_TIE_MASK)))
1644 {
1645 s_lpuartIsr(LPUART1, s_lpuartHandle[1]);
1646 }
1647 }
1648/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1649 exception return operation might vector to incorrect interrupt */
1650#if defined __CORTEX_M && (__CORTEX_M == 4U)
1651 __DSB();
1652#endif
1653}
1654#endif
1655#endif
1656
1657#if defined(LPUART0)
1658#if !(defined(FSL_FEATURE_LPUART_HAS_SHARED_IRQ0_IRQ1) && FSL_FEATURE_LPUART_HAS_SHARED_IRQ0_IRQ1)
1659#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1661{
1662 s_lpuartIsr(LPUART0, s_lpuartHandle[0]);
1663/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1664 exception return operation might vector to incorrect interrupt */
1665#if defined __CORTEX_M && (__CORTEX_M == 4U)
1666 __DSB();
1667#endif
1668}
1670{
1671 s_lpuartIsr(LPUART0, s_lpuartHandle[0]);
1672/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1673 exception return operation might vector to incorrect interrupt */
1674#if defined __CORTEX_M && (__CORTEX_M == 4U)
1675 __DSB();
1676#endif
1677}
1678#else
1680{
1681 s_lpuartIsr(LPUART0, s_lpuartHandle[0]);
1682/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1683 exception return operation might vector to incorrect interrupt */
1684#if defined __CORTEX_M && (__CORTEX_M == 4U)
1685 __DSB();
1686#endif
1687}
1688#endif
1689#endif
1690#endif
1691
1692#if defined(LPUART1)
1693#if !(defined(FSL_FEATURE_LPUART_HAS_SHARED_IRQ0_IRQ1) && FSL_FEATURE_LPUART_HAS_SHARED_IRQ0_IRQ1)
1694#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1696{
1697 s_lpuartIsr(LPUART1, s_lpuartHandle[1]);
1698/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1699 exception return operation might vector to incorrect interrupt */
1700#if defined __CORTEX_M && (__CORTEX_M == 4U)
1701 __DSB();
1702#endif
1703}
1705{
1706 s_lpuartIsr(LPUART1, s_lpuartHandle[1]);
1707/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1708 exception return operation might vector to incorrect interrupt */
1709#if defined __CORTEX_M && (__CORTEX_M == 4U)
1710 __DSB();
1711#endif
1712}
1713#else
1715{
1716 s_lpuartIsr(LPUART1, s_lpuartHandle[1]);
1717/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1718 exception return operation might vector to incorrect interrupt */
1719#if defined __CORTEX_M && (__CORTEX_M == 4U)
1720 __DSB();
1721#endif
1722}
1723#endif
1724#endif
1725#endif
1726
1727#if defined(LPUART2)
1728#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1730{
1731 s_lpuartIsr(LPUART2, s_lpuartHandle[2]);
1732/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1733 exception return operation might vector to incorrect interrupt */
1734#if defined __CORTEX_M && (__CORTEX_M == 4U)
1735 __DSB();
1736#endif
1737}
1739{
1740 s_lpuartIsr(LPUART2, s_lpuartHandle[2]);
1741/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1742 exception return operation might vector to incorrect interrupt */
1743#if defined __CORTEX_M && (__CORTEX_M == 4U)
1744 __DSB();
1745#endif
1746}
1747#else
1749{
1750 s_lpuartIsr(LPUART2, s_lpuartHandle[2]);
1751/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1752 exception return operation might vector to incorrect interrupt */
1753#if defined __CORTEX_M && (__CORTEX_M == 4U)
1754 __DSB();
1755#endif
1756}
1757#endif
1758#endif
1759
1760#if defined(LPUART3)
1761#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1763{
1764 s_lpuartIsr(LPUART3, s_lpuartHandle[3]);
1765/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1766 exception return operation might vector to incorrect interrupt */
1767#if defined __CORTEX_M && (__CORTEX_M == 4U)
1768 __DSB();
1769#endif
1770}
1772{
1773 s_lpuartIsr(LPUART3, s_lpuartHandle[3]);
1774/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1775 exception return operation might vector to incorrect interrupt */
1776#if defined __CORTEX_M && (__CORTEX_M == 4U)
1777 __DSB();
1778#endif
1779}
1780#else
1782{
1783 s_lpuartIsr(LPUART3, s_lpuartHandle[3]);
1784/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1785 exception return operation might vector to incorrect interrupt */
1786#if defined __CORTEX_M && (__CORTEX_M == 4U)
1787 __DSB();
1788#endif
1789}
1790#endif
1791#endif
1792
1793#if defined(LPUART4)
1794#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1796{
1797 s_lpuartIsr(LPUART4, s_lpuartHandle[4]);
1798/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1799 exception return operation might vector to incorrect interrupt */
1800#if defined __CORTEX_M && (__CORTEX_M == 4U)
1801 __DSB();
1802#endif
1803}
1805{
1806 s_lpuartIsr(LPUART4, s_lpuartHandle[4]);
1807/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1808 exception return operation might vector to incorrect interrupt */
1809#if defined __CORTEX_M && (__CORTEX_M == 4U)
1810 __DSB();
1811#endif
1812}
1813#else
1815{
1816 s_lpuartIsr(LPUART4, s_lpuartHandle[4]);
1817/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1818 exception return operation might vector to incorrect interrupt */
1819#if defined __CORTEX_M && (__CORTEX_M == 4U)
1820 __DSB();
1821#endif
1822}
1823#endif
1824#endif
1825
1826#if defined(LPUART5)
1827#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1829{
1830 s_lpuartIsr(LPUART5, s_lpuartHandle[5]);
1831/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1832 exception return operation might vector to incorrect interrupt */
1833#if defined __CORTEX_M && (__CORTEX_M == 4U)
1834 __DSB();
1835#endif
1836}
1838{
1839 s_lpuartIsr(LPUART5, s_lpuartHandle[5]);
1840/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1841 exception return operation might vector to incorrect interrupt */
1842#if defined __CORTEX_M && (__CORTEX_M == 4U)
1843 __DSB();
1844#endif
1845}
1846#else
1848{
1849 s_lpuartIsr(LPUART5, s_lpuartHandle[5]);
1850/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1851 exception return operation might vector to incorrect interrupt */
1852#if defined __CORTEX_M && (__CORTEX_M == 4U)
1853 __DSB();
1854#endif
1855}
1856#endif
1857#endif
1858
1859#if defined(LPUART6)
1860#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1862{
1863 s_lpuartIsr(LPUART6, s_lpuartHandle[6]);
1864/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1865 exception return operation might vector to incorrect interrupt */
1866#if defined __CORTEX_M && (__CORTEX_M == 4U)
1867 __DSB();
1868#endif
1869}
1871{
1872 s_lpuartIsr(LPUART6, s_lpuartHandle[6]);
1873/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1874 exception return operation might vector to incorrect interrupt */
1875#if defined __CORTEX_M && (__CORTEX_M == 4U)
1876 __DSB();
1877#endif
1878}
1879#else
1881{
1882 s_lpuartIsr(LPUART6, s_lpuartHandle[6]);
1883/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1884 exception return operation might vector to incorrect interrupt */
1885#if defined __CORTEX_M && (__CORTEX_M == 4U)
1886 __DSB();
1887#endif
1888}
1889#endif
1890#endif
1891
1892#if defined(LPUART7)
1893#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1895{
1896 s_lpuartIsr(LPUART7, s_lpuartHandle[7]);
1897/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1898 exception return operation might vector to incorrect interrupt */
1899#if defined __CORTEX_M && (__CORTEX_M == 4U)
1900 __DSB();
1901#endif
1902}
1904{
1905 s_lpuartIsr(LPUART7, s_lpuartHandle[7]);
1906/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1907 exception return operation might vector to incorrect interrupt */
1908#if defined __CORTEX_M && (__CORTEX_M == 4U)
1909 __DSB();
1910#endif
1911}
1912#else
1914{
1915 s_lpuartIsr(LPUART7, s_lpuartHandle[7]);
1916/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1917 exception return operation might vector to incorrect interrupt */
1918#if defined __CORTEX_M && (__CORTEX_M == 4U)
1919 __DSB();
1920#endif
1921}
1922#endif
1923#endif
1924
1925#if defined(LPUART8)
1926#if defined(FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ) && FSL_FEATURE_LPUART_HAS_SEPARATE_RX_TX_IRQ
1928{
1929 s_lpuartIsr(LPUART8, s_lpuartHandle[8]);
1930/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1931 exception return operation might vector to incorrect interrupt */
1932#if defined __CORTEX_M && (__CORTEX_M == 4U)
1933 __DSB();
1934#endif
1935}
1937{
1938 s_lpuartIsr(LPUART8, s_lpuartHandle[8]);
1939/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1940 exception return operation might vector to incorrect interrupt */
1941#if defined __CORTEX_M && (__CORTEX_M == 4U)
1942 __DSB();
1943#endif
1944}
1945#else
1947{
1948 s_lpuartIsr(LPUART8, s_lpuartHandle[8]);
1949/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1950 exception return operation might vector to incorrect interrupt */
1951#if defined __CORTEX_M && (__CORTEX_M == 4U)
1952 __DSB();
1953#endif
1954}
1955#endif
1956#endif
1957
1958#if defined(CM4_0__LPUART)
1960{
1961 s_lpuartIsr(CM4_0__LPUART, s_lpuartHandle[LPUART_GetInstance(CM4_0__LPUART)]);
1962/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1963 exception return operation might vector to incorrect interrupt */
1964#if defined __CORTEX_M && (__CORTEX_M == 4U)
1965 __DSB();
1966#endif
1967}
1968#endif
1969
1970#if defined(CM4_1__LPUART)
1972{
1973 s_lpuartIsr(CM4_1__LPUART, s_lpuartHandle[LPUART_GetInstance(CM4_1__LPUART)]);
1974/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1975 exception return operation might vector to incorrect interrupt */
1976#if defined __CORTEX_M && (__CORTEX_M == 4U)
1977 __DSB();
1978#endif
1979}
1980#endif
1981
1982#if defined(CM4__LPUART)
1984{
1985 s_lpuartIsr(CM4__LPUART, s_lpuartHandle[LPUART_GetInstance(CM4__LPUART)]);
1986/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1987 exception return operation might vector to incorrect interrupt */
1988#if defined __CORTEX_M && (__CORTEX_M == 4U)
1989 __DSB();
1990#endif
1991}
1992#endif
1993
1994#if defined(DMA__LPUART0)
1996{
1997 s_lpuartIsr(DMA__LPUART0, s_lpuartHandle[LPUART_GetInstance(DMA__LPUART0)]);
1998/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
1999 exception return operation might vector to incorrect interrupt */
2000#if defined __CORTEX_M && (__CORTEX_M == 4U)
2001 __DSB();
2002#endif
2003}
2004#endif
2005
2006#if defined(DMA__LPUART1)
2008{
2009 s_lpuartIsr(DMA__LPUART1, s_lpuartHandle[LPUART_GetInstance(DMA__LPUART1)]);
2010/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2011 exception return operation might vector to incorrect interrupt */
2012#if defined __CORTEX_M && (__CORTEX_M == 4U)
2013 __DSB();
2014#endif
2015}
2016#endif
2017
2018#if defined(DMA__LPUART2)
2020{
2021 s_lpuartIsr(DMA__LPUART2, s_lpuartHandle[LPUART_GetInstance(DMA__LPUART2)]);
2022/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2023 exception return operation might vector to incorrect interrupt */
2024#if defined __CORTEX_M && (__CORTEX_M == 4U)
2025 __DSB();
2026#endif
2027}
2028#endif
2029
2030#if defined(DMA__LPUART3)
2032{
2033 s_lpuartIsr(DMA__LPUART3, s_lpuartHandle[LPUART_GetInstance(DMA__LPUART3)]);
2034/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2035 exception return operation might vector to incorrect interrupt */
2036#if defined __CORTEX_M && (__CORTEX_M == 4U)
2037 __DSB();
2038#endif
2039}
2040#endif
2041
2042#if defined(DMA__LPUART4)
2044{
2045 s_lpuartIsr(DMA__LPUART4, s_lpuartHandle[LPUART_GetInstance(DMA__LPUART4)]);
2046/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2047 exception return operation might vector to incorrect interrupt */
2048#if defined __CORTEX_M && (__CORTEX_M == 4U)
2049 __DSB();
2050#endif
2051}
2052#endif
2053
2054#if defined(ADMA__LPUART0)
2056{
2057 s_lpuartIsr(ADMA__LPUART0, s_lpuartHandle[LPUART_GetInstance(ADMA__LPUART0)]);
2058/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2059 exception return operation might vector to incorrect interrupt */
2060#if defined __CORTEX_M && (__CORTEX_M == 4U)
2061 __DSB();
2062#endif
2063}
2064#endif
2065
2066#if defined(ADMA__LPUART1)
2068{
2069 s_lpuartIsr(ADMA__LPUART1, s_lpuartHandle[LPUART_GetInstance(ADMA__LPUART1)]);
2070/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2071 exception return operation might vector to incorrect interrupt */
2072#if defined __CORTEX_M && (__CORTEX_M == 4U)
2073 __DSB();
2074#endif
2075}
2076#endif
2077
2078#if defined(ADMA__LPUART2)
2080{
2081 s_lpuartIsr(ADMA__LPUART2, s_lpuartHandle[LPUART_GetInstance(ADMA__LPUART2)]);
2082/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2083 exception return operation might vector to incorrect interrupt */
2084#if defined __CORTEX_M && (__CORTEX_M == 4U)
2085 __DSB();
2086#endif
2087}
2088#endif
2089
2090#if defined(ADMA__LPUART3)
2092{
2093 s_lpuartIsr(ADMA__LPUART3, s_lpuartHandle[LPUART_GetInstance(ADMA__LPUART3)]);
2094/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
2095 exception return operation might vector to incorrect interrupt */
2096#if defined __CORTEX_M && (__CORTEX_M == 4U)
2097 __DSB();
2098#endif
2099}
2100#endif
static BenchController instance
static constexpr persistent_config_s * config
void LPUART8_TX_DriverIRQHandler(void)
void LPUART3_DriverIRQHandler(void)
void LPUART7_RX_DriverIRQHandler(void)
void LPUART_WriteNonBlocking(LPUART_Type *base, const uint8_t *data, size_t length)
Write to TX register using non-blocking method.
Definition fsl_lpuart.c:171
void(* lpuart_isr_t)(LPUART_Type *base, lpuart_handle_t *handle)
Definition fsl_lpuart.c:31
void LPUART0_LPUART1_TX_DriverIRQHandler(void)
void LPUART4_DriverIRQHandler(void)
void LPUART0_TX_DriverIRQHandler(void)
static lpuart_handle_t * s_lpuartHandle[ARRAY_SIZE(s_lpuartBases)]
Definition fsl_lpuart.c:80
void M4_LPUART_DriverIRQHandler(void)
void DMA_UART4_INT_DriverIRQHandler(void)
void M4_0_LPUART_DriverIRQHandler(void)
void LPUART3_RX_DriverIRQHandler(void)
void LPUART6_DriverIRQHandler(void)
void ADMA_UART2_INT_DriverIRQHandler(void)
void ADMA_UART0_INT_DriverIRQHandler(void)
void M4_1_LPUART_DriverIRQHandler(void)
void LPUART2_RX_DriverIRQHandler(void)
void LPUART2_TX_DriverIRQHandler(void)
static LPUART_Type *const s_lpuartBases[]
Definition fsl_lpuart.c:78
void LPUART7_DriverIRQHandler(void)
void LPUART0_RX_DriverIRQHandler(void)
void LPUART4_RX_DriverIRQHandler(void)
void ADMA_UART3_INT_DriverIRQHandler(void)
void LPUART1_RX_DriverIRQHandler(void)
static const clock_ip_name_t s_lpuartClock[]
Definition fsl_lpuart.c:90
void LPUART5_TX_DriverIRQHandler(void)
static const IRQn_Type s_lpuartTxIRQ[]
Definition fsl_lpuart.c:84
void LPUART0_DriverIRQHandler(void)
void LPUART8_DriverIRQHandler(void)
void LPUART0_LPUART1_DriverIRQHandler(void)
static bool LPUART_TransferIsRxRingBufferFull(LPUART_Type *base, lpuart_handle_t *handle)
Check whether the RX ring buffer is full.
Definition fsl_lpuart.c:153
void LPUART8_RX_DriverIRQHandler(void)
void LPUART6_RX_DriverIRQHandler(void)
void DMA_UART2_INT_DriverIRQHandler(void)
void ADMA_UART1_INT_DriverIRQHandler(void)
void LPUART1_DriverIRQHandler(void)
_lpuart_transfer_states
Definition fsl_lpuart.c:23
@ kLPUART_TxIdle
Definition fsl_lpuart.c:24
@ kLPUART_RxBusy
Definition fsl_lpuart.c:27
@ kLPUART_TxBusy
Definition fsl_lpuart.c:25
@ kLPUART_RxIdle
Definition fsl_lpuart.c:26
static lpuart_isr_t s_lpuartIsr
Definition fsl_lpuart.c:100
static const clock_ip_name_t s_lpuartPeriphClocks[]
Definition fsl_lpuart.c:94
void DMA_UART3_INT_DriverIRQHandler(void)
void LPUART0_LPUART1_RX_DriverIRQHandler(void)
void LPUART3_TX_DriverIRQHandler(void)
void LPUART5_RX_DriverIRQHandler(void)
void LPUART1_TX_DriverIRQHandler(void)
static const IRQn_Type s_lpuartIRQ[]
Definition fsl_lpuart.c:86
void DMA_UART1_INT_DriverIRQHandler(void)
void DMA_UART0_INT_DriverIRQHandler(void)
void LPUART7_TX_DriverIRQHandler(void)
void LPUART5_DriverIRQHandler(void)
void LPUART2_DriverIRQHandler(void)
static const IRQn_Type s_lpuartRxIRQ[]
Definition fsl_lpuart.c:83
void LPUART6_TX_DriverIRQHandler(void)
static void LPUART_ReadNonBlocking(LPUART_Type *base, uint8_t *data, size_t length)
Read RX register using non-blocking method.
Definition fsl_lpuart.c:185
void LPUART4_TX_DriverIRQHandler(void)
enum _clock_ip_name clock_ip_name_t
Peripheral clock name difinition used for clock gate, clock source and clock divider setting....
static void CLOCK_DisableClock(clock_ip_name_t name)
Disable the clock for specific IP.
Definition fsl_clock.h:653
static void CLOCK_EnableClock(clock_ip_name_t name)
Enable the clock for specific IP.
Definition fsl_clock.h:641
int32_t status_t
Type used for all status and error return values.
Definition fsl_common.h:169
@ kStatus_Success
Definition fsl_common.h:159
@ kStatus_NoTransferInProgress
Definition fsl_common.h:165
size_t rxRingBufferSize
Definition fsl_lpuart.h:238
void LPUART_TransferCreateHandle(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_callback_t callback, void *userData)
Initializes the LPUART handle.
Definition fsl_lpuart.c:942
uint8_t * rxRingBuffer
Definition fsl_lpuart.h:237
volatile uint8_t txState
Definition fsl_lpuart.h:245
uint32_t LPUART_GetEnabledInterrupts(LPUART_Type *base)
Gets enabled LPUART interrupts.
Definition fsl_lpuart.c:717
volatile uint16_t rxRingBufferHead
Definition fsl_lpuart.h:239
void LPUART_TransferHandleErrorIRQ(LPUART_Type *base, lpuart_handle_t *handle)
LPUART Error IRQ handle function.
uint8_t *volatile rxData
Definition fsl_lpuart.h:233
size_t txDataSizeAll
Definition fsl_lpuart.h:232
void LPUART_DisableInterrupts(LPUART_Type *base, uint32_t mask)
Disables LPUART interrupts according to a provided mask.
Definition fsl_lpuart.c:686
status_t LPUART_Init(LPUART_Type *base, const lpuart_config_t *config, uint32_t srcClock_Hz)
Initializes an LPUART instance with the user configuration structure and the peripheral clock.
Definition fsl_lpuart.c:239
volatile uint16_t rxRingBufferTail
Definition fsl_lpuart.h:240
void LPUART_Deinit(LPUART_Type *base)
Deinitializes a LPUART instance.
Definition fsl_lpuart.c:455
void LPUART_TransferAbortReceive(LPUART_Type *base, lpuart_handle_t *handle)
Aborts the interrupt-driven data receiving.
void LPUART_TransferStartRingBuffer(LPUART_Type *base, lpuart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
Sets up the RX ring buffer.
size_t LPUART_TransferGetRxRingBufferLength(LPUART_Type *base, lpuart_handle_t *handle)
Get the length of received data in RX ring buffer.
Definition fsl_lpuart.c:135
void(* lpuart_transfer_callback_t)(LPUART_Type *base, lpuart_handle_t *handle, status_t status, void *userData)
LPUART transfer callback function.
Definition fsl_lpuart.h:225
static void LPUART_SoftwareReset(LPUART_Type *base)
Resets the LPUART using software.
Definition fsl_lpuart.h:276
uint8_t *volatile txData
Definition fsl_lpuart.h:230
void LPUART_TransferAbortSend(LPUART_Type *base, lpuart_handle_t *handle)
Aborts the interrupt-driven data transmit.
status_t LPUART_TransferReceiveNonBlocking(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_t *xfer, size_t *receivedBytes)
Receives a buffer of data using the interrupt method.
void LPUART_GetDefaultConfig(lpuart_config_t *config)
Gets the default configuration structure.
Definition fsl_lpuart.c:519
volatile size_t txDataSize
Definition fsl_lpuart.h:231
uint32_t LPUART_GetInstance(LPUART_Type *base)
Get the LPUART instance from peripheral base address.
Definition fsl_lpuart.c:111
lpuart_transfer_callback_t callback
Definition fsl_lpuart.h:242
void LPUART_EnableInterrupts(LPUART_Type *base, uint32_t mask)
Enables LPUART interrupts according to a provided mask.
Definition fsl_lpuart.c:662
uint32_t LPUART_GetStatusFlags(LPUART_Type *base)
Gets LPUART status flags.
Definition fsl_lpuart.c:746
status_t LPUART_TransferGetReceiveCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
Gets the number of bytes that have been received.
volatile uint8_t rxState
Definition fsl_lpuart.h:246
void LPUART_WriteBlocking(LPUART_Type *base, const uint8_t *data, size_t length)
Writes to the transmitter register using a blocking method.
Definition fsl_lpuart.c:832
status_t LPUART_ClearStatusFlags(LPUART_Type *base, uint32_t mask)
Clears status flags with a provided mask.
Definition fsl_lpuart.c:777
void LPUART_TransferHandleIRQ(LPUART_Type *base, lpuart_handle_t *handle)
LPUART IRQ handle function.
volatile size_t rxDataSize
Definition fsl_lpuart.h:234
void LPUART_TransferStopRingBuffer(LPUART_Type *base, lpuart_handle_t *handle)
Aborts the background transfer and uninstalls the ring buffer.
status_t LPUART_TransferGetSendCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
Gets the number of bytes that have been written to the LPUART transmitter register.
size_t rxDataSizeAll
Definition fsl_lpuart.h:235
status_t LPUART_ReadBlocking(LPUART_Type *base, uint8_t *data, size_t length)
Reads the receiver data register using a blocking method.
Definition fsl_lpuart.c:862
status_t LPUART_SetBaudRate(LPUART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz)
Sets the LPUART instance baudrate.
Definition fsl_lpuart.c:564
status_t LPUART_TransferSendNonBlocking(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_t *xfer)
Transmits a buffer of data using the interrupt method.
@ kLPUART_IdleCharacter1
Definition fsl_lpuart.h:103
@ kLPUART_TransmissionCompleteInterruptEnable
Definition fsl_lpuart.h:125
@ kLPUART_TxDataRegEmptyInterruptEnable
Definition fsl_lpuart.h:124
@ kLPUART_RxDataRegFullInterruptEnable
Definition fsl_lpuart.h:126
@ kLPUART_RxOverrunInterruptEnable
Definition fsl_lpuart.h:128
@ kLPUART_IdleLineInterruptEnable
Definition fsl_lpuart.h:127
@ kLPUART_ParityDisabled
Definition fsl_lpuart.h:53
@ kLPUART_NoiseErrorFlag
Definition fsl_lpuart.h:154
@ kLPUART_ParityErrorFlag
Definition fsl_lpuart.h:158
@ kLPUART_RxOverrunFlag
Definition fsl_lpuart.h:152
@ kLPUART_RxDataRegFullFlag
Definition fsl_lpuart.h:149
@ kLPUART_TxDataRegEmptyFlag
Definition fsl_lpuart.h:145
@ kLPUART_IdleLineFlag
Definition fsl_lpuart.h:151
@ kLPUART_FramingErrorFlag
Definition fsl_lpuart.h:156
@ kLPUART_SevenDataBits
Definition fsl_lpuart.h:63
@ kLPUART_EightDataBits
Definition fsl_lpuart.h:61
@ kLPUART_IdleTypeStartBit
Definition fsl_lpuart.h:93
@ kStatus_LPUART_RxIdle
Definition fsl_lpuart.h:34
@ kStatus_LPUART_TxIdle
Definition fsl_lpuart.h:33
@ kStatus_LPUART_FlagCannotClearManually
Definition fsl_lpuart.h:37
@ kStatus_LPUART_FramingError
Definition fsl_lpuart.h:43
@ kStatus_LPUART_IdleLineDetected
Definition fsl_lpuart.h:47
@ kStatus_LPUART_RxRingBufferOverrun
Definition fsl_lpuart.h:39
@ kStatus_LPUART_NoiseError
Definition fsl_lpuart.h:42
@ kStatus_LPUART_RxBusy
Definition fsl_lpuart.h:32
@ kStatus_LPUART_BaudrateNotSupport
Definition fsl_lpuart.h:45
@ kStatus_LPUART_TxBusy
Definition fsl_lpuart.h:31
@ kStatus_LPUART_ParityError
Definition fsl_lpuart.h:44
@ kStatus_LPUART_RxHardwareOverrun
Definition fsl_lpuart.h:41
@ kLPUART_OneStopBit
Definition fsl_lpuart.h:70
@ kLPUART_CtsSampleAtStart
Definition fsl_lpuart.h:85
@ kLPUART_CtsSourcePin
Definition fsl_lpuart.h:78
LPUART configuration structure.
Definition fsl_lpuart.h:190
LPUART handle structure.
Definition fsl_lpuart.h:229
LPUART transfer structure.
Definition fsl_lpuart.h:216
composite packet size
uint16_t count
Definition tunerstudio.h:1