User | Revision | Line number | New contents of line |
lynxeyed_atsu |
0:63ed631d8c3a
|
1
|
/***********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
2
|
* @file lpc17xx_i2s.c
|
lynxeyed_atsu |
0:63ed631d8c3a
|
3
|
* @brief Contains all functions support for I2S firmware library on LPC17xx
|
lynxeyed_atsu |
0:63ed631d8c3a
|
4
|
* @version 3.0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
5
|
* @date 18. June. 2010
|
lynxeyed_atsu |
0:63ed631d8c3a
|
6
|
* @author NXP MCU SW Application Team
|
lynxeyed_atsu |
0:63ed631d8c3a
|
7
|
**************************************************************************
|
lynxeyed_atsu |
0:63ed631d8c3a
|
8
|
* Software that is described herein is for illustrative purposes only
|
lynxeyed_atsu |
0:63ed631d8c3a
|
9
|
* which provides customers with programming information regarding the
|
lynxeyed_atsu |
0:63ed631d8c3a
|
10
|
* products. This software is supplied "AS IS" without any warranties.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
11
|
* NXP Semiconductors assumes no responsibility or liability for the
|
lynxeyed_atsu |
0:63ed631d8c3a
|
12
|
* use of the software, conveys no license or title under any patent,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
13
|
* copyright, or mask work right to the product. NXP Semiconductors
|
lynxeyed_atsu |
0:63ed631d8c3a
|
14
|
* reserves the right to make changes in the software without
|
lynxeyed_atsu |
0:63ed631d8c3a
|
15
|
* notification. NXP Semiconductors also make no representation or
|
lynxeyed_atsu |
0:63ed631d8c3a
|
16
|
* warranty that such application will be suitable for the specified
|
lynxeyed_atsu |
0:63ed631d8c3a
|
17
|
* use without further testing or modification.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
18
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
19
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
20
|
/* Peripheral group ----------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
21
|
/** @addtogroup I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
22
|
* @{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
23
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
24
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
25
|
/* Includes ------------------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
26
|
//#include "mbed.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
27
|
#include "lpc17xx_i2s.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
28
|
#include "lpc17xx_clkpwr.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
29
|
#include "mbed.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
30
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
31
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
32
|
/* If this source file built with example, the LPC17xx FW library configuration
|
lynxeyed_atsu |
0:63ed631d8c3a
|
33
|
* file in each example directory ("lpc17xx_libcfg.h") must be included,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
34
|
* otherwise the default FW library configuration file must be included instead
|
lynxeyed_atsu |
0:63ed631d8c3a
|
35
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
36
|
#ifdef __BUILD_WITH_EXAMPLE__
|
lynxeyed_atsu |
0:63ed631d8c3a
|
37
|
#include "lpc17xx_libcfg.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
38
|
#else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
39
|
#include "lpc17xx_libcfg_default.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
40
|
#endif /* __BUILD_WITH_EXAMPLE__ */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
41
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
42
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
43
|
#ifdef _I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
44
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
45
|
/* Private Functions ---------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
46
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
47
|
static uint8_t i2s_GetWordWidth(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
48
|
static uint8_t i2s_GetChannel(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
49
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
50
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
51
|
* @brief Get I2S wordwidth value
|
lynxeyed_atsu |
0:63ed631d8c3a
|
52
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
53
|
* @param[in] TRMode is the I2S mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
54
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
55
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
56
|
* @return The wordwidth value, should be: 8,16 or 32
|
lynxeyed_atsu |
0:63ed631d8c3a
|
57
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
58
|
static uint8_t i2s_GetWordWidth(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
59
|
uint8_t value;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
60
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
61
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
62
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
63
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
64
|
if (TRMode == I2S_TX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
65
|
value = (I2Sx->I2SDAO) & 0x03; /* get wordwidth bit */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
66
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
67
|
value = (I2Sx->I2SDAI) & 0x03; /* get wordwidth bit */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
68
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
69
|
switch (value) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
70
|
case I2S_WORDWIDTH_8:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
71
|
return 8;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
72
|
case I2S_WORDWIDTH_16:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
73
|
return 16;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
74
|
default:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
75
|
return 32;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
76
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
77
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
78
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
79
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
80
|
* @brief Get I2S channel value
|
lynxeyed_atsu |
0:63ed631d8c3a
|
81
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
82
|
* @param[in] TRMode is the I2S mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
83
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
84
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
85
|
* @return The channel value, should be: 1(mono) or 2(stereo)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
86
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
87
|
static uint8_t i2s_GetChannel(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
88
|
uint8_t value;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
89
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
90
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
91
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
92
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
93
|
if (TRMode == I2S_TX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
94
|
value = (I2Sx->I2SDAO) & 0x04; /* get bit[2] */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
95
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
96
|
value = (I2Sx->I2SDAI) & 0x04; /* get bit[2] */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
97
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
98
|
if(value == I2S_MONO) return 1;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
99
|
return 2;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
100
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
101
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
102
|
/* End of Private Functions --------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
103
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
104
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
105
|
/* Public Functions ----------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
106
|
/** @addtogroup I2S_Public_Functions
|
lynxeyed_atsu |
0:63ed631d8c3a
|
107
|
* @{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
108
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
109
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
110
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
111
|
* @brief Initialize I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
112
|
* - Turn on power and clock
|
lynxeyed_atsu |
0:63ed631d8c3a
|
113
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
114
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
115
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
116
|
void I2S_Init(LPC_I2S_TypeDef *I2Sx) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
117
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
118
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
119
|
// Turn on power and clock
|
lynxeyed_atsu |
0:63ed631d8c3a
|
120
|
CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCI2S, ENABLE);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
121
|
LPC_I2S->I2SDAI = LPC_I2S->I2SDAO = 0x00;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
122
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
123
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
124
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
125
|
* @brief Configuration I2S, setting:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
126
|
* - master/slave mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
127
|
* - wordwidth value
|
lynxeyed_atsu |
0:63ed631d8c3a
|
128
|
* - channel mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
129
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
130
|
* @param[in] TRMode transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
131
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
132
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
133
|
* @param[in] ConfigStruct pointer to I2S_CFG_Type structure
|
lynxeyed_atsu |
0:63ed631d8c3a
|
134
|
* which will be initialized.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
135
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
136
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
137
|
void I2S_Config(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode, I2S_CFG_Type* ConfigStruct)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
138
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
139
|
uint32_t bps, config;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
140
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
141
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
142
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
143
|
CHECK_PARAM(PARAM_I2S_WORDWIDTH(ConfigStruct->wordwidth));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
144
|
CHECK_PARAM(PARAM_I2S_CHANNEL(ConfigStruct->mono));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
145
|
CHECK_PARAM(PARAM_I2S_STOP(ConfigStruct->stop));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
146
|
CHECK_PARAM(PARAM_I2S_RESET(ConfigStruct->reset));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
147
|
CHECK_PARAM(PARAM_I2S_WS_SEL(ConfigStruct->ws_sel));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
148
|
CHECK_PARAM(PARAM_I2S_MUTE(ConfigStruct->mute));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
149
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
150
|
/* Setup clock */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
151
|
bps = (ConfigStruct->wordwidth +1)*8;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
152
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
153
|
/* Calculate audio config */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
154
|
config = (bps - 1)<<6 | (ConfigStruct->ws_sel)<<5 | (ConfigStruct->reset)<<4 |
|
lynxeyed_atsu |
0:63ed631d8c3a
|
155
|
(ConfigStruct->stop)<<3 | (ConfigStruct->mono)<<2 | (ConfigStruct->wordwidth);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
156
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
157
|
if(TRMode == I2S_RX_MODE){
|
lynxeyed_atsu |
0:63ed631d8c3a
|
158
|
LPC_I2S->I2SDAI = config;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
159
|
}else{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
160
|
LPC_I2S->I2SDAO = config;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
161
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
162
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
163
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
164
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
165
|
* @brief DeInitial both I2S transmit or receive
|
lynxeyed_atsu |
0:63ed631d8c3a
|
166
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
167
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
168
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
169
|
void I2S_DeInit(LPC_I2S_TypeDef *I2Sx) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
170
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
171
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
172
|
// Turn off power and clock
|
lynxeyed_atsu |
0:63ed631d8c3a
|
173
|
CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCI2S, DISABLE);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
174
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
175
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
176
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
177
|
* @brief Get I2S Buffer Level
|
lynxeyed_atsu |
0:63ed631d8c3a
|
178
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
179
|
* @param[in] TRMode Transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
180
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
181
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
182
|
* @return current level of Transmit/Receive Buffer
|
lynxeyed_atsu |
0:63ed631d8c3a
|
183
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
184
|
uint8_t I2S_GetLevel(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
185
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
186
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
187
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
188
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
189
|
if(TRMode == I2S_TX_MODE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
190
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
191
|
return ((I2Sx->I2SSTATE >> 16) & 0xFF);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
192
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
193
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
194
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
195
|
return ((I2Sx->I2SSTATE >> 8) & 0xFF);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
196
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
197
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
198
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
199
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
200
|
* @brief I2S Start: clear all STOP,RESET and MUTE bit, ready to operate
|
lynxeyed_atsu |
0:63ed631d8c3a
|
201
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
202
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
203
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
204
|
void I2S_Start(LPC_I2S_TypeDef *I2Sx)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
205
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
206
|
//Clear STOP,RESET and MUTE bit
|
lynxeyed_atsu |
0:63ed631d8c3a
|
207
|
I2Sx->I2SDAO &= ~I2S_DAI_RESET;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
208
|
I2Sx->I2SDAI &= ~I2S_DAI_RESET;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
209
|
I2Sx->I2SDAO &= ~I2S_DAI_STOP;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
210
|
I2Sx->I2SDAI &= ~I2S_DAI_STOP;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
211
|
I2Sx->I2SDAO &= ~I2S_DAI_MUTE;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
212
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
213
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
214
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
215
|
* @brief I2S Send data
|
lynxeyed_atsu |
0:63ed631d8c3a
|
216
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
217
|
* @param[in] BufferData pointer to uint32_t is the data will be send
|
lynxeyed_atsu |
0:63ed631d8c3a
|
218
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
219
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
220
|
void I2S_Send(LPC_I2S_TypeDef *I2Sx, uint32_t BufferData) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
221
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
222
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
223
|
I2Sx->I2STXFIFO = BufferData;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
224
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
225
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
226
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
227
|
* @brief I2S Receive Data
|
lynxeyed_atsu |
0:63ed631d8c3a
|
228
|
* @param[in] I2Sx pointer to LPC_I2S_TypeDef
|
lynxeyed_atsu |
0:63ed631d8c3a
|
229
|
* @return received value
|
lynxeyed_atsu |
0:63ed631d8c3a
|
230
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
231
|
uint32_t I2S_Receive(LPC_I2S_TypeDef* I2Sx) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
232
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
233
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
234
|
return (I2Sx->I2SRXFIFO);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
235
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
236
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
237
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
238
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
239
|
* @brief I2S Pause
|
lynxeyed_atsu |
0:63ed631d8c3a
|
240
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
241
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
242
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
243
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
244
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
245
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
246
|
void I2S_Pause(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
247
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
248
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
249
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
250
|
if (TRMode == I2S_TX_MODE) //Transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
251
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
252
|
I2Sx->I2SDAO |= I2S_DAO_STOP;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
253
|
} else //Receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
254
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
255
|
I2Sx->I2SDAI |= I2S_DAI_STOP;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
256
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
257
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
258
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
259
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
260
|
* @brief I2S Mute
|
lynxeyed_atsu |
0:63ed631d8c3a
|
261
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
262
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
263
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
264
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
265
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
266
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
267
|
void I2S_Mute(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
268
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
269
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
270
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
271
|
if (TRMode == I2S_TX_MODE) //Transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
272
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
273
|
I2Sx->I2SDAO |= I2S_DAO_MUTE;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
274
|
} else //Receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
275
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
276
|
I2Sx->I2SDAI |= I2S_DAI_MUTE;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
277
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
278
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
279
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
280
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
281
|
* @brief I2S Stop
|
lynxeyed_atsu |
0:63ed631d8c3a
|
282
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
283
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
284
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
285
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
286
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
287
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
288
|
void I2S_Stop(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
289
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
290
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
291
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
292
|
if (TRMode == I2S_TX_MODE) //Transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
293
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
294
|
I2Sx->I2SDAO &= ~I2S_DAO_MUTE;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
295
|
I2Sx->I2SDAO |= I2S_DAO_STOP;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
296
|
I2Sx->I2SDAO |= I2S_DAO_RESET;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
297
|
} else //Receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
298
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
299
|
I2Sx->I2SDAI |= I2S_DAI_STOP;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
300
|
I2Sx->I2SDAI |= I2S_DAI_RESET;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
301
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
302
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
303
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
304
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
305
|
* @brief Set frequency for I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
306
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
307
|
* @param[in] Freq is the frequency for I2S will be set. It can range
|
lynxeyed_atsu |
0:63ed631d8c3a
|
308
|
* from 16-96 kHz(16, 22.05, 32, 44.1, 48, 96kHz)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
309
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
310
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
311
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
312
|
* @return Status: ERROR or SUCCESS
|
lynxeyed_atsu |
0:63ed631d8c3a
|
313
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
314
|
Status I2S_FreqConfig(LPC_I2S_TypeDef *I2Sx, uint32_t Freq, uint8_t TRMode) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
315
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
316
|
/* Calculate bit rate
|
lynxeyed_atsu |
0:63ed631d8c3a
|
317
|
* The formula is:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
318
|
* bit_rate = channel*wordwidth - 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
319
|
* 48kHz sample rate for 16 bit stereo date requires
|
lynxeyed_atsu |
0:63ed631d8c3a
|
320
|
* a bit rate of 48000*16*2=1536MHz (MCLK)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
321
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
322
|
uint32_t i2sPclk;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
323
|
uint64_t divider;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
324
|
uint8_t bitrate, channel, wordwidth;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
325
|
uint32_t x, y;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
326
|
uint16_t dif;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
327
|
uint16_t error;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
328
|
uint8_t x_divide, y_divide=0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
329
|
uint16_t ErrorOptimal = 0xFFFF;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
330
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
331
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
332
|
CHECK_PARAM(PRAM_I2S_FREQ(Freq));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
333
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
334
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
335
|
i2sPclk = CLKPWR_GetPCLK(CLKPWR_PCLKSEL_I2S);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
336
|
printf("I2S_PCLK = %dHz\r\n",i2sPclk);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
337
|
if(TRMode == I2S_TX_MODE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
338
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
339
|
channel = i2s_GetChannel(I2Sx,I2S_TX_MODE);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
340
|
wordwidth = i2s_GetWordWidth(I2Sx,I2S_TX_MODE);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
341
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
342
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
343
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
344
|
channel = i2s_GetChannel(I2Sx,I2S_RX_MODE);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
345
|
wordwidth = i2s_GetWordWidth(I2Sx,I2S_RX_MODE);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
346
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
347
|
bitrate = channel * wordwidth - 1;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
348
|
if (TRMode == I2S_TX_MODE)// Transmitter
|
lynxeyed_atsu |
0:63ed631d8c3a
|
349
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
350
|
I2Sx->I2STXBITRATE = bitrate;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
351
|
} else //Receiver
|
lynxeyed_atsu |
0:63ed631d8c3a
|
352
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
353
|
I2Sx->I2SRXBITRATE = bitrate;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
354
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
355
|
printf("TX CHANNEL= %d\r\n",i2s_GetChannel(I2Sx,I2S_TX_MODE));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
356
|
printf("TX WORDWIDTH= %dbits \r\n",i2s_GetWordWidth(I2Sx,I2S_TX_MODE));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
357
|
printf("I2STXBITRATE= %d,bitrate= %d \r\n",I2Sx->I2STXBITRATE,bitrate);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
358
|
/* Calculate X and Y divider
|
lynxeyed_atsu |
0:63ed631d8c3a
|
359
|
* The MCLK rate for the I2S transmitter is determined by the value
|
lynxeyed_atsu |
0:63ed631d8c3a
|
360
|
* in the I2STXRATE/I2SRXRATE register. The required I2STXRATE/I2SRXRATE
|
lynxeyed_atsu |
0:63ed631d8c3a
|
361
|
* setting depends on the desired audio sample rate desired, the format
|
lynxeyed_atsu |
0:63ed631d8c3a
|
362
|
* (stereo/mono) used, and the data size.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
363
|
* The formula is:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
364
|
* I2S_MCLK = PCLK * (X/Y) / 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
365
|
* We have:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
366
|
* I2S_MCLK = Freq * bit_rate;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
367
|
* So: (X/Y) = (Freq * bit_rate)/PCLK*2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
368
|
* We use a loop function to chose the most suitable X,Y value
|
lynxeyed_atsu |
0:63ed631d8c3a
|
369
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
370
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
371
|
divider = ((uint64_t)(Freq *( bitrate+1)/* * 2*/)<<16) / i2sPclk;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
372
|
for (y = 255; y > 0; y--) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
373
|
x = y * divider;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
374
|
dif = x & 0xFFFF;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
375
|
if(dif>0x8000) error = 0x10000-dif;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
376
|
else error = dif;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
377
|
if (error == 0)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
378
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
379
|
y_divide = y;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
380
|
break;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
381
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
382
|
else if (error < ErrorOptimal)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
383
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
384
|
ErrorOptimal = error;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
385
|
y_divide = y;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
386
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
387
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
388
|
//y_divide--;//for test
|
lynxeyed_atsu |
0:63ed631d8c3a
|
389
|
x_divide = (y_divide * Freq *( bitrate+1)* 2)/i2sPclk;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
390
|
if (TRMode == I2S_TX_MODE)// Transmitter
|
lynxeyed_atsu |
0:63ed631d8c3a
|
391
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
392
|
I2Sx->I2STXRATE = y_divide | (x_divide << 8);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
393
|
} else //Receiver
|
lynxeyed_atsu |
0:63ed631d8c3a
|
394
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
395
|
I2Sx->I2SRXRATE = y_divide | (x_divide << 8);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
396
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
397
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
398
|
printf("I2STXRATE=%d, x_divide=%d, y_divide=%d \r\n",I2Sx->I2STXRATE,x_divide,y_divide);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
399
|
return SUCCESS;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
400
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
401
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
402
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
403
|
* @brief I2S set bitrate
|
lynxeyed_atsu |
0:63ed631d8c3a
|
404
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
405
|
* @param[in] bitrate value will be set, it can be calculate as follows:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
406
|
* bitrate = channel * wordwidth - 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
407
|
* bitrate value should be in range: 0 .. 63
|
lynxeyed_atsu |
0:63ed631d8c3a
|
408
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
409
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
410
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
411
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
412
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
413
|
void I2S_SetBitRate(LPC_I2S_TypeDef *I2Sx, uint8_t bitrate, uint8_t TRMode)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
414
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
415
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
416
|
CHECK_PARAM(PARAM_I2S_BITRATE(bitrate));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
417
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
418
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
419
|
if(TRMode == I2S_TX_MODE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
420
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
421
|
I2Sx->I2STXBITRATE = bitrate;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
422
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
423
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
424
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
425
|
I2Sx->I2SRXBITRATE = bitrate;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
426
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
427
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
428
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
429
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
430
|
* @brief Configuration operating mode for I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
431
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
432
|
* @param[in] ModeConfig pointer to I2S_MODEConf_Type will be used to
|
lynxeyed_atsu |
0:63ed631d8c3a
|
433
|
* configure
|
lynxeyed_atsu |
0:63ed631d8c3a
|
434
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
435
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
436
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
437
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
438
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
439
|
void I2S_ModeConfig(LPC_I2S_TypeDef *I2Sx, I2S_MODEConf_Type* ModeConfig,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
440
|
uint8_t TRMode)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
441
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
442
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
443
|
CHECK_PARAM(PARAM_I2S_CLKSEL(ModeConfig->clksel));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
444
|
CHECK_PARAM(PARAM_I2S_4PIN(ModeConfig->fpin));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
445
|
CHECK_PARAM(PARAM_I2S_MCLK(ModeConfig->mcena));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
446
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
447
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
448
|
if (TRMode == I2S_TX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
449
|
I2Sx->I2STXMODE &= ~0x0F; //clear bit 3:0 in I2STXMODE register
|
lynxeyed_atsu |
0:63ed631d8c3a
|
450
|
if (ModeConfig->clksel == I2S_CLKSEL_MCLK) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
451
|
I2Sx->I2STXMODE |= 0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
452
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
453
|
if (ModeConfig->fpin == I2S_4PIN_ENABLE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
454
|
I2Sx->I2STXMODE |= (1 << 2);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
455
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
456
|
if (ModeConfig->mcena == I2S_MCLK_ENABLE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
457
|
I2Sx->I2STXMODE |= (1 << 3);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
458
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
459
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
460
|
I2Sx->I2SRXMODE &= ~0x0F; //clear bit 3:0 in I2STXMODE register
|
lynxeyed_atsu |
0:63ed631d8c3a
|
461
|
if (ModeConfig->clksel == I2S_CLKSEL_MCLK) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
462
|
I2Sx->I2SRXMODE |= 0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
463
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
464
|
if (ModeConfig->fpin == I2S_4PIN_ENABLE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
465
|
I2Sx->I2SRXMODE |= (1 << 2);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
466
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
467
|
if (ModeConfig->mcena == I2S_MCLK_ENABLE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
468
|
I2Sx->I2SRXMODE |= (1 << 3);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
469
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
470
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
471
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
472
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
473
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
474
|
* @brief Configure DMA operation for I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
475
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
476
|
* @param[in] DMAConfig pointer to I2S_DMAConf_Type will be used to configure
|
lynxeyed_atsu |
0:63ed631d8c3a
|
477
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
478
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
479
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
480
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
481
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
482
|
void I2S_DMAConfig(LPC_I2S_TypeDef *I2Sx, I2S_DMAConf_Type* DMAConfig,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
483
|
uint8_t TRMode)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
484
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
485
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
486
|
CHECK_PARAM(PARAM_I2S_DMA(DMAConfig->DMAIndex));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
487
|
CHECK_PARAM(PARAM_I2S_DMA_DEPTH(DMAConfig->depth));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
488
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
489
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
490
|
if (TRMode == I2S_RX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
491
|
if (DMAConfig->DMAIndex == I2S_DMA_1) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
492
|
LPC_I2S->I2SDMA1 = (DMAConfig->depth) << 8;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
493
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
494
|
LPC_I2S->I2SDMA2 = (DMAConfig->depth) << 8;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
495
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
496
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
497
|
if (DMAConfig->DMAIndex == I2S_DMA_1) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
498
|
LPC_I2S->I2SDMA1 = (DMAConfig->depth) << 16;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
499
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
500
|
LPC_I2S->I2SDMA2 = (DMAConfig->depth) << 16;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
501
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
502
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
503
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
504
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
505
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
506
|
* @brief Enable/Disable DMA operation for I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
507
|
* @param[in] I2Sx: I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
508
|
* @param[in] DMAIndex chose what DMA is used, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
509
|
* - I2S_DMA_1 = 0: DMA1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
510
|
* - I2S_DMA_2 = 1: DMA2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
511
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
512
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
513
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
514
|
* @param[in] NewState is new state of DMA operation, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
515
|
* - ENABLE
|
lynxeyed_atsu |
0:63ed631d8c3a
|
516
|
* - DISABLE
|
lynxeyed_atsu |
0:63ed631d8c3a
|
517
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
518
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
519
|
void I2S_DMACmd(LPC_I2S_TypeDef *I2Sx, uint8_t DMAIndex, uint8_t TRMode,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
520
|
FunctionalState NewState)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
521
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
522
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
523
|
CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
524
|
CHECK_PARAM(PARAM_I2S_DMA(DMAIndex));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
525
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
526
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
527
|
if (TRMode == I2S_RX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
528
|
if (DMAIndex == I2S_DMA_1) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
529
|
if (NewState == ENABLE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
530
|
I2Sx->I2SDMA1 |= 0x01;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
531
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
532
|
I2Sx->I2SDMA1 &= ~0x01;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
533
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
534
|
if (NewState == ENABLE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
535
|
I2Sx->I2SDMA2 |= 0x01;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
536
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
537
|
I2Sx->I2SDMA2 &= ~0x01;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
538
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
539
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
540
|
if (DMAIndex == I2S_DMA_1) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
541
|
if (NewState == ENABLE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
542
|
I2Sx->I2SDMA1 |= 0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
543
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
544
|
I2Sx->I2SDMA1 &= ~0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
545
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
546
|
if (NewState == ENABLE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
547
|
I2Sx->I2SDMA2 |= 0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
548
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
549
|
I2Sx->I2SDMA2 &= ~0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
550
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
551
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
552
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
553
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
554
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
555
|
* @brief Configure IRQ for I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
556
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
557
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
558
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
559
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
560
|
* @param[in] level is the FIFO level that triggers IRQ request
|
lynxeyed_atsu |
0:63ed631d8c3a
|
561
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
562
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
563
|
void I2S_IRQConfig(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode, uint8_t level) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
564
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
565
|
CHECK_PARAM(PARAM_I2S_TRX(TRMode));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
566
|
CHECK_PARAM(PARAM_I2S_IRQ_LEVEL(level));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
567
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
568
|
if (TRMode == I2S_RX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
569
|
I2Sx->I2SIRQ |= (level << 8);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
570
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
571
|
I2Sx->I2SIRQ |= (level << 16);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
572
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
573
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
574
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
575
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
576
|
* @brief Enable/Disable IRQ for I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
577
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
578
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
579
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
580
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
581
|
* @param[in] NewState is new state of DMA operation, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
582
|
* - ENABLE
|
lynxeyed_atsu |
0:63ed631d8c3a
|
583
|
* - DISABLE
|
lynxeyed_atsu |
0:63ed631d8c3a
|
584
|
* @return none
|
lynxeyed_atsu |
0:63ed631d8c3a
|
585
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
586
|
void I2S_IRQCmd(LPC_I2S_TypeDef *I2Sx, uint8_t TRMode, FunctionalState NewState) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
587
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
588
|
CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
589
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
590
|
if (TRMode == I2S_RX_MODE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
591
|
if (NewState == ENABLE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
592
|
I2Sx->I2SIRQ |= 0x01;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
593
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
594
|
I2Sx->I2SIRQ &= ~0x01;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
595
|
//Enable DMA
|
lynxeyed_atsu |
0:63ed631d8c3a
|
596
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
597
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
598
|
if (NewState == ENABLE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
599
|
I2Sx->I2SIRQ |= 0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
600
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
601
|
I2Sx->I2SIRQ &= ~0x02;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
602
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
603
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
604
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
605
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
606
|
* @brief Get I2S interrupt status
|
lynxeyed_atsu |
0:63ed631d8c3a
|
607
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
608
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
609
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
610
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
611
|
* @return FunctionState should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
612
|
* - ENABLE: interrupt is enable
|
lynxeyed_atsu |
0:63ed631d8c3a
|
613
|
* - DISABLE: interrupt is disable
|
lynxeyed_atsu |
0:63ed631d8c3a
|
614
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
615
|
FunctionalState I2S_GetIRQStatus(LPC_I2S_TypeDef *I2Sx,uint8_t TRMode)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
616
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
617
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
618
|
if(TRMode == I2S_TX_MODE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
619
|
return (FunctionalState)((I2Sx->I2SIRQ >> 1)&0x01);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
620
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
621
|
return (FunctionalState)((I2Sx->I2SIRQ)&0x01);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
622
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
623
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
624
|
/********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
625
|
* @brief Get I2S interrupt depth
|
lynxeyed_atsu |
0:63ed631d8c3a
|
626
|
* @param[in] I2Sx I2S peripheral selected, should be: LPC_I2S
|
lynxeyed_atsu |
0:63ed631d8c3a
|
627
|
* @param[in] TRMode is transmit/receive mode, should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
628
|
* - I2S_TX_MODE = 0: transmit mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
629
|
* - I2S_RX_MODE = 1: receive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
630
|
* @return depth of FIFO level on which to create an irq request
|
lynxeyed_atsu |
0:63ed631d8c3a
|
631
|
*********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
632
|
uint8_t I2S_GetIRQDepth(LPC_I2S_TypeDef *I2Sx,uint8_t TRMode)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
633
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
634
|
CHECK_PARAM(PARAM_I2Sx(I2Sx));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
635
|
if(TRMode == I2S_TX_MODE)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
636
|
return (((I2Sx->I2SIRQ)>>16)&0xFF);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
637
|
else
|
lynxeyed_atsu |
0:63ed631d8c3a
|
638
|
return (((I2Sx->I2SIRQ)>>8)&0xFF);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
639
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
640
|
/**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
641
|
* @}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
642
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
643
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
644
|
#endif /* _I2S */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
645
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
646
|
/**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
647
|
* @}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
648
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
649
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
650
|
/* --------------------------------- End Of File ------------------------------ */
|