api_cm.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _API_CM_H
  2. #define _API_CM_H
  3. #define PAGE_DATA_SIZE 250
  4. //每个Page 250 Byte
  5. #define PAGE0(x) (x)
  6. #define PAGE1(x) (0x100 + (x))
  7. #define PAGE2(x) (0x200 + (x))
  8. #define PAGE3(x) (0x300 + (x))
  9. #define PAGE4(x) (0x400 + (x))
  10. #define PAGE5(x) (0x500 + (x))
  11. #define PAGE6(x) (0x600 + (x))
  12. #define PAGE7(x) (0x700 + (x))
  13. #define PAGE8(x) (0x800 + (x))
  14. #define MAX_CM_PAGE 15 //根据需要定义大小
  15. #define SYS_CM_PAGE_NUM 0
  16. #define BT_CM_PAGE_NUM 1
  17. #define BT_CM_PAGE1_NUM 2
  18. #define EXT_CM_PAGE_NUM 3
  19. #define BTHID_CM_PAGE_NUM 4
  20. #define APP_CM_PAGE_NUM 5
  21. #define GFPS_PAGE_NUM 6
  22. #define BLE_CM_PAGE_NUM 7
  23. #define SYS_CM_PAGE(x) PAGE0(x)
  24. #define BT_CM_PAGE(x) PAGE1(x)
  25. #define BT_CM_PAGE1(x) PAGE2(x)
  26. #define EXT_CM_PAGE(x) PAGE3(x)
  27. #define BTHID_CM_PAGE(x) PAGE4(x)
  28. #define APP_CM_PAGE(x) PAGE5(x)
  29. #define GFPS_PAGE(x) PAGE6(x)
  30. #define BLE_CM_PAGE(x) PAGE7(x)
  31. #define DAC_PT_PAGE(x) PAGE8(x)
  32. void cm_init(uint max_page, u32 addr, uint len);
  33. void cm_sync(void); //将write写入cache的内容同步到spiflash中
  34. void cm_read(void *buf, u32 addr, uint len);
  35. u8 cm_read8(u32 addr);
  36. u16 cm_read16(u32 addr);
  37. u32 cm_read32(u32 addr);
  38. void cm_write(void *buf, u32 addr, uint len); //注意:write只是写入cache,需要调用cm_sync才会写入到spiflash中
  39. void cm_write8(u32 addr, u8 val);
  40. void cm_write16(u32 addr, u16 val);
  41. void cm_write32(u32 addr, u32 val);
  42. void cm_clear(u32 addr); //清除CM的一整个Page
  43. bool xcfg_init(void *xcfg, uint len);
  44. #endif