distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::devices::anonymous_namespace{SpiEeprom.cpp} Namespace Reference

Typedefs

using CommandWithAddressBuffer = std::array< uint8_t, 4 >
 buffer for command and address More...
 

Functions

SpiMasterTransfer getCommandWithAddress (const size_t capacity, const uint8_t command, const uint32_t address, CommandWithAddressBuffer &buffer)
 Combines command with address into a SpiMasterTransfer. More...
 

Variables

constexpr uint8_t rdsrCommand {0x5}
 RDSR (read status register) command. More...
 
constexpr uint8_t readCommand {0x3}
 READ command. More...
 
constexpr uint8_t wrenCommand {0x6}
 WREN (write enable) command. More...
 
constexpr uint8_t writeCommand {0x2}
 WRITE command. More...
 
constexpr uint8_t statusRegisterWip {1 << 0}
 mask of WIP (write in progress) bit in status register More...
 

Typedef Documentation

◆ CommandWithAddressBuffer

using distortos::devices::anonymous_namespace{SpiEeprom.cpp}::CommandWithAddressBuffer = typedef std::array<uint8_t, 4>

buffer for command and address

Function Documentation

◆ getCommandWithAddress()

SpiMasterTransfer distortos::devices::anonymous_namespace{SpiEeprom.cpp}::getCommandWithAddress ( const size_t  capacity,
const uint8_t  command,
const uint32_t  address,
CommandWithAddressBuffer buffer 
)

Combines command with address into a SpiMasterTransfer.

The address for READ and WRITE commands is encoded into variable number of bytes, depending on capacity of EEPROM chip:

  • capacity <= 256 bytes - 1 byte for address,
  • capacity == 512 bytes - 1 byte for address, MSB of address (9th bit) is placed at 4th bit of command,
  • 512 bytes < capacity <= 64k bytes - 2 bytes for address,
  • 64k bytes < capacity - 3 bytes for address.

The address is always big-endian.

Parameters
[in]capacityis the capacity of EEPROM, bytes
[in]commandis the command that will be combined with address into buffer, {readCommand, writeCommand}
[in]addressis the address that will be combined with command into buffer
[out]bufferis a reference to buffer into which command and address will be combined
Returns
SpiMasterTransfer with combined command and address
Here is the caller graph for this function:

Variable Documentation

◆ rdsrCommand

constexpr uint8_t distortos::devices::anonymous_namespace{SpiEeprom.cpp}::rdsrCommand {0x5}

RDSR (read status register) command.

◆ readCommand

constexpr uint8_t distortos::devices::anonymous_namespace{SpiEeprom.cpp}::readCommand {0x3}

READ command.

◆ statusRegisterWip

constexpr uint8_t distortos::devices::anonymous_namespace{SpiEeprom.cpp}::statusRegisterWip {1 << 0}

mask of WIP (write in progress) bit in status register

◆ wrenCommand

constexpr uint8_t distortos::devices::anonymous_namespace{SpiEeprom.cpp}::wrenCommand {0x6}

WREN (write enable) command.

◆ writeCommand

constexpr uint8_t distortos::devices::anonymous_namespace{SpiEeprom.cpp}::writeCommand {0x2}

WRITE command.