Contiki-NG
Macros | Functions

Implementation of a generic external SPI flash driver. More...

#include "contiki.h"
#include "ext-flash.h"
#include "dev/spi.h"
#include "gpio-hal.h"
#include "sys/log.h"
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define BLS_CODE_PROGRAM   0x02
 Page Program.
 
#define BLS_CODE_READ   0x03
 Read Data.
 
#define BLS_CODE_READ_STATUS   0x05
 Read Status Register.
 
#define BLS_CODE_WRITE_ENABLE   0x06
 Write Enable.
 
#define BLS_CODE_SECTOR_ERASE   0x20
 Sector Erase.
 
#define BLS_CODE_MDID   0x90
 Manufacturer Device ID.
 
#define BLS_CODE_PD   0xB9
 Power down.
 
#define BLS_CODE_RPD   0xAB
 Release Power-Down.
 
#define BLS_CODE_ERASE_4K   0x20
 Sector Erase.
 
#define BLS_CODE_ERASE_ALL   0xC7
 Mass Erase.
 
#define BLS_STATUS_BIT_BUSY   0x01
 Busy bit of the status register.
 

Functions

static const spi_device_tget_spi_conf (const spi_device_t *conf)
 Get spi configuration, return default configuration if NULL.
 
static bool select_on_bus (const spi_device_t *flash_spi_configuration)
 Clear external flash CSN line.
 
static void deselect (const spi_device_t *flash_spi_configuration)
 Set external flash CSN line.
 
static bool wait_ready (const spi_device_t *flash_spi_configuration)
 Wait till previous erase/program operation completes. More...
 
static uint8_t verify_part (const spi_device_t *flash_spi_configuration)
 Verify the flash part. More...
 
static bool power_down (const spi_device_t *flash_spi_configuration)
 Put the device in power save mode. More...
 
static bool power_standby (const spi_device_t *flash_spi_configuration)
 Take device out of power save mode and prepare it for normal operation. More...
 
static bool write_enable (const spi_device_t *flash_spi_configuration)
 Enable write. More...
 
bool ext_flash_open (const spi_device_t *conf)
 Initialize storage driver. More...
 
bool ext_flash_close (const spi_device_t *conf)
 Close the storage driver. More...
 
bool ext_flash_read (const spi_device_t *conf, uint32_t offset, uint32_t length, uint8_t *buf)
 Read storage content. More...
 
bool ext_flash_write (const spi_device_t *conf, uint32_t offset, uint32_t length, const uint8_t *buf)
 Write to storage sectors. More...
 
bool ext_flash_erase (const spi_device_t *conf, uint32_t offset, uint32_t length)
 Erase storage sectors corresponding to the range. More...
 
bool ext_flash_init (const spi_device_t *conf)
 Initialise the external flash. More...
 

Detailed Description

Implementation of a generic external SPI flash driver.

Definition in file ext-flash.c.