Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
I2SC - Inter-IC Sound Controller

Driver for the I2SC - Inter-IC Sound Controller module.

I2SC provides a 5-wire, bidirectional, synchronous, digital audio link with off-chip audio devices: ISDI, ISDO, IWS, ISCK and IMCK pins.

Modules

 

Data Structures

struct  i2s_config
 Configuration setting structure. More...
 
struct  i2s_dev_inst
 

Macros

#define I2S_RETRY_VALUE   10000
 

Typedefs

typedef void(* i2s_callback_t )(void)
 
typedef enum i2s_interrupt_source i2s_interrupt_source_t
 I2S interrupt source. More...
 

Enumerations

enum  i2s_data_format {
  I2S_DATA_32BIT = 0,
  I2S_DATA_24BIT,
  I2S_DATA_20BIT,
  I2S_DATA_18BIT,
  I2S_DATA_16BIT,
  I2S_DATA_16BIT_COMPACT,
  I2S_DATA_8BIT,
  I2S_DATA_8BIT_COMPACT
}
 Data format. More...
 
enum  i2s_dma_channel {
  I2S_ONE_DMA_CHANNEL_FOR_BOTH_CHANNELS = 0,
  I2S_ONE_DMA_CHANNEL_FOR_ONE_CHANNEL
}
 DMA channel usage for I2S transfer. More...
 
enum  i2s_fs_rate {
  I2S_FS_RATE_32 = 0,
  I2S_FS_RATE_64 = 1,
  I2S_FS_RATE_96 = 2,
  I2S_FS_RATE_128 = 3,
  I2S_FS_RATE_192 = 5,
  I2S_FS_RATE_256 = 7,
  I2S_FS_RATE_384 = 11,
  I2S_FS_RATE_512 = 15,
  I2S_FS_RATE_768 = 23,
  I2S_FS_RATE_1024 = 31,
  I2S_FS_RATE_1536 = 47,
  I2S_FS_RATE_2048 = 63
}
 Supported Master Clock to Sample Frequency (fs) Ratio. More...
 
enum  i2s_interrupt_source {
  I2S_INTERRUPT_RXRDY = 0,
  I2S_INTERRUPT_RXOR,
  I2S_INTERRUPT_TXRDY,
  I2S_INTERRUPT_TXUR,
  I2S_INTERRUPT_ENDRX,
  I2S_INTERRUPT_ENDTX,
  I2S_INTERRUPT_RXBUFF,
  I2S_INTERRUPT_TXBUFE,
  _I2S_INTERRUPT_SOURCE_NUM
}
 I2S interrupt source. More...
 
enum  i2s_number_of_channels {
  I2S_CHANNEL_MONO = 0,
  I2S_CHANNEL_STEREO
}
 Supported number of channels. More...
 

Functions

void i2s_clear_status (struct i2s_dev_inst *const dev_inst, i2s_interrupt_source_t source)
 Clear the I2S status value. More...
 
void i2s_disable (struct i2s_dev_inst *const dev_inst)
 Disable the I2S module. More...
 
static void i2s_disable_clocks (struct i2s_dev_inst *dev_inst)
 Disable the clocks for the I2S module. More...
 
void i2s_disable_interrupt (struct i2s_dev_inst *const dev_inst, i2s_interrupt_source_t source)
 Disable the specified interrput sources. More...
 
static void i2s_disable_reception (struct i2s_dev_inst *dev_inst)
 Disable the I2S module in reception. More...
 
static void i2s_disable_transmission (struct i2s_dev_inst *dev_inst)
 Disable the I2S module in transmission. More...
 
void i2s_enable (struct i2s_dev_inst *const dev_inst)
 Enable the I2S module. More...
 
static void i2s_enable_clocks (struct i2s_dev_inst *dev_inst)
 Enable the clocks for the I2S module. More...
 
void i2s_enable_interrupt (struct i2s_dev_inst *const dev_inst, i2s_interrupt_source_t source)
 Enable the specified interrput sources. More...
 
static void i2s_enable_reception (struct i2s_dev_inst *dev_inst)
 Enable the I2S module in reception. More...
 
static void i2s_enable_transmission (struct i2s_dev_inst *dev_inst)
 Enable the I2S module in transmission. More...
 
static void i2s_get_config_defaults (struct i2s_config *const cfg)
 Get the default I2S module configuration: Data format: 32 bits Sample frequecny ratio: 1024 Tx channel: Stereo Rx channel: Stereo DMA for Tx: 1 DMA channel for 1 I2S Tx channel DMA for Rx: 1 DMA channel for 1 I2S Rx channel Loopback: No Master mode: Yes Master clock enable: Yes Transmit data in underrun: Yes Slot length is 24: No. More...
 
static uint32_t i2s_get_interrupt_mask (struct i2s_dev_inst *const dev_inst)
 Get the I2S interrupts mask value. More...
 
static uint32_t i2s_get_status (struct i2s_dev_inst *dev_inst)
 Get the I2S status value. More...
 
enum status_code i2s_init (struct i2s_dev_inst *const dev_inst, I2sc *i2sc, struct i2s_config *const cfg)
 Initialize and configure the I2S module. More...
 
enum status_code i2s_read (struct i2s_dev_inst *dev_inst, uint32_t *data)
 Read a single message of data. More...
 
static void i2s_reset (struct i2s_dev_inst *dev_inst)
 Resets the I2S module. More...
 
void i2s_set_callback (struct i2s_dev_inst *const dev_inst, i2s_interrupt_source_t source, i2s_callback_t callback, uint8_t irq_level)
 Set callback for I2S. More...
 
enum status_code i2s_write (struct i2s_dev_inst *dev_inst, uint32_t data)
 Write a single message of data. More...
 

#define I2S_RETRY_VALUE   10000

Referenced by i2s_read(), and i2s_write().

typedef void(* i2s_callback_t)(void)

I2S interrupt source.

Data format.

Enumerator
I2S_DATA_32BIT 
I2S_DATA_24BIT 
I2S_DATA_20BIT 
I2S_DATA_18BIT 
I2S_DATA_16BIT 
I2S_DATA_16BIT_COMPACT 
I2S_DATA_8BIT 
I2S_DATA_8BIT_COMPACT 

DMA channel usage for I2S transfer.

Enumerator
I2S_ONE_DMA_CHANNEL_FOR_BOTH_CHANNELS 
I2S_ONE_DMA_CHANNEL_FOR_ONE_CHANNEL 

Supported Master Clock to Sample Frequency (fs) Ratio.

Enumerator
I2S_FS_RATE_32 
I2S_FS_RATE_64 
I2S_FS_RATE_96 
I2S_FS_RATE_128 
I2S_FS_RATE_192 
I2S_FS_RATE_256 
I2S_FS_RATE_384 
I2S_FS_RATE_512 
I2S_FS_RATE_768 
I2S_FS_RATE_1024 
I2S_FS_RATE_1536 
I2S_FS_RATE_2048 

I2S interrupt source.

Enumerator
I2S_INTERRUPT_RXRDY 
I2S_INTERRUPT_RXOR 
I2S_INTERRUPT_TXRDY 
I2S_INTERRUPT_TXUR 
I2S_INTERRUPT_ENDRX 
I2S_INTERRUPT_ENDTX 
I2S_INTERRUPT_RXBUFF 
I2S_INTERRUPT_TXBUFE 
_I2S_INTERRUPT_SOURCE_NUM 

Supported number of channels.

Enumerator
I2S_CHANNEL_MONO 
I2S_CHANNEL_STEREO 

void i2s_clear_status ( struct i2s_dev_inst dev_inst,
i2s_interrupt_source_t  source 
)

Clear the I2S status value.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source

References Assert, i2s_dev_inst::hw_dev, I2S_INTERRUPT_RXOR, and I2S_INTERRUPT_TXUR.

void i2s_disable ( struct i2s_dev_inst *const  dev_inst)

Disable the I2S module.

Parameters
dev_instDevice structure pointer.

References SLEEPMGR_ACTIVE, sleepmgr_unlock_mode(), and UNUSED.

Referenced by run_i2s_test().

static void i2s_disable_clocks ( struct i2s_dev_inst dev_inst)
inlinestatic

Disable the clocks for the I2S module.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

void i2s_disable_interrupt ( struct i2s_dev_inst *const  dev_inst,
i2s_interrupt_source_t  source 
)

Disable the specified interrput sources.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source

References Assert, i2s_dev_inst::hw_dev, I2S_INTERRUPT_ENDRX, I2S_INTERRUPT_ENDTX, I2S_INTERRUPT_RXBUFF, I2S_INTERRUPT_RXOR, I2S_INTERRUPT_RXRDY, I2S_INTERRUPT_TXBUFE, I2S_INTERRUPT_TXRDY, and I2S_INTERRUPT_TXUR.

static void i2s_disable_reception ( struct i2s_dev_inst dev_inst)
inlinestatic

Disable the I2S module in reception.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

static void i2s_disable_transmission ( struct i2s_dev_inst dev_inst)
inlinestatic

Disable the I2S module in transmission.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

void i2s_enable ( struct i2s_dev_inst *const  dev_inst)

Enable the I2S module.

Parameters
dev_instDevice structure pointer.

References SLEEPMGR_ACTIVE, sleepmgr_lock_mode(), and UNUSED.

Referenced by run_i2s_test().

static void i2s_enable_clocks ( struct i2s_dev_inst dev_inst)
inlinestatic

Enable the clocks for the I2S module.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

Referenced by run_i2s_test().

void i2s_enable_interrupt ( struct i2s_dev_inst *const  dev_inst,
i2s_interrupt_source_t  source 
)

Enable the specified interrput sources.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source

References Assert, i2s_dev_inst::hw_dev, I2S_INTERRUPT_ENDRX, I2S_INTERRUPT_ENDTX, I2S_INTERRUPT_RXBUFF, I2S_INTERRUPT_RXOR, I2S_INTERRUPT_RXRDY, I2S_INTERRUPT_TXBUFE, I2S_INTERRUPT_TXRDY, and I2S_INTERRUPT_TXUR.

Referenced by i2s_set_callback().

static void i2s_enable_reception ( struct i2s_dev_inst dev_inst)
inlinestatic

Enable the I2S module in reception.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

Referenced by run_i2s_test().

static void i2s_enable_transmission ( struct i2s_dev_inst dev_inst)
inlinestatic

Enable the I2S module in transmission.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

Referenced by run_i2s_test().

static void i2s_get_config_defaults ( struct i2s_config *const  cfg)
inlinestatic

Get the default I2S module configuration: Data format: 32 bits Sample frequecny ratio: 1024 Tx channel: Stereo Rx channel: Stereo DMA for Tx: 1 DMA channel for 1 I2S Tx channel DMA for Rx: 1 DMA channel for 1 I2S Rx channel Loopback: No Master mode: Yes Master clock enable: Yes Transmit data in underrun: Yes Slot length is 24: No.

Parameters
cfgPointer to I2S configuration.

References Assert, i2s_config::data_format, i2s_config::fs_ratio, I2S_CHANNEL_STEREO, I2S_DATA_32BIT, I2S_FS_RATE_1024, I2S_ONE_DMA_CHANNEL_FOR_ONE_CHANNEL, i2s_config::loopback, i2s_config::master_clock_divide, i2s_config::master_clock_enable, i2s_config::master_mode, i2s_config::rx_channels, i2s_config::rx_dma, i2s_config::slot_length_24, i2s_config::transmit_mode_underrun, i2s_config::tx_channels, and i2s_config::tx_dma.

Referenced by run_i2s_test().

static uint32_t i2s_get_interrupt_mask ( struct i2s_dev_inst *const  dev_inst)
inlinestatic

Get the I2S interrupts mask value.

Parameters
dev_instDevice structure pointer.
Returns
Interrupt mask value

References i2s_dev_inst::hw_dev.

Referenced by i2s_interrupt_handler().

static uint32_t i2s_get_status ( struct i2s_dev_inst dev_inst)
inlinestatic

Get the I2S status value.

Parameters
dev_instDevice structure pointer.
Returns
Status value

References i2s_dev_inst::hw_dev.

Referenced by i2s_interrupt_handler().

enum status_code i2s_init ( struct i2s_dev_inst *const  dev_inst,
I2sc *  i2sc,
struct i2s_config *const  cfg 
)

Initialize and configure the I2S module.

Parameters
dev_instDevice structure pointer.
i2scBase address of the I2SC instance.
cfgPointer to I2S configuration.
Returns
status

References _i2s_set_config(), Assert, i2s_dev_inst::cfg, i2s_dev_inst::hw_dev, i2s_reset(), and sysclk_enable_peripheral_clock().

Referenced by run_i2s_test().

enum status_code i2s_read ( struct i2s_dev_inst *const  dev_inst,
uint32_t *  data 
)

Read a single message of data.

Parameters
dev_instDevice structure pointer.
*dataPointer for receive data
Returns
status

References Assert, i2s_dev_inst::hw_dev, I2S_RETRY_VALUE, STATUS_ERR_TIMEOUT, and STATUS_OK.

Referenced by wait_transfer().

static void i2s_reset ( struct i2s_dev_inst dev_inst)
inlinestatic

Resets the I2S module.

Parameters
dev_instDevice structure pointer.

References i2s_dev_inst::hw_dev.

Referenced by i2s_init().

void i2s_set_callback ( struct i2s_dev_inst *const  dev_inst,
i2s_interrupt_source_t  source,
i2s_callback_t  callback,
uint8_t  irq_level 
)

Set callback for I2S.

Parameters
dev_instDevice structure pointer.
sourceInterrupt source.
callbackCallback function pointer.
irq_levelInterrupt level.

References Assert, callback, i2s_dev_inst::hw_dev, i2s_callback_pointer, and i2s_enable_interrupt().

enum status_code i2s_write ( struct i2s_dev_inst *const  dev_inst,
uint32_t  data 
)

Write a single message of data.

Parameters
dev_instDevice structure pointer.
dataThe data to write
Returns
status

References Assert, i2s_dev_inst::hw_dev, I2S_RETRY_VALUE, STATUS_ERR_TIMEOUT, and STATUS_OK.

Referenced by wait_transfer().