EFM32 Gecko Software Documentation
efm32g-doc-4.2.1
|
Flash controller (MSC) peripheral API
. More...
Data Structures | |
struct | MSC_ExecConfig_TypeDef |
Macros | |
#define | MSC_PROGRAM_TIMEOUT 10000000ul |
The timeout used while waiting for the flash to become ready after a write. This number indicates the number of iterations to perform before issuing a timeout. More... | |
#define | EM_MSC_RUN_FROM_FLASH |
By compiling with the define EM_MSC_RUN_FROM_FLASH the Flash controller (MSC) peripheral will remain in and execute from flash. This is useful for targets that don't want to allocate RAM space to hold the flash functions. Without this define the MSC peripheral functions will be copied into and run out of RAM. More... | |
#define | MSC_EXECCONFIG_DEFAULT |
#define | MSC_FUNC_PREFIX |
#define | MSC_FUNC_POSTFIX |
Enumerations | |
enum | MSC_Status_TypeDef { mscReturnOk = 0, mscReturnInvalidAddr = -1, mscReturnLocked = -2, mscReturnTimeOut = -3, mscReturnUnaligned = -4 } |
Functions | |
void | MSC_Init (void) |
Enables the flash controller for writing. More... | |
void | MSC_Deinit (void) |
Disables the flash controller for writing. | |
__STATIC_INLINE void | MSC_IntClear (uint32_t flags) |
Clear one or more pending MSC interrupts. More... | |
__STATIC_INLINE void | MSC_IntDisable (uint32_t flags) |
Disable one or more MSC interrupts. More... | |
__STATIC_INLINE void | MSC_IntEnable (uint32_t flags) |
Enable one or more MSC interrupts. More... | |
__STATIC_INLINE uint32_t | MSC_IntGet (void) |
Get pending MSC interrupt flags. More... | |
__STATIC_INLINE uint32_t | MSC_IntGetEnabled (void) |
Get enabled and pending MSC interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More... | |
__STATIC_INLINE void | MSC_IntSet (uint32_t flags) |
Set one or more pending MSC interrupts from SW. More... | |
MSC_FUNC_PREFIX MSC_Status_TypeDef | MSC_WriteWord (uint32_t *address, void const *data, uint32_t numBytes) |
Writes data to flash memory. This function is interrupt safe, but slower than MSC_WriteWordFast(), which writes to flash with interrupts disabled. Write data must be aligned to words and contain a number of bytes that is divisable by four. More... | |
MSC_FUNC_PREFIX MSC_Status_TypeDef | MSC_ErasePage (uint32_t *startAddress) |
Erases a page in flash memory. More... | |
Flash controller (MSC) Peripheral API
.
#define MSC_PROGRAM_TIMEOUT 10000000ul |
Definition at line 72 of file em_msc.h.
Referenced by MSC_ErasePage().
#define EM_MSC_RUN_FROM_FLASH |
#define MSC_EXECCONFIG_DEFAULT |
enum MSC_Status_TypeDef |
Return codes for writing/erasing the flash
void MSC_Init | ( | void | ) |
Definition at line 101 of file em_msc.c.
References CMU_ClockFreqGet(), cmuClock_AUX, MSC, MSC_UNLOCK_CODE, MSC_WRITECTRL_WREN, and SystemCoreClockGet().
Referenced by BSP_TraceProfilerEnable(), and NVMHAL_Init().
__STATIC_INLINE void MSC_IntClear | ( | uint32_t | flags | ) |
__STATIC_INLINE void MSC_IntDisable | ( | uint32_t | flags | ) |
__STATIC_INLINE void MSC_IntEnable | ( | uint32_t | flags | ) |
[in] | flags | MSC interrupt sources to enable. Use a bitwise logic OR combination of valid interrupt flags for the MSC module (MSC_IF_nnn). |
Definition at line 196 of file em_msc.h.
References MSC.
__STATIC_INLINE uint32_t MSC_IntGet | ( | void | ) |
__STATIC_INLINE uint32_t MSC_IntGetEnabled | ( | void | ) |
__STATIC_INLINE void MSC_IntSet | ( | uint32_t | flags | ) |
MSC_Status_TypeDef MSC_WriteWord | ( | uint32_t * | address, |
void const * | data, | ||
uint32_t | numBytes | ||
) |
It is recommended to run this code from RAM. On the Gecko family, it is required to run this function from RAM.
For IAR, Rowley, SimplicityStudio, Atollic and armgcc this will be achieved automatically by using attributes in the function proctype. For Keil uVision you must define a section called "ram_code" and place this manually in your project's scatter file.
This function requires a ystem core clock at 1MHz or higher.
[in] | address | Pointer to the flash word to write to. Must be aligned to words. |
[in] | data | Data to write to flash. |
[in] | numBytes | Number of bytes to write from flash. NB: Must be divisable by four. |
* flashReturnOk - Operation completed successfully. * flashReturnInvalidAddr - Operation tried to erase a non-flash area. * flashReturnLocked - Operation tried to erase a locked area of the flash. * flashReturnTimeOut - Operation timed out waiting for flash operation * to complete. Or the MSC timed out waiting for the software to write * the next word into the DWORD register. *
Definition at line 738 of file em_msc.c.
Referenced by BSP_TraceProfilerEnable(), and NVMHAL_Write().
MSC_Status_TypeDef MSC_ErasePage | ( | uint32_t * | startAddress | ) |
For IAR, Rowley, SimplicityStudio, Atollic and armgcc this will be achieved automatically by using attributes in the function proctype. For Keil uVision you must define a section called "ram_code" and place this manually in your project's scatter file.
[in] | startAddress | Pointer to the flash page to erase. Must be aligned to beginning of page boundary. |
* mscReturnOk - Operation completed successfully. * mscReturnInvalidAddr - Operation tried to erase a non-flash area. * mscReturnLocked - Operation tried to erase a locked area of the flash. * mscReturnTimeOut - Operation timed out waiting for flash operation * to complete. *
Definition at line 637 of file em_msc.c.
References FLASH_PAGE_SIZE, MSC, MSC_PROGRAM_TIMEOUT, MSC_STATUS_BUSY, MSC_STATUS_INVADDR, MSC_STATUS_LOCKED, MSC_WRITECMD_ERASEPAGE, MSC_WRITECMD_LADDRIM, MSC_WRITECTRL_WREN, mscReturnInvalidAddr, mscReturnLocked, mscReturnOk, and mscReturnTimeOut.
Referenced by BSP_TraceProfilerEnable(), and NVMHAL_PageErase().