Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_i2s.h
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 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 )
50typedef enum
51{
52 eI2SBusIdle = 0,
53 eI2SBusBusy = IOT_I2S_BUSY,
54} IotI2SBusStatus_t;
55
59typedef enum
60{
61 eI2SCompleted = IOT_I2S_SUCCESS,
62 eI2SLastWriteFailed = IOT_I2S_WRITE_FAILED,
63 eI2SLastReadFailed = IOT_I2S_READ_FAILED,
64} IotI2SOperationStatus_t;
65
69typedef enum
70{
71 eI2SSetConfig,
72 eI2SGetConfig,
73 eI2SGetBusState,
74 eI2SGetTxNoOfbytes,
75 eI2SGetRxNoOfbytes,
76} IotI2SIoctlRequest_t;
77
81typedef enum
82{
83 eI2SNormalMode,
84 eI2SLeftJustifiedMode,
85 eI2SRightJustifiedMode,
86 eI2SPcmMode,
87 eI2SDspMode,
88} IotI2SMode_t;
89
93typedef enum
94{
95 eI2SChannelStereo,
96 eI2SChannelMono,
97} IotI2SChannel_t;
98
102typedef enum
103{
104 eI2SFallingEdge,
105 eI2SRisingEdge,
106} IotI2SClkPolarity_t;
107
111typedef struct
112{
113 IotI2SMode_t xI2SMode;
114 IotI2SChannel_t xI2SChannel;
115 IotI2SClkPolarity_t xI2SSckPolarity;
116 IotI2SClkPolarity_t xI2SWsPolarity;
117 uint32_t ulI2SFrequency;
121
125struct IotI2SDescriptor;
126
130typedef struct IotI2SDescriptor * IotI2SHandle_t;
131
141typedef void ( * IotI2SCallback_t )( IotI2SOperationStatus_t xOpStatus,
142 void * pvUserContext );
143
155IotI2SHandle_t iot_i2s_open( int32_t lI2SInstance );
156
169void iot_i2s_set_callback( IotI2SHandle_t const pxI2SPeripheral,
170 IotI2SCallback_t xCallback,
171 void * pvUserContext );
172
189int32_t iot_i2s_read_async( IotI2SHandle_t const pxI2SPeripheral,
190 uint8_t * const pvBuffer,
191 size_t xBytes );
192
209int32_t iot_i2s_write_async( IotI2SHandle_t const pxI2SPeripheral,
210 uint8_t * const pvBuffer,
211 size_t xBytes );
212
229int32_t iot_i2s_read_sync( IotI2SHandle_t const pxI2SPeripheral,
230 uint8_t * const pvBuffer,
231 size_t xBytes );
232
249int32_t iot_i2s_write_sync( IotI2SHandle_t const pxI2SPeripheral,
250 uint8_t * const pvBuffer,
251 size_t xBytes );
252
264int32_t iot_i2s_close( IotI2SHandle_t const pxI2SPeripheral );
265
294int32_t iot_i2s_ioctl( IotI2SHandle_t const pxI2SPeripheral,
295 IotI2SIoctlRequest_t xI2SRequest,
296 void * const pvBuffer );
297
309int32_t iot_i2s_cancel( IotI2SHandle_t const pxI2SPeripheral );
310
311#endif /* ifndef _IOT_HAL_I2S_H_ */
I2S configuration.
Definition: iot_i2s.h:112
IotI2SChannel_t xI2SChannel
Definition: iot_i2s.h:114
IotI2SClkPolarity_t xI2SWsPolarity
Definition: iot_i2s.h:116
uint32_t ulI2SDataLength
Definition: iot_i2s.h:118
IotI2SClkPolarity_t xI2SSckPolarity
Definition: iot_i2s.h:115
IotI2SMode_t xI2SMode
Definition: iot_i2s.h:113
uint32_t ulI2SFrameLength
Definition: iot_i2s.h:119
uint32_t ulI2SFrequency
Definition: iot_i2s.h:117