]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/lpc_core/lpc_chip/chip_18xx_43xx/i2s_18xx_43xx.h
Add extra debug comment into list.c.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / lpc_core / lpc_chip / chip_18xx_43xx / i2s_18xx_43xx.h
1 /*\r
2  * @brief LPC18xx/43xx I2S driver\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\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
22  *\r
23  * @par\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
29  * this code.\r
30  */\r
31 \r
32 #ifndef __I2S_18XX_43XX_H_\r
33 #define __I2S_18XX_43XX_H_\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 /** @defgroup I2S_18XX_43XX CHIP: LPC18xx/43xx I2S driver\r
40  * @ingroup CHIP_18XX_43XX_Drivers\r
41  * @{\r
42  */\r
43 \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
46 \r
47 /**\r
48  * @brief I2S Audio Format Structure\r
49  */\r
50 typedef struct {\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
55 \r
56 /**\r
57  * @brief       Initialize for I2S\r
58  * @param       pI2S    : The base of I2S peripheral on the chip\r
59  * @return      Nothing\r
60  */\r
61 void Chip_I2S_Init(LPC_I2S_T *pI2S);\r
62 \r
63 /**\r
64  * @brief       Shutdown I2S\r
65  * @param       pI2S    : The base of I2S peripheral on the chip\r
66  * @return      Nothing\r
67  * @note        Reset all relative registers (DMA, transmit/receive control, interrupt) to default value\r
68  */\r
69 void Chip_I2S_DeInit(LPC_I2S_T *pI2S);\r
70 \r
71 /**\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
75  * @return      Nothing\r
76  * @note        The function writes to TXFIFO without checking any condition.\r
77  */\r
78 STATIC INLINE void Chip_I2S_Send(LPC_I2S_T *pI2S, uint32_t data)\r
79 {\r
80         IP_I2S_Send(pI2S, data);\r
81 }\r
82 \r
83 /**\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
88  */\r
89 STATIC INLINE uint32_t Chip_I2S_Receive(LPC_I2S_T *pI2S)\r
90 {\r
91         return IP_I2S_Receive(pI2S);\r
92 }\r
93 \r
94 /**\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
98  * @return      Nothing\r
99  */\r
100 STATIC INLINE void Chip_I2S_Start(LPC_I2S_T *pI2S, uint8_t TRMode)\r
101 {\r
102         IP_I2S_Start(pI2S, TRMode);\r
103 }\r
104 \r
105 /**\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
109  * @return      Nothing\r
110  */\r
111 STATIC INLINE void Chip_I2S_Pause(LPC_I2S_T *pI2S, uint8_t TRMode)\r
112 {\r
113         IP_I2S_Pause(pI2S, TRMode);\r
114 }\r
115 \r
116 /**\r
117  * @brief       Mute the Transmit channel\r
118  * @param       pI2S    : The base of I2S peripheral on the chip\r
119  * @return      Nothing\r
120  * @note        The data output from I2S transmit channel is always zeroes\r
121  */\r
122 STATIC INLINE void Chip_I2S_EnableMute(LPC_I2S_T *pI2S)\r
123 {\r
124         IP_I2S_EnableMute(pI2S);\r
125 }\r
126 \r
127 /**\r
128  * @brief       Un-Mute the I2S channel\r
129  * @param       pI2S    : The base of I2S peripheral on the chip\r
130  * @return      Nothing\r
131  */\r
132 STATIC INLINE void Chip_I2S_DisableMute(LPC_I2S_T *pI2S)\r
133 {\r
134         IP_I2S_DisableMute(pI2S);\r
135 }\r
136 \r
137 /**\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
141  * @return      Nothing\r
142  * @note        Pause, resets the transmit channel and FIFO asynchronously\r
143  */\r
144 STATIC INLINE void Chip_I2S_Stop(LPC_I2S_T *pI2S, uint8_t TRMode)\r
145 {\r
146         IP_I2S_Stop(pI2S, TRMode);\r
147 }\r
148 \r
149 /**\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
156  * @return      Nothing\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
161  */\r
162 STATIC INLINE void Chip_I2S_ModeConfig(LPC_I2S_T *pI2S,\r
163                                                                            uint8_t TRMode,\r
164                                                                            uint32_t clksel,\r
165                                                                            uint32_t fpin,\r
166                                                                            uint32_t mcena)\r
167 {\r
168         IP_I2S_ModeConfig(pI2S, TRMode, clksel, fpin, mcena);\r
169 }\r
170 \r
171 /**\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
176  */\r
177 STATIC INLINE uint8_t Chip_I2S_GetLevel(LPC_I2S_T *pI2S, uint8_t TRMode)\r
178 {\r
179         return IP_I2S_GetLevel(pI2S, TRMode);\r
180 }\r
181 \r
182 /**\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
188  */\r
189 Status Chip_I2S_Config(LPC_I2S_T *pI2S, uint8_t TRMode, Chip_I2S_Audio_Format_T *audio_format);\r
190 \r
191 /**\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
197  * @return      Nothing\r
198  */\r
199 void Chip_I2S_Int_Cmd(LPC_I2S_T *pI2S, uint8_t TRMode, FunctionalState NewState, uint8_t FIFO_Depth);\r
200 \r
201 /**\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
210  * @return      Nothing\r
211  */\r
212 void Chip_I2S_DMA_Cmd(LPC_I2S_T *pI2S, uint8_t TRMode, uint8_t DMANum, FunctionalState NewState, uint8_t FIFO_Depth);\r
213 \r
214 /**\r
215  * @}\r
216  */\r
217 \r
218 #ifdef __cplusplus\r
219 }\r
220 #endif\r
221 \r
222 #endif /* __I2S_18XX_43XX_H_ */\r