libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
I2CBase Class Reference

Low level I2C driver. More...

#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...
 

Detailed Description

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).

Author
SRLM

Member Function Documentation

void I2CBase::Init ( const int  scl = 28,
const int  sda = 29,
const int  frequency = 400000 
)
inline

Set the IO Pins to float high.

Does not require a cog.

Sets the bus speed to 444kHz.

Parameters
sclThe I2C SCL pin. Defaults to the Propeller default SCL pin.
sdaThe I2C SDA pin. Defaults to the Propeller default SDA pin.
frequencyThe frequency in hz to run the bus at.

Here is the call graph for this function:

unsigned char I2CBase::ReadByte ( const bool  acknowledge)
inline

Get a byte from the I2C bus.

Parameters
acknowledgetrue to acknowledge the byte received, false otherwise.
Returns
the byte clocked in off the bus.
bool I2CBase::SendByte ( const unsigned char  byte)
inline

Output a byte on the I2C bus.

Parameters
bytethe 8 bits to send on the bus.
Returns
true if the device acknowledges, false otherwise.
void I2CBase::SetFrequency ( const int  frequency)
inline
Parameters
frequencyThe frequency in hz to run the bus at.
void I2CBase::Start ( void  )
inline

Output a start condition on the I2C bus.

void I2CBase::Stop ( void  )
inline

Output a stop condition on the I2C bus.


The documentation for this class was generated from the following file: