TI-RTOS Drivers  tidrivers_full_2_20_00_08
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  */
151 #ifndef ti_drivers_I2S__include
152 #define ti_drivers_I2S__include
153 
154 #ifdef __cplusplus
155 extern "C" {
156 #endif
157 
158 #include <stdint.h>
159 #include <stddef.h>
160 
161 #include <ti/drivers/utils/List.h>
162 
180 #define I2S_CMD_RESERVED 32
181 
194 #define I2S_STATUS_RESERVED -32
195 
209 #define I2S_STATUS_SUCCESS 0
210 
217 #define I2S_STATUS_ERROR -1
218 
226 #define I2S_STATUS_UNDEFINEDCMD -2
227 
237 /* Add I2S_CMD_<commands> here */
238 
243 #define I2S_ERROR I2S_STATUS_ERROR
244 
248 #define I2S_WAIT_FOREVER ~(0)
249 
253 typedef struct I2S_Config *I2S_Handle;
254 
258 typedef struct I2S_BufDesc {
259 
262 
264  void *bufPtr;
265 
267  size_t bufSize;
268 
270  uintptr_t arg;
271 } I2S_BufDesc;
272 
283 typedef void (*I2S_Callback) (I2S_Handle, I2S_BufDesc *desc);
284 
291 typedef enum I2S_DataMode {
297 
305 } I2S_DataMode;
306 
312 typedef enum I2S_OpMode {
316 } I2S_OpMode;
317 
324 typedef enum I2S_SerInActiveConfig {
329 
335 typedef enum I2S_PinMode {
339 } I2S_PinMode;
340 
349 typedef struct I2S_Params {
352 
355 
357  unsigned char slotLength;
358 
360  unsigned char bitsPerSample;
361 
363  unsigned char numChannels;
364 
367 
370 
372  uint32_t readTimeout;
373 
376 
379 
381  uint32_t writeTimeout;
382 
384  uintptr_t customParams;
385 } I2S_Params;
386 
391 typedef void (*I2S_CloseFxn) (I2S_Handle handle);
392 
397 typedef int (*I2S_ControlFxn) (I2S_Handle handle,
398  unsigned int cmd,
399  void *arg);
400 
405 typedef void (*I2S_InitFxn) (I2S_Handle handle);
406 
411 typedef I2S_Handle (*I2S_OpenFxn) (I2S_Handle handle,
412  I2S_Params *params);
413 
418 typedef int (*I2S_IssueFxn) (I2S_Handle handle,I2S_BufDesc *desc);
419 
424 typedef size_t (*I2S_ReclaimFxn) (I2S_Handle handle,I2S_BufDesc **desc);
425 
431 typedef struct I2S_FxnTable {
434 
437 
440 
443 
446 
449 
452 
455 
456 } I2S_FxnTable;
457 
468 typedef struct I2S_Config {
472 
474  void *object;
475 
477  void const *hwAttrs;
478 } I2S_Config;
479 
490 extern void I2S_close(I2S_Handle handle);
491 
529 extern int I2S_control(I2S_Handle handle, unsigned int cmd, void *arg);
530 
539 extern void I2S_init(void);
540 
561 extern I2S_Handle I2S_open(unsigned int index, I2S_Params *params);
562 
585 extern void I2S_Params_init(I2S_Params *params);
586 
599 extern int I2S_read(I2S_Handle handle, I2S_BufDesc *desc);
600 
615 extern int I2S_readIssue(I2S_Handle handle, I2S_BufDesc *desc);
616 
627 extern size_t I2S_readReclaim(I2S_Handle handle, I2S_BufDesc **pDesc);
628 
641 extern int I2S_write(I2S_Handle handle, I2S_BufDesc *desc);
642 
655 extern int I2S_writeIssue(I2S_Handle handle, I2S_BufDesc *desc);
656 
667 extern size_t I2S_writeReclaim(I2S_Handle handle, I2S_BufDesc **pDesc);
668 
669 #ifdef __cplusplus
670 }
671 #endif
672 
673 #endif /* ti_drivers_I2S__include */
Definition: I2S.h:338
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:431
void * object
Definition: I2S.h:474
void(* I2S_CloseFxn)(I2S_Handle handle)
A function pointer to a driver specific implementation of I2S_CloseFxn().
Definition: I2S.h:391
struct I2S_Config * I2S_Handle
A handle that is returned from a I2S_open() call.
Definition: I2S.h:253
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:315
unsigned char slotLength
Definition: I2S.h:357
I2S_DataMode readMode
Definition: I2S.h:366
struct I2S_Config I2S_Config
I2S Global configuration.
struct I2S_Params I2S_Params
Basic I2S Parameters.
Definition: I2S.h:327
I2S_InitFxn initFxn
Definition: I2S.h:439
Definition: I2S.h:337
I2S_DataMode writeMode
Definition: I2S.h:375
I2S_Handle(* I2S_OpenFxn)(I2S_Handle handle, I2S_Params *params)
A function pointer to a driver specific implementation of I2S_OpenFxn().
Definition: I2S.h:411
unsigned char bitsPerSample
Definition: I2S.h:360
Definition: I2S.h:313
unsigned char numChannels
Definition: I2S.h:363
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:354
I2S Global configuration.
Definition: I2S.h:468
I2S_ReclaimFxn readReclaimFxn
Definition: I2S.h:448
Definition: I2S.h:304
size_t bufSize
Definition: I2S.h:267
struct I2S_BufDesc I2S_BufDesc
I2S buffer descriptor for issue/reclaim mode.
I2S_IssueFxn readIssueFxn
Definition: I2S.h:445
I2S buffer descriptor for issue/reclaim mode.
Definition: I2S.h:258
Definition: I2S.h:336
void(* I2S_InitFxn)(I2S_Handle handle)
A function pointer to a driver specific implementation of I2S_init().
Definition: I2S.h:405
I2S_FxnTable const * fxnTablePtr
Definition: I2S.h:471
void I2S_init(void)
Function to initializes the I2S module.
List_Elem qElem
Definition: I2S.h:261
Definition: List.h:126
I2S_DataMode
I2S mode settings.
Definition: I2S.h:291
I2S_OpMode
I2S mode settings.
Definition: I2S.h:312
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:433
Definition: I2S.h:326
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:325
uint32_t writeTimeout
Definition: I2S.h:381
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:451
I2S_SerInActiveConfig
I2S Serializer InActive state settings.
Definition: I2S.h:324
uintptr_t customParams
Definition: I2S.h:384
int(* I2S_IssueFxn)(I2S_Handle handle, I2S_BufDesc *desc)
A function pointer to a driver specific implementation of I2S_IssueFxn().
Definition: I2S.h:418
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:283
void I2S_Params_init(I2S_Params *params)
Function to initialize the I2S_Params struct to its defaults.
I2S_Callback writeCallback
Definition: I2S.h:378
uint32_t readTimeout
Definition: I2S.h:372
I2S_Callback readCallback
Definition: I2S.h:369
I2S_ReclaimFxn writeReclaimFxn
Definition: I2S.h:454
I2S_ControlFxn controlFxn
Definition: I2S.h:436
I2S_PinMode
I2S serial pin mode.
Definition: I2S.h:335
void const * hwAttrs
Definition: I2S.h:477
Definition: I2S.h:296
I2S_OpMode operationMode
Definition: I2S.h:351
I2S_OpenFxn openFxn
Definition: I2S.h:442
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:397
void * bufPtr
Definition: I2S.h:264
size_t(* I2S_ReclaimFxn)(I2S_Handle handle, I2S_BufDesc **desc)
A function pointer to a driver specific implementation of I2S_ReclaimFxn().
Definition: I2S.h:424
Definition: I2S.h:314
Linked List interface for use in drivers.
Basic I2S Parameters.
Definition: I2S.h:349
uintptr_t arg
Definition: I2S.h:270
Copyright 2016, Texas Instruments Incorporated