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_I2S_I2S_REVA_H_
22 #define LIBRARIES_PERIPHDRIVERS_SOURCE_I2S_I2S_REVA_H_
23 
24 /* **** Includes **** */
25 #include <stdint.h>
26 #include "i2s.h"
27 #include "i2s_reva_regs.h"
28 
29 /****** Definitions *****/
30 
31 /* **** Functions **** */
32 int MXC_I2S_RevA_Init(mxc_i2s_reva_regs_t *i2s, mxc_i2s_req_t *req);
33 
34 int MXC_I2S_RevA_Shutdown(mxc_i2s_reva_regs_t *i2s);
35 
36 int MXC_I2S_RevA_ConfigData(mxc_i2s_reva_regs_t *i2s, mxc_i2s_req_t *req);
37 
38 void MXC_I2S_RevA_TXEnable(mxc_i2s_reva_regs_t *i2s);
39 
40 void MXC_I2S_RevA_TXDisable(mxc_i2s_reva_regs_t *i2s);
41 
42 void MXC_I2S_RevA_RXEnable(mxc_i2s_reva_regs_t *i2s);
43 
44 void MXC_I2S_RevA_RXDisable(mxc_i2s_reva_regs_t *i2s);
45 
46 int MXC_I2S_RevA_SetRXThreshold(mxc_i2s_reva_regs_t *i2s, uint8_t threshold);
47 
48 int MXC_I2S_RevA_SetFrequency(mxc_i2s_reva_regs_t *i2s, mxc_i2s_ch_mode_t mode, uint16_t clkdiv);
49 
50 int MXC_I2S_RevA_SetSampleRate(mxc_i2s_reva_regs_t *i2s, uint32_t smpl_rate,
51                                mxc_i2s_wsize_t smpl_sz, uint32_t src_clk);
52 
53 int MXC_I2S_RevA_GetSampleRate(mxc_i2s_reva_regs_t *i2s, uint32_t src_clk);
54 
55 int MXC_I2S_RevA_CalculateClockDiv(mxc_i2s_reva_regs_t *i2s, uint32_t smpl_rate,
56                                    mxc_i2s_wsize_t word_sz, uint32_t src_clk);
57 
58 void MXC_I2S_RevA_Flush(mxc_i2s_reva_regs_t *i2s);
59 
60 int MXC_I2S_RevA_FillTXFIFO(mxc_i2s_reva_regs_t *i2s, void *txData, mxc_i2s_wsize_t wordSize,
61                             int len, int smpl_cnt);
62 
63 int MXC_I2S_RevA_ReadRXFIFO(mxc_i2s_reva_regs_t *i2s, void *rxData, mxc_i2s_wsize_t wordSize,
64                             int len, int smpl_cnt);
65 
66 void MXC_I2S_RevA_EnableInt(mxc_i2s_reva_regs_t *i2s, uint32_t flags);
67 
68 void MXC_I2S_RevA_DisableInt(mxc_i2s_reva_regs_t *i2s, uint32_t flags);
69 
70 int MXC_I2S_RevA_GetFlags(mxc_i2s_reva_regs_t *i2s);
71 
72 void MXC_I2S_RevA_ClearFlags(mxc_i2s_reva_regs_t *i2s, uint32_t flags);
73 
74 int MXC_I2S_RevA_Transaction(mxc_i2s_reva_regs_t *i2s, mxc_i2s_req_t *i2s_req);
75 
76 int MXC_I2S_RevA_TransactionAsync(mxc_i2s_reva_regs_t *i2s, mxc_i2s_req_t *i2s_req);
77 
78 int MXC_I2S_RevA_TXDMAConfig(mxc_i2s_reva_regs_t *i2s, void *src_addr, int len);
79 
80 int MXC_I2S_RevA_RXDMAConfig(mxc_i2s_reva_regs_t *i2s, void *dest_addr, int len);
81 
82 void MXC_I2S_RevA_Handler(mxc_i2s_reva_regs_t *i2s);
83 
84 void MXC_I2S_RevA_RegisterDMACallback(void (*callback)(int, int));
85 
86 void MXC_I2S_RevA_RegisterAsyncCallback(void (*callback)(int));
87 
88 #endif // LIBRARIES_PERIPHDRIVERS_SOURCE_I2S_I2S_REVA_H_
89