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.
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
PowerAwareI2C.h
00001 #ifndef _H_POWERAWAREI2C_H 00002 #define _H_POWERAWAREI2C_H 00003 00004 #include "mbed.h" 00005 #include "i2c_api.h" 00006 00007 /// This is a variation of I2C class from mbed, which adds power on and off functions to the I2C peripheral. This should save about 1 mA. 00008 class PowerAwareI2C : public I2C 00009 { 00010 public: 00011 PowerAwareI2C(PinName sda, PinName scl) : I2C(sda, scl) {} 00012 00013 /// Power on the I2C peripheral 00014 void powerOn() { 00015 _i2c.i2c->ENABLE = (TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos); 00016 } 00017 00018 /// Power off the I2C peripheral 00019 void powerOff() { 00020 _i2c.i2c->ENABLE = TWI_ENABLE_ENABLE_Disabled << TWI_ENABLE_ENABLE_Pos; 00021 _i2c.i2c->POWER = 0; 00022 } 00023 }; 00024 00025 #endif//_H_POWERAWAREI2C_H
Generated on Wed Jul 13 2022 08:50:41 by
