luat_sfd_onchip_air101.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "luat_base.h"
  2. #include "luat_sfd.h"
  3. #ifdef LUAT_SFD_ONCHIP
  4. #define LUAT_LOG_TAG "onchip"
  5. #include "luat_log.h"
  6. #include "wm_include.h"
  7. #include "wm_flash_map.h"
  8. #include "wm_internal_flash.h"
  9. int sfd_onchip_init (void* userdata) {
  10. sfd_onchip_t* onchip = (sfd_onchip_t*)userdata;
  11. if (onchip == NULL)
  12. return -1;
  13. return 0;
  14. }
  15. int sfd_onchip_status (void* userdata) {
  16. return 0;
  17. }
  18. int sfd_onchip_read (void* userdata, char* buff, size_t offset, size_t len) {
  19. int ret;
  20. sfd_onchip_t* onchip = (sfd_onchip_t*)userdata;
  21. if (onchip == NULL)
  22. return -1;
  23. ret = tls_fls_read(offset + onchip->addr, (u8 *)buff, len);
  24. if (ret != TLS_FLS_STATUS_OK)
  25. {
  26. return -1;
  27. }
  28. return 0;
  29. }
  30. int sfd_onchip_write (void* userdata, const char* buff, size_t offset, size_t len) {
  31. int ret;
  32. sfd_onchip_t* onchip = (sfd_onchip_t*)userdata;
  33. if (onchip == NULL)
  34. return -1;
  35. ret = tls_fls_write(offset + onchip->addr, (u8 *)buff, len);
  36. if (ret != TLS_FLS_STATUS_OK)
  37. {
  38. return -1;
  39. }
  40. return 0;
  41. }
  42. int sfd_onchip_erase (void* userdata, size_t offset, size_t len) {
  43. int ret;
  44. sfd_onchip_t* onchip = (sfd_onchip_t*)userdata;
  45. if (onchip == NULL)
  46. return -1;
  47. ret = tls_fls_erase(offset + onchip->addr);
  48. if (ret != TLS_FLS_STATUS_OK)
  49. {
  50. return -1;
  51. }
  52. return 0;
  53. }
  54. int sfd_onchip_ioctl (void* userdata, size_t cmd, void* buff) {
  55. return 0;
  56. }
  57. #endif