int main(void) { uint32_t pui32DataTx2[4]; uint32_t pui32DataRx2[8]; uint32_t ui32Index; // // Set the clocking to run directly from the external crystal/oscillator. // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the // crystal on your board. // g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Set up the serial console to use for displaying messages. This is // just for this example program and is not needed for SSI operation. // ConfigureUART(); // // Initialize and enable CS // InitGPIO(); // // Display the setup on the console. // UARTprintf("\n\nSSI ->\n"); UARTprintf(" Mode: SPI\n"); UARTprintf(" Data: 8-bit\n\n"); // // Init SPI0 as master. // InitSPI0(); // // Read any residual data from the SSI port. This makes sure the receive // FIFOs are empty, so we don't read any unwanted junk. This is done here // because the SPI SSI mode is full-duplex, which allows you to send and // receive at the same time. The SSIDataGetNonBlocking function returns // "true" when data was returned, and "false" when no data was returned. // The "non-blocking" function checks if there is any data in the receive // FIFO and does not "hang" if there isn't. // while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx2[0])) { } // // Initialize the data to send. // pui32DataTx2[0] = 0x00; pui32DataTx2[1] = 0x02; pui32DataTx2[2] = 0x2B; pui32DataTx2[3] = 0x0A; // // Display indication that the SSI is transmitting data. // GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0, 0x0); // // Send 4 bytes of data. // for(ui32Index = 0; ui32Index < 4; ui32Index++) { // // Send the data using the "blocking" put function. This function // will wait until there is room in the send FIFO before returning. // This allows you to assure that all the data you send makes it into // the send FIFO. // SSIDataPut(SSI0_BASE, pui32DataTx2[ui32Index]); } // // Wait until SSI0 is done transferring all the data in the transmit FIFO. // while(SSIBusy(SSI0_BASE)) { } GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, GPIO_PIN_4); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4); // // Read any residual data from the SSI port. This makes sure the receive // FIFOs are empty, so we don't read any unwanted junk. This is done here // because the SPI SSI mode is full-duplex, which allows you to send and // receive at the same time. The SSIDataGetNonBlocking function returns // "true" when data was returned, and "false" when no data was returned. // The "non-blocking" function checks if there is any data in the receive // FIFO and does not "hang" if there isn't. // while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx2[0])) { } // // Display the 8 bytes of data that were read from RX FIFO. // for(ui32Index = 0; ui32Index < 8; ui32Index++) { // // Put dummy bytes out to read bytes in // SSIDataPut(SSI0_BASE, 0xFF); // // Receive the data using the "blocking" Get function. This function // will wait until there is data in the receive FIFO before returning. // SSIDataGet(SSI0_BASE, &pui32DataRx2[ui32Index]); // // Since we are using 8-bit data, mask off the MSB. // pui32DataRx2[ui32Index] &= 0x00FF; } // // Wait until SSI0 is done transferring all the data in the transmit FIFO. // while(SSIBusy(SSI0_BASE)) { } //CS high GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0, GPIO_PIN_0); // // Return no errors // return(0); }