Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SSC - Synchronous Serial Controller (I2S)

Driver for the I2S protocol using the SSC (Synchronous Serial Controller).

The Atmel SSC provides a synchronous communication link with external devices. It supports several serial synchronous communication protocols generally used in audio and telecom applications such as I2S, Short Frame Sync, Long Frame Sync, etc.

Modules

 

Macros

#define SSC_I2S_TIMEOUT_VALUE   10000
 

Enumerations

enum  {
  SSC_I2S_ERROR = -1,
  SSC_I2S_OK = 0,
  SSC_I2S_TIMEOUT = 1,
  SSC_I2S_ERROR_ARGUMENT,
  SSC_I2S_ERROR_RX,
  SSC_I2S_ERROR_TX
}
 Error codes used by SSC I2S driver. More...
 
enum  {
  SSC_I2S_MODE_STEREO_OUT = 1,
  SSC_I2S_MODE_STEREO_OUT_EXT_CLK,
  SSC_I2S_MODE_SLAVE_STEREO_OUT,
  SSC_I2S_MODE_SLAVE_STEREO_IN,
  SSC_I2S_MODE_STEREO_OUT_MONO_IN,
  SSC_I2S_MODE_RIGHT_IN,
  SSC_I2S_MODE_STEREO_IN,
  SSC_I2S_MODE_STEREO_OUT_STEREO_IN
}
 SSC I2S modes. More...
 

Functions

void ssc_i2s_disable_interrupts (volatile avr32_ssc_t *ssc, unsigned long int_mask)
 Disables the specified SSC interrupts. More...
 
void ssc_i2s_enable_interrupts (volatile avr32_ssc_t *ssc, unsigned long int_mask)
 Enables the specified SSC interrupts. More...
 
unsigned long ssc_i2s_get_status (volatile avr32_ssc_t *ssc)
 Returns the SSC status. More...
 
int ssc_i2s_init (volatile avr32_ssc_t *ssc, unsigned int sample_frequency, unsigned int data_bit_res, unsigned int frame_bit_res, unsigned char mode, unsigned int pba_hz)
 Sets up registers and initializes SSC for use as I2S. More...
 
void ssc_i2s_reset (volatile avr32_ssc_t *ssc)
 Resets the SSC module. More...
 
int ssc_i2s_transfer (volatile avr32_ssc_t *ssc, unsigned int data)
 Transfers a single message of data. More...
 

#define SSC_I2S_TIMEOUT_VALUE   10000

Referenced by ssc_i2s_transfer().

anonymous enum

Error codes used by SSC I2S driver.

Enumerator
SSC_I2S_ERROR 
SSC_I2S_OK 
SSC_I2S_TIMEOUT 
SSC_I2S_ERROR_ARGUMENT 
SSC_I2S_ERROR_RX 
SSC_I2S_ERROR_TX 
anonymous enum

SSC I2S modes.

Enumerator
SSC_I2S_MODE_STEREO_OUT 

Two output channels.

SSC_I2S_MODE_STEREO_OUT_EXT_CLK 

Two output channels sampled with an external clock received from the SSC_RX_CLOCK line.

SSC_I2S_MODE_SLAVE_STEREO_OUT 

Two output channels controlled by the DAC.

SSC_I2S_MODE_SLAVE_STEREO_IN 

Two input channels controlled by the DAC.

SSC_I2S_MODE_STEREO_OUT_MONO_IN 

Two output, one input channel.

SSC_I2S_MODE_RIGHT_IN 

Right channel in. Used because one SSC only can manage one input channel at a time.

SSC_I2S_MODE_STEREO_IN 

Two input channels.

SSC_I2S_MODE_STEREO_OUT_STEREO_IN 

Two output channels and two input channels.

void ssc_i2s_disable_interrupts ( volatile avr32_ssc_t *  ssc,
unsigned long  int_mask 
)

Disables the specified SSC interrupts.

Parameters
sscBase address of the SSC instance.
int_maskBit-mask of SSC interrupts (AVR32_SSC_IDR_x_MASK).

References cpu_irq_disable, cpu_irq_enable, and cpu_irq_is_enabled.

void ssc_i2s_enable_interrupts ( volatile avr32_ssc_t *  ssc,
unsigned long  int_mask 
)

Enables the specified SSC interrupts.

Parameters
sscBase address of the SSC instance.
int_maskBit-mask of SSC interrupts (AVR32_SSC_IER_x_MASK).
unsigned long ssc_i2s_get_status ( volatile avr32_ssc_t *  ssc)

Returns the SSC status.

Parameters
sscBase address of the SSC instance.
Returns
The SSC Status Register.

Referenced by main().

int ssc_i2s_init ( volatile avr32_ssc_t *  ssc,
unsigned int  sample_frequency,
unsigned int  data_bit_res,
unsigned int  frame_bit_res,
unsigned char  mode,
unsigned int  pba_hz 
)

Sets up registers and initializes SSC for use as I2S.

Parameters
sscPointer to the correct volatile avr32_ssc_t struct
sample_frequencyThe sample frequency given in Hz
data_bit_resNumber of significant data bits in an I2S channel frame
frame_bit_resTotal number of bits in an I2S channel frame
modeI2S-mode
  • SSC_I2S_MODE_STEREO_OUT
  • SSC_I2S_MODE_STEREO_OUT_EXT_CLK
  • SSC_I2S_MODE_SLAVE_STEREO_OUT
  • SSC_I2S_MODE_STEREO_OUT_MONO_IN
  • SSC_I2S_MODE_RIGHT_IN
  • SSC_I2S_MODE_STEREO_IN
  • SSC_I2S_MODE_STEREO_OUT_STEREO_IN
pba_hzThe clock speed of the PBA bus in Hz.
Returns
Status
Return values
SSC_I2S_OKwhen no error occurred.
SSC_I2S_ERROR_ARGUMENTwhen invalid arguments are passed
Todo:
check input values

References set_clock_divider(), SSC_I2S_MODE_RIGHT_IN, SSC_I2S_MODE_SLAVE_STEREO_IN, SSC_I2S_MODE_SLAVE_STEREO_OUT, SSC_I2S_MODE_STEREO_OUT, SSC_I2S_MODE_STEREO_OUT_EXT_CLK, SSC_I2S_MODE_STEREO_OUT_MONO_IN, SSC_I2S_OK, and ssc_i2s_reset().

Referenced by aic23b_dac_setup(), and main().

void ssc_i2s_reset ( volatile avr32_ssc_t *  ssc)

Resets the SSC module.

Parameters
sscpointer to the correct volatile avr32_ssc_t struct

Referenced by aic23b_dac_stop(), ms3_dac_stop(), and ssc_i2s_init().

int ssc_i2s_transfer ( volatile avr32_ssc_t *  ssc,
unsigned int  data 
)

Transfers a single message of data.

Parameters
sscPointer to the correct volatile avr32_ssc_t struct
dataThe data to transfer
Returns
Status
Return values
SSC_I2S_OKwhen no error occurred.
SSC_I2S_TIMEOUTwhen a timeout occurred while trying to transfer

References data, SSC_I2S_OK, SSC_I2S_TIMEOUT, and SSC_I2S_TIMEOUT_VALUE.

Referenced by main().