MAX32675 Peripheral Driver API
Peripheral Driver API for the MAX32675
i2s.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  *************************************************************************** */
38 
39 #ifndef _I2S_H_
40 #define _I2S_H_
41 
42 /* **** Includes **** */
43 #include "mxc_sys.h"
44 #include "dma.h"
45 #include "i2s_regs.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
57 /* **** Definitions **** */
58 
60 typedef enum {
61  MXC_I2S_MONO_LEFT_CH = 2,
62  MXC_I2S_MONO_RIGHT_CH = 3
64 
66 typedef enum {
67  MXC_I2S_POL_NORMAL,
68  MXC_I2S_POL_INVERSE
70 
72 typedef enum {
73  MXC_I2S_MSB_FIRST,
74  MXC_I2S_LSB_FIRST
76 
78 typedef enum {
79  MXC_I2S_MSB_JUSTIFY,
80  MXC_I2S_LSB_JUSTIFY
82 
84 typedef enum {
85  MXC_I2S_DATASIZE_BYTE,
86  MXC_I2S_DATASIZE_HALFWORD,
87  MXC_I2S_DATASIZE_WORD
89 
91 typedef enum {
92  MXC_I2S_SAMPLESIZE_EIGTH,
93  MXC_I2S_SAMPLESIZE_SIXTEEN,
94  MXC_I2S_SAMPLESIZE_TWENTY,
95  MXC_I2S_SAMPLESIZE_TWENTYFOUR,
96  MXC_I2S_SAMPLESIZE_THIRTYTWO,
98 
100 typedef enum {
101  MXC_I2S_INTERNAL_SCK_WS_0,
102  MXC_I2S_INTERNAL_SCK_WS_1,
103  MXC_I2S_EXTERNAL_SCK_INTERNAL_WS,
104  MXC_I2S_EXTERNAL_SCK_EXTERNAL_WS,
106 
108 typedef struct {
109  mxc_i2s_ch_mode_t channelMode;
110  mxc_i2s_stereo_t stereoMode;
111  mxc_i2s_wsize_t wordSize;
112  mxc_i2s_justify_t justify;
113  mxc_i2s_bitorder_t bitOrder;
114  mxc_i2s_polarity_t wsPolarity;
115  mxc_i2s_samplesize_t sampleSize;
116  uint16_t clkdiv;
117  void *rawData;
118  void *txData;
119  void *rxData;
120  uint32_t length;
121 } mxc_i2s_req_t;
122 
123 /* **** Function Prototypes **** */
124 
131 int MXC_I2S_Init(mxc_i2s_req_t *req);
132 
138 int MXC_I2S_Shutdown(void);
139 
147 
151 void MXC_I2S_TXEnable(void);
152 
156 void MXC_I2S_TXDisable(void);
157 
161 void MXC_I2S_RXEnable(void);
162 
166 void MXC_I2S_RXDisable(void);
167 
174 int MXC_I2S_SetRXThreshold(uint8_t threshold);
175 
183 int MXC_I2S_SetFrequency(mxc_i2s_ch_mode_t mode, uint16_t clkdiv);
184 
189 void MXC_I2S_Flush(void);
190 
196 void MXC_I2S_EnableInt(uint32_t flags);
197 
203 void MXC_I2S_DisableInt(uint32_t flags);
204 
210 int MXC_I2S_GetFlags(void);
211 
217 void MXC_I2S_ClearFlags(uint32_t flags);
218 
225 void MXC_I2S_TXDMAConfig(void *src_addr, int len);
226 
233 void MXC_I2S_RXDMAConfig(void *dest_addr, int len);
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 
239 #endif /* _I2S_H_ */
mxc_i2s_wsize_t
mxc_i2s_wsize_t
I2S transaction word size.
Definition: i2s.h:84
MXC_I2S_TXEnable
void MXC_I2S_TXEnable(void)
Enable TX channel.
MXC_I2S_TXDMAConfig
void MXC_I2S_TXDMAConfig(void *src_addr, int len)
Configure TX DMA transaction.
MXC_I2S_EnableInt
void MXC_I2S_EnableInt(uint32_t flags)
Enable Interrupts.
MXC_I2S_TXDisable
void MXC_I2S_TXDisable(void)
Disable TX channel.
mxc_i2s_ch_mode_t
mxc_i2s_ch_mode_t
I2S channel mode.
Definition: i2s.h:100
MXC_I2S_RXDisable
void MXC_I2S_RXDisable(void)
Disable RX channel.
MXC_I2S_SetFrequency
int MXC_I2S_SetFrequency(mxc_i2s_ch_mode_t mode, uint16_t clkdiv)
Set I2S Frequency, automatically called by I2S_Init.
MXC_I2S_RXDMAConfig
void MXC_I2S_RXDMAConfig(void *dest_addr, int len)
Configure RX DMA transaction.
mxc_i2s_bitorder_t
mxc_i2s_bitorder_t
I2S transaction bit order.
Definition: i2s.h:72
MXC_I2S_Init
int MXC_I2S_Init(mxc_i2s_req_t *req)
Initialize I2S resources.
MXC_I2S_Shutdown
int MXC_I2S_Shutdown(void)
Release I2S, clear configuration and flush FIFOs.
MXC_I2S_RXEnable
void MXC_I2S_RXEnable(void)
Enable RX channel.
MXC_I2S_DisableInt
void MXC_I2S_DisableInt(uint32_t flags)
Disable Interrupt.
MXC_I2S_GetFlags
int MXC_I2S_GetFlags(void)
Get the set interrupt flags.
MXC_I2S_ClearFlags
void MXC_I2S_ClearFlags(uint32_t flags)
Clears Interrupt Flags.
mxc_i2s_polarity_t
mxc_i2s_polarity_t
I2S polarity configuration.
Definition: i2s.h:66
mxc_i2s_req_t
I2S Configuration Struct.
Definition: i2s.h:108
mxc_i2s_stereo_t
mxc_i2s_stereo_t
I2S stereo mode select.
Definition: i2s.h:60
MXC_I2S_Flush
void MXC_I2S_Flush(void)
Flush I2S FIFO.
mxc_i2s_samplesize_t
mxc_i2s_samplesize_t
I2S transaction sample size.
Definition: i2s.h:91
MXC_I2S_SetRXThreshold
int MXC_I2S_SetRXThreshold(uint8_t threshold)
Set threshold for RX FIFO
MXC_I2S_ConfigData
int MXC_I2S_ConfigData(mxc_i2s_req_t *req)
Configure data to be transmitted based on word and sample size.
mxc_i2s_justify_t
mxc_i2s_justify_t
I2S transaction justify order.
Definition: i2s.h:78