mirror of https://github.com/ARMmbed/mbed-os.git
I2CReset is not required as I2C driver does the recovery before init
parent
ccb08a3fa1
commit
a30da7e61e
|
@ -29,30 +29,9 @@
|
|||
#define EUI64_LEN 8
|
||||
#define EUI48_LEN 6
|
||||
|
||||
AT24Mac::I2CReset::I2CReset(PinName sda, PinName scl)
|
||||
{
|
||||
mbed::DigitalInOut pin_sda(sda, PIN_OUTPUT, PullUp, 1);
|
||||
mbed::DigitalInOut pin_scl(scl, PIN_OUTPUT, PullUp, 0);
|
||||
//generate 9 clocks for worst-case scenario
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
pin_scl = 1;
|
||||
wait_us(5);
|
||||
pin_scl = 0;
|
||||
wait_us(5);
|
||||
}
|
||||
//generate a STOP condition
|
||||
pin_sda = 0;
|
||||
wait_us(5);
|
||||
pin_scl = 1;
|
||||
wait_us(5);
|
||||
pin_sda = 1;
|
||||
wait_us(5);
|
||||
}
|
||||
using namespace mbed;
|
||||
|
||||
/*I2C needs to be reset before constructing the I2C object (in case I2C is stuck)
|
||||
because they use the same pins, therefore i2c_reset has to be before _i2c
|
||||
in the initializer list*/
|
||||
AT24Mac::AT24Mac(PinName sda, PinName scl) : i2c_reset(sda, scl), _i2c(sda, scl)
|
||||
AT24Mac::AT24Mac(PinName sda, PinName scl) : _i2c(sda , scl)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
|
|
@ -59,15 +59,6 @@ public:
|
|||
int read_eui48(void *buf);
|
||||
|
||||
private:
|
||||
/*
|
||||
* Dummy class to allow us to reset I2C before the I2C constructor is called in
|
||||
* the initializer list of AT24Mac's constructor
|
||||
*/
|
||||
class I2CReset {
|
||||
public:
|
||||
I2CReset(PinName sda, PinName scl);
|
||||
};
|
||||
I2CReset i2c_reset;
|
||||
mbed::I2C _i2c;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue