Example #1
0
/*
** This function will call the necessary McSPI APIs which will configure the
** McSPI controller.
*/
static void McSPISetUp(void)
{
    /* Reset the McSPI instance.*/
    McSPIReset(SOC_SPI_0_REGS);

    /* Enable chip select pin.*/
    McSPICSEnable(SOC_SPI_0_REGS);

    /* Enable master mode of operation.*/
    McSPIMasterModeEnable(SOC_SPI_0_REGS);

    /* Perform the necessary configuration for master mode.*/
    McSPIMasterModeConfig(SOC_SPI_0_REGS, MCSPI_SINGLE_CH, MCSPI_TX_RX_MODE,
                          MCSPI_DATA_LINE_COMM_MODE_1, MCSPI_CH_NUM);

    /* Configure the McSPI output frequency. */ 
    McSPIClkConfig(SOC_SPI_0_REGS, MCSPI_IN_CLK, MCSPI_OUT_FREQ, 
                   MCSPI_CH_NUM, MCSPI_CLK_MODE_0);

    /* Configure the word length.*/
    McSPIWordLengthSet(SOC_SPI_0_REGS, MCSPI_WORD_LENGTH(8), MCSPI_CH_NUM);

    /* Set polarity of SPIEN to low.*/
    McSPICSPolarityConfig(SOC_SPI_0_REGS, MCSPI_CS_POL_LOW, MCSPI_CH_NUM);

    /* Enable the Tx FIFO of McSPI.*/
    McSPITxFIFOConfig(SOC_SPI_0_REGS, MCSPI_TX_FIFO_ENABLE, MCSPI_CH_NUM);

    /* Enable the Rx FIFO of McSPI.*/
    McSPIRxFIFOConfig(SOC_SPI_0_REGS, MCSPI_RX_FIFO_ENABLE, MCSPI_CH_NUM);
}
Example #2
0
/*
** This function will call the necessary McSPI APIs which will configure the
** McSPI controller.
*/
static void McSPISetUp(Mcspi_t *McspiStruct)
{

	/* Reset the McSPI instance.*/
    McSPIReset(McspiStruct->BaseAddr);

    /* Enable chip select pin.*/
    McSPICSEnable(McspiStruct->BaseAddr);

    /* Enable master mode of operation.*/
    McSPIMasterModeEnable(McspiStruct->BaseAddr);

    /* Perform the necessary configuration for master mode.*/
    McSPIMasterModeConfig(McspiStruct->BaseAddr, MCSPI_SINGLE_CH, MCSPI_TX_RX_MODE, MCSPI_DATA_LINE_COMM_MODE_1, McspiStruct->Channel);

    /* Configure the McSPI bus clock depending on clock mode. */
    McSPIClkConfig(McspiStruct->BaseAddr, MCSPI_IN_CLK, McspiStruct->BaudRate, McspiStruct->Channel, MCSPI_CLK_MODE_0);

    /* Configure the word length.*/
    McSPIWordLengthSet(McspiStruct->BaseAddr, MCSPI_WORD_LENGTH(8), McspiStruct->Channel);

    /* Set polarity of SPIEN to low.*/
    McSPICSPolarityConfig(McspiStruct->BaseAddr, MCSPI_CS_POL_LOW, McspiStruct->Channel);

    /* Enable the transmitter FIFO of McSPI peripheral.*/
    McSPITxFIFOConfig(McspiStruct->BaseAddr, MCSPI_TX_FIFO_ENABLE, McspiStruct->Channel);

    /* Enable the receiver FIFO of McSPI peripheral.*/
    McSPIRxFIFOConfig(McspiStruct->BaseAddr, MCSPI_RX_FIFO_ENABLE, McspiStruct->Channel);
}
Example #3
0
/*
** This function will call the necessary McSPI APIs which will configure the 
** McSPI controller. 
*/
static void McSPISetUp(void)
{

    /* Reset the McSPI instance.*/
    McSPIReset(SOC_SPI_0_REGS);

    /* Enable chip select pin.*/
    McSPICSEnable(SOC_SPI_0_REGS);

    /* Enable master mode of operation.*/
    McSPIMasterModeEnable(SOC_SPI_0_REGS);

    /* Perform the necessary configuration for master mode.*/
    McSPIMasterModeConfig(SOC_SPI_0_REGS, MCSPI_SINGLE_CH, 
                          MCSPI_TX_RX_MODE, MCSPI_DATA_LINE_COMM_MODE_1,
                          chNum);

    /* Configure the McSPI bus clock depending on clock mode. */
    McSPIClkConfig(SOC_SPI_0_REGS, MCSPI_IN_CLK, MCSPI_OUT_FREQ, chNum, 
                   MCSPI_CLK_MODE_0);

    /* Configure the word length.*/
    McSPIWordLengthSet(SOC_SPI_0_REGS, MCSPI_WORD_LENGTH(8), chNum);

    /* Set polarity of SPIEN to low.*/
    McSPICSPolarityConfig(SOC_SPI_0_REGS, MCSPI_CS_POL_LOW, chNum);

    /* Enable the transmitter FIFO of McSPI peripheral.*/
    McSPITxFIFOConfig(SOC_SPI_0_REGS, MCSPI_TX_FIFO_ENABLE, chNum);

    /* Enable the receiver FIFO of McSPI peripheral.*/
    McSPIRxFIFOConfig(SOC_SPI_0_REGS, MCSPI_RX_FIFO_ENABLE, chNum);
}