mirror of https://github.com/ARMmbed/mbed-os.git
Changed I2C default instance to use placement new
parent
ffcc850104
commit
b440d72114
|
|
@ -23,7 +23,7 @@ I2CEEBlockDevice::I2CEEBlockDevice(
|
|||
bd_size_t size, bd_size_t block, int freq)
|
||||
: _i2c_addr(addr), _size(size), _block(block)
|
||||
{
|
||||
_i2c = new I2C(sda, scl);
|
||||
_i2c = new (_i2c_buffer) I2C(sda, scl);
|
||||
_i2c->frequency(freq);
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +36,9 @@ I2CEEBlockDevice::I2CEEBlockDevice(
|
|||
}
|
||||
I2CEEBlockDevice::~I2CEEBlockDevice()
|
||||
{
|
||||
_i2c->~I2C();
|
||||
if (_i2c == (I2C*)_i2c_buffer) {
|
||||
_i2c->~I2C();
|
||||
}
|
||||
}
|
||||
|
||||
int I2CEEBlockDevice::init()
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ public:
|
|||
|
||||
private:
|
||||
I2C * _i2c;
|
||||
uint32_t _i2c_buffer[sizeof(I2C) / sizeof(uint32_t)];
|
||||
uint8_t _i2c_addr;
|
||||
uint32_t _size;
|
||||
uint32_t _block;
|
||||
|
|
|
|||
Loading…
Reference in New Issue