Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
FlashWriter.h
00001 #ifndef __FLASHWRITER_H 00002 #define __FLASHWRITER_H 00003 00004 #include "stm32f4xx_flash.h" 00005 00006 /* Base address of the Flash sectors */ 00007 #define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */ 00008 #define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */ 00009 #define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */ 00010 #define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */ 00011 #define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */ 00012 #define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */ 00013 #define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */ 00014 #define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */ 00015 00016 static uint32_t __SECTOR_ADDRS[] = {ADDR_FLASH_SECTOR_0, ADDR_FLASH_SECTOR_1, ADDR_FLASH_SECTOR_2, ADDR_FLASH_SECTOR_3, 00017 ADDR_FLASH_SECTOR_4, ADDR_FLASH_SECTOR_5, ADDR_FLASH_SECTOR_6, ADDR_FLASH_SECTOR_7}; 00018 static uint32_t __SECTORS[] = {FLASH_Sector_0, FLASH_Sector_1, FLASH_Sector_2, FLASH_Sector_3, 00019 FLASH_Sector_4, FLASH_Sector_6, FLASH_Sector_6, FLASH_Sector_7}; 00020 class FlashWriter { 00021 public: 00022 FlashWriter(int sector); 00023 void open(); 00024 bool ready(); 00025 void write(uint32_t index, int x); 00026 void write(uint32_t index, unsigned int x); 00027 void write(uint32_t index, float x); 00028 void close(); 00029 private: 00030 uint32_t __base; 00031 uint32_t __sector; 00032 bool __ready; 00033 }; 00034 00035 int flashReadInt(uint32_t sector, uint32_t index); 00036 uint32_t flashReadUint(uint32_t sector, uint32_t index); 00037 float flashReadFloat(uint32_t sector, uint32_t index); 00038 00039 #endif
Generated on Tue Jul 12 2022 21:21:55 by
