1 /*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2023 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9 #ifndef _FSL_FLEXIO_MCULCD_H_
10 #define _FSL_FLEXIO_MCULCD_H_
11
12 #include "fsl_common.h"
13 #include "fsl_flexio.h"
14
15 /*!
16 * @addtogroup flexio_mculcd
17 * @{
18 */
19
20 /*******************************************************************************
21 * Definitions
22 ******************************************************************************/
23
24 /*! @name Driver version */
25 /*@{*/
26 /*! @brief FlexIO MCULCD driver version. */
27 #define FSL_FLEXIO_MCULCD_DRIVER_VERSION (MAKE_VERSION(2, 0, 8))
28 /*@}*/
29
30 #ifndef FLEXIO_MCULCD_WAIT_COMPLETE_TIME
31 /*!
32 * @brief The delay time to wait for FLEXIO transmit complete.
33 *
34 * Currently there is no method to detect whether the data has been
35 * sent out from the shifter, so the driver use a software delay for this. When
36 * the data is written to shifter buffer, the driver call the delay
37 * function to wait for the data shift out.
38 * If this value is too small, then the last few bytes might be lost when writing
39 * data using interrupt method or DMA method.
40 */
41 #define FLEXIO_MCULCD_WAIT_COMPLETE_TIME 512
42 #endif
43
44 #ifndef FLEXIO_MCULCD_DATA_BUS_WIDTH
45 /*!
46 * @brief The data bus width, must be 8 or 16.
47 */
48 #define FLEXIO_MCULCD_DATA_BUS_WIDTH 16UL
49 #endif
50
51 #if (16UL != FLEXIO_MCULCD_DATA_BUS_WIDTH) && (8UL != FLEXIO_MCULCD_DATA_BUS_WIDTH)
52 #error Only support data bus 8-bit or 16-bit
53 #endif
54
55 /*! @brief FlexIO LCD transfer status */
56 enum
57 {
58 kStatus_FLEXIO_MCULCD_Idle = MAKE_STATUS(kStatusGroup_FLEXIO_MCULCD, 0), /*!< FlexIO LCD is idle. */
59 kStatus_FLEXIO_MCULCD_Busy = MAKE_STATUS(kStatusGroup_FLEXIO_MCULCD, 1), /*!< FlexIO LCD is busy */
60 kStatus_FLEXIO_MCULCD_Error = MAKE_STATUS(kStatusGroup_FLEXIO_MCULCD, 2), /*!< FlexIO LCD error occurred */
61 };
62
63 /*! @brief Define FlexIO MCULCD pixel format. */
64 typedef enum _flexio_mculcd_pixel_format
65 {
66 kFLEXIO_MCULCD_RGB565 = 0, /*!< RGB565, 16-bit. */
67 kFLEXIO_MCULCD_BGR565, /*!< BGR565, 16-bit. */
68 kFLEXIO_MCULCD_RGB888, /*!< RGB888, 24-bit. */
69 kFLEXIO_MCULCD_BGR888, /*!< BGR888, 24-bit. */
70 } flexio_mculcd_pixel_format_t;
71
72 /*! @brief Define FlexIO MCULCD bus type. */
73 typedef enum _flexio_mculcd_bus
74 {
75 kFLEXIO_MCULCD_8080, /*!< Using Intel 8080 bus. */
76 kFLEXIO_MCULCD_6800, /*!< Using Motorola 6800 bus. */
77 } flexio_mculcd_bus_t;
78
79 /*! @brief Define FlexIO MCULCD interrupt mask. */
80 enum _flexio_mculcd_interrupt_enable
81 {
82 kFLEXIO_MCULCD_TxEmptyInterruptEnable = (1U << 0U), /*!< Transmit buffer empty interrupt enable. */
83 kFLEXIO_MCULCD_RxFullInterruptEnable = (1U << 1U), /*!< Receive buffer full interrupt enable. */
84 };
85
86 /*! @brief Define FlexIO MCULCD status mask. */
87 enum _flexio_mculcd_status_flags
88 {
89 kFLEXIO_MCULCD_TxEmptyFlag = (1U << 0U), /*!< Transmit buffer empty flag. */
90 kFLEXIO_MCULCD_RxFullFlag = (1U << 1U), /*!< Receive buffer full flag. */
91 };
92
93 /*! @brief Define FlexIO MCULCD DMA mask. */
94 enum _flexio_mculcd_dma_enable
95 {
96 kFLEXIO_MCULCD_TxDmaEnable = 0x1U, /*!< Tx DMA request source */
97 kFLEXIO_MCULCD_RxDmaEnable = 0x2U, /*!< Rx DMA request source */
98 };
99
100 /*! @brief Function to set or clear the CS and RS pin. */
101 typedef void (*flexio_mculcd_pin_func_t)(bool set);
102
103 /*! @brief Define FlexIO MCULCD access structure typedef. */
104 typedef struct _flexio_mculcd_type
105 {
106 FLEXIO_Type *flexioBase; /*!< FlexIO base pointer. */
107 flexio_mculcd_bus_t busType; /*!< The bus type, 8080 or 6800. */
108 uint8_t dataPinStartIndex; /*!< Start index of the data pin, the FlexIO pin dataPinStartIndex
109 to (dataPinStartIndex + FLEXIO_MCULCD_DATA_BUS_WIDTH -1)
110 will be used for data transfer. Only support data bus width 8 and 16. */
111 uint8_t ENWRPinIndex; /*!< Pin select for WR(8080 mode), EN(6800 mode). */
112 uint8_t RDPinIndex; /*!< Pin select for RD(8080 mode), not used in 6800 mode. */
113 uint8_t txShifterStartIndex; /*!< Start index of shifters used for data write, it must be 0 or 4. */
114 uint8_t txShifterEndIndex; /*!< End index of shifters used for data write. */
115 uint8_t rxShifterStartIndex; /*!< Start index of shifters used for data read. */
116 uint8_t rxShifterEndIndex; /*!< End index of shifters used for data read, it must be 3 or 7. */
117 uint8_t timerIndex; /*!< Timer index used in FlexIO MCULCD. */
118 flexio_mculcd_pin_func_t setCSPin; /*!< Function to set or clear the CS pin. */
119 flexio_mculcd_pin_func_t setRSPin; /*!< Function to set or clear the RS pin. */
120 flexio_mculcd_pin_func_t setRDWRPin; /*!< Function to set or clear the RD/WR pin, only used in 6800 mode. */
121 } FLEXIO_MCULCD_Type;
122
123 /*! @brief Define FlexIO MCULCD configuration structure. */
124 typedef struct _flexio_mculcd_config
125 {
126 bool enable; /*!< Enable/disable FlexIO MCULCD after configuration. */
127 bool enableInDoze; /*!< Enable/disable FlexIO operation in doze mode. */
128 bool enableInDebug; /*!< Enable/disable FlexIO operation in debug mode. */
129 bool enableFastAccess; /*!< Enable/disable fast access to FlexIO registers,
130 fast access requires the FlexIO clock to be at least
131 twice the frequency of the bus clock. */
132 uint32_t baudRate_Bps; /*!< Baud rate in bit-per-second for all data lines combined. */
133 } flexio_mculcd_config_t;
134
135 /*! @brief Transfer mode.*/
136 typedef enum _flexio_mculcd_transfer_mode
137 {
138 kFLEXIO_MCULCD_ReadArray, /*!< Read data into an array. */
139 kFLEXIO_MCULCD_WriteArray, /*!< Write data from an array. */
140 kFLEXIO_MCULCD_WriteSameValue, /*!< Write the same value many times. */
141 } flexio_mculcd_transfer_mode_t;
142
143 /*! @brief Define FlexIO MCULCD transfer structure. */
144 typedef struct _flexio_mculcd_transfer
145 {
146 uint32_t command; /*!< Command to send. */
147 flexio_mculcd_transfer_mode_t mode; /*!< Transfer mode. */
148 uint32_t dataAddrOrSameValue; /*!< When sending the same value for many times,
149 this is the value to send. When writing or reading array,
150 this is the address of the data array. */
151 size_t dataSize; /*!< How many bytes to transfer. */
152 } flexio_mculcd_transfer_t;
153
154 /*! @brief typedef for flexio_mculcd_handle_t in advance. */
155 typedef struct _flexio_mculcd_handle flexio_mculcd_handle_t;
156
157 /*! @brief FlexIO MCULCD callback for finished transfer.
158 *
159 * When transfer finished, the callback function is called and returns the
160 * @p status as kStatus_FLEXIO_MCULCD_Idle.
161 */
162 typedef void (*flexio_mculcd_transfer_callback_t)(FLEXIO_MCULCD_Type *base,
163 flexio_mculcd_handle_t *handle,
164 status_t status,
165 void *userData);
166
167 /*! @brief Define FlexIO MCULCD handle structure. */
168 struct _flexio_mculcd_handle
169 {
170 uint32_t dataAddrOrSameValue; /*!< When sending the same value for many times,
171 this is the value to send. When writing or reading array,
172 this is the address of the data array. */
173 size_t dataCount; /*!< Total count to be transferred. */
174 volatile size_t remainingCount; /*!< Remaining count to transfer. */
175 volatile uint32_t state; /*!< FlexIO MCULCD internal state. */
176 flexio_mculcd_transfer_callback_t completionCallback; /*!< FlexIO MCULCD transfer completed callback. */
177 void *userData; /*!< Callback parameter. */
178 };
179
180 /*******************************************************************************
181 * API
182 ******************************************************************************/
183
184 #if defined(__cplusplus)
185 extern "C" {
186 #endif /*_cplusplus*/
187
188 /*!
189 * @name FlexIO MCULCD Configuration
190 * @{
191 */
192
193 /*!
194 * @brief Ungates the FlexIO clock, resets the FlexIO module, configures the
195 * FlexIO MCULCD hardware, and configures the FlexIO MCULCD with FlexIO MCULCD
196 * configuration.
197 * The configuration structure can be filled by the user, or be set with default
198 * values
199 * by the @ref FLEXIO_MCULCD_GetDefaultConfig.
200 *
201 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
202 * @param config Pointer to the flexio_mculcd_config_t structure.
203 * @param srcClock_Hz FlexIO source clock in Hz.
204 * @retval kStatus_Success Initialization success.
205 * @retval kStatus_InvalidArgument Initialization failed because of invalid
206 * argument.
207 */
208 status_t FLEXIO_MCULCD_Init(FLEXIO_MCULCD_Type *base, flexio_mculcd_config_t *config, uint32_t srcClock_Hz);
209
210 /*!
211 * @brief Resets the FLEXIO_MCULCD timer and shifter configuration.
212 *
213 * @param base Pointer to the FLEXIO_MCULCD_Type.
214 */
215 void FLEXIO_MCULCD_Deinit(FLEXIO_MCULCD_Type *base);
216
217 /*!
218 * @brief Gets the default configuration to configure the FlexIO MCULCD.
219 *
220 * The default configuration value is:
221 * @code
222 * config->enable = true;
223 * config->enableInDoze = false;
224 * config->enableInDebug = true;
225 * config->enableFastAccess = true;
226 * config->baudRate_Bps = 96000000U;
227 * @endcode
228 * @param config Pointer to the flexio_mculcd_config_t structure.
229 */
230 void FLEXIO_MCULCD_GetDefaultConfig(flexio_mculcd_config_t *config);
231
232 /*@}*/
233
234 /*!
235 * @name Status
236 * @{
237 */
238
239 /*!
240 * @brief Gets FlexIO MCULCD status flags.
241 *
242 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
243 * @return status flag; OR'ed value or the @ref _flexio_mculcd_status_flags.
244 *
245 * @note Don't use this function with DMA APIs.
246 */
247 uint32_t FLEXIO_MCULCD_GetStatusFlags(FLEXIO_MCULCD_Type *base);
248
249 /*!
250 * @brief Clears FlexIO MCULCD status flags.
251 *
252 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
253 * @param mask Status to clear, it is the OR'ed value of @ref
254 * _flexio_mculcd_status_flags.
255 *
256 * @note Don't use this function with DMA APIs.
257 */
258 void FLEXIO_MCULCD_ClearStatusFlags(FLEXIO_MCULCD_Type *base, uint32_t mask);
259
260 /*@}*/
261
262 /*!
263 * @name Interrupts
264 * @{
265 */
266
267 /*!
268 * @brief Enables the FlexIO MCULCD interrupt.
269 *
270 * This function enables the FlexIO MCULCD interrupt.
271 *
272 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
273 * @param mask Interrupts to enable, it is the OR'ed value of @ref
274 * _flexio_mculcd_interrupt_enable.
275 */
276 void FLEXIO_MCULCD_EnableInterrupts(FLEXIO_MCULCD_Type *base, uint32_t mask);
277
278 /*!
279 * @brief Disables the FlexIO MCULCD interrupt.
280 *
281 * This function disables the FlexIO MCULCD interrupt.
282 *
283 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
284 * @param mask Interrupts to disable, it is the OR'ed value of @ref
285 * _flexio_mculcd_interrupt_enable.
286 */
287 void FLEXIO_MCULCD_DisableInterrupts(FLEXIO_MCULCD_Type *base, uint32_t mask);
288
289 /*@}*/
290
291 /*!
292 * @name DMA Control
293 * @{
294 */
295
296 /*!
297 * @brief Enables/disables the FlexIO MCULCD transmit DMA.
298 *
299 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
300 * @param enable True means enable DMA, false means disable DMA.
301 */
FLEXIO_MCULCD_EnableTxDMA(FLEXIO_MCULCD_Type * base,bool enable)302 static inline void FLEXIO_MCULCD_EnableTxDMA(FLEXIO_MCULCD_Type *base, bool enable)
303 {
304 FLEXIO_EnableShifterStatusDMA(base->flexioBase, (1UL << base->txShifterStartIndex), enable);
305 }
306
307 /*!
308 * @brief Enables/disables the FlexIO MCULCD receive DMA.
309 *
310 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
311 * @param enable True means enable DMA, false means disable DMA.
312 */
FLEXIO_MCULCD_EnableRxDMA(FLEXIO_MCULCD_Type * base,bool enable)313 static inline void FLEXIO_MCULCD_EnableRxDMA(FLEXIO_MCULCD_Type *base, bool enable)
314 {
315 FLEXIO_EnableShifterStatusDMA(base->flexioBase, (1UL << base->rxShifterEndIndex), enable);
316 }
317
318 /*!
319 * @brief Gets the FlexIO MCULCD transmit data register address.
320 *
321 * This function returns the MCULCD data register address, which is mainly used
322 * by DMA/eDMA.
323 *
324 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
325 * @return FlexIO MCULCD transmit data register address.
326 */
FLEXIO_MCULCD_GetTxDataRegisterAddress(FLEXIO_MCULCD_Type * base)327 static inline uint32_t FLEXIO_MCULCD_GetTxDataRegisterAddress(FLEXIO_MCULCD_Type *base)
328 {
329 return (uint32_t) & (base->flexioBase->SHIFTBUF[base->txShifterStartIndex]);
330 }
331
332 /*!
333 * @brief Gets the FlexIO MCULCD receive data register address.
334 *
335 * This function returns the MCULCD data register address, which is mainly used
336 * by DMA/eDMA.
337 *
338 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
339 * @return FlexIO MCULCD receive data register address.
340 */
FLEXIO_MCULCD_GetRxDataRegisterAddress(FLEXIO_MCULCD_Type * base)341 static inline uint32_t FLEXIO_MCULCD_GetRxDataRegisterAddress(FLEXIO_MCULCD_Type *base)
342 {
343 return (uint32_t) & (base->flexioBase->SHIFTBUF[base->rxShifterStartIndex]);
344 }
345
346 /*@}*/
347
348 /*!
349 * @name Bus Operations
350 * @{
351 */
352
353 /*!
354 * @brief Set desired baud rate.
355 *
356 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
357 * @param baudRate_Bps Desired baud rate in bit-per-second for all data lines combined.
358 * @param srcClock_Hz FLEXIO clock frequency in Hz.
359 * @retval kStatus_Success Set successfully.
360 * @retval kStatus_InvalidArgument Could not set the baud rate.
361 */
362 status_t FLEXIO_MCULCD_SetBaudRate(FLEXIO_MCULCD_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz);
363
364 /*!
365 * @brief Configures the FLEXIO MCULCD to multiple beats write mode.
366 *
367 * At the begining multiple beats write operation, the FLEXIO MCULCD is configured to
368 * multiple beats write mode using this function. After write operation, the configuration
369 * is cleared by @ref FLEXIO_MCULCD_ClearSingleBeatWriteConfig.
370 *
371 * @param base Pointer to the FLEXIO_MCULCD_Type.
372 *
373 * @note This is an internal used function, upper layer should not use.
374 */
375 void FLEXIO_MCULCD_SetSingleBeatWriteConfig(FLEXIO_MCULCD_Type *base);
376
377 /*!
378 * @brief Clear the FLEXIO MCULCD multiple beats write mode configuration.
379 *
380 * Clear the write configuration set by @ref FLEXIO_MCULCD_SetSingleBeatWriteConfig.
381 *
382 * @param base Pointer to the FLEXIO_MCULCD_Type.
383 *
384 * @note This is an internal used function, upper layer should not use.
385 */
386 void FLEXIO_MCULCD_ClearSingleBeatWriteConfig(FLEXIO_MCULCD_Type *base);
387
388 /*!
389 * @brief Configures the FLEXIO MCULCD to multiple beats read mode.
390 *
391 * At the begining or multiple beats read operation, the FLEXIO MCULCD is configured
392 * to multiple beats read mode using this function. After read operation, the configuration
393 * is cleared by @ref FLEXIO_MCULCD_ClearSingleBeatReadConfig.
394 *
395 * @param base Pointer to the FLEXIO_MCULCD_Type.
396 *
397 * @note This is an internal used function, upper layer should not use.
398 */
399 void FLEXIO_MCULCD_SetSingleBeatReadConfig(FLEXIO_MCULCD_Type *base);
400
401 /*!
402 * @brief Clear the FLEXIO MCULCD multiple beats read mode configuration.
403 *
404 * Clear the read configuration set by @ref FLEXIO_MCULCD_SetSingleBeatReadConfig.
405 *
406 * @param base Pointer to the FLEXIO_MCULCD_Type.
407 *
408 * @note This is an internal used function, upper layer should not use.
409 */
410 void FLEXIO_MCULCD_ClearSingleBeatReadConfig(FLEXIO_MCULCD_Type *base);
411
412 /*!
413 * @brief Configures the FLEXIO MCULCD to multiple beats write mode.
414 *
415 * At the begining multiple beats write operation, the FLEXIO MCULCD is configured to
416 * multiple beats write mode using this function. After write operation, the configuration
417 * is cleared by FLEXIO_MCULCD_ClearMultBeatsWriteConfig.
418 *
419 * @param base Pointer to the FLEXIO_MCULCD_Type.
420 *
421 * @note This is an internal used function, upper layer should not use.
422 */
423 void FLEXIO_MCULCD_SetMultiBeatsWriteConfig(FLEXIO_MCULCD_Type *base);
424
425 /*!
426 * @brief Clear the FLEXIO MCULCD multiple beats write mode configuration.
427 *
428 * Clear the write configuration set by FLEXIO_MCULCD_SetMultBeatsWriteConfig.
429 *
430 * @param base Pointer to the FLEXIO_MCULCD_Type.
431 *
432 * @note This is an internal used function, upper layer should not use.
433 */
434 void FLEXIO_MCULCD_ClearMultiBeatsWriteConfig(FLEXIO_MCULCD_Type *base);
435
436 /*!
437 * @brief Configures the FLEXIO MCULCD to multiple beats read mode.
438 *
439 * At the begining or multiple beats read operation, the FLEXIO MCULCD is configured
440 * to multiple beats read mode using this function. After read operation, the configuration
441 * is cleared by FLEXIO_MCULCD_ClearMultBeatsReadConfig.
442 *
443 * @param base Pointer to the FLEXIO_MCULCD_Type.
444 *
445 * @note This is an internal used function, upper layer should not use.
446 */
447 void FLEXIO_MCULCD_SetMultiBeatsReadConfig(FLEXIO_MCULCD_Type *base);
448
449 /*!
450 * @brief Clear the FLEXIO MCULCD multiple beats read mode configuration.
451 *
452 * Clear the read configuration set by FLEXIO_MCULCD_SetMultBeatsReadConfig.
453 *
454 * @param base Pointer to the FLEXIO_MCULCD_Type.
455 *
456 * @note This is an internal used function, upper layer should not use.
457 */
458 void FLEXIO_MCULCD_ClearMultiBeatsReadConfig(FLEXIO_MCULCD_Type *base);
459
460 /*!
461 * @brief Enables/disables the FlexIO MCULCD module operation.
462 *
463 * @param base Pointer to the FLEXIO_MCULCD_Type.
464 * @param enable True to enable, false does not have any effect.
465 */
FLEXIO_MCULCD_Enable(FLEXIO_MCULCD_Type * base,bool enable)466 static inline void FLEXIO_MCULCD_Enable(FLEXIO_MCULCD_Type *base, bool enable)
467 {
468 if (enable)
469 {
470 FLEXIO_Enable(base->flexioBase, enable);
471 }
472 }
473
474 /*!
475 * @brief Read data from the FLEXIO MCULCD RX shifter buffer.
476 *
477 * Read data from the RX shift buffer directly, it does no check whether the
478 * buffer is empty or not.
479 *
480 * If the data bus width is 8-bit:
481 * @code
482 * uint8_t value;
483 * value = (uint8_t)FLEXIO_MCULCD_ReadData(base);
484 * @endcode
485 *
486 * If the data bus width is 16-bit:
487 * @code
488 * uint16_t value;
489 * value = (uint16_t)FLEXIO_MCULCD_ReadData(base);
490 * @endcode
491 *
492 * @note This function returns the RX shifter buffer value (32-bit) directly.
493 * The return value should be converted according to data bus width.
494 *
495 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
496 * @return The data read out.
497 *
498 * @note Don't use this function with DMA APIs.
499 */
500 uint32_t FLEXIO_MCULCD_ReadData(FLEXIO_MCULCD_Type *base);
501
502 /*!
503 * @brief Write data into the FLEXIO MCULCD TX shifter buffer.
504 *
505 * Write data into the TX shift buffer directly, it does no check whether the
506 * buffer is full or not.
507 *
508 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
509 * @param data The data to write.
510 *
511 * @note Don't use this function with DMA APIs.
512 */
FLEXIO_MCULCD_WriteData(FLEXIO_MCULCD_Type * base,uint32_t data)513 static inline void FLEXIO_MCULCD_WriteData(FLEXIO_MCULCD_Type *base, uint32_t data)
514 {
515 base->flexioBase->SHIFTBUF[base->txShifterStartIndex] = data;
516 }
517
518 /*!
519 * @brief Assert the nCS to start transfer.
520 *
521 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
522 */
FLEXIO_MCULCD_StartTransfer(FLEXIO_MCULCD_Type * base)523 static inline void FLEXIO_MCULCD_StartTransfer(FLEXIO_MCULCD_Type *base)
524 {
525 base->setCSPin(false);
526 }
527
528 /*!
529 * @brief De-assert the nCS to stop transfer.
530 *
531 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
532 */
FLEXIO_MCULCD_StopTransfer(FLEXIO_MCULCD_Type * base)533 static inline void FLEXIO_MCULCD_StopTransfer(FLEXIO_MCULCD_Type *base)
534 {
535 base->setCSPin(true);
536 }
537
538 /*!
539 * @brief Wait for transmit data send out finished.
540 *
541 * Currently there is no effective method to wait for the data send out
542 * from the shiter, so here use a while loop to wait.
543 *
544 * @note This is an internal used function.
545 */
546 void FLEXIO_MCULCD_WaitTransmitComplete(void);
547
548 /*!
549 * @brief Send command in blocking way.
550 *
551 * This function sends the command and returns when the command has been sent
552 * out.
553 *
554 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
555 * @param command The command to send.
556 */
557 void FLEXIO_MCULCD_WriteCommandBlocking(FLEXIO_MCULCD_Type *base, uint32_t command);
558
559 /*!
560 * @brief Send data array in blocking way.
561 *
562 * This function sends the data array and returns when the data sent out.
563 *
564 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
565 * @param data The data array to send.
566 * @param size How many bytes to write.
567 */
568 void FLEXIO_MCULCD_WriteDataArrayBlocking(FLEXIO_MCULCD_Type *base, const void *data, size_t size);
569
570 /*!
571 * @brief Read data into array in blocking way.
572 *
573 * This function reads the data into array and returns when the data read
574 * finished.
575 *
576 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
577 * @param data The array to save the data.
578 * @param size How many bytes to read.
579 */
580 void FLEXIO_MCULCD_ReadDataArrayBlocking(FLEXIO_MCULCD_Type *base, void *data, size_t size);
581
582 /*!
583 * @brief Send the same value many times in blocking way.
584 *
585 * This function sends the same value many times. It could be used to clear the
586 * LCD screen. If the data bus width is 8, this function will send LSB 8 bits of
587 * @p sameValue for @p size times. If the data bus is 16, this function will send
588 * LSB 16 bits of @p sameValue for @p size / 2 times.
589 *
590 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
591 * @param sameValue The same value to send.
592 * @param size How many bytes to send.
593 */
594 void FLEXIO_MCULCD_WriteSameValueBlocking(FLEXIO_MCULCD_Type *base, uint32_t sameValue, size_t size);
595
596 /*!
597 * @brief Performs a polling transfer.
598 *
599 * @note The API does not return until the transfer finished.
600 *
601 * @param base pointer to FLEXIO_MCULCD_Type structure.
602 * @param xfer pointer to flexio_mculcd_transfer_t structure.
603 */
604 void FLEXIO_MCULCD_TransferBlocking(FLEXIO_MCULCD_Type *base, flexio_mculcd_transfer_t *xfer);
605 /*@}*/
606
607 /*!
608 * @name Transactional
609 * @{
610 */
611
612 /*!
613 * @brief Initializes the FlexIO MCULCD handle, which is used in transactional
614 * functions.
615 *
616 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
617 * @param handle Pointer to the flexio_mculcd_handle_t structure to store the
618 * transfer state.
619 * @param callback The callback function.
620 * @param userData The parameter of the callback function.
621 * @retval kStatus_Success Successfully create the handle.
622 * @retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range.
623 */
624 status_t FLEXIO_MCULCD_TransferCreateHandle(FLEXIO_MCULCD_Type *base,
625 flexio_mculcd_handle_t *handle,
626 flexio_mculcd_transfer_callback_t callback,
627 void *userData);
628
629 /*!
630 * @brief Transfer data using IRQ.
631 *
632 * This function sends data using IRQ. This is a non-blocking function, which
633 * returns right away. When all data is sent out/received, the callback
634 * function is called.
635 *
636 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
637 * @param handle Pointer to the flexio_mculcd_handle_t structure to store the
638 * transfer state.
639 * @param xfer FlexIO MCULCD transfer structure. See #flexio_mculcd_transfer_t.
640 * @retval kStatus_Success Successfully start a transfer.
641 * @retval kStatus_InvalidArgument Input argument is invalid.
642 * @retval kStatus_FLEXIO_MCULCD_Busy MCULCD is busy with another transfer.
643 */
644 status_t FLEXIO_MCULCD_TransferNonBlocking(FLEXIO_MCULCD_Type *base,
645 flexio_mculcd_handle_t *handle,
646 flexio_mculcd_transfer_t *xfer);
647
648 /*!
649 * @brief Aborts the data transfer, which used IRQ.
650 *
651 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
652 * @param handle Pointer to the flexio_mculcd_handle_t structure to store the
653 * transfer state.
654 */
655 void FLEXIO_MCULCD_TransferAbort(FLEXIO_MCULCD_Type *base, flexio_mculcd_handle_t *handle);
656
657 /*!
658 * @brief Gets the data transfer status which used IRQ.
659 *
660 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
661 * @param handle Pointer to the flexio_mculcd_handle_t structure to store the
662 * transfer state.
663 * @param count How many bytes transferred so far by the non-blocking transaction.
664 * @retval kStatus_Success Get the transferred count Successfully.
665 * @retval kStatus_NoTransferInProgress No transfer in process.
666 */
667 status_t FLEXIO_MCULCD_TransferGetCount(FLEXIO_MCULCD_Type *base, flexio_mculcd_handle_t *handle, size_t *count);
668
669 /*!
670 * @brief FlexIO MCULCD IRQ handler function.
671 *
672 * @param base Pointer to the FLEXIO_MCULCD_Type structure.
673 * @param handle Pointer to the flexio_mculcd_handle_t structure to store the
674 * transfer state.
675 */
676 void FLEXIO_MCULCD_TransferHandleIRQ(void *base, void *handle);
677
678 /*@}*/
679
680 #if defined(__cplusplus)
681 }
682 #endif /*_cplusplus*/
683 /*@}*/
684
685 #endif /*_FSL_FLEXIO_MCULCD_H_*/
686