flash.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // This file is part of parrocchetto.
  2. // parrocchetto is free software: you can redistribute it and/or modify
  3. // it under the terms of the GNU General Public License as published by
  4. // the Free Software Foundation, either version 3 of the License, or
  5. // (at your option) any later version.
  6. // parrocchetto is distributed in the hope that it will be useful,
  7. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. // GNU General Public License for more details.
  10. // You should have received a copy of the GNU General Public License
  11. // along with parrocchetto. If not, see <http://www.gnu.org/licenses/>.
  12. #ifndef FLASH_H
  13. #define FLASH_H
  14. #include <xc.h>
  15. #include <stdint.h>
  16. #include "spi1.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif /* __cplusplus */
  20. #define flash_init() flash_W25Q32JV_init()
  21. #define flash_read(page_addr, byte_addr, buf, size) flash_W25Q32JV_read(page_addr, byte_addr, buf, size)
  22. #define flash_pageread(addr, page) flash_W25Q32JV_pageread(addr, page)
  23. #define flash_pagewrite(addr, page) flash_W25Q32JV_pagewrite(addr, page)
  24. #define flash_sectorerase(addr) flash_W25Q32JV_sectorerase(addr)
  25. #define flash_erase() flash_W25Q32JV_erase()
  26. #define flash_busywait(addr) flash_W25Q32JV_busywait()
  27. #define flash_isbusy() flash_W25Q32JV_isbusy()
  28. void flash_AT45DB041D_init();
  29. uint8_t flash_AT45DB041D_identify(void);
  30. uint8_t flash_AT45DB041D_getstatus(void);
  31. void flash_AT45DB041D_erase();
  32. void flash_AT45DB041D_pageread(uint16_t addr, uint8_t* page);
  33. void flash_AT45DB041D_pagewrite(uint16_t addr, const uint8_t* page);
  34. void flash_W25Q32JV_init();
  35. uint8_t flash_W25Q32JV_identify(void);
  36. uint8_t flash_W25Q32JV_getstatus1(void);
  37. void flash_W25Q32JV_busywait(void);
  38. inline uint8_t flash_W25Q32JV_isbusy(void);
  39. void flash_W25Q32JV_read(uint16_t page_addr, uint8_t byte_addr, uint8_t* buf, uint8_t size);
  40. void flash_W25Q32JV_pageread(uint16_t addr, uint8_t* page);
  41. void flash_W25Q32JV_pagewrite(uint16_t addr, const uint8_t* page);
  42. void flash_W25Q32JV_sectorerase(uint16_t addr);
  43. void flash_W25Q32JV_erase();
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif // FLASH_H