2 * @brief LPC18xx/43xx I2S driver
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __I2S_18XX_43XX_H_
\r
33 #define __I2S_18XX_43XX_H_
\r
39 /** @defgroup I2S_18XX_43XX CHIP: LPC18xx/43xx I2S driver
\r
40 * @ingroup CHIP_18XX_43XX_Drivers
\r
44 #define I2S_DMA_REQUEST_NUMBER_1 IP_I2S_DMA_REQUEST_NUMBER_1
\r
45 #define I2S_DMA_REQUEST_NUMBER_2 IP_I2S_DMA_REQUEST_NUMBER_2
\r
48 * @brief I2S Audio Format Structure
\r
51 uint32_t SampleRate; /*!< Sample Rate */
\r
52 uint8_t ChannelNumber; /*!< Channel Number - 1 is mono, 2 is stereo */
\r
53 uint8_t WordWidth; /*!< Word Width - 8, 16 or 32 bits */
\r
54 } Chip_I2S_Audio_Format_T;
\r
57 * @brief Initialize for I2S
\r
58 * @param pI2S : The base of I2S peripheral on the chip
\r
61 void Chip_I2S_Init(LPC_I2S_T *pI2S);
\r
64 * @brief Shutdown I2S
\r
65 * @param pI2S : The base of I2S peripheral on the chip
\r
67 * @note Reset all relative registers (DMA, transmit/receive control, interrupt) to default value
\r
69 void Chip_I2S_DeInit(LPC_I2S_T *pI2S);
\r
72 * @brief Send a 32-bit data to TXFIFO for transmition
\r
73 * @param pI2S : The base of I2S peripheral on the chip
\r
74 * @param data : Data to be transmited
\r
76 * @note The function writes to TXFIFO without checking any condition.
\r
78 STATIC INLINE void Chip_I2S_Send(LPC_I2S_T *pI2S, uint32_t data)
\r
80 IP_I2S_Send(pI2S, data);
\r
84 * @brief Get received data from RXFIFO
\r
85 * @param pI2S : The base of I2S peripheral on the chip
\r
86 * @return Data received in RXFIFO
\r
87 * @note The function reads from RXFIFO without checking any condition.
\r
89 STATIC INLINE uint32_t Chip_I2S_Receive(LPC_I2S_T *pI2S)
\r
91 return IP_I2S_Receive(pI2S);
\r
95 * @brief Start the I2S
\r
96 * @param pI2S : The base of I2S peripheral on the chip
\r
97 * @param TRMode : Transmit/Receive mode, should be I2S_RX_MODE or I2S_TX_MODE
\r
100 STATIC INLINE void Chip_I2S_Start(LPC_I2S_T *pI2S, uint8_t TRMode)
\r
102 IP_I2S_Start(pI2S, TRMode);
\r
106 * @brief Disables accesses on FIFOs, places the transmit channel in mute mode
\r
107 * @param pI2S : The base of I2S peripheral on the chip
\r
108 * @param TRMode : Transmit/Receive mode, should be I2S_RX_MODE or I2S_TX_MODE
\r
111 STATIC INLINE void Chip_I2S_Pause(LPC_I2S_T *pI2S, uint8_t TRMode)
\r
113 IP_I2S_Pause(pI2S, TRMode);
\r
117 * @brief Mute the Transmit channel
\r
118 * @param pI2S : The base of I2S peripheral on the chip
\r
120 * @note The data output from I2S transmit channel is always zeroes
\r
122 STATIC INLINE void Chip_I2S_EnableMute(LPC_I2S_T *pI2S)
\r
124 IP_I2S_EnableMute(pI2S);
\r
128 * @brief Un-Mute the I2S channel
\r
129 * @param pI2S : The base of I2S peripheral on the chip
\r
132 STATIC INLINE void Chip_I2S_DisableMute(LPC_I2S_T *pI2S)
\r
134 IP_I2S_DisableMute(pI2S);
\r
138 * @brief Stop I2S asynchronously
\r
139 * @param pI2S : The base of I2S peripheral on the chip
\r
140 * @param TRMode : Transmit/Receive mode, should be I2S_RX_MODE or I2S_TX_MODE
\r
142 * @note Pause, resets the transmit channel and FIFO asynchronously
\r
144 STATIC INLINE void Chip_I2S_Stop(LPC_I2S_T *pI2S, uint8_t TRMode)
\r
146 IP_I2S_Stop(pI2S, TRMode);
\r
150 * @brief Set the I2S operating modes
\r
151 * @param pI2S : The base of I2S peripheral on the chip
\r
152 * @param TRMode : Transmit/Receive mode, should be I2S_RX_MODE or I2S_TX_MODE
\r
153 * @param clksel : Clock source selection for the receive bit clock divider
\r
154 * @param fpin : Receive 4-pin mode selection
\r
155 * @param mcena : Enable for the RX_MCLK output
\r
157 * @note In addition to master and slave modes, which are independently configurable for
\r
158 * the transmitter and the receiver, several different clock sources are possible,
\r
159 * including variations that share the clock and/or WS between the transmitter and
\r
160 * receiver. It also allows using I2S with fewer pins, typically four.
\r
162 STATIC INLINE void Chip_I2S_ModeConfig(LPC_I2S_T *pI2S,
\r
168 IP_I2S_ModeConfig(pI2S, TRMode, clksel, fpin, mcena);
\r
172 * @brief Get the current level of the Transmit/Receive FIFO
\r
173 * @param pI2S : The base of I2S peripheral on the chip
\r
174 * @param TRMode : Transmit/Receive mode, should be I2S_RX_MODE or I2S_TX_MODE
\r
175 * @return Current level of the Transmit/Receive FIFO
\r
177 STATIC INLINE uint8_t Chip_I2S_GetLevel(LPC_I2S_T *pI2S, uint8_t TRMode)
\r
179 return IP_I2S_GetLevel(pI2S, TRMode);
\r
183 * @brief Configure I2S for Audio Format input
\r
184 * @param pI2S : The base I2S peripheral on the chip
\r
185 * @param TRMode : Mode Rx/Tx
\r
186 * @param audio_format : Audio Format
\r
187 * @return SUCCESS or ERROR
\r
189 Status Chip_I2S_Config(LPC_I2S_T *pI2S, uint8_t TRMode, Chip_I2S_Audio_Format_T *audio_format);
\r
192 * @brief Enable/Disable Interrupt with a specific FIFO depth
\r
193 * @param pI2S : The base I2S peripheral on the chip
\r
194 * @param TRMode : Mode Rx/Tx
\r
195 * @param NewState : ENABLE or DISABLE interrupt
\r
196 * @param FIFO_Depth : FIFO level creating an irq request
\r
199 void Chip_I2S_Int_Cmd(LPC_I2S_T *pI2S, uint8_t TRMode, FunctionalState NewState, uint8_t FIFO_Depth);
\r
202 * @brief Enable/Disable DMA with a specific FIFO depth
\r
203 * @param pI2S : The base I2S peripheral on the chip
\r
204 * @param TRMode : Mode Rx/Tx
\r
205 * @param DMANum : Should be
\r
206 * - IP_I2S_DMA_REQUEST_NUMBER_1 : Using DMA1
\r
207 * - IP_I2S_DMA_REQUEST_NUMBER_2 : Using DMA2
\r
208 * @param NewState : ENABLE or DISABLE interrupt
\r
209 * @param FIFO_Depth : FIFO level creating an irq request
\r
212 void Chip_I2S_DMA_Cmd(LPC_I2S_T *pI2S, uint8_t TRMode, uint8_t DMANum, FunctionalState NewState, uint8_t FIFO_Depth);
\r
222 #endif /* __I2S_18XX_43XX_H_ */
\r