Robobo
Synchronous Serial Controller (SSC)

Macros

#define SSC_WPKEY   SSC_WPMR_WPKEY(0x535343)
 

Functions

uint32_t ssc_set_clock_divider (Ssc *p_ssc, uint32_t ul_bitrate, uint32_t ul_mck)
 Set up clock. 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...
 
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_reset (Ssc *p_ssc)
 Reset SSC module. More...
 
void ssc_enable_rx (Ssc *p_ssc)
 Enable SSC receiver. More...
 
void ssc_disable_rx (Ssc *p_ssc)
 Disable SSC receiver. More...
 
void ssc_enable_tx (Ssc *p_ssc)
 Enable SSC Transmitter. More...
 
void ssc_disable_tx (Ssc *p_ssc)
 Disable SSC Transmitter. More...
 
void ssc_set_normal_mode (Ssc *p_ssc)
 Configure SSC to work in normal mode. More...
 
void ssc_set_loop_mode (Ssc *p_ssc)
 Configure SSC to work in loop mode. 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_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...
 
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_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_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_rx_compare (Ssc *p_ssc, uint32_t ul_id, uint32_t ul_value)
 Configure SSC Receive Compare Register. More...
 
uint32_t ssc_get_rx_compare (Ssc *p_ssc, uint32_t ul_id)
 Get SSC Receive Compare Register. More...
 
void ssc_enable_interrupt (Ssc *p_ssc, uint32_t ul_sources)
 Enable SSC interrupts. More...
 
void ssc_disable_interrupt (Ssc *p_ssc, uint32_t ul_sources)
 Disable SSC interrupts. More...
 
uint32_t ssc_get_interrupt_mask (Ssc *p_ssc)
 Read SSC interrupt mask. More...
 
uint32_t ssc_get_status (Ssc *p_ssc)
 Read SSC status. 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_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_rx_ready (Ssc *p_ssc)
 Check if data has been received and loaded in SSC_RHR. More...
 
uint32_t ssc_is_tx_enabled (Ssc *p_ssc)
 Check if transmitter is enabled. More...
 
uint32_t ssc_is_rx_enabled (Ssc *p_ssc)
 Check if receiver is enabled. More...
 
uint32_t ssc_write (Ssc *p_ssc, uint32_t ul_frame)
 Write to SSC Transmit Holding Register. Send data through SSC Data frame. More...
 
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. More...
 
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. More...
 
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. More...
 
void ssc_set_writeprotect (Ssc *p_ssc, uint32_t ul_enable)
 Enable or disable write protection of SSC registers. More...
 
uint32_t ssc_get_writeprotect_status (Ssc *p_ssc)
 Indicate write protect status. More...
 

Detailed Description

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.

Function Documentation

void ssc_disable_interrupt ( Ssc p_ssc,
uint32_t  ul_sources 
)

Disable SSC interrupts.

Parameters
p_sscPointer to an SSC instance.
ul_sourcesInterrupts to be enabled.
void ssc_disable_rx ( Ssc p_ssc)

Disable SSC receiver.

Parameters
p_sscPointer to an SSC instance.
void ssc_disable_tx ( Ssc p_ssc)

Disable SSC Transmitter.

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

Parameters
p_sscPointer to an SSC instance.
void ssc_enable_interrupt ( Ssc p_ssc,
uint32_t  ul_sources 
)

Enable SSC interrupts.

Parameters
p_sscPointer to an SSC instance.
ul_sourcesInterrupts to be enabled.
void ssc_enable_rx ( Ssc p_ssc)

Enable SSC receiver.

Parameters
p_sscPointer to an SSC instance.
void ssc_enable_tx ( Ssc p_ssc)

Enable SSC Transmitter.

Parameters
p_sscPointer to an SSC instance.
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.

Parameters
p_sscPointer to an SSC instance.
uint32_t ssc_get_interrupt_mask ( Ssc p_ssc)

Read SSC interrupt mask.

Parameters
p_sscPointer to an SSC instance.
Returns
The interrupt mask value.
uint32_t ssc_get_rx_compare ( Ssc p_ssc,
uint32_t  ul_id 
)

Get SSC Receive Compare Register.

Parameters
p_sscPointer to an SSC instance.
ul_idCompare register ID.
Returns
Receive Compare Register value for the specified ul_id, otherwise SSC_RC_INVALID.
uint32_t ssc_get_status ( Ssc p_ssc)

Read SSC status.

Parameters
p_sscPointer to an SSC instance.
Returns
The SSC status value.
uint32_t ssc_get_writeprotect_status ( Ssc p_ssc)

Indicate write protect status.

Parameters
p_sscPointer to an SSC instance.
Returns
0 if the peripheral is not protected. Write Protect Violation Status otherwise.
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.

Note
If working in master mode, the divided clock needs to be configured before calling this function according to the sample rate and ul_datlen field.
Parameters
p_sscPointer to an SSC instance.
ul_modeWorking mode, SSC_I2S_MASTER_IN or SSC_I2S_SLAVE_IN.
ul_cksSource clock selection while working in SSC_I2S_SLAVE_IN mode.
ul_ch_modeChannel mode, stereo or mono.
ul_datlenData length for one channel.
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.

Note
If working in master mode, the divided clock needs to be configured before calling this function according to the sample rate and ul_datlen field.
Parameters
p_sscPointer to an SSC instance.
ul_modeWorking mode, SSC_I2S_MASTER_OUT or SSC_I2S_SLAVE_OUT.
ul_cksSource clock selection while working in SSC_I2S_SLAVE_OUT mode.
ul_ch_modeChannel mode, stereo or mono.
ul_datlenData length for one channel.
uint32_t ssc_is_rx_enabled ( Ssc p_ssc)

Check if receiver is enabled.

Parameters
p_sscPointer to an SSC instance.
Return values
SSC_RC_YESThe receiver is enabled.
SSC_RC_NOThe receiver is disabled.
uint32_t ssc_is_rx_ready ( Ssc p_ssc)

Check if data has been received and loaded in SSC_RHR.

Parameters
p_sscPointer to an SSC instance.
Return values
SSC_RC_YESThere is one data in the SSC_RHR.
SSC_RC_NOThere is no data in the SSC_RHR.
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.

Parameters
p_sscPointer to an SSC instance.
Return values
SSC_RC_YESBoth of the two registers are empty.
SSC_RC_NOAt least one of the two registers is not empty.
uint32_t ssc_is_tx_enabled ( Ssc p_ssc)

Check if transmitter is enabled.

Parameters
p_sscPointer to an SSC instance.
Return values
SSC_RC_YESThe transmitter is enabled.
SSC_RC_NOThe transmitter is disabled.
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).

Parameters
p_sscPointer to an SSC instance.
Return values
SSC_RC_YESThere is no data in the SSC_THR.
SSC_RC_NOThere is one data in the SSC_THR.
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.

Parameters
p_sscPointer to an SSC instance.
ul_dataPointer to the location where to store the received data.
Return values
SSC_RC_ERRORTime-out.
SSC_RC_OKSuccess.
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.

Parameters
p_sscPointer to an SSC instance.
Returns
Current RSHR value.
void ssc_reset ( Ssc p_ssc)

Reset SSC module.

Parameters
p_sscPointer to an SSC instance.
uint32_t ssc_set_clock_divider ( Ssc p_ssc,
uint32_t  ul_bitrate,
uint32_t  ul_mck 
)

Set up clock.

Parameters
p_sscPointer to an SSC instance.
ul_bitrateDesired bit clock.
ul_mckMCK clock.
Return values
SSC_RC_YESSuccess.
SSC_RC_NOInvalid input value.
void ssc_set_loop_mode ( Ssc p_ssc)

Configure SSC to work in loop mode.

Parameters
p_sscPointer to an SSC instance.
void ssc_set_normal_mode ( Ssc p_ssc)

Configure SSC to work in normal mode.

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

Parameters
p_sscPointer to an SSC instance.
p_rx_clk_optPointer to the receiver clock configuration structure.
p_rx_data_framePointer to the receiver data frame configuration structure.
void ssc_set_rx_compare ( Ssc p_ssc,
uint32_t  ul_id,
uint32_t  ul_value 
)

Configure SSC Receive Compare Register.

Parameters
p_sscPointer to an SSC instance.
ul_idCompare register ID.
ul_valueValue to configure.
void ssc_set_rx_stop_selection ( Ssc p_ssc,
uint32_t  ul_sel 
)

Configure SSC receive stop selection.

Parameters
p_sscPointer to an SSC instance.
ul_selCompare 0 used or Compare both 0 & 1 used.
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.

Parameters
p_sscPointer to an SSC instance.
ul_levelThe default driven level of TD pin.
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.

Parameters
p_sscPointer to an SSC instance.
p_tx_clk_optPointer to the transmitter clock configuration structure.
p_tx_data_framePointer to the transmitter data frame configuration structure.
void ssc_set_writeprotect ( Ssc p_ssc,
uint32_t  ul_enable 
)

Enable or disable write protection of SSC registers.

Parameters
p_sscPointer to an SSC instance.
ul_enable1 to enable, 0 to disable.
uint32_t ssc_write ( Ssc p_ssc,
uint32_t  ul_frame 
)

Write to SSC Transmit Holding Register. Send data through SSC Data frame.

Parameters
p_sscPointer to an SSC instance.
ul_frameFrame data to be transmitted.
Return values
SSC_RC_ERRORTime-out.
SSC_RC_OKSuccess.
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.

Parameters
p_sscPointer to an SSC instance.
ul_frameFrame Synchronization data.