1 /******************************************************************************
2  *
3  * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
4  * Analog Devices, Inc.),
5  * Copyright (C) 2023-2024 Analog Devices, Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************************/
20 
21 #ifndef LIBRARIES_PERIPHDRIVERS_SOURCE_UART_UART_REVC_H_
22 #define LIBRARIES_PERIPHDRIVERS_SOURCE_UART_UART_REVC_H_
23 
24 #include "mxc_device.h"
25 #include "mxc_assert.h"
26 #include "dma.h"
27 #include "uart_revc_regs.h"
28 #include "uart_regs.h"
29 
30 typedef struct _mxc_uart_revc_req_t mxc_uart_revc_req_t;
31 
32 struct _mxc_uart_revc_req_t {
33     mxc_uart_revc_regs_t *uart;
34     uint8_t *txData;
35     uint8_t *rxData;
36     uint32_t txLen;
37     uint32_t rxLen;
38     uint32_t txCnt;
39     uint32_t rxCnt;
40     mxc_uart_complete_cb_t callback;
41 };
42 
43 int MXC_UART_RevC_Init(mxc_uart_revc_regs_t *uart, unsigned int baud);
44 int MXC_UART_RevC_Shutdown(mxc_uart_revc_regs_t *uart);
45 int MXC_UART_RevC_ReadyForSleep(mxc_uart_revc_regs_t *uart);
46 int MXC_UART_RevC_SetFrequency(mxc_uart_revc_regs_t *uart, unsigned int baud);
47 int MXC_UART_RevC_GetFrequency(mxc_uart_revc_regs_t *uart);
48 int MXC_UART_RevC_SetDataSize(mxc_uart_revc_regs_t *uart, int dataSize);
49 int MXC_UART_RevC_SetStopBits(mxc_uart_revc_regs_t *uart, mxc_uart_stop_t stopBits);
50 int MXC_UART_RevC_SetParity(mxc_uart_revc_regs_t *uart, mxc_uart_parity_t parity);
51 int MXC_UART_RevC_GetActive(mxc_uart_revc_regs_t *uart);
52 int MXC_UART_RevC_AbortTransmission(mxc_uart_revc_regs_t *uart);
53 int MXC_UART_RevC_ReadCharacterRaw(mxc_uart_revc_regs_t *uart);
54 int MXC_UART_RevC_WriteCharacterRaw(mxc_uart_revc_regs_t *uart, uint8_t character);
55 int MXC_UART_RevC_Read(mxc_uart_revc_regs_t *uart, uint8_t *buffer, int *len);
56 int MXC_UART_RevC_Write(mxc_uart_revc_regs_t *uart, uint8_t *byte, int *len);
57 unsigned int MXC_UART_RevC_ReadRXFIFO(mxc_uart_revc_regs_t *uart, unsigned char *bytes,
58                                       unsigned int len);
59 int MXC_UART_RevC_ReadRXFIFODMA(mxc_uart_revc_regs_t *uart, unsigned char *bytes, unsigned int len,
60                                 mxc_uart_dma_complete_cb_t callback, mxc_dma_config_t config);
61 unsigned int MXC_UART_RevC_GetRXFIFOAvailable(mxc_uart_revc_regs_t *uart);
62 unsigned int MXC_UART_RevC_WriteTXFIFO(mxc_uart_revc_regs_t *uart, unsigned char *bytes,
63                                        unsigned int len);
64 int MXC_UART_RevC_WriteTXFIFODMA(mxc_uart_revc_regs_t *uart, unsigned char *bytes, unsigned int len,
65                                  mxc_uart_dma_complete_cb_t callback, mxc_dma_config_t config);
66 unsigned int MXC_UART_RevC_GetTXFIFOAvailable(mxc_uart_revc_regs_t *uart);
67 int MXC_UART_RevC_ClearRXFIFO(mxc_uart_revc_regs_t *uart);
68 int MXC_UART_RevC_ClearTXFIFO(mxc_uart_revc_regs_t *uart);
69 int MXC_UART_RevC_SetRXThreshold(mxc_uart_revc_regs_t *uart, unsigned int numBytes);
70 unsigned int MXC_UART_RevC_GetRXThreshold(mxc_uart_revc_regs_t *uart);
71 unsigned int MXC_UART_RevC_GetFlags(mxc_uart_revc_regs_t *uart);
72 int MXC_UART_RevC_ClearFlags(mxc_uart_revc_regs_t *uart, unsigned int flags);
73 int MXC_UART_RevC_EnableInt(mxc_uart_revc_regs_t *uart, unsigned int mask);
74 int MXC_UART_RevC_DisableInt(mxc_uart_revc_regs_t *uart, unsigned int mask);
75 unsigned int MXC_UART_RevC_GetStatus(mxc_uart_revc_regs_t *uart);
76 int MXC_UART_RevC_Transaction(mxc_uart_revc_req_t *req);
77 int MXC_UART_RevC_TransactionAsync(mxc_uart_revc_req_t *req);
78 int MXC_UART_RevC_TransactionDMA(mxc_uart_revc_req_t *req);
79 int MXC_UART_RevC_AbortAsync(mxc_uart_revc_regs_t *uart);
80 int MXC_UART_RevC_AsyncHandler(mxc_uart_revc_regs_t *uart);
81 int MXC_UART_RevC_AsyncStop(mxc_uart_revc_regs_t *uart);
82 int MXC_UART_RevC_AsyncCallback(mxc_uart_revc_regs_t *uart, int retVal);
83 void MXC_UART_RevC_DMACallback(int ch, int error);
84 
85 #endif // LIBRARIES_PERIPHDRIVERS_SOURCE_UART_UART_REVC_H_
86