COSA
An Object-Oriented Platform for Arduino Programming
S25FL127S Class Reference

#include <S25FL127S.hh>

Inheritance diagram for S25FL127S:
Inheritance graph
Collaboration diagram for S25FL127S:
Collaboration graph

Classes

union  config_t
 
union  status1_t
 
union  status2_t
 

Public Member Functions

 S25FL127S (Board::DigitalPin csn=Board::D5)
 
virtual bool begin ()
 
virtual bool is_ready ()
 
virtual int read (void *dest, uint32_t src, size_t size)
 
virtual int erase (uint32_t dest, uint8_t size=4)
 
virtual int write (uint32_t dest, const void *src, size_t size)
 
virtual int write_P (uint32_t dest, const void *buf, size_t size)
 
uint8_t read_config ()
 
uint8_t read_status1 ()
 
uint8_t read_status2 ()
 
virtual bool end ()
 

Public Attributes

const uint32_t SECTOR_BYTES
 
const uint32_t SECTOR_MASK
 
const uint16_t SECTOR_MAX
 
const uint32_t DEVICE_BYTES
 

Static Public Attributes

static const size_t PAGE_MAX = 256
 
static const size_t PAGE_MASK = PAGE_MAX - 1
 
static const uint32_t DEFAULT_SECTOR_BYTES = 4096
 

Protected Types

enum  Command {
  READ_ID = 0x90, RDRID = 0x9f, RSFDP = 0x5a, RES = 0xab,
  RDSR1 = 0x05, RDSR2 = 0x07, RDCR = 0x35, WRR = 0x01,
  WRDI = 0x04, WREN = 0x06, CLSR = 0x30, ABRD = 0x14,
  ABWR = 0x15, BRRD = 0x16, BRWR = 0x17, BRAC = 0x89,
  DLPRD = 0x41, PNVDLR = 0x43, WVDLR = 0x4A, READ = 0x03,
  READ4 = 0x13, FAST_READ = 0x0b, FAST_READ4 = 0x0c, DOR = 0x3b,
  DOR4 = 0x3c, QOR = 0x6b, QOR4 = 0x6c, DIOR = 0xbb,
  DIOR4 = 0xbc, QIOR = 0xeb, QIOR4 = 0xec, PP = 0x02,
  PP4 = 0x12, QPP = 0x32, QPP4 = 0x34, PGSP = 0x85,
  PGRS = 0x8a, P4E = 0x20, P4E4 = 0x21, BER = 0x60,
  SER = 0xd8, SER4 = 0xdc, ERSP = 0x75, ERRS = 0x7a,
  OTPP = 0x42, OTPR = 0x4b, DYBRD = 0xe0, DYBWR = 0xe1,
  PPBRD = 0xe2, PPBP = 0xe3, PPBE = 0xe4, ASPRD = 0x2b,
  ASPP = 0x2f, PLBRD = 0xa7, PLBWR = 0xa6, PASSRD = 0xe7,
  PASSP = 0xe8, PASSU = 0xe9, RESET = 0xf0, MBR = 0xff
}
 

Protected Member Functions

uint8_t issue (Command cmd)
 
void set_clock (Clock rate)
 
void set_clock (uint32_t freq)
 

Static Protected Member Functions

static Clock clock (uint32_t freq)
 
static Clock cycle (uint16_t ns)
 

Protected Attributes

status1_t m_status
 
Driverm_next
 List of drivers. More...
 
Interrupt::Handlerm_irq
 Interrupt handler. More...
 
OutputPin m_cs
 Device chip select pin. More...
 
Pulse m_pulse
 Chip select pulse width. More...
 
uint8_t m_spcr
 SPI/SPCR hardware control register setting. More...
 
uint8_t m_spsr
 SPI/SPSR hardware status register. More...
 

Static Protected Attributes

static const uint8_t MANUFACTURER = 0x01
 
static const uint8_t DEVICE = 0x17
 

Detailed Description

Cosa SPANSINO S25FL127S flash device driver class. Implements the Cosa Flash device driver interface with erase, read and write/program flash memory blocks.

References

  1. S25FL127S, 128 Mbit (16 Mbyte) MirrorBit(R) Flash Non-Volatile Memory, CMOS 3.0 Volt Core, Serial Peripheral Interface with Mult-I/O, Data Sheet, Pub.nr. S25127S_00, Rev. 05, Issue Date Nov. 15, 2013.

Definition at line 39 of file S25FL127S.hh.

Member Enumeration Documentation

enum S25FL127S::Command
protected

Command Set (table 10.2, pp. 73-74)

Enumerator
READ_ID 

Read Electronic Manufacturer Signature.

Read Device Identification

RDRID 

Read ID (JEDEC).

RSFDP 

Read JEDEC Serial Flash Parameters.

RES 

Read Electronic Signature.

RDSR1 

Read Status Register#1.

Register Access

RDSR2 

Read Status Register#2.

RDCR 

Read Configuration Register#1.

WRR 

Write Register (Status-1, Config-1).

WRDI 

Write Disable.

WREN 

Write Enable.

CLSR 

Clear Status Register#1.

ABRD 

AutoBoot Register Read.

ABWR 

AutoBoot Register Write.

BRRD 

Bank Register Read.

BRWR 

Bank Register Write.

BRAC 

Bank Register Access.

DLPRD 

Data Learning Pattern Read.

PNVDLR 

Program NV Data Learning Register.

WVDLR 

Write Volatile Data Learning Register.

READ 

Read (3- or 4-byte address).

Read Flash Array

READ4 

Read (4-byte address).

FAST_READ 

Fast Read (3- or 4-byte address).

FAST_READ4 

Fast Read (4-byte address).

DOR 

Read Dual Out (3- or 4-byte address).

DOR4 

Read Dual Out (4-byte address).

QOR 

Read Quad Out (3- or 4-byte address).

QOR4 

Read Quad Out (4-byte address).

DIOR 

Dual I/O Read (3- or 4-byte address).

DIOR4 

Dual I/O Read (4-byte address).

QIOR 

Read Quad Out (3- or 4-byte address).

QIOR4 

Read Quad Out (4-byte address).

PP 

Page Program (3- or 4-byte address).

Program Flash Array

PP4 

Page Program (4-byte address).

QPP 

Quad Page Program (3- or 4-byte address).

QPP4 

Quad Page Program (4-byte address).

PGSP 

Program Suspend.

PGRS 

Program Resume.

P4E 

Parameter 4-kB, sector erase.

Erase Flash Array

P4E4 

Parameter 4-kB, sector erase (4-byte addr).

BER 

Bulk Erase.

SER 

Erase 64 kB or 256 kB.

SER4 

Erase 64 kB or 256 kB (4-byte addr).

ERSP 

Erase Suspend.

ERRS 

Erase Resume.

OTPP 

OTP Program.

One Time Program Array

OTPR 

OTP Read.

DYBRD 

DYB Read.

Advanced Sector Protection

DYBWR 

DYB Write.

PPBRD 

PPB Read.

PPBP 

PPB Program.

PPBE 

PPB Erase.

ASPRD 

ASP Read.

ASPP 

ASP Program.

PLBRD 

PPB Lock Bit Read.

PLBWR 

PPB Lock Bit Write.

PASSRD 

Password Read.

PASSP 

Password Program.

PASSU 

Password unlock.

RESET 

Software Reset.

Reset

MBR 

Mode Bit Reset.

Definition at line 230 of file S25FL127S.hh.

Constructor & Destructor Documentation

S25FL127S::S25FL127S ( Board::DigitalPin  csn = Board::D5)
inline

Construct S25FL127S device driver with given chip select pin.

Parameters
[in]csnchip select pin (default D5/D3).

Definition at line 52 of file S25FL127S.hh.

Member Function Documentation

bool S25FL127S::begin ( )
virtual

Initiate the flash memory device driver and check for valid identification. Return true(1) if the successful otherwise false(0).

Returns
bool

Reimplemented from Flash::Device.

Definition at line 24 of file S25FL127S.cpp.

static Clock SPI::Driver::clock ( uint32_t  freq)
inlinestaticinherited

Calculate SPI clock rate (scale factor) for given frequency.

Parameters
[in]freqdevice max frequency (in Hz).
Returns
clock rate.

Definition at line 117 of file SPI.hh.

static Clock SPI::Driver::cycle ( uint16_t  ns)
inlinestaticinherited

Calculate SPI clock rate (scale factor) for given clock cycle time in nano seconds.

Parameters
[in]nsmin device clock cycle time.
Returns
clock rate.

Definition at line 135 of file SPI.hh.

virtual bool Flash::Device::end ( )
inlinevirtualinherited

Terminate the flash memory device driver. Return true(1) if the successful otherwise false(0).

Returns
bool.

Definition at line 78 of file Flash.hh.

int S25FL127S::erase ( uint32_t  dest,
uint8_t  size = 4 
)
virtual

Erase given flash block for given byte address. The size of the erased sector is either 4 or 64 KB. Give sector size 255 to erase chip. The default configuration consists of 16X4 KB sectors from low address followed by 255X64 KB sectors. The highest sector is reserved. Returs zero(0) if successful otherwise an negative error code (EINVAL on illegal sector size, EFAULT if not successful).

Parameters
[in]destdestination block byte address to erase.
Returns
zero or negative error code.

Implements Flash::Device.

Definition at line 81 of file S25FL127S.cpp.

bool S25FL127S::is_ready ( )
virtual

Return true(1) if the device is ready, write cycle is completed, otherwise false(0).

Returns
bool

Implements Flash::Device.

Definition at line 46 of file S25FL127S.cpp.

uint8_t S25FL127S::issue ( Command  cmd)
protected

Issue given command and return result.

Parameters
[in]cmdcommand code.
Returns
result.

Definition at line 213 of file S25FL127S.cpp.

int S25FL127S::read ( void *  dest,
uint32_t  src,
size_t  size 
)
virtual

Read flash block with the given size into the buffer from the source address. Return number of bytes read or negative error code.

Parameters
[in]destbuffer to read from flash into.
[in]srcaddress in flash to read from.
[in]sizenumber of bytes to read.
Returns
number of bytes or negative error code.

Implements Flash::Device.

Definition at line 61 of file S25FL127S.cpp.

uint8_t S25FL127S::read_config ( )
inline

Read device configuration register 1.

Returns
configuration.

Definition at line 157 of file S25FL127S.hh.

uint8_t S25FL127S::read_status1 ( )
inline

Read device status register 1.

Returns
status code.

Definition at line 189 of file S25FL127S.hh.

uint8_t S25FL127S::read_status2 ( )
inline

Read device status register 2.

Returns
status code.

Definition at line 221 of file S25FL127S.hh.

void SPI::Driver::set_clock ( Clock  rate)
inherited

Set SPI master clock rate.

Parameters
[in]clockrate.

Definition at line 297 of file SPI.cpp.

void SPI::Driver::set_clock ( uint32_t  freq)
inlineinherited

Set SPI master clock frequency.

Parameters
[in]freqdevice max frequency (in Hz).

Definition at line 157 of file SPI.hh.

int S25FL127S::write ( uint32_t  dest,
const void *  src,
size_t  size 
)
virtual

Write flash block at given destination address with the contents of the source buffer. Return number of bytes written or negative error code (EFAULT if not successful).

Parameters
[in]destaddress in flash to write to.
[in]srcbuffer to write to flash.
[in]sizenumber of bytes to write.
Returns
number of bytes or negative error code.

Implements Flash::Device.

Definition at line 115 of file S25FL127S.cpp.

int S25FL127S::write_P ( uint32_t  dest,
const void *  buf,
size_t  size 
)
virtual

Write flash block at given destination address with contents of the source buffer in program memory. Return number of bytes written or negative error code (EFAULT is not successful).

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Implements Flash::Device.

Definition at line 164 of file S25FL127S.cpp.

Member Data Documentation

const uint32_t Flash::Device::DEFAULT_SECTOR_BYTES = 4096
staticinherited

Default size of sector in bytes.

Definition at line 37 of file Flash.hh.

const uint8_t S25FL127S::DEVICE = 0x17
staticprotected

Device code

Definition at line 312 of file S25FL127S.hh.

const uint32_t Flash::Device::DEVICE_BYTES
inherited

Number of bytes of device.

Definition at line 46 of file Flash.hh.

OutputPin SPI::Driver::m_cs
protectedinherited

Device chip select pin.

Definition at line 166 of file SPI.hh.

Interrupt::Handler* SPI::Driver::m_irq
protectedinherited

Interrupt handler.

Definition at line 165 of file SPI.hh.

Driver* SPI::Driver::m_next
protectedinherited

List of drivers.

Definition at line 164 of file SPI.hh.

Pulse SPI::Driver::m_pulse
protectedinherited

Chip select pulse width.

Definition at line 167 of file SPI.hh.

uint8_t SPI::Driver::m_spcr
protectedinherited

SPI/SPCR hardware control register setting.

Definition at line 173 of file SPI.hh.

uint8_t SPI::Driver::m_spsr
protectedinherited

SPI/SPSR hardware status register.

Definition at line 174 of file SPI.hh.

status1_t S25FL127S::m_status
protected

Latest status; is_ready() call

Definition at line 322 of file S25FL127S.hh.

const uint8_t S25FL127S::MANUFACTURER = 0x01
staticprotected

Manufacturer code

Definition at line 309 of file S25FL127S.hh.

const size_t S25FL127S::PAGE_MASK = PAGE_MAX - 1
static

Definition at line 45 of file S25FL127S.hh.

const size_t S25FL127S::PAGE_MAX = 256
static

Default programming page buffer size (pp. 61, 97).

Definition at line 44 of file S25FL127S.hh.

const uint32_t Flash::Device::SECTOR_BYTES
inherited

Size of sector in bytes.

Definition at line 34 of file Flash.hh.

const uint32_t Flash::Device::SECTOR_MASK
inherited

Sector address mask.

Definition at line 40 of file Flash.hh.

const uint16_t Flash::Device::SECTOR_MAX
inherited

Number of sectors.

Definition at line 43 of file Flash.hh.


The documentation for this class was generated from the following files: