20 #include "platform/platform.h" 21 #include "hal/gpio_api.h" 23 #if DEVICE_I2C || defined(DOXYGEN_ONLY) 25 #include "hal/i2c_api.h" 26 #include "platform/SingletonPtr.h" 27 #include "platform/PlatformMutex.h" 28 #include "platform/NonCopyable.h" 31 #include "platform/CThunk.h" 32 #include "hal/dma_api.h" 33 #include "platform/Callback.h" 102 I2C(PinName sda, PinName scl);
132 int read(
int address,
char *data,
int length,
bool repeated =
false);
158 int write(
int address,
const char *data,
int length,
bool repeated =
false);
181 virtual void lock(
void);
185 virtual void unlock(
void);
192 #if DEVICE_I2C_ASYNCH 210 int transfer(
int address,
const char *tx_buffer,
int tx_length,
char *rx_buffer,
int rx_length,
const event_callback_t &
callback,
int event = I2C_EVENT_TRANSFER_COMPLETE,
bool repeated =
false);
216 #if !defined(DOXYGEN_ONLY) 219 void lock_deep_sleep();
222 void unlock_deep_sleep();
224 void irq_handler_asynch(
void);
228 bool _deep_sleep_locked;
232 #if !defined(DOXYGEN_ONLY) 255 int recover(PinName sda, PinName scl);
void frequency(int hz)
Set the frequency of the I2C interface.
virtual void lock(void)
Acquire exclusive access to this I2C bus.
int write(int address, const char *data, int length, bool repeated=false)
Write to an I2C slave.
int transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t &callback, int event=I2C_EVENT_TRANSFER_COMPLETE, bool repeated=false)
Start nonblocking I2C transfer.
Asynch I2C HAL structure.
An I2C Master, used for communicating with I2C slave devices.
Prevents generation of copy constructor and copy assignment operator in derived classes.
void start(void)
Creates a start condition on the I2C bus.
void stop(void)
Creates a stop condition on the I2C bus.
void abort_transfer()
Abort the ongoing I2C transfer.
Class for created a pointer with data bound to it.
int read(int address, char *data, int length, bool repeated=false)
Read from an I2C slave.
virtual void unlock(void)
Release exclusive access to this I2C bus.
I2C(PinName sda, PinName scl)
Create an I2C Master interface, connected to the specified pins.