TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
I2S.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
154 #ifndef ti_drivers_I2S__include
155 #define ti_drivers_I2S__include
156 
157 #ifdef __cplusplus
158 extern "C" {
159 #endif
160 
161 #include <stdint.h>
162 #include <stddef.h>
163 
164 #include <ti/drivers/utils/List.h>
165 
177 #define I2S_CMD_RESERVED 32
178 
191 #define I2S_STATUS_RESERVED -32
192 
199 #define I2S_STATUS_SUCCESS 0
200 
207 #define I2S_STATUS_ERROR -1
208 
216 #define I2S_STATUS_UNDEFINEDCMD -2
217 
218 #define I2S_ERROR I2S_STATUS_ERROR
219 
223 #define I2S_WAIT_FOREVER ~(0)
224 
228 typedef struct I2S_Config *I2S_Handle;
229 
233 typedef struct I2S_BufDesc {
234 
236  List_Elem qElem;
237 
239  void *bufPtr;
240 
242  size_t bufSize;
243 
245  uintptr_t arg;
246 } I2S_BufDesc;
247 
258 typedef void (*I2S_Callback) (I2S_Handle, I2S_BufDesc *desc);
259 
266 typedef enum I2S_DataMode {
272 
280 } I2S_DataMode;
281 
287 typedef enum I2S_OpMode {
291 } I2S_OpMode;
292 
299 typedef enum I2S_SerInActiveConfig {
304 
310 typedef enum I2S_PinMode {
314 } I2S_PinMode;
315 
324 typedef struct I2S_Params {
327 
330 
332  unsigned char slotLength;
333 
335  unsigned char bitsPerSample;
336 
338  unsigned char numChannels;
339 
342 
345 
347  uint32_t readTimeout;
348 
351 
354 
356  uint32_t writeTimeout;
357 
359  void * customParams;
360 } I2S_Params;
361 
366 typedef void (*I2S_CloseFxn) (I2S_Handle handle);
367 
372 typedef int (*I2S_ControlFxn) (I2S_Handle handle,
373  unsigned int cmd,
374  void *arg);
375 
380 typedef void (*I2S_InitFxn) (I2S_Handle handle);
381 
386 typedef I2S_Handle (*I2S_OpenFxn) (I2S_Handle handle,
387  I2S_Params *params);
388 
393 typedef int (*I2S_IssueFxn) (I2S_Handle handle,I2S_BufDesc *desc);
394 
399 typedef size_t (*I2S_ReclaimFxn) (I2S_Handle handle,I2S_BufDesc **desc);
400 
406 typedef struct I2S_FxnTable {
409 
412 
415 
418 
421 
424 
427 
430 
431 } I2S_FxnTable;
432 
443 typedef struct I2S_Config {
447 
449  void *object;
450 
452  void const *hwAttrs;
453 } I2S_Config;
454 
465 extern void I2S_close(I2S_Handle handle);
466 
485 extern int I2S_control(I2S_Handle handle, unsigned int cmd, void *arg);
486 
495 extern void I2S_init(void);
496 
517 extern I2S_Handle I2S_open(unsigned int index, I2S_Params *params);
518 
541 extern void I2S_Params_init(I2S_Params *params);
542 
555 extern int I2S_read(I2S_Handle handle, I2S_BufDesc *desc);
556 
571 extern int I2S_readIssue(I2S_Handle handle, I2S_BufDesc *desc);
572 
583 extern size_t I2S_readReclaim(I2S_Handle handle, I2S_BufDesc **pDesc);
584 
597 extern int I2S_write(I2S_Handle handle, I2S_BufDesc *desc);
598 
611 extern int I2S_writeIssue(I2S_Handle handle, I2S_BufDesc *desc);
612 
623 extern size_t I2S_writeReclaim(I2S_Handle handle, I2S_BufDesc **pDesc);
624 
625 #ifdef __cplusplus
626 }
627 #endif
628 
629 #endif /* ti_drivers_I2S__include */
Definition: I2S.h:313
int I2S_write(I2S_Handle handle, I2S_BufDesc *desc)
Function to queue a buffer of data to the I2S in callback mode for writing.
The definition of a I2S function table that contains the required set of functions to control a speci...
Definition: I2S.h:406
void * object
Definition: I2S.h:449
void(* I2S_CloseFxn)(I2S_Handle handle)
A function pointer to a driver specific implementation of I2S_CloseFxn().
Definition: I2S.h:366
struct I2S_Config * I2S_Handle
A handle that is returned from a I2S_open() call.
Definition: I2S.h:228
int I2S_writeIssue(I2S_Handle handle, I2S_BufDesc *desc)
Function to queue a buffer of data to the I2S in Issue/Reclaim mode for writing.
size_t I2S_readReclaim(I2S_Handle handle, I2S_BufDesc **pDesc)
Function to retrieve a full buffer of data read by the I2S.
int I2S_read(I2S_Handle handle, I2S_BufDesc *desc)
Function to queue a buffer of data to the I2S in callback mode for reading.
Definition: I2S.h:290
unsigned char slotLength
Definition: I2S.h:332
I2S_DataMode readMode
Definition: I2S.h:341
struct I2S_Config I2S_Config
I2S Global configuration.
struct I2S_Params I2S_Params
Basic I2S Parameters.
Definition: I2S.h:302
I2S_InitFxn initFxn
Definition: I2S.h:414
Definition: I2S.h:312
I2S_DataMode writeMode
Definition: I2S.h:350
I2S_Handle(* I2S_OpenFxn)(I2S_Handle handle, I2S_Params *params)
A function pointer to a driver specific implementation of I2S_OpenFxn().
Definition: I2S.h:386
unsigned char bitsPerSample
Definition: I2S.h:335
Definition: I2S.h:288
unsigned char numChannels
Definition: I2S.h:338
size_t I2S_writeReclaim(I2S_Handle handle, I2S_BufDesc **pDesc)
Function to retrieve a buffer that the I2S has finished writing.
uint32_t samplingFrequency
Definition: I2S.h:329
I2S Global configuration.
Definition: I2S.h:443
I2S_ReclaimFxn readReclaimFxn
Definition: I2S.h:423
Definition: I2S.h:279
size_t bufSize
Definition: I2S.h:242
struct I2S_BufDesc I2S_BufDesc
I2S buffer descriptor for issue/reclaim mode.
I2S_IssueFxn readIssueFxn
Definition: I2S.h:420
I2S buffer descriptor for issue/reclaim mode.
Definition: I2S.h:233
Definition: I2S.h:311
void(* I2S_InitFxn)(I2S_Handle handle)
A function pointer to a driver specific implementation of I2S_init().
Definition: I2S.h:380
I2S_FxnTable const * fxnTablePtr
Definition: I2S.h:446
void I2S_init(void)
Function to initializes the I2S module.
List_Elem qElem
Definition: I2S.h:236
I2S_DataMode
I2S mode settings.
Definition: I2S.h:266
I2S_OpMode
I2S mode settings.
Definition: I2S.h:287
void * customParams
Definition: I2S.h:359
I2S_Handle I2S_open(unsigned int index, I2S_Params *params)
Function to initialize a given I2S peripheral specified by the particular index value. The parameter specifies which mode the I2S will operate.
I2S_CloseFxn closeFxn
Definition: I2S.h:408
Definition: I2S.h:301
struct I2S_FxnTable I2S_FxnTable
The definition of a I2S function table that contains the required set of functions to control a speci...
Definition: I2S.h:300
uint32_t writeTimeout
Definition: I2S.h:356
int I2S_control(I2S_Handle handle, unsigned int cmd, void *arg)
Function performs implementation specific features on a given I2S_Handle.
int I2S_readIssue(I2S_Handle handle, I2S_BufDesc *desc)
Function to queue a buffer of data to the I2S in Issue/Reclaim mode for reading.
I2S_IssueFxn writeIssueFxn
Definition: I2S.h:426
I2S_SerInActiveConfig
I2S Serializer InActive state settings.
Definition: I2S.h:299
int(* I2S_IssueFxn)(I2S_Handle handle, I2S_BufDesc *desc)
A function pointer to a driver specific implementation of I2S_IssueFxn().
Definition: I2S.h:393
void(* I2S_Callback)(I2S_Handle, I2S_BufDesc *desc)
The definition of a callback function used by the I2S driver when used in I2S_MODE_CALLBACK.
Definition: I2S.h:258
void I2S_Params_init(I2S_Params *params)
Function to initialize the I2S_Params struct to its defaults.
I2S_Callback writeCallback
Definition: I2S.h:353
uint32_t readTimeout
Definition: I2S.h:347
I2S_Callback readCallback
Definition: I2S.h:344
I2S_ReclaimFxn writeReclaimFxn
Definition: I2S.h:429
I2S_ControlFxn controlFxn
Definition: I2S.h:411
I2S_PinMode
I2S serial pin mode.
Definition: I2S.h:310
void const * hwAttrs
Definition: I2S.h:452
Definition: I2S.h:271
I2S_OpMode operationMode
Definition: I2S.h:326
I2S_OpenFxn openFxn
Definition: I2S.h:417
void I2S_close(I2S_Handle handle)
Function to close a given I2S peripheral specified by the I2S handle.
int(* I2S_ControlFxn)(I2S_Handle handle, unsigned int cmd, void *arg)
A function pointer to a driver specific implementation of I2S_control().
Definition: I2S.h:372
void * bufPtr
Definition: I2S.h:239
size_t(* I2S_ReclaimFxn)(I2S_Handle handle, I2S_BufDesc **desc)
A function pointer to a driver specific implementation of I2S_ReclaimFxn().
Definition: I2S.h:399
Definition: I2S.h:289
Basic I2S Parameters.
Definition: I2S.h:324
uintptr_t arg
Definition: I2S.h:245
Copyright 2015, Texas Instruments Incorporated