Shield Code 6.0
Loading...
Searching...
No Matches
AT25M02 Class Reference

Interfaces with the AT25M02 EEPROM chip. More...

#include <AT25M02.hpp>

Public Member Functions

 AT25M02 ()
 
void init ()
 Initialize the AT25M02 EEPROM device. Define spi settings, chip select pin, and set initial variables to zero.
 
bool writeData (byte *bytes, uint32_t length)
 Write from the given array to the memory. This data is appended to the end of the queue. Returns true if it successfully wrote all bytes. Returns false if it could not write every byte without overwriting existing data.
 
int readData (byte *dest, uint32_t length)
 Write the given number of bytes from the ram into the destination array. These bytes are taken from the start of the queue. Returns how many bytes were read and written to the array.
 
uint32_t freeBytes ()
 Returns how many bytes are free and available to be written to.
 
uint32_t usedBytes ()
 Returns the number of bytes currently being used.
 
bool isReady ()
 Checks if the RAM is ready for a new command.
 

Private Member Functions

byte readStatusReg ()
 
uint32_t usedMemoryBytes ()
 
uint32_t freeMemoryBytes ()
 
uint32_t usedBufferBytes ()
 
uint32_t freeBufferBytes ()
 
uint32_t readWriteBuffer (byte *dest, uint32_t length)
 
uint32_t readMemory (byte *dest, uint32_t length)
 
void setWRSR (byte val)
 Sets the WRSR (Write status reg)
 
void waitUntilReady ()
 Waits until the RAM is ready to write.
 
void writePage (uint32_t addr, byte *bytes, uint32_t length)
 Write the given data to the RAM in a page write. Increments mem_end when done.
 
void csl ()
 
void csh ()
 
void sendCommand (Command cmd)
 

Private Attributes

uint8_t write_buffer [256]
 
uint32_t wb_end
 
uint32_t mem_start
 
uint32_t mem_end
 
bool ram_full
 
SPISettings spi_settings
 
int chip_select_pin
 

Detailed Description

Interfaces with the AT25M02 EEPROM chip.

Definition at line 32 of file AT25M02.hpp.

Constructor & Destructor Documentation

◆ AT25M02()

AT25M02::AT25M02 ( )
inline

Definition at line 35 of file AT25M02.hpp.

Member Function Documentation

◆ csh()

void AT25M02::csh ( )
private

Definition at line 239 of file AT25M02.cpp.

◆ csl()

void AT25M02::csl ( )
private

Definition at line 231 of file AT25M02.cpp.

◆ freeBufferBytes()

uint32_t AT25M02::freeBufferBytes ( )
private

Definition at line 87 of file AT25M02.cpp.

◆ freeBytes()

uint32_t AT25M02::freeBytes ( )

Returns how many bytes are free and available to be written to.

Definition at line 55 of file AT25M02.cpp.

◆ freeMemoryBytes()

uint32_t AT25M02::freeMemoryBytes ( )
private

Definition at line 77 of file AT25M02.cpp.

◆ init()

void AT25M02::init ( )

Initialize the AT25M02 EEPROM device. Define spi settings, chip select pin, and set initial variables to zero.

Definition at line 39 of file AT25M02.cpp.

◆ isReady()

bool AT25M02::isReady ( )

Checks if the RAM is ready for a new command.

Definition at line 187 of file AT25M02.cpp.

◆ readData()

int AT25M02::readData ( byte *  dest,
uint32_t  length 
)

Write the given number of bytes from the ram into the destination array. These bytes are taken from the start of the queue. Returns how many bytes were read and written to the array.

Definition at line 172 of file AT25M02.cpp.

◆ readMemory()

uint32_t AT25M02::readMemory ( byte *  dest,
uint32_t  length 
)
private

Definition at line 141 of file AT25M02.cpp.

◆ readStatusReg()

byte AT25M02::readStatusReg ( )
private

Definition at line 245 of file AT25M02.cpp.

◆ readWriteBuffer()

uint32_t AT25M02::readWriteBuffer ( byte *  dest,
uint32_t  length 
)
private

Definition at line 130 of file AT25M02.cpp.

◆ sendCommand()

void AT25M02::sendCommand ( Command  cmd)
private

Definition at line 260 of file AT25M02.cpp.

◆ setWRSR()

void AT25M02::setWRSR ( byte  val)
private

Sets the WRSR (Write status reg)

Definition at line 272 of file AT25M02.cpp.

◆ usedBufferBytes()

uint32_t AT25M02::usedBufferBytes ( )
private

Definition at line 82 of file AT25M02.cpp.

◆ usedBytes()

uint32_t AT25M02::usedBytes ( )

Returns the number of bytes currently being used.

Definition at line 63 of file AT25M02.cpp.

◆ usedMemoryBytes()

uint32_t AT25M02::usedMemoryBytes ( )
private

Definition at line 68 of file AT25M02.cpp.

◆ waitUntilReady()

void AT25M02::waitUntilReady ( )
private

Waits until the RAM is ready to write.

Definition at line 289 of file AT25M02.cpp.

◆ writeData()

bool AT25M02::writeData ( byte *  bytes,
uint32_t  length 
)

Write from the given array to the memory. This data is appended to the end of the queue. Returns true if it successfully wrote all bytes. Returns false if it could not write every byte without overwriting existing data.

Definition at line 98 of file AT25M02.cpp.

◆ writePage()

void AT25M02::writePage ( uint32_t  addr,
byte *  bytes,
uint32_t  length 
)
private

Write the given data to the RAM in a page write. Increments mem_end when done.

Definition at line 206 of file AT25M02.cpp.

Member Data Documentation

◆ chip_select_pin

int AT25M02::chip_select_pin
private

Definition at line 128 of file AT25M02.hpp.

◆ mem_end

uint32_t AT25M02::mem_end
private

Definition at line 102 of file AT25M02.hpp.

◆ mem_start

uint32_t AT25M02::mem_start
private

Definition at line 101 of file AT25M02.hpp.

◆ ram_full

bool AT25M02::ram_full
private

Definition at line 103 of file AT25M02.hpp.

◆ spi_settings

SPISettings AT25M02::spi_settings
private

Definition at line 105 of file AT25M02.hpp.

◆ wb_end

uint32_t AT25M02::wb_end
private

Definition at line 100 of file AT25M02.hpp.

◆ write_buffer

uint8_t AT25M02::write_buffer[256]
private

Definition at line 99 of file AT25M02.hpp.


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