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);
139 int read(
int address,
char *data,
int length,
bool repeated =
false);
165 int write(
int address,
const char *data,
int length,
bool repeated =
false);
188 virtual void lock(
void);
192 virtual void unlock(
void);
194 #if DEVICE_I2C_ASYNCH 212 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);
218 #if !defined(DOXYGEN_ONLY) 221 void lock_deep_sleep();
224 void unlock_deep_sleep();
228 bool _deep_sleep_locked;
229 bool _async_transfer_ongoing;
233 #if !defined(DOXYGEN_ONLY) 256 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.
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.
Structure describing the status of async transfer.
void stop(void)
Creates a stop condition on the I2C bus.
void timeout(uint32_t timeout)
Configure the timeout duration in microseconds for blocking transmission.
void abort_transfer()
Abort the ongoing I2C transfer.
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.