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
15#include "phal_F4/phal_F4.h"
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#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbyte */
32#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbyte */
33#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbyte */
34#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbyte */
35#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbyte */
36#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbyte */
37#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbyte */
38#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbyte */
39#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbyte */
40#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbyte */
41#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbyte */
42#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbyte */
43
44#define ADDR_FLASH_SECTOR_12 ((uint32_t)0x08100000) /* 128 KiB */
45#define ADDR_FLASH_SECTOR_13 ((uint32_t)0x08120000) /* 128 KiB */
46#define ADDR_FLASH_SECTOR_14 ((uint32_t)0x08140000) /* 128 KiB */
47#define ADDR_FLASH_SECTOR_15 ((uint32_t)0x08160000) /* 128 KiB */
48
49#define USER_FLASH_END_ADDRESS ((uint32_t)0x0817FFFF) /* Last usable flash address */
50#define MAX_FLASH_SECTOR (16 - 1)
51
52uint32_t PHAL_flashReadU32(uint32_t addr);
53
54uint8_t PHAL_flashWriteU32(uint32_t address, uint32_t value);
55uint8_t PHAL_flashWriteU32_Buffered(uint32_t Address, uint32_t* data, uint32_t count);
56
57uint8_t PHAL_flashWriteU64(uint32_t address, uint64_t data);
58uint8_t PHAL_flashErasePage(uint8_t page);
59uint8_t PHAL_flashErase(uint32_t* addr, uint32_t words);
60
61#endif
uint8_t PHAL_flashWriteU32_Buffered(uint32_t Address, uint32_t *data, uint32_t count)
Definition flash.c:152
uint32_t PHAL_flashReadU32(uint32_t addr)
Definition flash.c:77
uint8_t PHAL_flashWriteU64(uint32_t address, uint64_t data)
Definition flash.c:143
uint8_t PHAL_flashWriteU32(uint32_t address, uint32_t value)
Definition flash.c:97
@ 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:226
uint8_t PHAL_flashErasePage(uint8_t page)
Definition flash.c:189