MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
Flash Controller (FLC)

Modules

 FLC_Registers
 Registers, Bit Masks and Bit Positions for the FLC Peripheral Module.
 

Macros

#define MXC_FLASH_PAGE_MASK   ~(MXC_FLASH_PAGE_SIZE - 1)
 Bit mask that can be used to find the starting address of a page in flash.
 
#define MXC_FLASH_PAGE_ADDR(page)   (MXC_FLASH_MEM_BASE + ((unsigned long)page * MXC_FLASH_PAGE_SIZE))
 Calculate the address of a page in flash from the page number.
 

Functions

int FLC_Init (const sys_cfg_t *sys_cfg)
 Initializes the Flash Controller for erase/write operations. More...
 
int FLC_Busy (void)
 Checks if Flash Controller is busy. More...
 
int FLC_MassErase (void)
 Erases the entire flash array. More...
 
int FLC_PageErase (uint32_t address)
 Erases the page of flash at the specified address. More...
 
int FLC_MultiPageErase (uint32_t start, uint32_t end)
 Erases flash pages from start to end address inclusive. More...
 
int FLC_Erase (uint32_t start, uint32_t end, uint32_t *buffer, unsigned length)
 Erase a range from start to end address. More...
 
int FLC_Write32 (uint32_t address, uint32_t data)
 Writes the specified 32-bit value to flash. More...
 
int FLC_Write128 (uint32_t address, uint32_t *data)
 Writes the specified 128-bits of data to flash. More...
 
int FLC_Write (uint32_t address, uint32_t length, uint32_t *buffer)
 Writes data to flash. More...
 
int FLC_EnableInt (uint32_t mask)
 Enable flash interrupts. More...
 
int FLC_DisableInt (uint32_t mask)
 Disable flash interrupts. More...
 
int FLC_GetFlags (void)
 Retrieve flash interrupt flags. More...
 
int FLC_ClearFlags (uint32_t mask)
 Clear flash interrupt flags. More...
 
int FLC_UnlockInfoBlock (uint32_t address)
 Unlock info block. More...
 
int FLC_LockInfoBlock (uint32_t address)
 Lock info block. More...
 

Detailed Description

Function Documentation

◆ FLC_Init()

int FLC_Init ( const sys_cfg_t *  sys_cfg)
Returns
E_NO_ERROR if successful.

◆ FLC_Busy()

int FLC_Busy ( void  )

Reading or executing from flash is not possible if flash is busy with an erase or write operation.

Returns
If non-zero, flash operation is in progress

◆ FLC_MassErase()

int FLC_MassErase ( void  )
Note
This function must be executed from RAM.
Returns
E_NO_ERROR If function is successful.

◆ FLC_PageErase()

int FLC_PageErase ( uint32_t  address)
Note
This function must be executed from RAM.
Parameters
addressAny address within the page to erase.
Returns
E_NO_ERROR If function is successful.

◆ FLC_MultiPageErase()

int FLC_MultiPageErase ( uint32_t  start,
uint32_t  end 
)
Note
This function must be executed from RAM.
Parameters
startAny address within the first page to erase.
endAny address within the last page to erase.
Returns
E_NO_ERROR If function is successful.

◆ FLC_Erase()

int FLC_Erase ( uint32_t  start,
uint32_t  end,
uint32_t *  buffer,
unsigned  length 
)

The function performs a read-modify-write of flash pages as needed.

Note
This function must be executed from RAM.
Parameters
startStarting address to erase, inclusive.
endEnding address to erase, exclusive.
bufferData buffer to restore data in beginning and ending pages.
lengthLength of given buffer.
Note
Buffer should be appropriate size to store all of the data remaining in the first and last pages. length should be greater than or equal to (start % MXC_FLASH_PAGE_SIZE) and ((MXC_FLASH_PAGE_SIZE - (end % MXC_FLASH_PAGE_SIZE)) % MXC_FLASH_PAGE_SIZE).
Returns
E_NO_ERROR If function is successful.

◆ FLC_Write32()

int FLC_Write32 ( uint32_t  address,
uint32_t  data 
)
Note
This function must be executed from RAM.
Parameters
address32-bit aligned address in flash to write.
datavalue to be written to flash.
Returns
E_NO_ERROR If function is successful.
Note
make sure to disable ICC with ICC_Disable(); before Running this function

◆ FLC_Write128()

int FLC_Write128 ( uint32_t  address,
uint32_t *  data 
)
Note
This function must be executed from RAM.
Parameters
address128-bit aligned address in flash to write.
datapointer to data to be written to flash.
Returns
E_NO_ERROR If function is successful.
Note
make sure to disable ICC with ICC_Disable(); before Running this function

◆ FLC_Write()

int FLC_Write ( uint32_t  address,
uint32_t  length,
uint32_t *  buffer 
)
Note
This function must be executed from RAM.
Parameters
addressAddress in flash to start writing from.
lengthNumber of bytes to be written.
bufferPointer to data to be written to flash.
Returns
E_NO_ERROR If function is successful.
Note
make sure to disable ICC with ICC_Disable(); before Running this function

◆ FLC_EnableInt()

int FLC_EnableInt ( uint32_t  mask)
Parameters
maskInterrupts to enable
Returns
E_NO_ERROR If function is successful.

◆ FLC_DisableInt()

int FLC_DisableInt ( uint32_t  mask)
Parameters
maskInterrupts to disable
Returns
E_NO_ERROR If function is successful.

◆ FLC_GetFlags()

int FLC_GetFlags ( void  )
Returns
Interrupt flags registers

◆ FLC_ClearFlags()

int FLC_ClearFlags ( uint32_t  mask)
Note
Provide the bit position to clear, even if the flag is write-0-to-clear
Parameters
maskFlag bit(s) to clear
Returns
E_NO_ERROR If function is successful.

◆ FLC_UnlockInfoBlock()

int FLC_UnlockInfoBlock ( uint32_t  address)
Parameters
[in]addressThe address in the info block needing written to
Returns
E_NO_ERROR If function is successful.

◆ FLC_LockInfoBlock()

int FLC_LockInfoBlock ( uint32_t  address)
Parameters
[in]addressThe address in the info block that was written to
Returns
E_NO_ERROR If function is successful.