The Synchronous Serial Controller (SSC) provides a synchronous communication link with external devices.
It supports many serial synchronous communication protocols generally used in audio and telecom applications such as I2S, Short Frame Sync, Long Frame Sync, etc. This is a driver for configuration and use of the SSC peripheral.
Macros | |
#define | SSC_TCMR_START_TF_EDGE SSC_TCMR_START_RF_EDGE |
#define | SSC_TCMR_START_TF_FALLING SSC_TCMR_START_RF_FALLING |
#define | SSC_TCMR_START_TF_RISING SSC_TCMR_START_RF_RISING |
#define | SSC_WPMR_WPKEY_PASSWD SSC_WPMR_WPKEY(0x535343) |
Functions | |
void | ssc_disable_interrupt (Ssc *p_ssc, uint32_t ul_sources) |
Disable SSC interrupts. More... | |
void | ssc_disable_rx (Ssc *p_ssc) |
Disable SSC receiver. More... | |
void | ssc_disable_tx (Ssc *p_ssc) |
Disable SSC Transmitter. More... | |
void | ssc_disable_tx_frame_sync_data (Ssc *p_ssc) |
The TD line is driven with the default value during the Transmit Frame Sync signal. More... | |
void | ssc_enable_interrupt (Ssc *p_ssc, uint32_t ul_sources) |
Enable SSC interrupts. More... | |
void | ssc_enable_rx (Ssc *p_ssc) |
Enable SSC receiver. More... | |
void | ssc_enable_tx (Ssc *p_ssc) |
Enable SSC Transmitter. More... | |
void | ssc_enable_tx_frame_sync_data (Ssc *p_ssc) |
The TD line is driven with the SSC_TSHR register value during the transmission of the Transmit Frame Sync Signal. More... | |
uint32_t | ssc_get_interrupt_mask (Ssc *p_ssc) |
Read SSC interrupt mask. More... | |
Pdc * | ssc_get_pdc_base (Ssc *p_ssc) |
Get SSC PDC registers base address. More... | |
void * | ssc_get_rx_access (Ssc *p_ssc) |
Get Receive address for DMA operation. More... | |
uint32_t | ssc_get_rx_compare (Ssc *p_ssc, uint32_t ul_id) |
Get SSC Receive Compare Register. More... | |
uint32_t | ssc_get_status (Ssc *p_ssc) |
Read SSC status. More... | |
void * | ssc_get_tx_access (Ssc *p_ssc) |
Get Transmit address for DMA operation. More... | |
uint32_t | ssc_get_writeprotect_status (Ssc *p_ssc) |
Indicate write protect status. More... | |
void | ssc_i2s_set_receiver (Ssc *p_ssc, uint32_t ul_mode, uint32_t ul_cks, uint32_t ul_ch_mode, uint32_t ul_datlen) |
Setup for I2S receiver. More... | |
void | ssc_i2s_set_transmitter (Ssc *p_ssc, uint32_t ul_mode, uint32_t ul_cks, uint32_t ul_ch_mode, uint32_t ul_datlen) |
Setup for I2S transmitter. More... | |
uint32_t | ssc_is_rx_buf_end (Ssc *p_ssc) |
Check if one receive buffer is filled. More... | |
uint32_t | ssc_is_rx_buf_full (Ssc *p_ssc) |
Check if both receive buffers are full. More... | |
uint32_t | ssc_is_rx_enabled (Ssc *p_ssc) |
Check if receiver is enabled. More... | |
uint32_t | ssc_is_rx_ready (Ssc *p_ssc) |
Check if data has been received and loaded in SSC_RHR. More... | |
uint32_t | ssc_is_tx_buf_empty (Ssc *p_ssc) |
Check if both transmit buffers are empty. More... | |
uint32_t | ssc_is_tx_buf_end (Ssc *p_ssc) |
Check if the register SSC_TCR has reached 0. More... | |
uint32_t | ssc_is_tx_empty (Ssc *p_ssc) |
Check if the last data written in SSC_THR has been loaded in TSR and the last data loaded in TSR has been transmitted. More... | |
uint32_t | ssc_is_tx_enabled (Ssc *p_ssc) |
Check if transmitter is enabled. More... | |
uint32_t | ssc_is_tx_ready (Ssc *p_ssc) |
Check if data has been loaded in SSC_THR and is waiting to be loaded in the Transmit Shift Register (TSR). More... | |
uint32_t | ssc_read (Ssc *p_ssc, uint32_t *ul_data) |
Read from SSC Receive Holding Register. More... | |
uint32_t | ssc_read_sync_data (Ssc *p_ssc) |
Read from SSC Receive Synchronization Holding Register. More... | |
void | ssc_reset (Ssc *p_ssc) |
Reset SSC module. More... | |
uint32_t | ssc_set_clock_divider (Ssc *p_ssc, uint32_t ul_bitrate, uint32_t ul_mck) |
Set up clock. More... | |
void | ssc_set_loop_mode (Ssc *p_ssc) |
Configure SSC to work in loop mode. More... | |
void | ssc_set_normal_mode (Ssc *p_ssc) |
Configure SSC to work in normal mode. More... | |
void | ssc_set_receiver (Ssc *p_ssc, clock_opt_t *p_rx_clk_opt, data_frame_opt_t *p_rx_data_frame) |
Configure SSC receiver clock mode and date frame configuration. More... | |
void | ssc_set_rx_compare (Ssc *p_ssc, uint32_t ul_id, uint32_t ul_value) |
Configure SSC Receive Compare Register. More... | |
void | ssc_set_rx_stop_selection (Ssc *p_ssc, uint32_t ul_sel) |
Configure SSC receive stop selection. More... | |
void | ssc_set_td_default_level (Ssc *p_ssc, uint32_t ul_level) |
Configure SSC default level driven on the TD pin while out of transmission. More... | |
void | ssc_set_transmitter (Ssc *p_ssc, clock_opt_t *p_tx_clk_opt, data_frame_opt_t *p_tx_data_frame) |
Configure SSC transmitter clock mode and date frame configuration. More... | |
void | ssc_set_writeprotect (Ssc *p_ssc, uint32_t ul_enable) |
Enable or disable write protection of SSC registers. More... | |
uint32_t | ssc_write (Ssc *p_ssc, uint32_t ul_frame) |
Write to SSC Transmit Holding Register. More... | |
void | ssc_write_sync_data (Ssc *p_ssc, uint32_t ul_frame) |
Write to SSC Transmit Synchronization Holding Register. More... | |
#define SSC_TCMR_START_TF_EDGE SSC_TCMR_START_RF_EDGE |
Referenced by ssc_i2s_set_transmitter().
#define SSC_TCMR_START_TF_FALLING SSC_TCMR_START_RF_FALLING |
Referenced by ssc_i2s_set_transmitter().
#define SSC_TCMR_START_TF_RISING SSC_TCMR_START_RF_RISING |
Referenced by ssc_i2s_set_transmitter().
#define SSC_WPMR_WPKEY_PASSWD SSC_WPMR_WPKEY(0x535343) |
Referenced by ssc_set_writeprotect().
void ssc_disable_interrupt | ( | Ssc * | p_ssc, |
uint32_t | ul_sources | ||
) |
Disable SSC interrupts.
p_ssc | Pointer to an SSC instance. |
ul_sources | Interrupts to be enabled. |
Referenced by SSC_Handler().
void ssc_disable_rx | ( | Ssc * | p_ssc | ) |
Disable SSC receiver.
p_ssc | Pointer to an SSC instance. |
void ssc_disable_tx | ( | Ssc * | p_ssc | ) |
Disable SSC Transmitter.
p_ssc | Pointer to an SSC instance. |
void ssc_disable_tx_frame_sync_data | ( | Ssc * | p_ssc | ) |
The TD line is driven with the default value during the Transmit Frame Sync signal.
p_ssc | Pointer to an SSC instance. |
void ssc_enable_interrupt | ( | Ssc * | p_ssc, |
uint32_t | ul_sources | ||
) |
Enable SSC interrupts.
p_ssc | Pointer to an SSC instance. |
ul_sources | Interrupts to be enabled. |
Referenced by run_ssc_test().
void ssc_enable_rx | ( | Ssc * | p_ssc | ) |
void ssc_enable_tx | ( | Ssc * | p_ssc | ) |
void ssc_enable_tx_frame_sync_data | ( | Ssc * | p_ssc | ) |
The TD line is driven with the SSC_TSHR register value during the transmission of the Transmit Frame Sync Signal.
p_ssc | Pointer to an SSC instance. |
uint32_t ssc_get_interrupt_mask | ( | Ssc * | p_ssc | ) |
Read SSC interrupt mask.
p_ssc | Pointer to an SSC instance. |
Pdc* ssc_get_pdc_base | ( | Ssc * | p_ssc | ) |
Get SSC PDC registers base address.
p_ssc | Pointer to SSC registers set instance. |
void* ssc_get_rx_access | ( | Ssc * | p_ssc | ) |
Get Receive address for DMA operation.
p_ssc | Pointer to an SSC instance. |
uint32_t ssc_get_rx_compare | ( | Ssc * | p_ssc, |
uint32_t | ul_id | ||
) |
Get SSC Receive Compare Register.
p_ssc | Pointer to an SSC instance. |
ul_id | Compare register ID. |
References COMPARE_ID0, COMPARE_ID1, and SSC_RC_INVALID.
uint32_t ssc_get_status | ( | Ssc * | p_ssc | ) |
Read SSC status.
p_ssc | Pointer to an SSC instance. |
Referenced by SSC_Handler().
void* ssc_get_tx_access | ( | Ssc * | p_ssc | ) |
Get Transmit address for DMA operation.
p_ssc | Pointer to an SSC instance. |
uint32_t ssc_get_writeprotect_status | ( | Ssc * | p_ssc | ) |
Indicate write protect status.
p_ssc | Pointer to an SSC instance. |
void ssc_i2s_set_receiver | ( | Ssc * | p_ssc, |
uint32_t | ul_mode, | ||
uint32_t | ul_cks, | ||
uint32_t | ul_ch_mode, | ||
uint32_t | ul_datlen | ||
) |
Setup for I2S receiver.
p_ssc | Pointer to an SSC instance. |
ul_mode | Working mode, SSC_I2S_MASTER_IN or SSC_I2S_SLAVE_IN. |
ul_cks | Source clock selection while working in SSC_I2S_SLAVE_IN mode. |
ul_ch_mode | Channel mode, stereo or mono. |
ul_datlen | Data length for one channel. |
References SSC_AUDIO_MONO_LEFT, SSC_AUDIO_MONO_RIGHT, SSC_AUDIO_STERO, SSC_I2S_MASTER_IN, SSC_I2S_SLAVE_IN, ssc_set_receiver(), clock_opt_t::ul_ckg, clock_opt_t::ul_cki, clock_opt_t::ul_cko, clock_opt_t::ul_cks, data_frame_opt_t::ul_datlen, data_frame_opt_t::ul_datnb, data_frame_opt_t::ul_fsedge, data_frame_opt_t::ul_fslen, data_frame_opt_t::ul_fsos, data_frame_opt_t::ul_msbf, clock_opt_t::ul_period, clock_opt_t::ul_start_sel, and clock_opt_t::ul_sttdly.
void ssc_i2s_set_transmitter | ( | Ssc * | p_ssc, |
uint32_t | ul_mode, | ||
uint32_t | ul_cks, | ||
uint32_t | ul_ch_mode, | ||
uint32_t | ul_datlen | ||
) |
Setup for I2S transmitter.
p_ssc | Pointer to an SSC instance. |
ul_mode | Working mode, SSC_I2S_MASTER_OUT or SSC_I2S_SLAVE_OUT. |
ul_cks | Source clock selection while working in SSC_I2S_SLAVE_OUT mode. |
ul_ch_mode | Channel mode, stereo or mono. |
ul_datlen | Data length for one channel. |
References SSC_AUDIO_MONO_LEFT, SSC_AUDIO_MONO_RIGHT, SSC_AUDIO_STERO, SSC_I2S_MASTER_OUT, SSC_I2S_SLAVE_OUT, ssc_set_td_default_level(), ssc_set_transmitter(), SSC_TCMR_START_TF_EDGE, SSC_TCMR_START_TF_FALLING, SSC_TCMR_START_TF_RISING, clock_opt_t::ul_ckg, clock_opt_t::ul_cki, clock_opt_t::ul_cko, clock_opt_t::ul_cks, data_frame_opt_t::ul_datlen, data_frame_opt_t::ul_datnb, data_frame_opt_t::ul_fsedge, data_frame_opt_t::ul_fslen, data_frame_opt_t::ul_fsos, data_frame_opt_t::ul_msbf, clock_opt_t::ul_period, clock_opt_t::ul_start_sel, and clock_opt_t::ul_sttdly.
uint32_t ssc_is_rx_buf_end | ( | Ssc * | p_ssc | ) |
Check if one receive buffer is filled.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | Receive Counter has reached zero. |
SSC_RC_NO | Data is written on the Receive Counter Register or Receive Next Counter Register. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_rx_buf_full | ( | Ssc * | p_ssc | ) |
Check if both receive buffers are full.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | Both of the two receive buffers have reached 0. |
SSC_RC_NO | One of the two receive buffers hasn't reached 0. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_rx_enabled | ( | Ssc * | p_ssc | ) |
Check if receiver is enabled.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | The receiver is enabled. |
SSC_RC_NO | The receiver is disabled. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_rx_ready | ( | Ssc * | p_ssc | ) |
Check if data has been received and loaded in SSC_RHR.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | There is one data in the SSC_RHR. |
SSC_RC_NO | There is no data in the SSC_RHR. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_tx_buf_empty | ( | Ssc * | p_ssc | ) |
Check if both transmit buffers are empty.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | Both of the two transmit buffers have reached 0. |
SSC_RC_NO | One of the two transmit buffers hasn't reached 0. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_tx_buf_end | ( | Ssc * | p_ssc | ) |
Check if the register SSC_TCR has reached 0.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | The register SSC_TCR has reached 0. |
SSC_RC_NO | The register SSC_TCR hasn't reached 0. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_tx_empty | ( | Ssc * | p_ssc | ) |
Check if the last data written in SSC_THR has been loaded in TSR and the last data loaded in TSR has been transmitted.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | Both of the two registers are empty. |
SSC_RC_NO | At least one of the two registers is not empty. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_tx_enabled | ( | Ssc * | p_ssc | ) |
Check if transmitter is enabled.
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | The transmitter is enabled. |
SSC_RC_NO | The transmitter is disabled. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_is_tx_ready | ( | Ssc * | p_ssc | ) |
Check if data has been loaded in SSC_THR and is waiting to be loaded in the Transmit Shift Register (TSR).
p_ssc | Pointer to an SSC instance. |
SSC_RC_YES | There is no data in the SSC_THR. |
SSC_RC_NO | There is one data in the SSC_THR. |
References SSC_RC_NO, and SSC_RC_YES.
uint32_t ssc_read | ( | Ssc * | p_ssc, |
uint32_t * | ul_data | ||
) |
Read from SSC Receive Holding Register.
Read data that is received in SSC Data frame.
p_ssc | Pointer to an SSC instance. |
ul_data | Pointer to the location where to store the received data. |
SSC_RC_ERROR | Time-out. |
SSC_RC_OK | Success. |
References SSC_DEFAULT_TIMEOUT, SSC_RC_ERROR, and SSC_RC_OK.
Referenced by SSC_Handler().
uint32_t ssc_read_sync_data | ( | Ssc * | p_ssc | ) |
Read from SSC Receive Synchronization Holding Register.
Read data that is received in SSC Synchronization frame. When the sync data is actually used, after successfully reading the application data by calling ssc_read(), call this function, and the return sync data is useful.
p_ssc | Pointer to an SSC instance. |
void ssc_reset | ( | Ssc * | p_ssc | ) |
uint32_t ssc_set_clock_divider | ( | Ssc * | p_ssc, |
uint32_t | ul_bitrate, | ||
uint32_t | ul_mck | ||
) |
Set up clock.
p_ssc | Pointer to an SSC instance. |
ul_bitrate | Desired bit clock. |
ul_mck | MCK clock. |
SSC_RC_YES | Success. |
SSC_RC_NO | Invalid input value. |
References SSC_RC_NO, and SSC_RC_YES.
Referenced by run_ssc_test().
void ssc_set_loop_mode | ( | Ssc * | p_ssc | ) |
Configure SSC to work in loop mode.
p_ssc | Pointer to an SSC instance. |
Referenced by run_ssc_test().
void ssc_set_normal_mode | ( | Ssc * | p_ssc | ) |
Configure SSC to work in normal mode.
p_ssc | Pointer to an SSC instance. |
void ssc_set_receiver | ( | Ssc * | p_ssc, |
clock_opt_t * | p_rx_clk_opt, | ||
data_frame_opt_t * | p_rx_data_frame | ||
) |
Configure SSC receiver clock mode and date frame configuration.
p_ssc | Pointer to an SSC instance. |
p_rx_clk_opt | Pointer to the receiver clock configuration structure. |
p_rx_data_frame | Pointer to the receiver data frame configuration structure. |
References clock_opt_t::ul_ckg, clock_opt_t::ul_cki, clock_opt_t::ul_cko, clock_opt_t::ul_cks, data_frame_opt_t::ul_datlen, data_frame_opt_t::ul_datnb, data_frame_opt_t::ul_fsedge, data_frame_opt_t::ul_fslen, data_frame_opt_t::ul_fslen_ext, data_frame_opt_t::ul_fsos, data_frame_opt_t::ul_msbf, clock_opt_t::ul_period, clock_opt_t::ul_start_sel, and clock_opt_t::ul_sttdly.
Referenced by run_ssc_test(), and ssc_i2s_set_receiver().
void ssc_set_rx_compare | ( | Ssc * | p_ssc, |
uint32_t | ul_id, | ||
uint32_t | ul_value | ||
) |
Configure SSC Receive Compare Register.
p_ssc | Pointer to an SSC instance. |
ul_id | Compare register ID. |
ul_value | Value to configure. |
References COMPARE_ID0, and COMPARE_ID1.
void ssc_set_rx_stop_selection | ( | Ssc * | p_ssc, |
uint32_t | ul_sel | ||
) |
Configure SSC receive stop selection.
p_ssc | Pointer to an SSC instance. |
ul_sel | Compare 0 used or Compare both 0 & 1 used. |
References SSC_RX_STOP_COMPARE_0, and SSC_RX_STOP_COMPARE_0_1.
void ssc_set_td_default_level | ( | Ssc * | p_ssc, |
uint32_t | ul_level | ||
) |
Configure SSC default level driven on the TD pin while out of transmission.
p_ssc | Pointer to an SSC instance. |
ul_level | The default driven level of TD pin. |
Referenced by ssc_i2s_set_transmitter().
void ssc_set_transmitter | ( | Ssc * | p_ssc, |
clock_opt_t * | p_tx_clk_opt, | ||
data_frame_opt_t * | p_tx_data_frame | ||
) |
Configure SSC transmitter clock mode and date frame configuration.
p_ssc | Pointer to an SSC instance. |
p_tx_clk_opt | Pointer to the transmitter clock configuration structure. |
p_tx_data_frame | Pointer to the transmitter data frame configuration structure. |
References clock_opt_t::ul_ckg, clock_opt_t::ul_cki, clock_opt_t::ul_cko, clock_opt_t::ul_cks, data_frame_opt_t::ul_datlen, data_frame_opt_t::ul_datnb, data_frame_opt_t::ul_fsedge, data_frame_opt_t::ul_fslen, data_frame_opt_t::ul_fslen_ext, data_frame_opt_t::ul_fsos, data_frame_opt_t::ul_msbf, clock_opt_t::ul_period, clock_opt_t::ul_start_sel, and clock_opt_t::ul_sttdly.
Referenced by run_ssc_test(), and ssc_i2s_set_transmitter().
void ssc_set_writeprotect | ( | Ssc * | p_ssc, |
uint32_t | ul_enable | ||
) |
Enable or disable write protection of SSC registers.
p_ssc | Pointer to an SSC instance. |
ul_enable | 1 to enable, 0 to disable. |
References SSC_WPMR_WPKEY_PASSWD.
uint32_t ssc_write | ( | Ssc * | p_ssc, |
uint32_t | ul_frame | ||
) |
Write to SSC Transmit Holding Register.
Send data through SSC Data frame.
p_ssc | Pointer to an SSC instance. |
ul_frame | Frame data to be transmitted. |
SSC_RC_ERROR | Time-out. |
SSC_RC_OK | Success. |
References SSC_DEFAULT_TIMEOUT, SSC_RC_ERROR, and SSC_RC_OK.
Referenced by run_ssc_test().
void ssc_write_sync_data | ( | Ssc * | p_ssc, |
uint32_t | ul_frame | ||
) |
Write to SSC Transmit Synchronization Holding Register.
Send data through SSC Synchronization frame. If there is sync data that needs to be transmitted, call this function first to send out the sync data, and then call the ssc_write() function to send out application data.
p_ssc | Pointer to an SSC instance. |
ul_frame | Frame Synchronization data. |