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 "rtos/Mutex.h"
28#include "platform/NonCopyable.h"
31#include "platform/CThunk.h"
33#include "platform/Callback.h"
236 I2C(PinName sda, PinName scl);
270 Result read(
int address,
char *data,
int length,
bool repeated =
false);
285 Result write(
int address,
const char *data,
int length,
bool repeated =
false);
352 MBED_DEPRECATED_SINCE(
"mbed-ce",
"Use I2C::write_byte() instead for better readability and return codes")
439#if !defined(DOXYGEN_ONLY)
442 void lock_deep_sleep();
445 void unlock_deep_sleep();
447 void irq_handler_asynch(
void);
451 bool _deep_sleep_locked;
455#if !defined(DOXYGEN_ONLY)
476 int recover(PinName sda, PinName scl);
Class for created a pointer with data bound to it.
An I2C Master, used for communicating with I2C slave devices.
Result read(int address, char *data, int length, bool repeated=false)
Read from an I2C slave.
Result transfer_and_wait(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, rtos::Kernel::Clock::duration_u32 timeout=rtos::Kernel::wait_for_u32_forever, bool repeated=false)
Start I2C transfer and wait until it is complete.
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.
Result write_byte(int data)
Write a single byte out on the I2C bus.
int read(int ack)
Read a single byte from the I2C bus.
virtual void unlock(void)
Release exclusive access to this I2C bus.
int read_byte(bool ack)
Read a single byte from the I2C bus.
I2C(const i2c_pinmap_t &static_pinmap)
Create an I2C Master interface, connected to the specified pins.
Result write(int address, const char *data, int length, bool repeated=false)
Write to an I2C slave.
void abort_transfer()
Abort the ongoing I2C transfer.
void stop(void)
Creates a stop condition on the I2C bus.
void frequency(int hz)
Set the frequency of the I2C interface.
virtual void lock(void)
Acquire exclusive access to this I2C bus.
I2C(PinName sda, PinName scl)
Create an I2C Master interface, connected to the specified pins.
void start(void)
Creates a start condition on the I2C bus.
Result
Result code for I2C operations.
@ TIMEOUT
Timeout waiting for I2C hardware.
@ OTHER_ERROR
Other error in I2C operation.
Prevents generation of copy constructor and copy assignment operator in derived classes.
#define I2C_EVENT_TRANSFER_COMPLETE
Indicates that the transfer completed successfully.
DMAUsage
Enumeration of possible DMA usage hints.
constexpr Clock::duration_u32 wait_for_u32_forever
Magic "wait forever" constant for Kernel::Clock::duration_u32-based APIs.
Utility class for creating and using a singleton.
Asynch I2C HAL structure.