PropWare
2.1.2
C++ objects and CMake build system for Parallax Propeller
|
Click here for docs on the
develop
branch.
#include <i2c_base.h>
Public Member Functions | |
void | Init (const int scl=28, const int sda=29, const int frequency=400000) |
void | SetFrequency (const int frequency) |
void | Start (void) |
void | Stop (void) |
bool | SendByte (const unsigned char byte) |
unsigned char | ReadByte (const bool acknowledge) |
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).
Definition at line 21 of file i2c_base.h.
void libpropeller::I2CBase::Init | ( | const int | scl = 28 , |
const int | sda = 29 , |
||
const int | frequency = 400000 |
||
) |
Set the IO Pins to float high. Does not require a cog.
Sets the bus speed to 444kHz.
scl | The I2C SCL pin. Defaults to the Propeller default SCL pin. |
sda | The I2C SDA pin. Defaults to the Propeller default SDA pin. |
frequency | The frequency in hz to run the bus at. |
Definition at line 32 of file i2c_base.h.
unsigned char libpropeller::I2CBase::ReadByte | ( | const bool | acknowledge | ) |
Get a byte from the I2C bus.
acknowledge | true to acknowledge the byte received, false otherwise. |
Definition at line 156 of file i2c_base.h.
bool libpropeller::I2CBase::SendByte | ( | const unsigned char | byte | ) |
Output a byte on the I2C bus.
byte | the 8 bits to send on the bus. |
Definition at line 92 of file i2c_base.h.
void libpropeller::I2CBase::SetFrequency | ( | const int | frequency | ) |
frequency | The frequency in hz to run the bus at. |
Definition at line 53 of file i2c_base.h.
void libpropeller::I2CBase::Start | ( | void | ) |
Output a start condition on the I2C bus.
Definition at line 73 of file i2c_base.h.
void libpropeller::I2CBase::Stop | ( | void | ) |
Output a stop condition on the I2C bus.
Definition at line 82 of file i2c_base.h.