/******************************************************************************* * Function Name : MAL_Init * Description : Initializes the Media on the STM32 * Input : None * Output : None * Return : None *******************************************************************************/ uint16_t MAL_Init(void) { FLASH_If_Init(); /* Internal Flash */ #if defined(USE_STM3210B_EVAL) || defined(USE_STM3210E_EVAL) SPI_If_Init(); /* SPI Flash */ #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ #ifdef USE_STM3210E_EVAL NOR_If_Init(); /* NOR Flash */ FSMC_NOR_ReadID(&NOR_ID); FSMC_NOR_ReturnToReadMode(); /* select the alternate descriptor following NOR ID */ if ((NOR_ID.Manufacturer_Code == 0x01)&&(NOR_ID.Device_Code2 == NOR_S29GL128)) { DFU_String_Descriptor[6].Descriptor = DFU_StringInterface2_3; } /* select the alternate descriptor following NOR ID */ if ((NOR_ID.Manufacturer_Code == 0x20)&&(NOR_ID.Device_Code2 == NOR_M29W128G)) { DFU_String_Descriptor[6].Descriptor = DFU_StringInterface2_2; } #endif /* USE_STM3210E_EVAL */ return MAL_OK; }
/** * @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) { } }