/******************************************************************************
** INTERNAL VARIABLE DEFINITIONS
*******************************************************************************/
volatile unsigned int flag = 1;
unsigned int tx_len;
unsigned int rx_len;
unsigned char vrf_data[260];
unsigned char tx_data[260];
volatile unsigned char rx_data[260];
unsigned char *p_tx;
volatile unsigned char *p_rx;
volatile unsigned char StatusResponseMessage[16];
/******************************************************************************
** INTERNAL FUNCTION DEFINITIONS
*******************************************************************************/
int main(void)
{
/* Waking up the SPI1 instance. */
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_SPI0, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);
/* Initializing the UART instance for serial communication. */
UARTStdioInit();
UARTPuts("Welcome to StarterWare SPI application.\r\n\r\n", -1);
UARTPuts("Here the SPI controller on the SoC communicates with", -1);
UARTPuts(" the Fingerprint Sensor present on the LCDK.\r\n\r\n", -1);
/* Performing the Pin Multiplexing for SPI0. */
SPIPinMuxSetup(0);
/*
** Using the Chip Select(CS) 0 pin of SPI0 to communicate with the Fingerprint Sensor.
*/
SPI0CSPinMuxSetup(0);
/* Enable use of SPI1 interrupts. */
SetUpInt();
/* Configuring and enabling the SPI1 instance. */
SetUpSPI();
/* Issue a Reset to the Fingerprint Sensor */
// ResetCommand();
// UARTPuts("Attempting to Reset the Fingerprint Sensor.\r\n\r\n", -1);
//
// /* Read the Status of the Fingerprint Sensor */
// GetStatusCommand();
// if(StatusResponseMessage[11] == 0x48)
// {
// UARTPuts("Fingerprint Sensor Successfully Reset.\r\n\r\n", -1);
// }
// else
// {
// UARTPuts("ERROR: Fingerprint Sensor Reset Attempt Unsuccessful.\r\n\r\n", -1);
// }
/* Configures SPI Data Format Register */
SPIConfigDataFmtReg(SPI_DATA_FORMAT0);
/* Selects the SPI Data format register to used and Sets CSHOLD
* to assert CS pin(line)
*/
SPIDat1Config(SOC_SPI_0_REGS, (SPI_CSHOLD | SPI_DATA_FORMAT0), cs);
/* map interrupts to interrupt line INT1 */
SPIIntLevelSet(SOC_SPI_0_REGS, SPI_RECV_INTLVL | SPI_TRANSMIT_INTLVL);
/* Enable SPI communication */
SPIEnable(SOC_SPI_0_REGS);
}
//** Configures Data Format register of SPI
static void SPIConfigDataFmtReg(unsigned int dataFormat)
{
/* Configures the polarity and phase of SPI clock */
SPIConfigClkFormat(SOC_SPI_0_REGS,(SPI_CLK_POL_HIGH | SPI_CLK_INPHASE),dataFormat);//SPI_CLK_POL_HIGH SPI_CLK_OUTOFPHASE
//SPIConfigClkFormat(SOC_SPI_0_REGS,(SPI_CLK_POL_LOW | SPI_CLK_INPHASE),dataFormat);
/* Configures SPI to transmit MSB bit First during data transfer */
SPIShiftMsbFirst(SOC_SPI_0_REGS, dataFormat);
/* Sets the Charcter length */
SPICharLengthSet(SOC_SPI_0_REGS, CHAR_LENGTH, dataFormat);
}