Bare Metal Programming Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Static Public Member Functions | List of all members
bmptk::hardware::i2c_master< extern_scl, extern_sda, frequency > Class Template Reference

simple I2C bus master More...

#include <i2c.h>

Inheritance diagram for bmptk::hardware::i2c_master< extern_scl, extern_sda, frequency >:
bmptk::hardware::i2c_interface

Static Public Member Functions

static void init ()
 initialize the i2c pins
 
static void put_start ()
 output an i2c start condition
 
static void put_stop ()
 output an i2c stop condition
 
static bool get_ack ()
 receive and return an ack
 
static void put_ack ()
 output an ack
 
static void put_nack ()
 output a nack
 
static void put_byte (unsigned char x)
 output a byte
 
static unsigned char get_byte ()
 receive and return a byte (without ack or nack)
 
- Static Public Member Functions inherited from bmptk::hardware::i2c_interface
static void init ()
 initialize the i2c bus
 
static void put_start ()
 output an I2C start condition
 
static void put_stop ()
 output an I2C stop condition
 
static bool get_ack ()
 get an acknowledge
 
static void put_ack ()
 output an ack
 
static void put_nack ()
 output a nack
 
static void put_byte (unsigned char x)
 output a byte, 8 bits, MSB first
 
static unsigned char get_byte ()
 get (receive) a byte, 8 bits, MSB first
 
static void write (unsigned char address, unsigned const char *data, int n)
 multi-byte write transaction
 
static void read (unsigned char address, unsigned char *data, int n)
 multi-byte read transaction
 

Additional Inherited Members

- Public Types inherited from bmptk::hardware::i2c_interface
enum  { type = type_i2c_bus }
 identify this type as an i2c bus
 

Detailed Description

template<class extern_scl, class extern_sda, unsigned int frequency = 1 * bmptk::MHz>
class bmptk::hardware::i2c_master< extern_scl, extern_sda, frequency >

simple I2C bus master

This class implements a simple bit-banged (software-only) I2C bus master. It does not support clock stretching.

The last parameter is the (maximum) frequency of the clock. For higher frequency arguments, the actual frequency will be limited by the target's bmptk::current_time() calls. On an LPC1114 at 12 MHz, the real maximum frequency is ~ 50 kHz.

Definition at line 118 of file i2c.h.


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