1 /*
2  * Copyright 2017 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  */
9 
10 #ifndef _FSL_IO_H
11 #define _FSL_IO_H
12 
13 #include "fsl_common.h"
14 /*******************************************************************************
15  * Definitions
16  ******************************************************************************/
17 /*! @brief define a notify callback for IO
18 * @param size , transfer data size.
19 * @param rx, indicate a rx transfer is success.
20 * @param tx, indicate a tx transfer is success.
21 */
22 typedef void (*notify)(size_t *size, bool rx, bool tx);
23 
24 /*! @brief State structure storing io. */
25 typedef struct io_State
26 {
27     void *ioBase;   /*!< Base of the IP register. */
28     uint8_t ioType; /*!< device type */
29 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
30     notify callBack; /*!< define the callback function for buffer */
31 #endif
32 
33 } io_state_t;
34 
35 /*******************************************************************************
36  * Prototypes
37  ******************************************************************************/
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif /* __cplusplus */
41 
42 /*!
43  * @brief io init function.
44  *
45  * Call this function to init IO.
46  *
47  * @param io configuration pointer
48  * @param baudRate baud rate
49  * @param clkSrcFreq clock freq
50  * @param ringbuffer used to receive character
51  */
52 void IO_Init(io_state_t *io, uint32_t baudRate, uint32_t clkSrcFreq, uint8_t *ringBuffer);
53 
54 /*!
55  * @brief Deinit IO.
56  *
57  * Call this function to Deinit IO.
58  *
59  * @return deinit status
60  */
61 status_t IO_Deinit(void);
62 
63 /*!
64  * @brief io transfer function.
65  *
66  * Call this function to transfer log.
67  * Print log:
68  * @code
69  * IO_Transfer(ch, size, true);
70  * @endcode
71  * Scanf log:
72  * @code
73  * IO_Transfer(ch, size, false);
74  * @endcode
75  *
76  * @param   ch  transfer buffer pointer
77  * @param	size transfer size
78  * @param   tx indicate the transfer is TX or RX
79  */
80 status_t IO_Transfer(uint8_t *ch, size_t size, bool tx);
81 
82 /*!
83  * @brief io wait idle.
84  *
85  * Call this function to wait the io idle
86  *
87  * @return Indicates whether wait idle was successful or not.
88  */
89 status_t IO_WaitIdle(void);
90 
91 #if defined(__cplusplus)
92 }
93 #endif /* __cplusplus */
94 
95 #endif /* _FSL_IO_H */
96