Skip to content

Commit a2ad29b

Browse files
committed
Add api to free I2C object
ARMmbed#15191
1 parent 3827c56 commit a2ad29b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

drivers/include/drivers/I2C.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class I2C : private NonCopyable<I2C> {
168168
*/
169169
int write(int data);
170170

171+
/** Frees the i2c object, allowing us to sleeps
172+
*/
173+
void free(void);
174+
171175
/** Creates a start condition on the I2C bus
172176
*/
173177
void start(void);

drivers/source/I2C.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ int I2C::read(int ack)
113113
return ret;
114114
}
115115

116+
void I2C::free(void)
117+
{
118+
lock();
119+
i2c_free(&_i2c);
120+
unlock();
121+
}
122+
116123
void I2C::start(void)
117124
{
118125
lock();

0 commit comments

Comments
 (0)