86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : bsp_w25qxx.h
|
|
* @brief : BSP layer for W25QXX flash memory
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
#ifndef BSP_W25QXX_H
|
|
#define BSP_W25QXX_H
|
|
|
|
#include "w25qxx.h"
|
|
#include "hal_spi.h"
|
|
#include "hal_gpio.h"
|
|
|
|
/**
|
|
* @brief W25QXX chip select pin configuration
|
|
*/
|
|
#define W25QXX_CS_PORT HAL_GPIO_PORT_B
|
|
#define W25QXX_CS_PIN HAL_GPIO_PIN_0
|
|
|
|
/**
|
|
* @brief W25QXX SPI instance
|
|
*/
|
|
#define W25QXX_SPI_INSTANCE HAL_SPI_INSTANCE_1
|
|
|
|
/**
|
|
* @brief Initialize W25QXX flash memory
|
|
* @retval true if initialization is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_init(void);
|
|
|
|
/**
|
|
* @brief Get W25QXX device information
|
|
* @param info Pointer to device information structure to fill
|
|
* @retval true if successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_get_device_info(w25qxx_device_info_t *info);
|
|
|
|
/**
|
|
* @brief Read data from W25QXX flash memory
|
|
* @param address Starting address to read from
|
|
* @param data Pointer to data buffer to store read data
|
|
* @param size Size of data to read
|
|
* @retval true if read is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_read(uint32_t address, uint8_t *data, uint32_t size);
|
|
|
|
/**
|
|
* @brief Write data to W25QXX flash memory
|
|
* @param address Starting address to write to
|
|
* @param data Pointer to data buffer to write
|
|
* @param size Size of data to write
|
|
* @retval true if write is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_write(uint32_t address, const uint8_t *data, uint32_t size);
|
|
|
|
/**
|
|
* @brief Erase 4KB block
|
|
* @param address Address within the block to erase
|
|
* @retval true if erase is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_erase_block_4kb(uint32_t address);
|
|
|
|
/**
|
|
* @brief Erase 32KB block
|
|
* @param address Address within the block to erase
|
|
* @retval true if erase is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_erase_block_32kb(uint32_t address);
|
|
|
|
/**
|
|
* @brief Erase 64KB block
|
|
* @param address Address within the block to erase
|
|
* @retval true if erase is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_erase_block_64kb(uint32_t address);
|
|
|
|
/**
|
|
* @brief Erase entire chip
|
|
* @retval true if erase is successful, false otherwise
|
|
*/
|
|
bool bsp_w25qxx_erase_chip(void);
|
|
|
|
#endif /* BSP_W25QXX_H */ |