libpropeller
Making PropellerGCC Easier
|
#include <i2c_base.h>
Public Member Functions | |
void | Init (const int scl=28, const int sda=29, const int frequency=400000) |
Set the IO Pins to float high. More... | |
void | SetFrequency (const int frequency) |
void | Start (void) |
Output a start condition on the I2C bus. More... | |
void | Stop (void) |
Output a stop condition on the I2C bus. More... | |
bool | SendByte (const unsigned char byte) |
Output a byte on the I2C bus. More... | |
unsigned char | ReadByte (const bool acknowledge) |
Get a byte from the I2C bus. More... | |
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).
|
inline |
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. |
|
inline |
Get a byte from the I2C bus.
acknowledge | true to acknowledge the byte received, false otherwise. |
|
inline |
Output a byte on the I2C bus.
byte | the 8 bits to send on the bus. |
|
inline |
frequency | The frequency in hz to run the bus at. |
|
inline |
Output a start condition on the I2C bus.
|
inline |
Output a stop condition on the I2C bus.