Exemple #1
0
/*******************************************************************************
* Function Name  : NOR_If_Erase
* Description    : Erase sector
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t NOR_If_Erase(uint32_t Address)
{
	/* Erase the destination memory */
	FSMC_NOR_EraseBlock(Address & 0x00FFFFFF);

	return MAL_OK;
}
Exemple #2
0
/**
  * @brief   Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
    /* System Clocks Configuration */
    RCC_Configuration();

    /* Initialize Leds mounted on STM3210X-EVAL board */
    STM_EVAL_LEDInit(LED1);
    STM_EVAL_LEDInit(LED2);

    /* Write/read to/from FSMC SRAM memory  *************************************/
    /* Enable the FSMC Clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

    /* Configure FSMC Bank1 NOR/SRAM2 */
    FSMC_NOR_Init();

    /* Read NOR memory ID */
    FSMC_NOR_ReadID(&NOR_ID);

    FSMC_NOR_ReturnToReadMode();

    /* Erase the NOR memory block to write on */
    FSMC_NOR_EraseBlock(WRITE_READ_ADDR);

    /* Write data to FSMC NOR memory */
    /* Fill the buffer to send */
    Fill_Buffer(TxBuffer, BUFFER_SIZE, 0x3210);
    FSMC_NOR_WriteBuffer(TxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);

    /* Read data from FSMC NOR memory */
    FSMC_NOR_ReadBuffer(RxBuffer, WRITE_READ_ADDR, BUFFER_SIZE);

    /* Read back NOR memory and check content correctness */
    for (Index = 0x00; (Index < BUFFER_SIZE) && (WriteReadStatus == 0); Index++)
    {
        if (RxBuffer[Index] != TxBuffer[Index])
        {
            WriteReadStatus = Index + 1;
        }
    }

    if (WriteReadStatus == 0)
    {
        /* OK */
        /* Turn on LED1 */
        STM_EVAL_LEDOn(LED1);
    }
    else
    {
        /* KO */
        /* Turn on LED2 */
        STM_EVAL_LEDOn(LED2);
    }

    while (1)
    {
    }
}