Microchip® Advanced Software Framework

i2sc.h File Reference

I2S driver for SAM.

This file defines a useful set of functions for the I2S on SAM devices.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "status_codes.h"

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...