soft_flash.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef __SOFT_FLASH_H
  2. #define __SOFT_FLASH_H
  3. #include "pilot_navigation.h"
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #define TOTAL_PAGE 4096
  7. //前10页用来存储用户配置。
  8. #define pidinf_addr (512 * 16)
  9. #define verinf_addr (512 * 24)
  10. #define confinf_addr (512 * 32)
  11. //===IAP地址不能更改,更改后BOOTLOADER也要改
  12. #define IAP_ADDR (512 * 5)
  13. #define caminf_addr (512 * 40)
  14. #define parinf_addr (512 * 48)
  15. //第11页,一整页用来存储数据的结束地址。一整页写入比字节写入要节约一半时间
  16. // #define DATA_END_ADDR (512 * 11)
  17. // #define DATA_END_PAGE (11)
  18. //第12页,一整页用来存储POS总数。一整页写入比字节写入要节约一半时间
  19. #define POS_TOTAL_ADDR (512 * 56)
  20. #define POS_TOTAL_PAGE (12)
  21. // 禁飞区存储地址
  22. #define NO_FLY_ZONE_ADDR (512 * 64)
  23. // 每条禁飞区占用的长度为 2字节是否有效标志 + 1 字节总条数 +
  24. // 1 字节当前条顶点个数 + (8 × 3 × 4) 字节数据 = 100 字节
  25. #define SIZE_OF_ONE_NO_FLY_ZONE (2 + 1 + 1 + (8 * 3 * 4))
  26. // 第一点调整的高度
  27. #define FPALTCHANGE_ADDR (512 * 80)
  28. #define BREAKPOINT_ADDR (512 * 88)
  29. //第一个航点存储在 WAYPOINT_ADDR+sizeof(waypoint)中,预留100页用来存储航点
  30. //按照最多1500个航点,sizeof(waypoint) =
  31. // 28,每页512字节,总共需要83页的FLASH空间。
  32. #define WAYPOINT_ADDR (512 * 96)
  33. //存储POS的开始地址,预留100页用来记录POS,
  34. //按照sizeof(photopoint) =
  35. // 32,每页512字节,200页可以记录3200个POS信息,暂时限制记录3000POS
  36. #define POS_START_PAGE 200
  37. //数据记录的开始地址
  38. // #define DATA_START_PAGE 400
  39. extern bool write_pid_information, write_conf_information,
  40. write_par_information, write_cam_information, write_ver_information,
  41. write_waypoint_information, write_breakpoint_information,
  42. write_pos_information, write_postotal_information, write_iap_flag,
  43. write_rcfactor_flag, write_custom_noflyzone;
  44. void flash_at45db_initial(void);
  45. bool flash_isexist(void);
  46. bool flash_isbusy(void);
  47. void flash_read_bytes(unsigned int add, unsigned char *pdata,
  48. unsigned short len);
  49. void flash_write_bytes(unsigned int add, unsigned char *pdata,
  50. unsigned short len);
  51. short flash_read_int16(unsigned int add);
  52. void flash_write_int16(unsigned int add, short wvalue);
  53. void flash_read_page(unsigned short Page_Add, unsigned char *pdata);
  54. void flash_write_page(unsigned short page, unsigned char *Data);
  55. void flash_write_bytes_ononepage(unsigned short page, unsigned char *pdata,
  56. unsigned short len);
  57. void initial_parameters(void);
  58. void write_par_to_flash(void);
  59. #endif