flash.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __DRV_FLASH_H
  2. #define __DRV_FLASH_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ifdef __DRV_FLASH_H_GLOBAL
  7. #define __DRV_FLASH_H_EXTERN
  8. #else
  9. #define __DRV_FLASH_H_EXTERN extern
  10. #endif
  11. /************************************************************************************************
  12. * Version *
  13. ************************************************************************************************/
  14. /************************************************************************************************
  15. * How to use *
  16. ************************************************************************************************/
  17. /************************************************************************************************
  18. * Enable config *
  19. ************************************************************************************************/
  20. /************************************************************************************************
  21. * Includes *
  22. ************************************************************************************************/
  23. #include <stdint.h>
  24. /************************************************************************************************
  25. * Defines *
  26. ************************************************************************************************/
  27. #define FMC_PAGE_SIZE ((uint16_t)0x800)
  28. #define FMC_PAGE_SIZE_U16 ((uint16_t)0x400)
  29. #define FMC_FLASH_BASE ((uint32_t)0x08000000)
  30. #define FMC_PAGE_SIZE_16K ((uint32_t)0x4000)
  31. #define FMC_PAGE_SIZE_32K ((uint32_t)0x8000)
  32. #define FMC_PAGE_SIZE_64K ((uint32_t)0x10000)
  33. #define FMC_PAGE_SIZE_128K ((uint32_t)0x20000)
  34. /************************************************************************************************
  35. * Defines *
  36. ************************************************************************************************/
  37. void fmc_clear_flag_star(void);
  38. void fmc_clear_flag_end(void);
  39. uint8_t fmc_read_byte(uint32_t read_addr);
  40. uint16_t fmc_read_half_word(uint32_t read_addr);
  41. uint8_t fmc_read_n_half_word(uint32_t read_addr, uint16_t *buff, uint16_t count);
  42. uint8_t fmc_read_one_page(uint32_t read_addr, uint16_t *buff);
  43. uint8_t fmc_erase_pages(uint32_t erase_addr, uint16_t len);
  44. uint8_t fmc_write_n_half_word(uint32_t write_addr, uint16_t *buff, uint16_t len);
  45. uint16_t firmware_crc16_ccitt_false(uint16_t init_value, uint8_t *pbuff, uint32_t len);
  46. #ifdef __cplusplus
  47. };
  48. #endif
  49. #endif // __DRV_FLASH_H