FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_i2s.h
1 /*
2  * FreeRTOS Common IO V1.0.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
26 /*******************************************************************************
27 * @file iot_hal_i2s.h
28 * @brief File for the APIs of I2S called by application layer.
29 *******************************************************************************
30 */
31 
32 #ifndef _IOT_I2S_H_
33 #define _IOT_I2S_H_
34 
38 #define IOT_I2S_SUCCESS ( 0 )
39 #define IOT_I2S_INVALID_VALUE ( 1 )
40 #define IOT_I2S_NOT_INITIALIZED ( 2 )
41 #define IOT_I2S_BUSY ( 3 )
42 #define IOT_I2S_WRITE_FAILED ( 4 )
43 #define IOT_I2S_READ_FAILED ( 5 )
44 #define IOT_I2S_NOTHING_TO_CANCEL ( 7 )
45 #define IOT_I2S_FUNCTION_NOT_SUPPORTED ( 8 )
50 typedef enum
51 {
52  eI2SBusIdle = 0,
53  eI2SBusBusy = IOT_I2S_BUSY,
54 } IotI2SBusStatus_t;
55 
59 typedef enum
60 {
61  eI2SCompleted = IOT_I2S_SUCCESS,
62  eI2SLastWriteFailed = IOT_I2S_WRITE_FAILED,
63  eI2SLastReadFailed = IOT_I2S_READ_FAILED,
65 } IotI2SOperationStatus_t;
66 
70 typedef enum
71 {
72  eI2SSetConfig,
73  eI2SGetConfig,
74  eI2SGetBusState,
75  eI2SGetTxNoOfbytes,
76  eI2SGetRxNoOfbytes,
77 } IotI2SIoctlRequest_t;
78 
82 typedef enum
83 {
84  eI2SNormalMode,
85  eI2SLeftJustifiedMode,
86  eI2SRightJustifiedMode,
87  eI2SPcmMode,
88  eI2SDspMode,
89 } IotI2SMode_t;
90 
94 typedef enum
95 {
96  eI2SChannelStereo,
97  eI2SChannelMono,
98 } IotI2SChannel_t;
99 
103 typedef enum
104 {
105  eI2SFallingEdge,
106  eI2SRisingEdge,
107 } IotI2SClkPolarity_t;
108 
112 typedef struct
113 {
114  IotI2SMode_t xI2SMode;
115  IotI2SChannel_t xI2SChannel;
116  IotI2SClkPolarity_t xI2SSckPolarity;
117  IotI2SClkPolarity_t xI2SWsPolarity;
118  uint32_t ulI2SFrequency;
119  uint32_t ulI2SDataLength;
120  uint32_t ulI2SFrameLength;
122 
126 struct IotI2SDescriptor;
127 
131 typedef struct IotI2SDescriptor * IotI2SHandle_t;
132 
142 typedef void ( * IotI2SCallback_t )( IotI2SOperationStatus_t xOpStatus, void * pvUserContext );
143 
155 IotI2SHandle_t iot_i2s_open( int32_t lI2SInstance );
156 
169 void iot_i2s_set_callback( IotI2SHandle_t const pxI2SPeripheral,
170  IotI2SCallback_t xCallback,
171  void * pvUserContext );
172 
189 int32_t iot_i2s_read_async( IotI2SHandle_t const pxI2SPeripheral,
190  uint8_t * const pvBuffer,
191  size_t xBytes);
192 
209 int32_t iot_i2s_write_async( IotI2SHandle_t const pxI2SPeripheral,
210  uint8_t * const pvBuffer,
211  size_t xBytes);
212 
229 int32_t iot_i2s_read_sync( IotI2SHandle_t const pxI2SPeripheral,
230  uint8_t * const pvBuffer,
231  size_t xBytes);
232 
249 int32_t iot_i2s_write_sync( IotI2SHandle_t const pxI2SPeripheral,
250  uint8_t * const pvBuffer,
251  size_t xBytes);
252 
264 int32_t iot_i2s_close( IotI2SHandle_t const pxI2SPeripheral);
265 
294 int32_t iot_i2s_ioctl( IotI2SHandle_t const pxI2SPeripheral,
295  IotI2SIoctlRequest_t xI2SRequest,
296  void * const pvBuffer );
297 
309 int32_t iot_i2s_cancel( IotI2SHandle_t const pxI2SPeripheral);
310 
311 #endif /* ifndef _IOT_HAL_I2S_H_ */
IotI2SClkPolarity_t xI2SWsPolarity
Definition: iot_i2s.h:117
IotI2SMode_t xI2SMode
Definition: iot_i2s.h:114
IotI2SChannel_t xI2SChannel
Definition: iot_i2s.h:115
I2S configuration.
Definition: iot_i2s.h:112
uint32_t ulI2SFrameLength
Definition: iot_i2s.h:120
uint32_t ulI2SFrequency
Definition: iot_i2s.h:118
IotI2SClkPolarity_t xI2SSckPolarity
Definition: iot_i2s.h:116
uint32_t ulI2SDataLength
Definition: iot_i2s.h:119