EE445M RTOS
Taken at the University of Texas Spring 2015
Ssi_api

Functions

static uint32_t _SSIIntNumberGet (uint32_t ui32Base)
 
void SSIConfigSetExpClk (uint32_t ui32Base, uint32_t ui32SSIClk, uint32_t ui32Protocol, uint32_t ui32Mode, uint32_t ui32BitRate, uint32_t ui32DataWidth)
 
void SSIEnable (uint32_t ui32Base)
 
void SSIDisable (uint32_t ui32Base)
 
void SSIIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void SSIIntUnregister (uint32_t ui32Base)
 
void SSIIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void SSIIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
 
uint32_t SSIIntStatus (uint32_t ui32Base, bool bMasked)
 
void SSIIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void SSIDataPut (uint32_t ui32Base, uint32_t ui32Data)
 
int32_t SSIDataPutNonBlocking (uint32_t ui32Base, uint32_t ui32Data)
 
void SSIDataGet (uint32_t ui32Base, uint32_t *pui32Data)
 
int32_t SSIDataGetNonBlocking (uint32_t ui32Base, uint32_t *pui32Data)
 
void SSIDMAEnable (uint32_t ui32Base, uint32_t ui32DMAFlags)
 
void SSIDMADisable (uint32_t ui32Base, uint32_t ui32DMAFlags)
 
bool SSIBusy (uint32_t ui32Base)
 
void SSIClockSourceSet (uint32_t ui32Base, uint32_t ui32Source)
 
uint32_t SSIClockSourceGet (uint32_t ui32Base)
 
void SSIAdvModeSet (uint32_t ui32Base, uint32_t ui32Mode)
 
void SSIAdvDataPutFrameEnd (uint32_t ui32Base, uint32_t ui32Data)
 
int32_t SSIAdvDataPutFrameEndNonBlocking (uint32_t ui32Base, uint32_t ui32Data)
 
void SSIAdvFrameHoldEnable (uint32_t ui32Base)
 
void SSIAdvFrameHoldDisable (uint32_t ui32Base)
 

Variables

static const uint32_t g_ppui32SSIIntMap [][2]
 
static const uint_fast8_t g_ui8SSIIntMapRows
 
static const uint32_t g_ppui32SSIIntMapSnowflake [][2]
 
static const uint_fast8_t g_ui8SSIIntMapSnowflakeRows
 

Detailed Description

Function Documentation

static uint32_t _SSIIntNumberGet ( uint32_t  ui32Base)
static

Returns the interrupt number of SSI module .

Parameters
ui32Baseis the base address of the SSI module.

This function returns the interrupt number for the SSI module with the base address passed in the ui32Base parameter.

Returns
Returns an SSI interrupt number, or 0 if the interrupt does not exist.

Definition at line 119 of file ssi.c.

References ASSERT, CLASS_IS_TM4C129, g_ppui32SSIIntMap, g_ppui32SSIIntMapSnowflake, g_ui8SSIIntMapRows, and g_ui8SSIIntMapSnowflakeRows.

Referenced by SSIIntRegister(), and SSIIntUnregister().

120 {
121  uint_fast8_t ui8Idx, ui8Rows;
122  const uint32_t (*ppui32SSIIntMap)[2];
123 
124  //
125  // Check the arguments.
126  //
127  ASSERT(_SSIBaseValid(ui32Base));
128 
129  ppui32SSIIntMap = g_ppui32SSIIntMap;
130  ui8Rows = g_ui8SSIIntMapRows;
131 
132  if(CLASS_IS_TM4C129)
133  {
134  ppui32SSIIntMap = g_ppui32SSIIntMapSnowflake;
135  ui8Rows = g_ui8SSIIntMapSnowflakeRows;
136  }
137 
138  //
139  // Loop through the table that maps SSI base addresses to interrupt
140  // numbers.
141  //
142  for(ui8Idx = 0; ui8Idx < ui8Rows; ui8Idx++)
143  {
144  //
145  // See if this base address matches.
146  //
147  if(ppui32SSIIntMap[ui8Idx][0] == ui32Base)
148  {
149  //
150  // Return the corresponding interrupt number.
151  //
152  return(ppui32SSIIntMap[ui8Idx][1]);
153  }
154  }
155 
156  //
157  // The base address could not be found, so return an error.
158  //
159  return(0);
160 }
static const uint_fast8_t g_ui8SSIIntMapSnowflakeRows
Definition: ssi.c:80
static const uint32_t g_ppui32SSIIntMap[][2]
Definition: ssi.c:63
#define ASSERT(expr)
Definition: debug.h:67
static const uint_fast8_t g_ui8SSIIntMapRows
Definition: ssi.c:70
static const uint32_t g_ppui32SSIIntMapSnowflake[][2]
Definition: ssi.c:73
#define CLASS_IS_TM4C129
Definition: hw_types.h:99

Here is the caller graph for this function:

void SSIAdvDataPutFrameEnd ( uint32_t  ui32Base,
uint32_t  ui32Data 
)

Puts a data element into the SSI transmit FIFO as the end of a frame.

Parameters
ui32Basespecifies the SSI module base address.
ui32Datais the data to be transmitted over the SSI interface.

This function places the supplied data into the transmit FIFO of the specified SSI module, marking it as the end of a frame. If there is no space available in the transmit FIFO, this function waits until there is space available before returning. After this byte is transmitted by the SSI module, the FSS signal de-asserts for at least one SSI clock.

Note
The upper 24 bits of ui32Data are discarded by the hardware.
The availability of the advanced mode of SSI operation varies with the Tiva part and SSI in use. Please consult the data sheet for the part in use to determine whether this support is available.
Returns
None.

Definition at line 1010 of file ssi.c.

References ASSERT, HWREG, SSI_CR1_EOM, SSI_O_CR1, SSI_O_DR, SSI_O_SR, and SSI_SR_TNF.

1011 {
1012  //
1013  // Check the arguments.
1014  //
1015  ASSERT(_SSIBaseValid(ui32Base));
1016  ASSERT((ui32Data & 0xff) == 0);
1017 
1018  //
1019  // Wait until there is space.
1020  //
1021  while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF))
1022  {
1023  }
1024 
1025  //
1026  // Write the data to the SSI.
1027  //
1028  HWREG(ui32Base + SSI_O_CR1) |= SSI_CR1_EOM;
1029  HWREG(ui32Base + SSI_O_DR) = ui32Data;
1030 }
#define SSI_SR_TNF
Definition: hw_ssi.h:127
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_CR1_EOM
Definition: hw_ssi.h:94
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_O_DR
Definition: hw_ssi.h:50
#define SSI_O_SR
Definition: hw_ssi.h:51
int32_t SSIAdvDataPutFrameEndNonBlocking ( uint32_t  ui32Base,
uint32_t  ui32Data 
)

Puts a data element into the SSI transmit FIFO as the end of a frame.

Parameters
ui32Basespecifies the SSI module base address.
ui32Datais the data to be transmitted over the SSI interface.

This function places the supplied data into the transmit FIFO of the specified SSI module, marking it as the end of a frame. After this byte is transmitted by the SSI module, the FSS signal de-asserts for at least one SSI clock. If there is no space in the FIFO, then this function returns a zero.

Note
The upper 24 bits of ui32Data are discarded by the hardware.
The availability of the advanced mode of SSI operation varies with the Tiva part and SSI in use. Please consult the data sheet for the part in use to determine whether this support is available.
Returns
Returns the number of elements written to the SSI transmit FIFO.

Definition at line 1055 of file ssi.c.

References ASSERT, HWREG, SSI_CR1_EOM, SSI_O_CR1, SSI_O_DR, SSI_O_SR, and SSI_SR_TNF.

1056 {
1057  //
1058  // Check the arguments.
1059  //
1060  ASSERT(_SSIBaseValid(ui32Base));
1061  ASSERT((ui32Data & 0xff) == 0);
1062 
1063  //
1064  // Check for space to write.
1065  //
1066  if(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF)
1067  {
1068  HWREG(ui32Base + SSI_O_CR1) |= SSI_CR1_EOM;
1069  HWREG(ui32Base + SSI_O_DR) = ui32Data;
1070  return(1);
1071  }
1072  else
1073  {
1074  return(0);
1075  }
1076 }
#define SSI_SR_TNF
Definition: hw_ssi.h:127
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_CR1_EOM
Definition: hw_ssi.h:94
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_O_DR
Definition: hw_ssi.h:50
#define SSI_O_SR
Definition: hw_ssi.h:51
void SSIAdvFrameHoldDisable ( uint32_t  ui32Base)

Configures the SSI advanced mode to de-assert the SSIFss signal after every byte transfer.

Parameters
ui32Baseis the base address of the SSI module.

This function configures the SSI module to de-assert the SSIFss signal for one SSI clock cycle after every byte is transferred using one of the advanced modes (instead of leaving it asserted for the entire transfer). This mode is the default operation.

Note
The availability of the advanced mode of SSI operation varies with the Tiva part and SSI in use. Please consult the data sheet for the part in use to determine whether this support is available.
Returns
None.

Definition at line 1132 of file ssi.c.

References ASSERT, HWREG, SSI_CR1_FSSHLDFRM, and SSI_O_CR1.

1133 {
1134  //
1135  // Check the arguments.
1136  //
1137  ASSERT(_SSIBaseValid(ui32Base));
1138 
1139  //
1140  // Clear the hold frame bit.
1141  //
1142  HWREG(ui32Base + SSI_O_CR1) &= ~(SSI_CR1_FSSHLDFRM);
1143 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_CR1_FSSHLDFRM
Definition: hw_ssi.h:95
void SSIAdvFrameHoldEnable ( uint32_t  ui32Base)

Configures the SSI advanced mode to hold the SSIFss signal during the full transfer.

Parameters
ui32Baseis the base address of the SSI module.

This function configures the SSI module to de-assert the SSIFss signal during the entire data transfer when using one of the advanced modes (instead of briefly de-asserting it after every byte). When using this mode, SSIFss can be directly controlled via SSIAdvDataPutFrameEnd() and SSIAdvDataPutFrameEndNonBlocking().

Note
The availability of the advanced mode of SSI operation varies with the Tiva part and SSI in use. Please consult the data sheet for the part in use to determine whether this support is available.
Returns
None.

Definition at line 1099 of file ssi.c.

References ASSERT, HWREG, SSI_CR1_FSSHLDFRM, and SSI_O_CR1.

1100 {
1101  //
1102  // Check the arguments.
1103  //
1104  ASSERT(_SSIBaseValid(ui32Base));
1105 
1106  //
1107  // Set the hold frame bit.
1108  //
1109  HWREG(ui32Base + SSI_O_CR1) |= SSI_CR1_FSSHLDFRM;
1110 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_CR1_FSSHLDFRM
Definition: hw_ssi.h:95
void SSIAdvModeSet ( uint32_t  ui32Base,
uint32_t  ui32Mode 
)

Selects the advanced mode of operation for the SSI module.

Parameters
ui32Baseis the base address of the SSI module.
ui32Modeis the mode of operation to use.

This function selects the mode of operation for the SSI module, which is needed when using the advanced operation modes (Bi- or Quad-SPI). One of the following modes can be selected:

  • SSI_ADV_MODE_LEGACY - Disables the advanced modes of operation, resulting in legacy, or backwards-compatible, operation. When this mode is selected, it is not valid to switch to Bi- or Quad-SPI operation. This mode is the default.
  • SSI_ADV_MODE_WRITE - The advanced mode of operation where data is only written to the slave; any data clocked in via the SSIRx pin is thrown away (instead of being placed into the SSI Rx FIFO).
  • SSI_ADV_MODE_READ_WRITE - The advanced mode of operation where data is written to and read from the slave; this mode is the same as SSI_ADV_MODE_LEGACY but allows transitions to Bi- or Quad-SPI operation.
  • SSI_ADV_MODE_BI_READ - The advanced mode of operation where data is read from the slave in Bi-SPI mode, with two bits of data read on every SSI clock.
  • SSI_ADV_MODE_BI_WRITE - The advanced mode of operation where data is written to the slave in Bi-SPI mode, with two bits of data written on every SSI clock.
  • SSI_ADV_MODE_QUAD_READ - The advanced mode of operation where data is read from the slave in Quad-SPI mode, with four bits of data read on every SSI clock.
  • SSI_ADV_MODE_QUAD_WRITE - The advanced mode of operation where data is written to the slave in Quad-SPI mode, with four bits of data written on every SSI clock.

The following mode transitions are valid (other transitions produce undefined results):

//! +----------+-------------------------------------------------------------+
//! |FROM      |                             TO                              |
//! |          |Legacy|Write|Read Write|Bi Read|Bi Write|Quad Read|Quad Write|
//! +----------+------+-----+----------+-------+--------+---------+----------+
//! |Legacy    | yes  | yes |   yes    |       |        |         |          |
//! |Write     | yes  | yes |   yes    |  yes  |  yes   |   yes   |   yes    |
//! |Read/Write| yes  | yes |   yes    |  yes  |  yes   |   yes   |   yes    |
//! |Bi Read   |      | yes |   yes    |  yes  |  yes   |         |          |
//! |Bi write  |      | yes |   yes    |  yes  |  yes   |         |          |
//! |Quad read |      | yes |   yes    |       |        |   yes   |   yes    |
//! |Quad write|      | yes |   yes    |       |        |   yes   |   yes    |
//! +----------+------+-----+----------+-------+--------+---------+----------+
//! 
When using an advanced mode of operation, the SSI module must have been
configured for eight data bits and the \b SSI_FRF_MOTO_MODE_0 protocol.
The advanced mode operation that is selected applies only to data newly
written into the FIFO; the data that is already present in the FIFO is
handled using the advanced mode of operation in effect when that data was
written.

Switching into and out of legacy mode should only occur when the FIFO is
empty.

\note The availability of the advanced mode of SSI operation varies with
the Tiva part and SSI in use.  Please consult the data sheet for the
part in use to determine whether this support is available.

\return None.  

Definition at line 965 of file ssi.c.

References ASSERT, HWREG, SSI_ADV_MODE_BI_READ, SSI_ADV_MODE_BI_WRITE, SSI_ADV_MODE_LEGACY, SSI_ADV_MODE_QUAD_READ, SSI_ADV_MODE_QUAD_WRITE, SSI_ADV_MODE_READ_WRITE, SSI_ADV_MODE_WRITE, SSI_CR1_DIR, SSI_CR1_MODE_M, and SSI_O_CR1.

966 {
967  //
968  // Check the arguments.
969  //
970  ASSERT(_SSIBaseValid(ui32Base));
971  ASSERT((ui32Mode == SSI_ADV_MODE_LEGACY) ||
972  (ui32Mode == SSI_ADV_MODE_WRITE) ||
973  (ui32Mode == SSI_ADV_MODE_READ_WRITE) ||
974  (ui32Mode == SSI_ADV_MODE_BI_READ) ||
975  (ui32Mode == SSI_ADV_MODE_BI_WRITE) ||
976  (ui32Mode == SSI_ADV_MODE_QUAD_READ) ||
977  (ui32Mode == SSI_ADV_MODE_QUAD_WRITE));
978 
979  //
980  // Set the SSI mode of operation.
981  //
982  HWREG(ui32Base + SSI_O_CR1) =
983  ((HWREG(ui32Base + SSI_O_CR1) & ~(SSI_CR1_DIR | SSI_CR1_MODE_M)) |
984  ui32Mode);
985 }
#define SSI_ADV_MODE_WRITE
Definition: ssi.h:108
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_ADV_MODE_QUAD_READ
Definition: ssi.h:111
#define SSI_CR1_MODE_M
Definition: hw_ssi.h:98
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_ADV_MODE_QUAD_WRITE
Definition: ssi.h:112
#define SSI_ADV_MODE_BI_READ
Definition: ssi.h:109
#define SSI_CR1_DIR
Definition: hw_ssi.h:97
#define SSI_ADV_MODE_READ_WRITE
Definition: ssi.h:107
#define SSI_ADV_MODE_BI_WRITE
Definition: ssi.h:110
#define SSI_ADV_MODE_LEGACY
Definition: ssi.h:106
bool SSIBusy ( uint32_t  ui32Base)

Determines whether the SSI transmitter is busy or not.

Parameters
ui32Baseis the base address of the SSI module.

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.

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

Definition at line 813 of file ssi.c.

References ASSERT, HWREG, SSI_O_SR, and SSI_SR_BSY.

814 {
815  //
816  // Check the arguments.
817  //
818  ASSERT(_SSIBaseValid(ui32Base));
819 
820  //
821  // Determine if the SSI is busy.
822  //
823  return((HWREG(ui32Base + SSI_O_SR) & SSI_SR_BSY) ? true : false);
824 }
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_SR_BSY
Definition: hw_ssi.h:124
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_SR
Definition: hw_ssi.h:51
uint32_t SSIClockSourceGet ( uint32_t  ui32Base)

Gets the data clock source for the specified SSI peripheral.

Parameters
ui32Baseis the base address of the SSI module.

This function returns the data clock source for the specified SSI.

Note
The ability to specify the SSI data clock source varies with the Tiva part and SSI in use. Please consult the data sheet for the part in use to determine whether this support is available.
Returns
Returns the current clock source, which is either SSI_CLOCK_SYSTEM or SSI_CLOCK_PIOSC.

Definition at line 881 of file ssi.c.

References ASSERT, HWREG, and SSI_O_CC.

882 {
883  //
884  // Check the arguments.
885  //
886  ASSERT(_SSIBaseValid(ui32Base));
887 
888  //
889  // Return the SSI clock source.
890  //
891  return(HWREG(ui32Base + SSI_O_CC));
892 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CC
Definition: hw_ssi.h:59
void SSIClockSourceSet ( uint32_t  ui32Base,
uint32_t  ui32Source 
)

Sets the data clock source for the specified SSI peripheral.

Parameters
ui32Baseis the base address of the SSI module.
ui32Sourceis the baud clock source for the SSI.

This function allows the baud clock source for the SSI to be selected. The possible clock source are the system clock (SSI_CLOCK_SYSTEM) or the precision internal oscillator (SSI_CLOCK_PIOSC).

Changing the baud clock source changes the data rate generated by the SSI. Therefore, the data rate should be reconfigured after any change to the SSI clock source.

Note
The ability to specify the SSI baud clock source varies with the Tiva part and SSI in use. Please consult the data sheet for the part in use to determine whether this support is available.
Returns
None.

Definition at line 849 of file ssi.c.

References ASSERT, HWREG, SSI_CLOCK_PIOSC, SSI_CLOCK_SYSTEM, and SSI_O_CC.

850 {
851  //
852  // Check the arguments.
853  //
854  ASSERT(_SSIBaseValid(ui32Base));
855  ASSERT((ui32Source == SSI_CLOCK_SYSTEM) ||
856  (ui32Source == SSI_CLOCK_PIOSC));
857 
858  //
859  // Set the SSI clock source.
860  //
861  HWREG(ui32Base + SSI_O_CC) = ui32Source;
862 }
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_CLOCK_SYSTEM
Definition: ssi.h:98
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CC
Definition: hw_ssi.h:59
#define SSI_CLOCK_PIOSC
Definition: ssi.h:99
void SSIConfigSetExpClk ( uint32_t  ui32Base,
uint32_t  ui32SSIClk,
uint32_t  ui32Protocol,
uint32_t  ui32Mode,
uint32_t  ui32BitRate,
uint32_t  ui32DataWidth 
)

Configures the synchronous serial interface.

Parameters
ui32Basespecifies the SSI module base address.
ui32SSIClkis the rate of the clock supplied to the SSI module.
ui32Protocolspecifies the data transfer protocol.
ui32Modespecifies the mode of operation.
ui32BitRatespecifies the clock rate.
ui32DataWidthspecifies number of bits transferred per frame.

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

The ui32Protocol parameter defines the data frame format. The ui32Protocol 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, SSI_FRF_TI, or SSI_FRF_NMW. Note that the SSI_FRF_NMW option is only available on some devices. Refer to the device data sheet to determine if the Microwire format is supported on a particular device. The Motorola frame formats encode the following polarity and phase configurations:

Polarity Phase       Mode
  0       0   SSI_FRF_MOTO_MODE_0
  0       1   SSI_FRF_MOTO_MODE_1
  1       0   SSI_FRF_MOTO_MODE_2
  1       1   SSI_FRF_MOTO_MODE_3

The ui32Mode parameter defines the operating mode of the SSI module. The SSI module can operate as a master or slave; if it is a slave, the SSI can be configured to disable output on its serial output line. The ui32Mode parameter can be one of the following values: SSI_MODE_MASTER, SSI_MODE_SLAVE, or SSI_MODE_SLAVE_OD.

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

  • FSSI >= 2 * bit rate (master mode)
  • FSSI >= 12 * bit rate (slave modes)

where FSSI 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 ui32DataWidth 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. This value is returned by SysCtlClockGet(), or it can be explicitly hard coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()).

Returns
None.

Definition at line 221 of file ssi.c.

References ASSERT, HWREG, SSI_CR0_FRF_M, SSI_CR1_MS, SSI_CR1_SOD, SSI_FRF_MOTO_MODE_0, SSI_FRF_MOTO_MODE_1, SSI_FRF_MOTO_MODE_2, SSI_FRF_MOTO_MODE_3, SSI_FRF_NMW, SSI_FRF_TI, SSI_MODE_MASTER, SSI_MODE_SLAVE, SSI_MODE_SLAVE_OD, SSI_O_CPSR, SSI_O_CR0, and SSI_O_CR1.

224 {
225  uint32_t ui32MaxBitRate;
226  uint32_t ui32RegVal;
227  uint32_t ui32PreDiv;
228  uint32_t ui32SCR;
229  uint32_t ui32SPH_SPO;
230 
231  //
232  // Check the arguments.
233  //
234  ASSERT(_SSIBaseValid(ui32Base));
235  ASSERT((ui32Protocol == SSI_FRF_MOTO_MODE_0) ||
236  (ui32Protocol == SSI_FRF_MOTO_MODE_1) ||
237  (ui32Protocol == SSI_FRF_MOTO_MODE_2) ||
238  (ui32Protocol == SSI_FRF_MOTO_MODE_3) ||
239  (ui32Protocol == SSI_FRF_TI) ||
240  (ui32Protocol == SSI_FRF_NMW));
241  ASSERT((ui32Mode == SSI_MODE_MASTER) ||
242  (ui32Mode == SSI_MODE_SLAVE) ||
243  (ui32Mode == SSI_MODE_SLAVE_OD));
244  ASSERT(((ui32Mode == SSI_MODE_MASTER) &&
245  (ui32BitRate <= (ui32SSIClk / 2))) ||
246  ((ui32Mode != SSI_MODE_MASTER) &&
247  (ui32BitRate <= (ui32SSIClk / 12))));
248  ASSERT((ui32SSIClk / ui32BitRate) <= (254 * 256));
249  ASSERT((ui32DataWidth >= 4) && (ui32DataWidth <= 16));
250 
251  //
252  // Set the mode.
253  //
254  ui32RegVal = (ui32Mode == SSI_MODE_SLAVE_OD) ? SSI_CR1_SOD : 0;
255  ui32RegVal |= (ui32Mode == SSI_MODE_MASTER) ? 0 : SSI_CR1_MS;
256  HWREG(ui32Base + SSI_O_CR1) = ui32RegVal;
257 
258  //
259  // Set the clock predivider.
260  //
261  ui32MaxBitRate = ui32SSIClk / ui32BitRate;
262  ui32PreDiv = 0;
263  do
264  {
265  ui32PreDiv += 2;
266  ui32SCR = (ui32MaxBitRate / ui32PreDiv) - 1;
267  }
268  while(ui32SCR > 255);
269  HWREG(ui32Base + SSI_O_CPSR) = ui32PreDiv;
270 
271  //
272  // Set protocol and clock rate.
273  //
274  ui32SPH_SPO = (ui32Protocol & 3) << 6;
275  ui32Protocol &= SSI_CR0_FRF_M;
276  ui32RegVal = (ui32SCR << 8) | ui32SPH_SPO | ui32Protocol |
277  (ui32DataWidth - 1);
278  HWREG(ui32Base + SSI_O_CR0) = ui32RegVal;
279 }
#define SSI_O_CR0
Definition: hw_ssi.h:48
#define SSI_CR0_FRF_M
Definition: hw_ssi.h:69
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_MODE_SLAVE
Definition: ssi.h:81
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_FRF_TI
Definition: ssi.h:77
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_FRF_NMW
Definition: ssi.h:78
#define SSI_FRF_MOTO_MODE_0
Definition: ssi.h:73
#define SSI_FRF_MOTO_MODE_2
Definition: ssi.h:75
#define SSI_O_CPSR
Definition: hw_ssi.h:52
#define SSI_CR1_SOD
Definition: hw_ssi.h:105
#define SSI_CR1_MS
Definition: hw_ssi.h:106
#define SSI_MODE_MASTER
Definition: ssi.h:80
#define SSI_MODE_SLAVE_OD
Definition: ssi.h:82
#define SSI_FRF_MOTO_MODE_1
Definition: ssi.h:74
#define SSI_FRF_MOTO_MODE_3
Definition: ssi.h:76
void SSIDataGet ( uint32_t  ui32Base,
uint32_t *  pui32Data 
)

Gets a data element from the SSI receive FIFO.

Parameters
ui32Basespecifies the SSI module base address.
pui32Datais a pointer to a storage location for data that was received over the SSI interface.

This function gets received data from the receive FIFO of the specified SSI module and places that data into the location specified by the pui32Data parameter. If there is no data available, this function waits until data is received before returning.

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

Definition at line 667 of file ssi.c.

References ASSERT, HWREG, SSI_O_DR, SSI_O_SR, and SSI_SR_RNE.

668 {
669  //
670  // Check the arguments.
671  //
672  ASSERT(_SSIBaseValid(ui32Base));
673 
674  //
675  // Wait until there is data to be read.
676  //
677  while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE))
678  {
679  }
680 
681  //
682  // Read data from SSI.
683  //
684  *pui32Data = HWREG(ui32Base + SSI_O_DR);
685 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_DR
Definition: hw_ssi.h:50
#define SSI_SR_RNE
Definition: hw_ssi.h:126
#define SSI_O_SR
Definition: hw_ssi.h:51
int32_t SSIDataGetNonBlocking ( uint32_t  ui32Base,
uint32_t *  pui32Data 
)

Gets a data element from the SSI receive FIFO.

Parameters
ui32Basespecifies the SSI module base address.
pui32Datais a pointer to a storage location for data that was received over the SSI interface.

This function gets received data from the receive FIFO of the specified SSI module and places that data into the location specified by the ui32Data parameter. If there is no data in the FIFO, then this function returns a zero.

Note
Only the lower N bits of the value written to pui32Data contain valid data, where N is the data width as configured by SSIConfigSetExpClk(). For example, if the interface is configured for 8-bit data width, only the lower 8 bits of the value written to pui32Data contain valid data.
Returns
Returns the number of elements read from the SSI receive FIFO.

Definition at line 710 of file ssi.c.

References ASSERT, HWREG, SSI_O_DR, SSI_O_SR, and SSI_SR_RNE.

711 {
712  //
713  // Check the arguments.
714  //
715  ASSERT(_SSIBaseValid(ui32Base));
716 
717  //
718  // Check for data to read.
719  //
720  if(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE)
721  {
722  *pui32Data = HWREG(ui32Base + SSI_O_DR);
723  return(1);
724  }
725  else
726  {
727  return(0);
728  }
729 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_DR
Definition: hw_ssi.h:50
#define SSI_SR_RNE
Definition: hw_ssi.h:126
#define SSI_O_SR
Definition: hw_ssi.h:51
void SSIDataPut ( uint32_t  ui32Base,
uint32_t  ui32Data 
)

Puts a data element into the SSI transmit FIFO.

Parameters
ui32Basespecifies the SSI module base address.
ui32Datais the data to be transmitted over the SSI interface.

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.

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

Definition at line 579 of file ssi.c.

References ASSERT, HWREG, SSI_CR0_DSS_M, SSI_O_CR0, SSI_O_DR, SSI_O_SR, and SSI_SR_TNF.

580 {
581  //
582  // Check the arguments.
583  //
584  ASSERT(_SSIBaseValid(ui32Base));
585  ASSERT((ui32Data & (0xfffffffe << (HWREG(ui32Base + SSI_O_CR0) &
586  SSI_CR0_DSS_M))) == 0);
587 
588  //
589  // Wait until there is space.
590  //
591  while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF))
592  {
593  }
594 
595  //
596  // Write the data to the SSI.
597  //
598  HWREG(ui32Base + SSI_O_DR) = ui32Data;
599 }
#define SSI_O_CR0
Definition: hw_ssi.h:48
#define SSI_SR_TNF
Definition: hw_ssi.h:127
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_DR
Definition: hw_ssi.h:50
#define SSI_CR0_DSS_M
Definition: hw_ssi.h:73
#define SSI_O_SR
Definition: hw_ssi.h:51
int32_t SSIDataPutNonBlocking ( uint32_t  ui32Base,
uint32_t  ui32Data 
)

Puts a data element into the SSI transmit FIFO.

Parameters
ui32Basespecifies the SSI module base address.
ui32Datais the data to be transmitted over the SSI interface.

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.

Note
The upper 32 - N bits of ui32Data are discarded by the hardware, where N is the data width as configured by SSIConfigSetExpClk(). For example, if the interface is configured for 8-bit data width, the upper 24 bits of ui32Data are discarded.
Returns
Returns the number of elements written to the SSI transmit FIFO.

Definition at line 621 of file ssi.c.

References ASSERT, HWREG, SSI_CR0_DSS_M, SSI_O_CR0, SSI_O_DR, SSI_O_SR, and SSI_SR_TNF.

622 {
623  //
624  // Check the arguments.
625  //
626  ASSERT(_SSIBaseValid(ui32Base));
627  ASSERT((ui32Data & (0xfffffffe << (HWREG(ui32Base + SSI_O_CR0) &
628  SSI_CR0_DSS_M))) == 0);
629 
630  //
631  // Check for space to write.
632  //
633  if(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF)
634  {
635  HWREG(ui32Base + SSI_O_DR) = ui32Data;
636  return(1);
637  }
638  else
639  {
640  return(0);
641  }
642 }
#define SSI_O_CR0
Definition: hw_ssi.h:48
#define SSI_SR_TNF
Definition: hw_ssi.h:127
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_DR
Definition: hw_ssi.h:50
#define SSI_CR0_DSS_M
Definition: hw_ssi.h:73
#define SSI_O_SR
Definition: hw_ssi.h:51
void SSIDisable ( uint32_t  ui32Base)

Disables the synchronous serial interface.

Parameters
ui32Basespecifies the SSI module base address.

This function disables operation of the synchronous serial interface.

Returns
None.

Definition at line 319 of file ssi.c.

References ASSERT, HWREG, SSI_CR1_SSE, and SSI_O_CR1.

320 {
321  //
322  // Check the arguments.
323  //
324  ASSERT(_SSIBaseValid(ui32Base));
325 
326  //
327  // Read-modify-write the enable bit.
328  //
329  HWREG(ui32Base + SSI_O_CR1) &= ~(SSI_CR1_SSE);
330 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_CR1_SSE
Definition: hw_ssi.h:107
void SSIDMADisable ( uint32_t  ui32Base,
uint32_t  ui32DMAFlags 
)

Disables SSI DMA operation.

Parameters
ui32Baseis the base address of the SSI module.
ui32DMAFlagsis a bit mask of the DMA features to disable.

This function is used to disable SSI DMA features that were enabled by SSIDMAEnable(). The specified SSI DMA features are disabled. The ui32DMAFlags parameter is the logical OR of any of the following values:

  • SSI_DMA_RX - disable DMA for receive
  • SSI_DMA_TX - disable DMA for transmit
Returns
None.

Definition at line 784 of file ssi.c.

References ASSERT, HWREG, and SSI_O_DMACTL.

785 {
786  //
787  // Check the arguments.
788  //
789  ASSERT(_SSIBaseValid(ui32Base));
790 
791  //
792  // Clear the requested bits in the SSI DMA control register.
793  //
794  HWREG(ui32Base + SSI_O_DMACTL) &= ~ui32DMAFlags;
795 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_DMACTL
Definition: hw_ssi.h:57
void SSIDMAEnable ( uint32_t  ui32Base,
uint32_t  ui32DMAFlags 
)

Enables SSI DMA operation.

Parameters
ui32Baseis the base address of the SSI module.
ui32DMAFlagsis a bit mask of the DMA features to enable.

This function enables the specified SSI DMA features. The SSI can be configured to use DMA for transmit and/or receive data transfers. The ui32DMAFlags parameter is the logical OR of any of the following values:

  • 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.
Returns
None.

Definition at line 753 of file ssi.c.

References ASSERT, HWREG, and SSI_O_DMACTL.

754 {
755  //
756  // Check the arguments.
757  //
758  ASSERT(_SSIBaseValid(ui32Base));
759 
760  //
761  // Set the requested bits in the SSI DMA control register.
762  //
763  HWREG(ui32Base + SSI_O_DMACTL) |= ui32DMAFlags;
764 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_DMACTL
Definition: hw_ssi.h:57
void SSIEnable ( uint32_t  ui32Base)

Enables the synchronous serial interface.

Parameters
ui32Basespecifies the SSI module base address.

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

Returns
None.

Definition at line 294 of file ssi.c.

References ASSERT, HWREG, SSI_CR1_SSE, and SSI_O_CR1.

295 {
296  //
297  // Check the arguments.
298  //
299  ASSERT(_SSIBaseValid(ui32Base));
300 
301  //
302  // Read-modify-write the enable bit.
303  //
304  HWREG(ui32Base + SSI_O_CR1) |= SSI_CR1_SSE;
305 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_CR1
Definition: hw_ssi.h:49
#define SSI_CR1_SSE
Definition: hw_ssi.h:107
void SSIIntClear ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears SSI interrupt sources.

Parameters
ui32Basespecifies the SSI module base address.
ui32IntFlagsis a bit mask of the interrupt sources to be cleared.

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 ui32IntFlags parameter can consist of either or both the SSI_RXTO and SSI_RXOR values.

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).
Returns
None.

Definition at line 546 of file ssi.c.

References ASSERT, HWREG, and SSI_O_ICR.

547 {
548  //
549  // Check the arguments.
550  //
551  ASSERT(_SSIBaseValid(ui32Base));
552 
553  //
554  // Clear the requested interrupt sources.
555  //
556  HWREG(ui32Base + SSI_O_ICR) = ui32IntFlags;
557 }
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_O_ICR
Definition: hw_ssi.h:56
#define ASSERT(expr)
Definition: debug.h:67
void SSIIntDisable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables individual SSI interrupt sources.

Parameters
ui32Basespecifies the SSI module base address.
ui32IntFlagsis a bit mask of the interrupt sources to be disabled.

This function disables the indicated SSI interrupt sources. The ui32IntFlags parameter can be any of the SSI_TXFF, SSI_RXFF, SSI_RXTO, or SSI_RXOR values.

Returns
None.

Definition at line 469 of file ssi.c.

References ASSERT, HWREG, and SSI_O_IM.

470 {
471  //
472  // Check the arguments.
473  //
474  ASSERT(_SSIBaseValid(ui32Base));
475 
476  //
477  // Disable the specified interrupts.
478  //
479  HWREG(ui32Base + SSI_O_IM) &= ~(ui32IntFlags);
480 }
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_O_IM
Definition: hw_ssi.h:53
#define ASSERT(expr)
Definition: debug.h:67
void SSIIntEnable ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables individual SSI interrupt sources.

Parameters
ui32Basespecifies the SSI module base address.
ui32IntFlagsis a bit mask of the interrupt sources to be enabled.

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 ui32IntFlags parameter can be any of the SSI_TXFF, SSI_RXFF, SSI_RXTO, or SSI_RXOR values.

Returns
None.

Definition at line 441 of file ssi.c.

References ASSERT, HWREG, and SSI_O_IM.

442 {
443  //
444  // Check the arguments.
445  //
446  ASSERT(_SSIBaseValid(ui32Base));
447 
448  //
449  // Enable the specified interrupts.
450  //
451  HWREG(ui32Base + SSI_O_IM) |= ui32IntFlags;
452 }
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_O_IM
Definition: hw_ssi.h:53
#define ASSERT(expr)
Definition: debug.h:67
void SSIIntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the synchronous serial interface.

Parameters
ui32Basespecifies the SSI module base address.
pfnHandleris a pointer to the function to be called when the synchronous serial interface interrupt occurs.

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 SSIIntEnable(). If necessary, it is the interrupt handler's responsibility to clear the interrupt source via SSIIntClear().

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 353 of file ssi.c.

References _SSIIntNumberGet(), ASSERT, IntEnable(), and IntRegister().

354 {
355  uint32_t ui32Int;
356 
357  //
358  // Check the arguments.
359  //
360  ASSERT(_SSIBaseValid(ui32Base));
361 
362  //
363  // Determine the interrupt number based on the SSI module.
364  //
365  ui32Int = _SSIIntNumberGet(ui32Base);
366 
367  ASSERT(ui32Int != 0);
368 
369  //
370  // Register the interrupt handler, returning an error if an error occurs.
371  //
372  IntRegister(ui32Int, pfnHandler);
373 
374  //
375  // Enable the synchronous serial interface interrupt.
376  //
377  IntEnable(ui32Int);
378 }
#define ASSERT(expr)
Definition: debug.h:67
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
Definition: ssi.c:119
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

uint32_t SSIIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current interrupt status.

Parameters
ui32Basespecifies the SSI module base address.
bMaskedis false if the raw interrupt status is required or true if the masked interrupt status is required.

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.

Returns
The current interrupt status, enumerated as a bit field of SSI_TXFF, SSI_RXFF, SSI_RXTO, and SSI_RXOR.

Definition at line 499 of file ssi.c.

References ASSERT, HWREG, SSI_O_MIS, and SSI_O_RIS.

500 {
501  //
502  // Check the arguments.
503  //
504  ASSERT(_SSIBaseValid(ui32Base));
505 
506  //
507  // Return either the interrupt status or the raw interrupt status as
508  // requested.
509  //
510  if(bMasked)
511  {
512  return(HWREG(ui32Base + SSI_O_MIS));
513  }
514  else
515  {
516  return(HWREG(ui32Base + SSI_O_RIS));
517  }
518 }
#define HWREG(x)
Definition: hw_types.h:48
#define SSI_O_RIS
Definition: hw_ssi.h:54
#define ASSERT(expr)
Definition: debug.h:67
#define SSI_O_MIS
Definition: hw_ssi.h:55
void SSIIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the synchronous serial interface.

Parameters
ui32Basespecifies the SSI module base address.

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.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 397 of file ssi.c.

References _SSIIntNumberGet(), ASSERT, IntDisable(), and IntUnregister().

398 {
399  uint32_t ui32Int;
400 
401  //
402  // Check the arguments.
403  //
404  ASSERT(_SSIBaseValid(ui32Base));
405 
406  //
407  // Determine the interrupt number based on the SSI module.
408  //
409  ui32Int = _SSIIntNumberGet(ui32Base);
410 
411  ASSERT(ui32Int != 0);
412 
413  //
414  // Disable the interrupt.
415  //
416  IntDisable(ui32Int);
417 
418  //
419  // Unregister the interrupt handler.
420  //
421  IntUnregister(ui32Int);
422 }
#define ASSERT(expr)
Definition: debug.h:67
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
Definition: ssi.c:119
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684

Here is the call graph for this function:

Variable Documentation

const uint32_t g_ppui32SSIIntMap[][2]
static
Initial value:
=
{
}
#define SSI1_BASE
Definition: hw_memmap.h:58
#define INT_SSI1_TM4C123
Definition: hw_ints.h:99
#define INT_SSI0_TM4C123
Definition: hw_ints.h:71
#define INT_SSI2_TM4C123
Definition: hw_ints.h:118
#define SSI3_BASE
Definition: hw_memmap.h:60
#define INT_SSI3_TM4C123
Definition: hw_ints.h:119
#define SSI2_BASE
Definition: hw_memmap.h:59
#define SSI0_BASE
Definition: hw_memmap.h:57

Definition at line 63 of file ssi.c.

Referenced by _SSIIntNumberGet().

const uint32_t g_ppui32SSIIntMapSnowflake[][2]
static
Initial value:
=
{
}
#define SSI1_BASE
Definition: hw_memmap.h:58
#define INT_SSI0_TM4C129
Definition: hw_ints.h:183
#define INT_SSI3_TM4C129
Definition: hw_ints.h:231
#define SSI3_BASE
Definition: hw_memmap.h:60
#define INT_SSI1_TM4C129
Definition: hw_ints.h:210
#define SSI2_BASE
Definition: hw_memmap.h:59
#define SSI0_BASE
Definition: hw_memmap.h:57
#define INT_SSI2_TM4C129
Definition: hw_ints.h:230

Definition at line 73 of file ssi.c.

Referenced by _SSIIntNumberGet().

const uint_fast8_t g_ui8SSIIntMapRows
static
Initial value:
=
sizeof(g_ppui32SSIIntMap) / sizeof(g_ppui32SSIIntMap[0])
static const uint32_t g_ppui32SSIIntMap[][2]
Definition: ssi.c:63

Definition at line 70 of file ssi.c.

Referenced by _SSIIntNumberGet().

const uint_fast8_t g_ui8SSIIntMapSnowflakeRows
static
Initial value:
=
static const uint32_t g_ppui32SSIIntMapSnowflake[][2]
Definition: ssi.c:73

Definition at line 80 of file ssi.c.

Referenced by _SSIIntNumberGet().