APM:Libraries
Macros | Functions | Variables
flash.c File Reference
#include "flash.h"
#include "hal.h"
Include dependency graph for flash.c:

Go to the source code of this file.

Macros

#define KB(x)   ((x*1024))
 
#define STM32_FLASH_BASE   0x08000000
 
#define STM32_FLASH_SIZE   KB(BOARD_FLASH_SIZE)
 
#define STM32_FLASH_DISABLE_ISR   0
 
#define STM32_FLASH_BANK2_START   (STM32_FLASH_BASE+0x00080000)
 
#define FLASH_KEY1   0x45670123
 
#define FLASH_KEY2   0xCDEF89AB
 

Functions

static uint16_t getreg16 (unsigned int addr)
 
static void putreg16 (uint16_t val, unsigned int addr)
 
static void stm32_flash_wait_idle (void)
 
static void stm32_flash_unlock (void)
 
void stm32_flash_lock (void)
 
uint32_t stm32_flash_getpageaddr (uint32_t page)
 
uint32_t stm32_flash_getpagesize (uint32_t page)
 
uint32_t stm32_flash_getnumpages ()
 
static bool stm32_flash_ispageerased (uint32_t page)
 
bool stm32_flash_erasepage (uint32_t page)
 
int32_t stm32_flash_write (uint32_t addr, const void *buf, uint32_t count)
 

Variables

static uint32_t flash_pageaddr [STM32_FLASH_NPAGES]
 
static bool flash_pageaddr_initialised
 

Macro Definition Documentation

◆ FLASH_KEY1

#define FLASH_KEY1   0x45670123

Definition at line 101 of file flash.c.

Referenced by stm32_flash_unlock().

◆ FLASH_KEY2

#define FLASH_KEY2   0xCDEF89AB

Definition at line 102 of file flash.c.

Referenced by stm32_flash_unlock().

◆ KB

#define KB (   x)    ((x*1024))

Definition at line 66 of file flash.c.

◆ STM32_FLASH_BANK2_START

#define STM32_FLASH_BANK2_START   (STM32_FLASH_BASE+0x00080000)

Definition at line 75 of file flash.c.

◆ STM32_FLASH_BASE

#define STM32_FLASH_BASE   0x08000000

Definition at line 68 of file flash.c.

Referenced by stm32_flash_getpageaddr(), and stm32_flash_write().

◆ STM32_FLASH_DISABLE_ISR

#define STM32_FLASH_DISABLE_ISR   0

Definition at line 72 of file flash.c.

◆ STM32_FLASH_SIZE

#define STM32_FLASH_SIZE   KB(BOARD_FLASH_SIZE)

Definition at line 69 of file flash.c.

Referenced by stm32_flash_write().

Function Documentation

◆ getreg16()

static uint16_t getreg16 ( unsigned int  addr)
inlinestatic

Definition at line 107 of file flash.c.

Referenced by stm32_flash_write().

Here is the caller graph for this function:

◆ putreg16()

static void putreg16 ( uint16_t  val,
unsigned int  addr 
)
inlinestatic

Definition at line 115 of file flash.c.

Referenced by stm32_flash_write().

Here is the caller graph for this function:

◆ stm32_flash_erasepage()

bool stm32_flash_erasepage ( uint32_t  page)

Definition at line 215 of file flash.c.

Referenced by ChibiOS::Storage::_flash_erase_sector().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stm32_flash_getnumpages()

uint32_t stm32_flash_getnumpages ( void  )

Definition at line 188 of file flash.c.

◆ stm32_flash_getpageaddr()

uint32_t stm32_flash_getpageaddr ( uint32_t  page)

Definition at line 157 of file flash.c.

Referenced by ChibiOS::Storage::_flash_read_data(), ChibiOS::Storage::_flash_write_data(), and stm32_flash_ispageerased().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stm32_flash_getpagesize()

uint32_t stm32_flash_getpagesize ( uint32_t  page)

Definition at line 180 of file flash.c.

Referenced by stm32_flash_getpageaddr(), and stm32_flash_ispageerased().

Here is the caller graph for this function:

◆ stm32_flash_ispageerased()

static bool stm32_flash_ispageerased ( uint32_t  page)
static

Definition at line 193 of file flash.c.

Referenced by stm32_flash_erasepage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stm32_flash_lock()

void stm32_flash_lock ( void  )

Definition at line 141 of file flash.c.

Referenced by stm32_flash_erasepage(), and stm32_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stm32_flash_unlock()

static void stm32_flash_unlock ( void  )
static

Definition at line 127 of file flash.c.

Referenced by stm32_flash_erasepage(), and stm32_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stm32_flash_wait_idle()

static void stm32_flash_wait_idle ( void  )
static

Definition at line 120 of file flash.c.

Referenced by stm32_flash_erasepage(), stm32_flash_lock(), stm32_flash_unlock(), and stm32_flash_write().

Here is the caller graph for this function:

◆ stm32_flash_write()

int32_t stm32_flash_write ( uint32_t  addr,
const void *  buf,
uint32_t  count 
)

Definition at line 259 of file flash.c.

Referenced by ChibiOS::Storage::_flash_write_data().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ flash_pageaddr

uint32_t flash_pageaddr[STM32_FLASH_NPAGES]
static

Definition at line 97 of file flash.c.

Referenced by stm32_flash_getpageaddr().

◆ flash_pageaddr_initialised

bool flash_pageaddr_initialised
static

Definition at line 98 of file flash.c.

Referenced by stm32_flash_getpageaddr().