PropWare
C++ objects and CMake build system for Parallax Propeller
|
Low level I2C driver. Only does the most basic functions that all I2C devices implement. More...
#include <i2cbase.h>
Public Member Functions | |
I2CBase (const Pin::Mask sclMask=DEFAULT_SCL_MASK, const Pin::Mask sdaMask=DEFAULT_SDA_MASK, const unsigned int frequency=DEFAULT_FREQUENCY) | |
Set the IO Pins to float high; Does not require a cog. More... | |
void | set_frequency (const unsigned int frequency) |
Set the bus frequency. More... | |
void | start () const |
Output a start condition on the I2C bus. | |
void | stop () const |
Output a stop condition on the I2C bus. | |
bool | send_byte (const uint8_t byte) const |
Output a byte on the I2C bus. More... | |
uint8_t | read_byte (const bool acknowledge) const |
Get a byte from the bus. More... | |
Static Public Attributes | |
static const Pin::Mask | DEFAULT_SCL_MASK = Pin::P28 |
static const Pin::Mask | DEFAULT_SDA_MASK = Pin::P29 |
static const unsigned int | DEFAULT_FREQUENCY = 400000 |
Low level I2C driver. Only does the most basic functions that all I2C devices implement.
Requires that the SDA and SCL pins have sufficient pullups. These should be selected based on the capacitance of the devices on the I2C bus, and the expected clock speed (400kHz currently).
PropWare::I2CBase::I2CBase | ( | const Pin::Mask | sclMask = DEFAULT_SCL_MASK , |
const Pin::Mask | sdaMask = DEFAULT_SDA_MASK , |
||
const unsigned int | frequency = DEFAULT_FREQUENCY |
||
) |
Set the IO Pins to float high; Does not require a cog.
[in] | sclMask | SCL pin mask; Defaults to the Propeller default SCL pin. |
[in] | sdaMask | SDA pin mask; Defaults to the Propeller default SDA pin. |
[in] | frequency | Frequency in Hz to run the bus |
Definition at line 56 of file i2cbase.h.
uint8_t PropWare::I2CBase::read_byte | ( | const bool | acknowledge | ) | const |
bool PropWare::I2CBase::send_byte | ( | const uint8_t | byte | ) | const |
void PropWare::I2CBase::set_frequency | ( | const unsigned int | frequency | ) |