Quentin Roche / ST_I2S

Dependents:   X_NUCLEO_CCA02M1

Fork of ST_I2S by ST

Embed: (wiki syntax)

« Back to documentation index

I2S Configuration Functions

I2S Configuration Functions

Functions

void i2s_init (i2s_t *obj, PinName data, PinName sclk, PinName wsel, PinName fdpx, PinName mclk, i2s_mode_t mode)
 Initialize the I2S peripheral.
void i2s_free (i2s_t *obj)
 Release a I2S object.
void i2s_format (i2s_t *obj, int dbits, int fbits, int polarity)
 Configure the I2S format.
void i2s_set_protocol (i2s_t *obj, i2s_bitorder_t protocol)
 Configure the I2S protocol.
void i2s_set_mode (i2s_t *obj, i2s_mode_t mode)
 Configure the I2S mode.
void i2s_audio_frequency (i2s_t *obj, uint32_t hz)
 Set the I2S audio frequency.

Function Documentation

void i2s_audio_frequency ( i2s_t obj,
uint32_t  hz 
)

Set the I2S audio frequency.

Actual frequency may differ from the desired frequency due to available dividers and bus clock Configures the I2S audio frequency

Parameters:
[in,out]objThe I2S object to configure
[in]hzThe baud rate in Hz
void i2s_format ( i2s_t obj,
int  dbits,
int  fbits,
int  polarity 
)

Configure the I2S format.

Set the number of bits per frame, configure clock polarity and phase, shift order and master/slave mode

Parameters:
[in,out]objThe I2S object to configure
[in]dbitsNumber of data bits per I2S frame (16, 24, or 32)
[in]fbitsNumber of bits per I2S frame (16 or 32)
[in]polarityClock polarity (either 0 or 1, default = 0)
void i2s_free ( i2s_t obj )

Release a I2S object.

TODO: i2s_free is currently unimplemented This will require reference counting at the C++ level to be safe

Return the pins owned by the I2S object to their reset state Disable the I2S peripheral Disable the I2S clock

Parameters:
[in]objThe I2S object to deinitialize
void i2s_init ( i2s_t obj,
PinName  data,
PinName  sclk,
PinName  wsel,
PinName  fdpx,
PinName  mclk,
i2s_mode_t  mode 
)

Initialize the I2S peripheral.

Configures the pins used by I2S, sets a default format and frequency, and enables the peripheral

Parameters:
[out]objThe I2S object to initialize
[in]dataI2S data input/output pin
[in]sclkI2S clock output pin
[in]wselI2S word select output pin (might be NC for PDM sources)
[in]fdpxI2S data input pin (for full-duplex operation, default = NC)
[in]mclkI2S master clock output pin (default = NC, enables master clock output when not NC)
[in]modeI2S mode to be applied
void i2s_set_mode ( i2s_t obj,
i2s_mode_t  mode 
)

Configure the I2S mode.

Parameters:
[in,out]objThe I2S object to configure
[in]modeI2S mode to be applied
void i2s_set_protocol ( i2s_t obj,
i2s_bitorder_t  protocol 
)

Configure the I2S protocol.

Parameters:
[in,out]objThe I2S object to configure
[in]protocolI2S protocol to be used