libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
Flash peripheral API

SWM050 Flash API. More...

Collaboration diagram for Flash peripheral API:

Macros

#define IAP_WR   (void *)(0x1000AB)
 
#define IAP_E   (void *)(0x100127)
 

Functions

uint32_t flash_write (uint32_t *dest, uint32_t *src, uint8_t cnt)
 Write to the user flash. More...
 
uint32_t flash_read (uint32_t *src, uint32_t *dest, uint8_t cnt)
 Read from the user flash. More...
 
uint32_t flash_erase (void)
 Erase the user flash. More...
 

Variables

uint32_t(* iap_write_read )(uint32_t *, uint32_t *, uint8_t, uint8_t) = IAP_WR
 
uint32_t(* iap_erase )(void) = IAP_E
 

Detailed Description

SWM050 Flash API.

LGPL License Terms libopencm3 License

Author
© 2019 Caleb Szalacinski conta.nosp@m.ct@s.nosp@m.kiboy.nosp@m..net

Macro Definition Documentation

◆ IAP_E

#define IAP_E   (void *)(0x100127)

Definition at line 31 of file flash.c.

◆ IAP_WR

#define IAP_WR   (void *)(0x1000AB)

Definition at line 30 of file flash.c.

Function Documentation

◆ flash_erase()

uint32_t flash_erase ( void  )

Erase the user flash.

Erases the entire 0.5k user flash area. Must be performed only when the system clock is 18Mhz.

Returns
1 if successful, 0 if error

Definition at line 93 of file flash.c.

References iap_erase.

◆ flash_read()

uint32_t flash_read ( uint32_t *  src,
uint32_t *  dest,
uint8_t  cnt 
)

Read from the user flash.

Reads words from the 0.5k user flash area. Must be performed only when the system clock is 18Mhz.

Parameters
[in]srcSource address The memory area to copy from. From 0x00 - 0x1FC, as long as it is word-aligned
[out]destDestination address The memory area to copy to.
[in]cntNumber of words to read From 1 - 128 as long as (src + (cnt * 4)) < 0x200
Returns
1 if successful, 0 if error

Definition at line 79 of file flash.c.

References iap_write_read.

◆ flash_write()

uint32_t flash_write ( uint32_t *  dest,
uint32_t *  src,
uint8_t  cnt 
)

Write to the user flash.

Writes words to the 0.5k user flash area. Must be performed only when the system clock is 18Mhz.

Parameters
[in]destDestination address The memory area to copy to. From 0x00 - 0x1FC, as long as it is word-aligned
[in]srcSource address The memory area to copy from.
[in]cntNumber of words to write From 1-128 as long as (dest + (cnt * 4)) < 0x200
Returns
1 if successful, 0 if error

Definition at line 55 of file flash.c.

References iap_write_read.

Variable Documentation

◆ iap_erase

uint32_t(* iap_erase) (void) ( void  ) = IAP_E

Definition at line 34 of file flash.c.

Referenced by flash_erase().

◆ iap_write_read

uint32_t(* iap_write_read) (uint32_t *, uint32_t *, uint8_t, uint8_t) ( uint32_t *  ,
uint32_t *  ,
uint8_t  ,
uint8_t   
) = IAP_WR

Definition at line 33 of file flash.c.

Referenced by flash_read(), and flash_write().