SSI Module

The Synchronous Serial Interface (SSI) API provides a set of functions for configuring and using the SSI module, a serial communications protocol. Functions are provided to setup and configure the module operating options, send and receive data, and for interrupt/error handling

group ssi_api

This module is used for SSI configurations.

Defines

SSI_INT_TXEOT 0x00000040U
SSI_INT_DMATX 0x00000020U
SSI_INT_DMARX 0x00000010U
SSI_INT_TXFF 0x00000008U
SSI_INT_RXFF 0x00000004U
SSI_INT_RXTO 0x00000002U
SSI_INT_RXOR 0x00000001U
SSI_FRF_MOTO_MODE_0 0x00000000U
SSI_FRF_MOTO_MODE_1 0x00000002U
SSI_FRF_MOTO_MODE_2 0x00000001U
SSI_FRF_MOTO_MODE_3 0x00000003U
SSI_FRF_TI 0x00000010U
SSI_MODE_MASTER 0x00000000U
SSI_MODE_SLAVE 0x00000001U
SSI_DMA_TX 0x00000002U
SSI_DMA_RX 0x00000001U

Functions

void SSI_enableModule(uint32_t base)

Enables the synchronous serial interface.

This function enables operation of the synchronous serial interface. The synchronous serial interface must be configured before it is enabled.

Parameters
  • base: specifies the SSI module base address.

Note

The function SSI_setConfig() must be called before calling SSI_enableModule() function

Return

None.

void SSI_disableModule(uint32_t base)

Disables the synchronous serial interface.

This function disables operation of the synchronous serial interface.

Parameters
  • base: specifies the SSI module base address.

Return

None.

void SSI_registerInterrupt(uint32_t intNum, void (*pfnHandler)(void))

Registers an interrupt handler for the synchronous serial interface.

This function registers the handler to be called when an SSI interrupt occurs. This function enables the global interrupt in the interrupt controller; specific SSI interrupts must be enabled via

SSI_enableInterrupt(). If necessary, it is the interrupt handler’s responsibility to clear the interrupt source via SSI_clearInterruptStatus().
Parameters
  • intNum: specifies the SSI interrupt number

  • pfnHandler: is a pointer to the function to be called when the SSI interrupt occurs.

See

Interrupt_registerHandler() for important information about registering interrupt handlers.

Return

None.

void SSI_unregisterInterrupt(uint32_t intNum)

Unregisters an interrupt handler for the synchronous serial interface.

This function clears the handler to be called when an SSI interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

Parameters
  • intNum: specifies the SSI interrupt number

See

Interrupt_registerHandler() for important information about registering interrupt handlers.

Return

None.

void SSI_enableInterrupt(uint32_t base, uint32_t interrupts)

Enables individual SSI interrupt sources.

This function enables the indicated SSI interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. The

interrupts parameter can be any of the \b SSI_INT_TXEOT, SSI_INT_DMATX, SSI_INT_DMARX, SSI_INT_TXFF, SSI_INT_RXFF, SSI_INT_RXTO, or SSI_INT_RXOR values.
Parameters
  • base: specifies the SSI module base address.

  • interrupts: is a bit mask of the interrupt sources to be enabled.

Return

None.

void SSI_disableInterrupt(uint32_t base, uint32_t interrupts)

Disables individual SSI interrupt sources.

This function disables the indicated SSI interrupt sources. The

interrupts parameter can be any of the SSI_INT_TXEOT, SSI_INT_DMATX, SSI_INT_DMARX, SSI_INT_TXFF, SSI_INT_RXFF, SSI_INT_RXTO, or SSI_INT_RXOR values.
Parameters
  • base: specifies the SSI module base address.

  • interrupts: is a bit mask of the interrupt sources to be disabled.

Return

None.

uint32_t SSI_getInterruptStatus(uint32_t base, bool masked)

Gets the current interrupt status.

This function returns the interrupt status for the SSI module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Parameters
  • base: specifies the SSI module base address.

  • masked: is false if the raw interrupt status is required or true if the masked interrupt status is required.

Return

The current interrupt status, enumerated as a bit field of SSI_INT_TXEOT, SSI_INT_DMATX, b SSI_INT_DMARX, SSI_INT_TXFF, SSI_INT_RXFF, SSI_RXTO, or SSI_RXOR

void SSI_clearInterruptStatus(uint32_t base, uint32_t interrupts)

Clears SSI interrupt sources.

This function clears the specified SSI interrupt sources so that they no longer assert. This function must be called in the interrupt handler to keep the interrupts from being triggered again immediately upon exit. The

interrupts parameter can consist of either or both the SSI_RXTO and SSI_RXOR values.
Parameters
  • base: specifies the SSI module base address.

  • interrupts: is a bit mask of the interrupt sources to be cleared.

Note

Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).

Return

None.

void SSI_enableDMA(uint32_t base, uint32_t dmaFlags)

Enables SSI DMA operation.

This function enables the specified SSI DMA features. The SSI can be configured to use DMA for transmit and/or receive data transfers. The

dmaFlags parameter is the logical OR of any of the following values:
Parameters
  • base: is the base address of the SSI module.

  • dmaFlags: is a bit mask of the DMA features to enable.

  • SSI_DMA_RX - enable DMA for receive

  • SSI_DMA_TX - enable DMA for transmit

Note

The uDMA controller must also be set up before DMA can be used with the SSI.

Return

None.

void SSI_disableDMA(uint32_t base, uint32_t dmaFlags)

Disables SSI DMA operation.

This function is used to disable SSI DMA features that were enabled by

SSI_enableDMA(). The specified SSI DMA features are disabled. The dmaFlags parameter is the logical OR of any of the following values:
Parameters
  • base: is the base address of the SSI module.

  • dmaFlags: is a bit mask of the DMA features to disable.

  • SSI_DMA_RX - disable DMA for receive

  • SSI_DMA_TX - disable DMA for transmit

Return

None.

bool SSI_isBusy(uint32_t base)

Determines whether the SSI transmitter is busy or not.

This function allows the caller to determine whether all transmitted bytes have cleared the transmitter hardware. If

false is returned, then the transmit FIFO is empty and all bits of the last transmitted word have left the hardware shift register.
Parameters
  • base: is the base address of the SSI module.

Return

Returns true if the SSI is transmitting or false if all transmissions are complete.

void SSI_enableLoopback(uint32_t base)

Enables internal loopback mode for SSI.

This function configures SSI port in internal loopback mode to help with diagnostics and debug. In this mode, Output of the transmit serial shift register is connected internally to the input of the receive serial shift register.

Parameters
  • base: is the base address of the SSI module.

Return

None.

void SSI_disableLoopback(uint32_t base)

Disables internal loopback mode for SSI.

This function is used to disable SSI internal loopback that was enabled by

SSI_enableLoopback().
Parameters
  • base: is the base address of the SSI module.

Return

None.

void SSI_enableFssHold(uint32_t base)

Enables the Fss hold feature

This function configures the SSI module to hold the FSS low when there is available data in the Tx FIFO. The Fss signal is de-asserted when the Tx FIFO is empty

Parameters
  • base: is the base address of the SSI module.

Note

This feature is not available in TI frame format. It is only available in Freescale frame format.

Return

None.

void SSI_disableFssHold(uint32_t base)

Disables the Fss hold feature

This function configures the SSI module to de-assert the SSIFss signal for one SSI clock cycle after every byte is transferred. This mode is the default operation.

Parameters
  • base: is the base address of the SSI module.

Note

This feature is not available in TI frame format. It is only available in Freescale frame format.

Return

None.

void SSI_setConfig(uint32_t base, uint32_t ssiClk, uint32_t protocol, uint32_t mode, uint32_t bitRate, uint32_t dataWidth)

Configures the synchronous serial interface.

This function configures the synchronous serial interface. It sets the SSI protocol, mode of operation, bit rate, and data width.

Parameters
  • base: specifies the SSI module base address.

  • ssiClk: is the rate of the clock supplied to the SSI module.

  • protocol: specifies the data transfer protocol.

  • mode: specifies the mode of operation.

  • bitRate: specifies the clock rate.

  • dataWidth: specifies number of bits transferred per frame.

The protocol parameter defines the data frame format. The protocol parameter can be one of the following values: SSI_FRF_MOTO_MODE_0, SSI_FRF_MOTO_MODE_1, SSI_FRF_MOTO_MODE_2, SSI_FRF_MOTO_MODE_3 or SSI_FRF_TI. The Motorola/Freescale frame formats encode the following polarity and phase configurations:

The mode parameter defines the operating mode of the SSI module. The SSI module can operate as a master or slave. The mode parameter can be one of the following values: SSI_MODE_MASTER or SSI_MODE_SLAVE.

The bitRate parameter defines the bit rate for the SSI. This bit rate must satisfy the following clock ratio criteria:

  • ssiClk >= 2 * bit rate (master mode)

  • ssiClk >= 12 * bit rate (slave modes)

where ssiClk is the frequency of the clock supplied to the SSI module. Note that there are frequency limits for FSSI that are described in the Bit Rate Generation section of the SSI chapter in the data sheet.

The dataWidth parameter defines the width of the data transfers and can be a value between 4 and 16, inclusive.

The peripheral clock is the same as the processor clock. The macro CM_CLK_FREQ from sysctl.h can be used as the parameter

Return

None.

void SSI_writeData(uint32_t base, uint32_t data)

Puts a data element into the SSI transmit FIFO.

This function places the supplied data into the transmit FIFO of the specified SSI module. If there is no space available in the transmit FIFO, this function waits until there is space available before returning.

Parameters
  • base: specifies the SSI module base address.

  • data: is the data to be transmitted over the SSI interface.

Note

The upper 32 - N bits of data are discarded by the hardware, where N is the data width as configured by SSI_setConfig(). For example, if the interface is configured for 8-bit data width, the upper 24 bits of data are discarded.

Return

None.

int32_t SSI_writeDataNonBlocking(uint32_t base, uint32_t data)

Puts a data element into the SSI transmit FIFO.

This function places the supplied data into the transmit FIFO of the specified SSI module. If there is no space in the FIFO, then this function returns a zero.

Parameters
  • base: specifies the SSI module base address.

  • data: is the data to be transmitted over the SSI interface.

Note

The upper 32 - N bits of data are discarded by the hardware, where N is the data width as configured by SSI_setConfig(). For example, if the interface is configured for 8-bit data width, the upper 24 bits of data are discarded.

Return

Returns the number of elements written to the SSI transmit FIFO.

void SSI_readData(uint32_t base, uint32_t *dataPtr)

Gets a data element from the SSI receive FIFO.

This function gets received data from the receive FIFO of the specified SSI module and places that data into the location specified by the

dataPtr parameter. If there is no data available, this function waits until data is received before returning.
Parameters
  • base: specifies the SSI module base address.

  • dataPtr: is a pointer to a storage location for data that was received over the SSI interface.

Note

Only the lower N bits of the value written to dataPtr contain valid data, where N is the data width as configured by SSI_setConfig(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to dataPtr contain valid data.

Return

None.

int32_t SSI_readDataNonBlocking(uint32_t base, uint32_t *dataPtr)

Gets a data element from the SSI receive FIFO.

This function gets received data from the receive FIFO of the specified SSI module and places that data into the location specified by the

data parameter. If there is no data in the FIFO, then this function returns a zero.
Parameters
  • base: specifies the SSI module base address.

  • dataPtr: is a pointer to a storage location for data that was received over the SSI interface.

Note

Only the lower N bits of the value written to dataPtr contain valid data, where N is the data width as configured by SSI_setConfig(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to dataPtr contain valid data.

Return

Returns the number of elements read from the SSI receive FIFO.

The following describes important details and recommendations when using the SSI API.

Once system control enables the SSI module, SSI_setConfig() needs to be called to set properties like master or slave mode, baud rate, data format, data width. There are functions available to configure the interrupts and DMA support if required. Once the configuration is done SSI_enableModule() should be called to enable the operation of the module.

To transmit data, there are a two options. SSI_writeDataNonBlocking() will check if the trasnmit buffer is empty. If empty, it writes the specified data to the transmit buffer and return. If not empty, it returns a fail status.

SSI_writeData() function waits for the trnamit buffer to be empty before writing the specified data.

To receive data, there are a two options. SSI_readDataNonBlocking() will check if there is data availbale in the receive buffer. If available, it returns the buffer content. Else, it returns a fail status.

SSI_readData() function waits for the recieve data and returns the same.

The code for this module is contained in driverlib_cm/ssi.c, with driverlib_cm/ssi.h containing the API declarations for use by applications.