19 #ifdef CONFIG_MODULE_FLASH_ENABLE 25 #define FLASH_COMMAND_WRITE_ENABLE ((uint8_t) 0x06 ) 28 #define FLASH_COMMAND_READ_DATA ((uint8_t) 0x03 ) 31 #define FLASH_COMMAND_FAST_READ_DATA ((uint8_t) 0x03 ) 35 #define FLASH_COMMAND_PAGE_PROGRAM ((uint8_t) 0x02 ) 38 #define FLASH_COMMAND_READ_STATUS_REGISTER ((uint8_t) 0x05 ) 41 #define FLASH_COMMAND_WRITE_STATUS_REGISTER ((uint8_t) 0x01 ) 45 #define FLASH_COMMAND_BLOCK_ERASE ((uint8_t) 0xD8 ) 49 #define FLASH_COMMAND_SECTOR_ERASE ((uint8_t) 0x20 ) 52 #define FLASH_COMMAND_CHIP_ERASE ((uint8_t) 0xC7 ) 55 #define FLASH_COMMAND_POWER_DOWN ((uint8_t) 0xB9 ) 102 #define FLASH_CS_ACTIVE() HAL_GPIO_WritePin(FLASH_SPI_CS_GPIO_PORT,FLASH_SPI_CS_GPIO_PIN,GPIO_PIN_RESET); 103 #define FLASH_CS_INACTIVE() HAL_GPIO_WritePin(FLASH_SPI_CS_GPIO_PORT,FLASH_SPI_CS_GPIO_PIN,GPIO_PIN_SET); 109 #define FLASH_STATUS_REGISTER_WRITEINPROGRESS_BIT ( 1 << 0) 111 #define FLASH_STATUS_REGISTER_WRITEENABLELATCH_BIT ( 1 << 1) 114 #define FLASH_STATUS_REGISTER_BP0_BIT ( 1 << 2) 116 #define FLASH_STATUS_REGISTER_BP1_BIT ( 1 << 3) 118 #define FLASH_STATUS_REGISTER_BP2_BIT ( 1 << 4) 120 #define FLASH_STATUS_REGISTER_BP3_BIT ( 1 << 5) 123 #define FLASH_STATUS_REGISTER_RESERVED_BIT ( 1 << 6) 125 #define FLASH_STATUS_REGISTER_STATUSREGISTERPROTECTED_BIT ( 1 << 7) 153 void FLASH_Init(
void );
154 void FLASH_Test (
void );
155 void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
156 void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
158 uint8_t FLASH_Read(uint32_t address, uint8_t *Buffer, uint8_t size, uint16_t timeout);
159 uint8_t FLASH_Write(uint32_t address, uint8_t *Buffer, uint8_t size, uint16_t timeout);
161 uint8_t FLASH_BlockErase (uint32_t address, uint16_t timeout);
162 uint8_t FLASH_SectorErase (uint32_t address, uint16_t timeout);
164 void FLASH_Test_WithEraseWriteRead (
void );
167 #endif // #ifdef CONFIG_MODULE_FLASH_ENABLE