#include "at32f403a_407.h"
#include "extended_sram.h"
#include "model_cfg.h"


//
void extend_SRAM(void)
{
    // check if RAM has been set to 224K, if not, change EOPB0
    if(((USD->eopb0)&0xFF)!=0xFE)
    {
        // Unlock Option Bytes Program Erase controller
        flash_unlock();
        
        // erase user system data bytes 
        flash_user_system_data_erase();

        // Change SRAM size to 224KB
        flash_user_system_data_program((uint32_t)&USD->eopb0, 0xFE);
        nvic_system_reset();
    }
}