|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
57 const bool autoIncrement =
true)
59 m_memoryAddress(initialMemoryAddress),
60 m_deviceAddress(deviceAddress),
61 m_autoIncrement(autoIncrement) { }
69 return this->m_driver->
ping(this->m_deviceAddress);
80 bool put(
const uint16_t address,
const uint8_t
byte)
const {
82 while (!this->
ping());
84 return this->m_driver->
put(this->m_deviceAddress, address,
byte);
96 bool put(
const uint16_t startAddress,
const uint8_t bytes[],
const size_t length)
const {
98 while (!this->
ping());
100 return this->m_driver->
put(this->m_deviceAddress, startAddress, bytes, length);
109 this->
put(this->m_memoryAddress, (uint8_t) c);
110 if (this->m_autoIncrement)
111 ++this->m_memoryAddress;
119 virtual void puts(
const char *
string) {
120 const size_t stringLength = strlen(
string);
121 this->
put(this->m_memoryAddress, (
const uint8_t *)
string, stringLength);
122 if (this->m_autoIncrement)
123 this->m_memoryAddress += stringLength;
133 uint8_t
get(
const uint16_t address)
const {
135 while (!this->
ping());
137 return this->m_driver->
get(this->m_deviceAddress, address);
149 bool get(
const uint16_t address, uint8_t *buffer,
const size_t length)
const {
151 while (!this->
ping());
153 return this->m_driver->
get(this->m_deviceAddress, address, buffer, length);
162 const uint8_t
byte = this->
get(this->m_memoryAddress);
163 if (this->m_autoIncrement)
164 ++this->m_memoryAddress;
174 return this->m_memoryAddress;
183 this->m_memoryAddress = address;
192 return m_autoIncrement;
201 m_autoIncrement = autoIncrement;
206 uint16_t m_memoryAddress;
207 const uint8_t m_deviceAddress;
208 bool m_autoIncrement;
bool put(const uint16_t startAddress, const uint8_t bytes[], const size_t length) const
Place multiple bytes of data into sequential memory locations in EEPROM.
bool ping() const
Check that the EEPROM is responding.
bool is_auto_increment() const
Determine if auto incrementing of the internal address pointer is enabled.
bool put(const uint8_t device, const T address, const uint8_t byte) const
Put a single byte with the following format:
Interface for all classes capable of printing.
PropWare::I2CMaster pwI2c
Global I2C instance for easy and shared use by Propeller applications (not thread safe!...
Eeprom(const I2CMaster &driver=pwI2c, const uint16_t initialMemoryAddress=DEFAULT_INITIAL_MEMORY_ADDRESS, const uint8_t deviceAddress=DEFAULT_DEVICE_ADDRESS, const bool autoIncrement=true)
Construct an instance that, by default, will read from and write to the standard EEPROM.
static const uint16_t DEFAULT_INITIAL_MEMORY_ADDRESS
virtual void put_char(const char c)
uint8_t get(const uint16_t address) const
Read a byte from EEPROM.
bool put(const uint16_t address, const uint8_t byte) const
Place a byte of data into a specific address.
Interface for all classes capable of printing.
void set_memory_address(const uint16_t address)
Set the current address of the internal pointer.
void set_auto_increment(const bool autoIncrement)
Set auto incrementing of the internal address pointer to enabled or disabled.
uint8_t get(const uint8_t device, const T address) const
Get a single byte with the following format:
bool ping(const uint8_t device) const
Test for the Acknowledge of a device by sending start and the slave address.
uint16_t get_memory_address() const
Retrieve the current address of the internal pointer.
virtual void puts(const char *string)
static const uint8_t DEFAULT_DEVICE_ADDRESS
Generic definitions and functions for the Parallax Propeller.
bool get(const uint16_t address, uint8_t *buffer, const size_t length) const
Read an array of sequential bytes from EEPROM.