/** @file flash.c * Module handling flash memory interface registers. * * The module provides functions to configure the flash and perform read and * writes */ //--includes-------------------------------------------------------------------- #include "flash.h" #include "flash_regs.h" //--local definitions----------------------------------------------------------- //--local variables------------------------------------------------------------- static volatile struct FLASH* regs = (struct FLASH*)FLASH_BASE_ADDRESS; //--public functions------------------------------------------------------------ void flash_configure(enum FlashPreset preset) { //restore default configuration regs->ACR.word &= !0x3f; regs->ACR.word |= 0x30; //apply new configuration switch (preset) { case FLASH_PRESET_LOW_CLOCK_SPEED: regs->ACR.HLFCYA = 0x1; //half cycle for power saving break; case FLASH_PRESET_MEDIUM_CLOCK_SPEED: regs->ACR.LATENCY = 0x1; break; case FLASH_PRESET_HIGH_CLOCK_SPEED: regs->ACR.LATENCY = 0x2; break; default: break; } } //--local functions-------------------------------------------------------------