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.
Fork of tilt_angles by
ENGO333_I2C.cpp
00001 #include "ENGO333_I2C.h" 00002 00003 ENGO333_I2C::ENGO333_I2C(PinName sda, PinName scl) : i2c(sda, scl) 00004 { 00005 // Do nothing 00006 } 00007 00008 ENGO333_I2C::~ENGO333_I2C() 00009 { 00010 // Do nothing 00011 } 00012 00013 void ENGO333_I2C::setSpeed(int freq) 00014 { 00015 this->i2c.frequency(freq); 00016 } 00017 00018 void ENGO333_I2C::writeOneByte(char deviceAddress, char registerAddress, char value) 00019 { 00020 char temp[2]; 00021 temp[0] = registerAddress; 00022 temp[1] = value; 00023 this->i2c.write(deviceAddress, temp, 2); 00024 } 00025 00026 char ENGO333_I2C::readOneByte(char deviceAddress, char registerAddress) 00027 { 00028 char temp = 0; 00029 this->i2c.write(deviceAddress, ®isterAddress, 1); 00030 this->i2c.read(deviceAddress, &temp, 1); 00031 return (char)temp; 00032 } 00033 00034 void ENGO333_I2C::readBytes(char deviceAddress, char registerAddress, char* value, int length) 00035 { 00036 this->i2c.write(deviceAddress, ®isterAddress, 1); 00037 this->i2c.read(deviceAddress, value, length); 00038 } 00039
Generated on Sat Jul 16 2022 15:16:04 by
1.7.2
