PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Embed: (wiki syntax)

« Back to documentation index

SoftwareI2C Class Reference

SoftwareI2C Class Reference

SoftwareI2C class. More...

#include <SoftwareI2C.h>

Public Member Functions

 SoftwareI2C (PinName sda, PinName scl)
 Initializes interface.
void read (uint8_t device_address, uint8_t *data, uint8_t data_bytes)
 Read 1 or more bytes from the I2C slave.
void write (uint8_t device_address, uint8_t *data, uint8_t data_bytes)
 Write 1 or more bytes to the I2C slave.
void write (uint8_t device_address, uint8_t byte)
 Write 1 byte to the I2C slave.
void randomRead (uint8_t device_address, uint8_t start_address, uint8_t *data, uint8_t data_bytes)
 Read 1 or more bytes from the I2C slave at the specified memory address.
void randomWrite (uint8_t device_address, uint8_t start_address, uint8_t *data, uint8_t data_bytes)
 Write 1 or more bytes to the I2C slave at the specified memory address.
void randomWrite (uint8_t device_address, uint8_t start_address, uint8_t byte)
 Write 1 byte to the I2C slave at the specified memory address.
uint16_t read16 (uint8_t device_address, uint8_t start_address)
 Read 2 bytes from the I2C slave at the specified memory address and return them as an 16bit unsigned integer.
uint32_t read24 (uint8_t device_address, uint8_t start_address)
 Read 3 bytes from the I2C slave at the specified memory address and return them as an 32bit unsigned integer.
uint32_t read32 (uint8_t device_address, uint8_t start_address)
 Read 4 bytes from the I2C slave at the specified memory address and return them as an 32bit unsigned integer.

Detailed Description

SoftwareI2C class.

Definition at line 16 of file SoftwareI2C.h.


Constructor & Destructor Documentation

SoftwareI2C ( PinName  sda,
PinName  scl 
)

Initializes interface.

Parameters:
sdaGPIO pin to use as I2C SDA
sclGPIO pin to use as I2C SCL

Definition at line 15 of file SoftwareI2C.cpp.


Member Function Documentation

void randomRead ( uint8_t  device_address,
uint8_t  start_address,
uint8_t *  data,
uint8_t  data_bytes 
)

Read 1 or more bytes from the I2C slave at the specified memory address.

Parameters:
device_addressThe address of the device to read from
start_addressThe memory address to read from
dataThe allocated array to read into
data_bytesThe number of bytes to read

Definition at line 95 of file SoftwareI2C.cpp.

void randomWrite ( uint8_t  device_address,
uint8_t  start_address,
uint8_t *  data,
uint8_t  data_bytes 
)

Write 1 or more bytes to the I2C slave at the specified memory address.

Parameters:
device_addressThe address of the device to write to
start_addressThe memory address to write to
dataThe data to write
data_bytesThe number of bytes to write

Definition at line 147 of file SoftwareI2C.cpp.

void randomWrite ( uint8_t  device_address,
uint8_t  start_address,
uint8_t  byte 
)

Write 1 byte to the I2C slave at the specified memory address.

Parameters:
device_addressThe address of the device to write to
start_addressThe memory address to write to
byteThe data to write

Definition at line 128 of file SoftwareI2C.cpp.

void read ( uint8_t  device_address,
uint8_t *  data,
uint8_t  data_bytes 
)

Read 1 or more bytes from the I2C slave.

Parameters:
device_addressThe address of the device to read from
dataAn allocated array to read the data into
data_bytesNumber of bytes to read (must be equal to or less then the allocated memory in data)

Definition at line 37 of file SoftwareI2C.cpp.

uint16_t read16 ( uint8_t  device_address,
uint8_t  start_address 
)

Read 2 bytes from the I2C slave at the specified memory address and return them as an 16bit unsigned integer.

Parameters:
device_addressThe address of the device to read from
start_addressThe memory address to read from
Returns:
MSB 16bit unsigned integer

Definition at line 169 of file SoftwareI2C.cpp.

uint32_t read24 ( uint8_t  device_address,
uint8_t  start_address 
)

Read 3 bytes from the I2C slave at the specified memory address and return them as an 32bit unsigned integer.

Parameters:
device_addressThe address of the device to read from
start_addressThe memory address to read from
Returns:
MSB 32bit unsigned integer

Definition at line 185 of file SoftwareI2C.cpp.

uint32_t read32 ( uint8_t  device_address,
uint8_t  start_address 
)

Read 4 bytes from the I2C slave at the specified memory address and return them as an 32bit unsigned integer.

Parameters:
device_addressThe address of the device to read from
start_addressThe memory address to read from
Returns:
MSB 32bit unsigned integer

Definition at line 202 of file SoftwareI2C.cpp.

void write ( uint8_t  device_address,
uint8_t  byte 
)

Write 1 byte to the I2C slave.

Parameters:
device_addressThe address of the device to write to
byteThe data to write

Definition at line 78 of file SoftwareI2C.cpp.

void write ( uint8_t  device_address,
uint8_t *  data,
uint8_t  data_bytes 
)

Write 1 or more bytes to the I2C slave.

Parameters:
device_addressThe address of the device to write to
dataAn array to write the data from
data_bytesNumber of bytes to write from array

Definition at line 59 of file SoftwareI2C.cpp.