extmem_flash.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef EXTMEM_FLASH_H
  2. #define EXTMEM_FLASH_H
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #include "stm32l1xx_hal.h"
  6. #include "drivers/spi/spi.h"
  7. #include "drivers/flash/at45db321d.h"
  8. #define EXTMEM_HIBERNATE_ENABLED 1
  9. typedef struct
  10. {
  11. #if AT45DB321D_POWER_MANAGEMENT
  12. void ( *SetPinPowerOn)();
  13. void ( *SetPinPowerOff)();
  14. #endif
  15. #if AT45DB321D_RESET_MANAGEMENT
  16. void ( *ResetPinAssert)();
  17. void ( *ResetPinRelease)();
  18. #endif
  19. #if AT45DB321D_HW_WR_PROTECT
  20. void ( *HwWrProtPinAssert)();
  21. void ( *HwWrProtPinRelease)();
  22. #endif
  23. }
  24. ExtMemPins_Handle_t;
  25. extern const ExtMemPins_Handle_t ExtMemPinsHandle;
  26. typedef enum
  27. {
  28. extmem_bank_factory,
  29. extmem_bank_user,
  30. }
  31. eExtMem_Bank_t;
  32. typedef struct
  33. {
  34. flash_size_t factoryBankSize;
  35. flash_size_t userBankSize;
  36. }
  37. ExtMem_Bank_Properties_t;
  38. typedef struct
  39. {
  40. bool ( *Init)();
  41. bool ( *Write)( flash_address_t address, __FLASH_BYTE * pBuffer, flash_address_t size );
  42. bool ( *Read)( flash_address_t address, __FLASH_BYTE * pBuffer, flash_address_t size );
  43. bool ( *RangeCheck_Read)( flash_address_t address, flash_address_t size );
  44. bool ( *RangeCheck_Write)( flash_address_t address, flash_address_t size );
  45. bool ( *BankProtect)( eExtMem_Bank_t bankId, bool protectStatus );
  46. bool ( *CheckBankProtect)( eExtMem_Bank_t bankId, bool * pActualProtectStatus );
  47. bool ( *DeInit)( bool bForce );
  48. const flash_properties_t * pFlashProperties;
  49. const ExtMem_Bank_Properties_t * pBanksProperties;
  50. }
  51. ExtMem_Handle_t;
  52. extern const ExtMem_Handle_t ExtMemHandle;
  53. #endif