interFlash.c 978 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "interFlash.h"
  2. #include "nwy_file.h"
  3. #define flash_addr 0x607b0000
  4. static nwyspiflash_t *interFp = NULL;
  5. /*初始化内部FLASH接口*/
  6. bool interFlashInit(void){
  7. nwyspiflash_t *fp=NULL;
  8. if(NULL!=interFp) return true;
  9. fp==nwy_flash_open(NAME_FLASH_1);
  10. if(NULL==fp) return false;
  11. interFp=fp;
  12. return true;
  13. }
  14. /*擦出内部FLASH接口*/
  15. bool interFlashErace(unsigned int flash_addr, int size){
  16. if(NULL==interFp) return false;
  17. return nwy_flash_erase(interFp,flash_addr, size);
  18. }
  19. /*写内部FLASH接口*/
  20. bool interFlashWrite(unsigned int flash_addr, unsigned char *data_ptr, int size){
  21. if(NULL==interFp) return false;
  22. return nwy_flash_write(interFp,flash_addr, data_ptr, size);
  23. }
  24. /*读内部FLASH接口*/
  25. bool interFlashRead(unsigned int flash_addr, unsigned char *data_ptr, int size){
  26. if(NULL==interFp) return false;
  27. return nwy_flash_read(interFp, flash_addr, data_ptr, size);
  28. }
  29. char interFlashTest(void){
  30. if(false==interFlashInit()) return 1;
  31. if(false==interFlashErace(
  32. }