flash.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __FLASH_H
  2. #define __FLASH_H
  3. #include "stm32f4xx.h"
  4. //FLASH起始地址
  5. #define STM32_FLASH_BASE 0x08000000
  6. //#define STM32_FLASH_BASE1 0x08020000 //STM32 FLASH的起始地址
  7. #define STM32_FLASH_BASE1 0x08060000
  8. #define STM32_FLASH_BASE2 0x08040000 //STM32 FLASH的起始地址
  9. #define STM32_FLASH_BASE3 0x08060000
  10. #define FLASH_ADDR1(x) (STM32_FLASH_BASE1+x*4)
  11. #define FLASH_ADDR2(x) (STM32_FLASH_BASE2+x*4)
  12. #define FLASH_ADDR3(x) (STM32_FLASH_BASE3+x*4)
  13. #define FLASH_INIT_FLAG 0
  14. #define TRACK_P_ADDR 1
  15. #define TRACK_I_ADDR 2
  16. #define TRACK_D_ADDR 3
  17. #define BRUSH_P_ADDR 4
  18. #define BRUSH_I_ADDR 5
  19. #define BRUSH_D_ADDR 6
  20. //STALL_Param.HMag
  21. #define STALL_HMag 7
  22. #define STALL_LMag 8
  23. #define STALL_RPM 9
  24. #define STALL_MaxCurrent 10
  25. #define STALL_Time 11
  26. #define LEFT_TRACK_DIR 12
  27. #define RIGHT_TRACK_DIR 13
  28. //FLASH 扇区的起始地址
  29. #define ADDR_FLASH_SECTOR_0 ((u32)0x08000000) //扇区0起始地址, 16 Kbytes
  30. #define ADDR_FLASH_SECTOR_1 ((u32)0x08004000) //扇区1起始地址, 16 Kbytes
  31. #define ADDR_FLASH_SECTOR_2 ((u32)0x08008000) //扇区2起始地址, 16 Kbytes
  32. #define ADDR_FLASH_SECTOR_3 ((u32)0x0800C000) //扇区3起始地址, 16 Kbytes
  33. #define ADDR_FLASH_SECTOR_4 ((u32)0x08010000) //扇区4起始地址, 64 Kbytes
  34. #define ADDR_FLASH_SECTOR_5 ((u32)0x08020000) //扇区5起始地址, 128 Kbytes
  35. #define ADDR_FLASH_SECTOR_6 ((u32)0x08040000) //扇区6起始地址, 128 Kbytes
  36. #define ADDR_FLASH_SECTOR_7 ((u32)0x08060000) //扇区7起始地址, 128 Kbytes
  37. #define ADDR_FLASH_SECTOR_8 ((u32)0x08080000) //扇区8起始地址, 128 Kbytes
  38. #define ADDR_FLASH_SECTOR_9 ((u32)0x080A0000) //扇区9起始地址, 128 Kbytes
  39. #define ADDR_FLASH_SECTOR_10 ((u32)0x080C0000) //扇区10起始地址,128 Kbytes
  40. #define ADDR_FLASH_SECTOR_11 ((u32)0x080E0000) //扇区11起始地址,128 Kbytes
  41. u32 STMFLASH_ReadWord(u32 faddr); //读出字
  42. void STMFLASH_Write(u32 WriteAddr,u32 *pBuffer,u32 NumToWrite); //从指定地址开始写入指定长度的数据
  43. void STMFLASH_Read(u32 ReadAddr,u32 *pBuffer,u32 NumToRead); //从指定地址开始读出指定长度的数据
  44. void Flash_WriteInf(void);
  45. void Flash_ReadInf(void);
  46. void Flash_ResetInf(void);
  47. float ReadFloatWord(u32 faddr);
  48. void param_init(void);
  49. //u32 Init_Flash_Data;
  50. #endif