Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 120_robot_H_Bridge8835_UserButton_DIR_PWM_I2C_LCD 140_robot_H_Bridge8835_DIR_PWM_US_LCD xxx_Uhr_I2C_LCD_Delay_Bua xxx_Uhr_I2C_LCD_Delay_BuaV ... more
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:
-
sda GPIO pin to use as I2C SDA scl GPIO 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_address The address of the device to read from start_address The memory address to read from data The allocated array to read into data_bytes The number of bytes to read
Definition at line 97 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_address The address of the device to write to start_address The memory address to write to data The data to write data_bytes The number of bytes to write
Definition at line 149 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_address The address of the device to write to start_address The memory address to write to byte The data to write
Definition at line 130 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_address The address of the device to read from data An allocated array to read the data into data_bytes Number 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_address The address of the device to read from start_address The memory address to read from
- Returns:
- MSB 16bit unsigned integer
Definition at line 171 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_address The address of the device to read from start_address The memory address to read from
- Returns:
- MSB 32bit unsigned integer
Definition at line 187 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_address The address of the device to read from start_address The memory address to read from
- Returns:
- MSB 32bit unsigned integer
Definition at line 204 of file SoftwareI2C.cpp.
void write | ( | uint8_t | device_address, |
uint8_t | byte | ||
) |
Write 1 byte to the I2C slave.
- Parameters:
-
device_address The address of the device to write to byte The data to write
Definition at line 80 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_address The address of the device to write to data An array to write the data from data_bytes Number of bytes to write from array
Definition at line 60 of file SoftwareI2C.cpp.
Generated on Tue Jul 26 2022 02:31:18 by
