COSA
An Object-Oriented Platform for Arduino Programming
|
#include <W25X40CL.hh>
Classes | |
union | status_t |
Public Member Functions | |
W25X40CL (Board::DigitalPin csn=Board::D15) | |
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_status () |
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 { WREN = 0x06, WREVSR = 0x50, WRDI = 0x04, RDSR = 0x05, WRR = 0x01, READ = 0x03, FRD = 0x0b, FRDDIO = 0xbb, PP = 0x02, SER = 0x20, B32ER = 0x52, B64ER = 0xd8, CER = 0x60, PWD = 0xb9, RLPWD = 0xab, RDID = 0x90, RDIDDIO = 0x92, RDJID = 0x9f, RDUID = 0x4b } |
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 | |
status_t | m_status |
Driver * | m_next |
List of drivers. More... | |
Interrupt::Handler * | m_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 = 0xef |
static const uint8_t | DEVICE = 0x12 |
Cosa Winbond W25X40CL flash device driver class. Implements the Cosa Flash device driver interface with erase, read and write/program flash memory blocks.
Definition at line 38 of file W25X40CL.hh.
|
protected |
Instruction Set (chap. 8.2.2, pp. 15)
Definition at line 163 of file W25X40CL.hh.
|
inline |
Construct W25X40CL device driver with given chip select pin.
[in] | csn | chip select pin (default D15/D3). |
Definition at line 51 of file W25X40CL.hh.
|
virtual |
Initiate the flash memory device driver and check for valid identification. Return true(1) if the successful otherwise false(0).
Reimplemented from Flash::Device.
Definition at line 24 of file W25X40CL.cpp.
|
inlinestaticinherited |
|
inlinestaticinherited |
|
inlinevirtualinherited |
|
virtual |
Erase given flash block for given byte address. The size of the erased sector/block is either 4/32/64 KB or 255 for chip erase. The flash memory consists of 128 X 4 KB sectors. The highest sector is reserved. Returs zero(0) if successful otherwise an negative error code (EINVAL if illegal sector size).
[in] | dest | destination block byte address to erase. |
[in] | size | of sector to erase in Kbyte (Default 4 KByte). |
Implements Flash::Device.
Definition at line 80 of file W25X40CL.cpp.
|
virtual |
Return true(1) if the device is ready, write cycle is completed, otherwise false(0).
Implements Flash::Device.
Definition at line 46 of file W25X40CL.cpp.
|
protected |
Issue given command and return result.
[in] | cmd | command code. |
Definition at line 205 of file W25X40CL.cpp.
|
virtual |
Read flash block with the given size into the buffer from the source address. Return number of bytes read or negative error code.
[in] | dest | buffer to read from flash into. |
[in] | src | address in flash to read from. |
[in] | size | number of bytes to read. |
Implements Flash::Device.
Definition at line 61 of file W25X40CL.cpp.
|
inline |
|
inherited |
|
inlineinherited |
|
virtual |
Write flash block at given destination address with the contents of the source buffer. Return number of bytes written or negative error code.
[in] | dest | address in flash to write to. |
[in] | src | buffer to write to flash. |
[in] | size | number of bytes to write. |
Implements Flash::Device.
Definition at line 113 of file W25X40CL.cpp.
|
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.
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
Implements Flash::Device.
Definition at line 159 of file W25X40CL.cpp.
|
staticinherited |
|
staticprotected |
Device code
Definition at line 189 of file W25X40CL.hh.
|
inherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
Latest status; is_ready() call
Definition at line 199 of file W25X40CL.hh.
|
staticprotected |
Manufacturer code
Definition at line 186 of file W25X40CL.hh.
|
static |
Definition at line 44 of file W25X40CL.hh.
|
static |
Default programming page buffer size (pp. 61, 97).
Definition at line 43 of file W25X40CL.hh.
|
inherited |
|
inherited |
|
inherited |