flash 2.0.0.0
flash.h File Reference

This file contains API for Flash Click driver. More...

#include "drv_digital_out.h"
#include "drv_spi_master.h"

Go to the source code of this file.

Data Structures

struct  flash_t
 Click context object definition. More...
 
struct  flash_cfg_t
 Click configuration structure definition. More...
 

Macros

#define FLASH_MEM_ADDR_FIRST_PAGE_START   0x0
 
#define FLASH_MEM_ADDR_FIRST_PAGE_END   0xFF
 
#define FLASH_MEM_ADDR_SECOND_PAGE_START   0x100
 
#define FLASH_MEM_ADDR_SECOND_PAGE_END   0x1FF
 
#define FLASH_MEM_ADDR_LAST_PAGE_START   0xFFF00
 
#define FLASH_MEM_ADDR_LAST_PAGE_END   0xFFFFF
 
#define FLASH_MEM_ADDR_FIRST_SECTOR_START   0x0
 
#define FLASH_MEM_ADDR_FIRST_SECTOR_END   0xFFF
 
#define FLASH_MEM_ADDR_LAST_SECTOR_START   0xFF000
 
#define FLASH_MEM_ADDR_LAST_SECTOR_END   0xFFFFF
 
#define FLASH_MEM_ADDR_FIRST_BLOCK_START   0x0
 
#define FLASH_MEM_ADDR_FIRST_BLOCK_END   0xFFFF
 
#define FLASH_MEM_ADDR_LAST_BLOCK_START   0xF0000
 
#define FLASH_MEM_ADDR_LAST_BLOCK_END   0xFFFFF
 
#define FLASH_NDATA_TRANSFER_MIN   1
 
#define FLASH_NDATA_TRANSFER_MAX   256
 
#define FLASH_STATUS_MASK_WRITE_BUSY   0x1
 
#define FLASH_STATUS_MASK_WRITE_EN   0x2
 
#define FLASH_STATUS_MASK_BLOCK_PROTECT   0x3C
 
#define FLASH_STATUS_MASK_WP_DIS   0x40
 
#define FLASH_STATUS_MASK_OTP_LOCK   0x80
 
#define FLASH_STATUS_SET_BLOCK_PROT_BIT0   0x4
 
#define FLASH_STATUS_SET_BLOCK_PROT_BIT1   0x8
 
#define FLASH_STATUS_SET_BLOCK_PROT_BIT2   0x10
 
#define FLASH_STATUS_SET_BLOCK_PROT_BIT3   0x20
 
#define FLASH_STATUS_SET_WP_DIS   0x40
 
#define FLASH_STATUS_SET_OTP_LOCK   0x80
 
#define FLASH_MAP_MIKROBUS(cfg, mikrobus)
 

Enumerations

enum  flash_err_t { FLASH_OK = 0x0 , FLASH_ERR_INIT_DRV = 0xFD , FLASH_ERR_MEM_ADDR , FLASH_ERR_NDATA }
 Click error code definition. More...
 
enum  flash_pin_state_t { FLASH_PIN_STATE_LOW = 0 , FLASH_PIN_STATE_HIGH }
 Click pin states. More...
 

Functions

void flash_cfg_setup (flash_cfg_t *cfg)
 Config Object Setup function.
 
flash_err_t flash_init (flash_t *ctx, flash_cfg_t *cfg)
 Click Initialization function.
 
void flash_default_cfg (flash_t *ctx)
 Click Default Configuration function.
 
void flash_reset (flash_t *ctx)
 Reset function.
 
void flash_write_enable (flash_t *ctx)
 Write Enable function.
 
void flash_write_disable (flash_t *ctx)
 Write Disable function.
 
void flash_write_status (flash_t *ctx, uint8_t data_tx)
 Status Write function.
 
uint8_t flash_read_status (flash_t *ctx)
 Status Read function.
 
void flash_read_id (flash_t *ctx, uint8_t *manufact_id, uint16_t *dev_id)
 ID Read function.
 
flash_err_t flash_write_byte (flash_t *ctx, uint32_t mem_addr, uint8_t data_tx)
 Byte Write function.
 
flash_err_t flash_read_byte (flash_t *ctx, uint32_t mem_addr, uint8_t *data_rx)
 Byte Read function.
 
flash_err_t flash_write_page (flash_t *ctx, uint32_t mem_addr, uint8_t *data_tx, uint16_t n_data)
 Page Write function.
 
flash_err_t flash_read_page (flash_t *ctx, uint32_t mem_addr, uint8_t *data_rx, uint16_t n_data)
 Page Read function.
 
void flash_erase_chip (flash_t *ctx)
 Chip Erase function.
 
flash_err_t flash_erase_block (flash_t *ctx, uint32_t mem_addr)
 Block Erase function.
 
flash_err_t flash_erase_half_block (flash_t *ctx, uint32_t mem_addr)
 Half Block Erase function.
 
flash_err_t flash_erase_sector (flash_t *ctx, uint32_t mem_addr)
 Sector Erase function.
 
void flash_set_write_protect_pin (flash_t *ctx, flash_pin_state_t state)
 WP Pin Set function.
 
void flash_set_hold_pin (flash_t *ctx, flash_pin_state_t state)
 HLD Pin Set function.
 

Detailed Description

This file contains API for Flash Click driver.