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/FunctionPointer.h" 95 I2C(PinName sda, PinName scl);
118 int read(
int address,
char *data,
int length,
bool repeated =
false);
144 int write(
int address,
const char *data,
int length,
bool repeated =
false);
167 virtual void lock(
void);
171 virtual void unlock(
void);
178 #if DEVICE_I2C_ASYNCH 196 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);
202 #if !defined(DOXYGEN_ONLY) 205 void lock_deep_sleep();
208 void unlock_deep_sleep();
210 void irq_handler_asynch(
void);
214 bool _deep_sleep_locked;
218 #if !defined(DOXYGEN_ONLY) 241 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.