PCM#

Introduction#

PCM protocol is widely used in audio applications for transmitting and storing audio data. The PCM peripheral in the SI91x family supports mono audio data transmission and reception with configurable sampling rates and resolutions.

The PCM peripheral provides the following features:

  1. Programmable audio resolutions

  2. Configurable sampling rates

  3. Mono audio support

  4. DMA-based data transfer

Configuration#

The PCM module can be configured using the following parameters:

  1. Audio resolutions supported: sl_pcm_data_resolution_t

  2. Sampling rates supported: sl_pcm_sampling_rate_t

  • For more information on configuring available parameters, see the respective peripheral example readme document.

Usage#

The PCM module can be initialized and configured to transmit or receive audio data. Below are the steps to use the PCM module:

  1. Initialize the PCM: sl_si91x_pcm_init

  2. Configure PCM settings: sl_si91x_pcm_set_configuration

  3. Perform data operations:

  4. Deinitialize the PCM: sl_si91x_pcm_deinit

(end addtogroup PCM)

Enumerations#

enum
SL_PCM_RESOLUTION_12 = 12
SL_PCM_RESOLUTION_16 = 16
SL_PCM_RESOLUTION_20 = 20
SL_PCM_RESOLUTION_24 = 24
SL_PCM_RESOLUTION_32 = 32
}

Enumeration for PCM audio data resolutions.

enum
SL_PCM_SAMPLING_RATE_8000 = 8000
SL_PCM_SAMPLING_RATE_11025 = 11025
SL_PCM_SAMPLING_RATE_16000 = 16000
SL_PCM_SAMPLING_RATE_22050 = 22050
SL_PCM_SAMPLING_RATE_24000 = 24000
}

Enumeration for PCM sample rates.

Functions#

sl_status_t
sl_si91x_pcm_init(uint32_t pcm_instance, sl_i2s_handle_t *pcm_handle)

To initialize the PCM peripheral.

sl_status_t
sl_si91x_pcm_deinit(sl_i2s_handle_t *pcm_handle)

To uninitialize the PCM peripheral.

sl_status_t
sl_si91x_pcm_set_configuration(sl_i2s_handle_t pcm_handle, uint16_t pcm_sampling_frequency, uint16_t pcm_resolution, uint16_t mode)

To configure the PCM module.

sl_status_t
sl_si91x_pcm_transmit_data(sl_i2s_handle_t pcm_handle, const void *data, uint32_t size)

To transmit PCM data.

sl_status_t
sl_si91x_pcm_receive_data(sl_i2s_handle_t pcm_handle, const void *data, uint32_t size)

To receive PCM data.

sl_status_t
sl_si91x_pcm_register_event_callback(sl_i2s_handle_t pcm_handle, sl_i2s_signal_event_t callback_event)

To register the event callback function.

sl_status_t
sl_si91x_pcm_unregister_event_callback(sl_i2s_handle_t pcm_handle)

To unregister the event callback function.

sl_status_t
sl_si91x_pcm_end_transfer(sl_i2s_handle_t pcm_handle, sl_i2s_xfer_type_t abort_type)

To abort the PCM transfer.

uint32_t
sl_si91x_pcm_get_transmit_data_count(sl_i2s_handle_t pcm_handle)

To get the transmitted data count of PCM.

uint32_t
sl_si91x_pcm_get_receive_data_count(sl_i2s_handle_t pcm_handle)

To get the received data count of PCM.

sl_si91x_pcm_get_status(sl_i2s_handle_t pcm_handle)

To get the PCM peripheral status.

Enumeration Documentation#

sl_pcm_data_resolution_t#

sl_pcm_data_resolution_t

Enumeration for PCM audio data resolutions.

This enumeration defines the various audio data resolutions for the PCM PCM peripheral. It specifies the number of bits per audio sample that can be used.

Enumerator
SL_PCM_RESOLUTION_12

12-bit resolution.

SL_PCM_RESOLUTION_16

16-bit resolution.

SL_PCM_RESOLUTION_20

20-bit resolution.

SL_PCM_RESOLUTION_24

24-bit resolution.

SL_PCM_RESOLUTION_32

32-bit resolution.


sl_pcm_sampling_rate_t#

sl_pcm_sampling_rate_t

Enumeration for PCM sample rates.

This enumeration defines the various sample rates for the PCM PCM peripheral. It specifies the number of samples per second (in Hz) that can be used.

Enumerator
SL_PCM_SAMPLING_RATE_8000

8 kHz

SL_PCM_SAMPLING_RATE_11025

11.025 kHz

SL_PCM_SAMPLING_RATE_16000

16 kHz

SL_PCM_SAMPLING_RATE_22050

22.05 kHz

SL_PCM_SAMPLING_RATE_24000

24 kHz


Function Documentation#

sl_si91x_pcm_init#

sl_status_t sl_si91x_pcm_init (uint32_t pcm_instance, sl_i2s_handle_t * pcm_handle)

To initialize the PCM peripheral.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]pcm_instance

Double pointer to the I2S/PCM driver handle sl_i2s_handle_t.

sl_i2s_handle_t *[in]pcm_handle

0 - PCM0, 1 - PCM1 (ULP_PCM)

This API enables the clock for the PCM peripheral and configures the SCLK, WSCLK, DIN, and DOUT pins. It also requires the address of a pointer for storing the PCM handle, which can be used for other function calls.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Operation successful.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

    • SL_STATUS_NULL_POINTER - Invalid null pointer received as an argument.

    • SL_STATUS_BUSY - Driver is busy.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_deinit#

sl_status_t sl_si91x_pcm_deinit (sl_i2s_handle_t * pcm_handle)

To uninitialize the PCM peripheral.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t *[in]pcm_handle

Double pointer to the I2S/PCM driver handle sl_i2s_handle_t.

This API disables the DMA instance used for PCM transfer and powers down the PCM peripheral by disabling the clock supply to PCM.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Operation successful.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

    • SL_STATUS_NULL_POINTER - Invalid null pointer received as an argument.

For more information on status codes, see SL STATUS DOCUMENTATION.

Note

  • When the PCM module is used in combination with other peripherals, see the notes below while deinitializing in the application:

    1. Whenever sl_si91x_pcm_deinit() is called, it will disable the clock for the peripheral. To power off the peripheral, you have to power down the power domain (PERI_EFUSE) which contains the following peripherals: USART, UART, I2C, SSI Master, SSI Slave, Generic-SPI Master, PCM Master, PCM Slave, Micro-DMA Controller, Config Timer, Random-Number Generator, CRC Accelerator, SIO, QEI, MCPWM, and EFUSE. Use the following API to power down the particular power domain if other peripherals are not being used: sl_si91x_peri_efuse_power_down()

    2. Some peripherals (ULP Peripherals, UULP Peripherals, GPDMA, and SDIO-SPI) have separate domains and can be powered down independently. For additional details, see the Power Architecture section in the Hardware Reference Manual. The ULP_UART has a separate power domain, ULPSS_PWRGATE_ULP_UART, which can be powered down independently. See the rsi_power_save.h file for all power gate definitions.


sl_si91x_pcm_set_configuration#

sl_status_t sl_si91x_pcm_set_configuration (sl_i2s_handle_t pcm_handle, uint16_t pcm_sampling_frequency, uint16_t pcm_resolution, uint16_t mode)

To configure the PCM module.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

uint16_t[in]pcm_sampling_frequency

The sampling frequency for sending or eceiving data.

uint16_t[in]pcm_resolution

Data resolution for the data being sent or received.

uint16_t[in]mode

Mode of operation (e.g., master or slave mode).

Note that PCM supports only mono mode.

This API configures sampling frequency and resolution of the PCM module.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_transmit_data#

sl_status_t sl_si91x_pcm_transmit_data (sl_i2s_handle_t pcm_handle, const void * data, uint32_t size)

To transmit PCM data.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

const void *[in]data

Address of the transmit data.

uint32_t[in]size

Size of the data to be transmitted.

This API configures the PCM Tx DMA channel descriptors and triggers the DMA transfer.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

    • SL_STATUS_NULL_POINTER - Invalid null pointer received as an argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_receive_data#

sl_status_t sl_si91x_pcm_receive_data (sl_i2s_handle_t pcm_handle, const void * data, uint32_t size)

To receive PCM data.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

const void *[in]data

Address of the receive data.

uint32_t[in]size

Size of the data to be received.

This API configures the PCM Rx DMA channel descriptors and triggers the DMA transfer.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

    • SL_STATUS_NULL_POINTER - Invalid null pointer received as an argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_register_event_callback#

sl_status_t sl_si91x_pcm_register_event_callback (sl_i2s_handle_t pcm_handle, sl_i2s_signal_event_t callback_event)

To register the event callback function.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

sl_i2s_signal_event_t[in]callback_event

Pointer to the function to be called at the time of interrupt.

This API registers a callback function to notify the application of transfer complete events. Callbacks should be registered before starting the PCM transfer.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_BUSY - Driver is busy.

    • SL_STATUS_NULL_POINTER - The parameter is a null pointer.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_unregister_event_callback#

sl_status_t sl_si91x_pcm_unregister_event_callback (sl_i2s_handle_t pcm_handle)

To unregister the event callback function.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

This function unregisters the previously registered callback function. It can be used only if callbacks are registered using sl_si91x_pcm_register_event_callback().

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

    • SL_STATUS_NULL_POINTER - Invalid null pointer received as argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_end_transfer#

sl_status_t sl_si91x_pcm_end_transfer (sl_i2s_handle_t pcm_handle, sl_i2s_xfer_type_t abort_type)

To abort the PCM transfer.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

sl_i2s_xfer_type_t[in]abort_type

Abort type, either ARM_SAI_ABORT_SEND or ARM_SAI_ABORT_RECEIVE.

This function disables the PCM clocks and DMA channel, stopping the frame-sync generation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - Parameters are invalid.

    • SL_STATUS_NULL_POINTER - Invalid null pointer received as an argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_pcm_get_transmit_data_count#

uint32_t sl_si91x_pcm_get_transmit_data_count (sl_i2s_handle_t pcm_handle)

To get the transmitted data count of PCM.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

This function retrieves the count of data bytes that have been transmitted by the PCM module. It can be used to monitor the progress of an ongoing PCM data transfer.

Returns

  • uint32_t The number of data bytes transmitted.


sl_si91x_pcm_get_receive_data_count#

uint32_t sl_si91x_pcm_get_receive_data_count (sl_i2s_handle_t pcm_handle)

To get the received data count of PCM.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

This function retrieves the count of data bytes that have been received by the PCM module. It can be used to monitor the progress of an ongoing PCM data transfer.

Returns

  • uint32_t The number of data bytes received.


sl_si91x_pcm_get_status#

sl_i2s_status_t sl_si91x_pcm_get_status (sl_i2s_handle_t pcm_handle)

To get the PCM peripheral status.

Parameters
TypeDirectionArgument NameDescription
sl_i2s_handle_t[in]pcm_handle

Pointer to the I2S/PCM driver handle sl_i2s_handle_t.

This function retrieves the current status of the PCM module, including:

  1. Frame error

  2. Rx busy

  3. Rx overflow

  4. Tx busy

  5. Tx underflow

Returns

  • sl_pcm_status_t Structure containing the pcm status information.