2026-05-19 11:49:22 +08:00
|
|
|
#ifndef INCLUDED_DRV_SOFTI2C_H
|
|
|
|
|
#define INCLUDED_DRV_SOFTI2C_H
|
|
|
|
|
|
|
|
|
|
#ifndef INCLUDED_DRV_DEVICE_H
|
|
|
|
|
#include <drv_device.h>
|
|
|
|
|
#endif /*INCLUDED_DRV_DEVICE_H*/
|
|
|
|
|
|
|
|
|
|
typedef struct drv_softi2c_t drv_softi2c_t;
|
|
|
|
|
|
|
|
|
|
struct drv_softi2c_t{
|
2026-05-19 22:34:08 +08:00
|
|
|
drv_device_t device;
|
|
|
|
|
os_err_t (*put)(void* self, uint8_t data);
|
|
|
|
|
os_err_t (*get)(void* self, uint8_t ack, uint8_t* data);
|
|
|
|
|
os_err_t (*wait_ack)(void* handle);
|
2026-05-19 11:49:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define drv_softi2c_start(dev) drv_device_open(dev)
|
|
|
|
|
#define drv_softi2c_stop(dev) drv_device_close(dev)
|
2026-05-19 22:34:08 +08:00
|
|
|
#define drv_softi2c_put(dev, data) ((drv_softi2c_t*)(dev->handle))->put((dev)->handle, (data))
|
|
|
|
|
#define drv_softi2c_get(dev, ack, data) ((drv_softi2c_t*)(dev->handle))->get((dev)->handle, (ack), (data))
|
2026-05-19 22:44:32 +08:00
|
|
|
#define drv_softi2c_wait_ack(dev) ((drv_softi2c_t*)(dev->handle))->wait_ack((dev)->handle)
|
2026-05-19 11:49:22 +08:00
|
|
|
|
|
|
|
|
#endif /*INCLUDED_DRV_SOFTI2C_H*/
|