Flash.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef __FLASH_H_
  2. #define __FLASH_H_
  3. #include "define.h"
  4. #define FLASH_CS_ENABLE nrf_gpio_pin_write(FLASH_SS_PIN, 0);
  5. #define FLASH_CS_DISABLE nrf_gpio_pin_write(FLASH_SS_PIN, 1);
  6. #define Flash_Secpos_Size 4096
  7. #define FLASH_SYS_IDX 0
  8. #define FLASH_DEV_IDX 1
  9. #define FLASH_ALARM_IDX 256
  10. #define FLASH_ALARM_SIZE 4096
  11. #define FLASH_ALARM_LEN 256
  12. //W25X32
  13. #define Flash_ID1 0xEF16 //w25q64的ID
  14. //指令表
  15. #define Flash_Instruct_WriteEnable 0x06 //写使能
  16. #define Flash_Instruct_WriteDisable 0x04 //写禁止
  17. #define Flash_Instruct_ReadStatusReg 0x05 //读状态寄存器
  18. #define Flash_Instruct_WriteStatusReg 0x01 //写状态寄存器
  19. #define Flash_Instruct_ReadData 0x03 //读数据
  20. #define Flash_Instruct_FastReadData 0x0B //快速读数据
  21. #define Flash_Instruct_FastReadDual 0x3B //双倍快速读数据
  22. #define Flash_Instruct_PageProgram 0x02 //页编程
  23. #define Flash_Instruct_BlockErase 0xD8 //块擦除64K
  24. #define Flash_Instruct_SectorErase 0x20 //扇区擦除
  25. #define Flash_Instruct_ChipErase 0xC7 //全片擦除
  26. #define Flash_Instruct_PowerDown 0xB9 //低功耗
  27. #define Flash_Instruct_ReleasePowerDown 0xAB //唤醒
  28. #define Flash_Instruct_DeviceID 0xAB //芯片ID
  29. #define Flash_Instruct_ManufactDeviceID 0x90 //芯片ID
  30. #define Flash_Instruct_JedecDeviceID 0x9F //JEDEC ID
  31. #define Flash_Instruct_UniqueID 0x4B //Unique ID
  32. typedef enum
  33. {
  34. FLASH_QUEUE_TIME=0,
  35. FLASH_QUEUE_INT=1,
  36. FLASH_QUEUE_BUSY=2,
  37. }FLASH_QUEUE_TYPE;
  38. typedef enum
  39. {
  40. FLASH_BUSY,
  41. FLASH_ENABLE,
  42. FLASH_DISABLE
  43. }FLASH_STAT;
  44. typedef enum
  45. {
  46. FLASH_WRITE,
  47. FLASH_READ,
  48. FLASH_UNIQUEID, //读取UniqueID
  49. FLASH_MDID, //读取ManufactDeviceID
  50. FLASH_SLEEP,
  51. FLASH_WAKEUP,
  52. FLASH_DELAY,
  53. }FLASH_WORK;
  54. typedef struct{
  55. FLASH_WORK flash_work;
  56. FLASH_STAT flash_stat;
  57. }FLASH_STRUCT;
  58. void Flash_Gpio_Init(void);
  59. #endif