robot

Dependencies:   FastPWM3 mbed

Committer:
bwang
Date:
Tue Nov 13 17:46:23 2018 +0000
Revision:
252:38644631ed97
Parent:
181:d3510c8beab6
11/13/2018 12:45 - hitting <return> on empty line prints "\r>", so that hitting enter after intially connecting to the controller generates a prompt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 181:d3510c8beab6 1 #ifndef __FLASHWRITER_H
bwang 181:d3510c8beab6 2 #define __FLASHWRITER_H
bwang 181:d3510c8beab6 3
bwang 181:d3510c8beab6 4 #include "stm32f4xx_flash.h"
bwang 181:d3510c8beab6 5
bwang 181:d3510c8beab6 6 /* Base address of the Flash sectors */
bwang 181:d3510c8beab6 7 #define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
bwang 181:d3510c8beab6 8 #define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
bwang 181:d3510c8beab6 9 #define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
bwang 181:d3510c8beab6 10 #define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
bwang 181:d3510c8beab6 11 #define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
bwang 181:d3510c8beab6 12 #define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
bwang 181:d3510c8beab6 13 #define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
bwang 181:d3510c8beab6 14 #define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
bwang 181:d3510c8beab6 15
bwang 181:d3510c8beab6 16 static uint32_t __SECTOR_ADDRS[] = {ADDR_FLASH_SECTOR_0, ADDR_FLASH_SECTOR_1, ADDR_FLASH_SECTOR_2, ADDR_FLASH_SECTOR_3,
bwang 181:d3510c8beab6 17 ADDR_FLASH_SECTOR_4, ADDR_FLASH_SECTOR_5, ADDR_FLASH_SECTOR_6, ADDR_FLASH_SECTOR_7};
bwang 181:d3510c8beab6 18 static uint32_t __SECTORS[] = {FLASH_Sector_0, FLASH_Sector_1, FLASH_Sector_2, FLASH_Sector_3,
bwang 181:d3510c8beab6 19 FLASH_Sector_4, FLASH_Sector_6, FLASH_Sector_6, FLASH_Sector_7};
bwang 181:d3510c8beab6 20 class FlashWriter {
bwang 181:d3510c8beab6 21 public:
bwang 181:d3510c8beab6 22 FlashWriter(int sector);
bwang 181:d3510c8beab6 23 void open();
bwang 181:d3510c8beab6 24 bool ready();
bwang 181:d3510c8beab6 25 void write(uint32_t index, int x);
bwang 181:d3510c8beab6 26 void write(uint32_t index, unsigned int x);
bwang 181:d3510c8beab6 27 void write(uint32_t index, float x);
bwang 181:d3510c8beab6 28 void close();
bwang 181:d3510c8beab6 29 private:
bwang 181:d3510c8beab6 30 uint32_t __base;
bwang 181:d3510c8beab6 31 uint32_t __sector;
bwang 181:d3510c8beab6 32 bool __ready;
bwang 181:d3510c8beab6 33 };
bwang 181:d3510c8beab6 34
bwang 181:d3510c8beab6 35 int flashReadInt(uint32_t sector, uint32_t index);
bwang 181:d3510c8beab6 36 uint32_t flashReadUint(uint32_t sector, uint32_t index);
bwang 181:d3510c8beab6 37 float flashReadFloat(uint32_t sector, uint32_t index);
bwang 181:d3510c8beab6 38
bwang 181:d3510c8beab6 39 #endif