Ejemplo n.º 1
0
/*
**  This function will send the Write Enable command to the Flash device.
*/
static void WriteEnable(void)
{
    unsigned int dummy = 0;
    unsigned short length = 0;

    txBuffer[0] = FLASH_WRITE_ENABLE;

    length = 1;

    /* Configure the write enable parameters for Edma transfer.*/
    McSpiTxEdmaParamSet(MCSPI_TX_EVENT, MCSPI_TX_EVENT, txBuffer,
                        length);

    /* Configure the write enable parameters for Edma receive.*/
    McSpiRxEdmaParamSet(MCSPI_RX_EVENT, MCSPI_RX_EVENT, (unsigned char *)dummy,
                        length, FALSE);

    /* Register the call-back function for Tx/Rx events of McSPI.*/
    cb_Fxn[MCSPI_TX_EVENT] = &CallBack;
    cb_Fxn[MCSPI_RX_EVENT] = &CallBack;

    McSPITransfer(length);

    /* Check whether write enable command is properly latched on to flash */
    IsWriteEnabled();
}
Ejemplo n.º 2
0
static void WriteEnable(void)
{
    unsigned int buffLength = 1;
    volatile char writeEn;
    volatile char dummy;

    writeEn = SPI_FLASH_WRITE_EN;

    /* Configure the PaRAM registers in EDMA for Transmission. */
    SpiTxEdmaParamSet(EDMA3_CHA_SPI1_TX, EDMA3_CHA_SPI1_TX, &writeEn, buffLength);

    /* Registering Callback Function for Transmission. */
    cb_Fxn[EDMA3_CHA_SPI1_TX] = &callback; 

    /* Configure the PaRAM registers in EDMA for Reception. */
    SpiRxEdmaParamSet(EDMA3_CHA_SPI1_RX, EDMA3_CHA_SPI1_RX, &dummy, buffLength, FALSE);

    /* Registering Callback Function for Reception. */
    cb_Fxn[EDMA3_CHA_SPI1_RX] = &callback;

    /* Assert the CSHOLD line corresponding to the SPI Flash. */
    CSHoldAssert();

    /* Enable SPI controller to generate DMA events */
    SPIIntEnable(SOC_SPI_1_REGS, SPI_DMA_REQUEST_ENA_INT);

    /* Wait until both the flags are set to 1 in the callback function. */
    while((0 == flagTx) || (0 == flagRx));

    flagTx = 0;
    flagRx = 0;

    /* Deassert the CSHOLD line corresponding to the SPI Flash. */
    CSHoldDeassert();

    /* Wait until SPI Flash is enabled for writing. */
    while (IsWriteEnabled() != TRUE);
}