PER Firmware
Loading...
Searching...
No Matches
flash.h
Go to the documentation of this file.
1
12#ifndef _PHAL_FLASH_H_
13#define _PHAL_FLASH_H_
14
16
17enum {
22};
23
24// Flash magic numbers obtained from family reference manual
25#define FLASH_KEY_1 0x45670123
26#define FLASH_KEY_2 0xCDEF89AB
27
28#define PHAL_FLASH_TIMEOUT 500000U
29
30/* Base address of the Flash sectors */
31#ifdef STM32F407xx
32#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbyte */
33#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbyte */
34#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbyte */
35#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbyte */
36#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbyte */
37#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbyte */
38#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbyte */
39#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbyte */
40#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbyte */
41#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbyte */
42#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbyte */
43#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbyte */
44
45#define USER_FLASH_END_ADDRESS ((uint32_t)0x080FFFFF) /* Last usable flash address */
46#define MAX_FLASH_SECTOR (12 - 1)
47#endif
48
49uint32_t PHAL_flashReadU32(uint32_t addr);
50
51uint8_t PHAL_flashWriteU32(uint32_t address, uint32_t value);
52uint8_t PHAL_flashWriteU32_Buffered(uint32_t Address, uint32_t* data, uint32_t count);
53
54uint8_t PHAL_flashWriteU64(uint32_t address, uint64_t data);
55uint8_t PHAL_flashErasePage(uint8_t page);
56uint8_t PHAL_flashErase(uint32_t* addr, uint32_t words);
57
58#endif
uint8_t PHAL_flashWriteU32_Buffered(uint32_t Address, uint32_t *data, uint32_t count)
Definition flash.c:148
uint32_t PHAL_flashReadU32(uint32_t addr)
Definition flash.c:73
uint8_t PHAL_flashWriteU64(uint32_t address, uint64_t data)
Definition flash.c:139
uint8_t PHAL_flashWriteU32(uint32_t address, uint32_t value)
Definition flash.c:93
@ FLASH_FAIL
Definition flash.h:19
@ FLASH_TIMEOUT
Definition flash.h:21
@ FLASH_OK
Definition flash.h:18
@ FLASH_ADDR_NOT_CLEARED
Definition flash.h:20
uint8_t PHAL_flashErase(uint32_t *addr, uint32_t words)
Definition flash.c:222
uint8_t PHAL_flashErasePage(uint8_t page)
Definition flash.c:185