/**
******************************************************************************
* @brief Main program body
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "gd32f1x0.h"
#include "gd32f1x0_gpio.h"
#include "gd32f1x0_eval.h"
/* Check whether the specified pages is write protected */
if((WriteProtected_Value | (~FMC_PAGES_PROTECTED)) != 0xFFFFFFFF)
{
/* Erase all the option Bytes */
FMCStatus = FMC_OB_Erase();
/* Check if other pages write protected */
if(ProtectedPages != 0x0)
{
/* Restore other pages write protected */
FMCStatus = FMC_OB_EnableWRP(ProtectedPages);
}
/* Generate a system reset to reload the option byte */
FMC_OB_Reset();
}
#elif defined WRITE_PROTECTION_ENABLE
/* Get already write protected pages and the new specified pages to be protected */
ProtectedPages = (~WriteProtected_Value) | FMC_PAGES_PROTECTED;
/* Check whether the specified pages is write protected */
if(((~WriteProtected_Value) & FMC_PAGES_PROTECTED )!= FMC_PAGES_PROTECTED)
{
FMCStatus = FMC_OB_Erase();
/* Enable the pages write protection */
FMCStatus = FMC_OB_EnableWRP(ProtectedPages);
/* Generate a system reset to reload the option byte */
FMC_OB_Reset();
}
#endif
#ifdef FMC_PAGE_PROGRAM
/* Define the number of page to be erased */
NbrOfPage = (BANK1_WRITE_END_ADDR - BANK1_WRITE_START_ADDR) / FMC_PAGE_SIZE;