api_cm.h 1.4 KB

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