luat_sfd.h 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef LUAT_SFD_H
  2. #define LUAT_SFD_H
  3. #include "luat_base.h"
  4. #include "luat_spi.h"
  5. #include "luat_zbuff.h"
  6. typedef struct sdf_opts {
  7. int (*initialize) (void* userdata);
  8. int (*status) (void* userdata);
  9. int (*read) (void* userdata, char* buff, size_t offset, size_t len);
  10. int (*write) (void* userdata, const char* buff, size_t offset, size_t len);
  11. int (*erase) (void* userdata, size_t offset, size_t len);
  12. int (*ioctl) (void* userdata, size_t cmd, void* buff);
  13. }sdf_opts_t;
  14. typedef struct sfd_drv {
  15. const sdf_opts_t* opts;
  16. uint8_t type;
  17. union
  18. {
  19. struct sfd_spi {
  20. int id;
  21. int cs;
  22. } spi;
  23. luat_zbuff_t* zbuff;
  24. } cfg;
  25. size_t sector_size;
  26. size_t sector_count;
  27. size_t erase_size;
  28. char chip_id[8];
  29. } sfd_drv_t;
  30. typedef struct sfd_onchip {
  31. char name[8];
  32. size_t addr;
  33. size_t block_count;
  34. size_t block_size;
  35. //const sdf_opts_t* opts;
  36. }sfd_onchip_t;
  37. #endif