驱动优化
This commit is contained in:
+6
-13
@@ -8,22 +8,15 @@
|
||||
typedef struct drv_softi2c_t drv_softi2c_t;
|
||||
|
||||
struct drv_softi2c_t{
|
||||
drv_device_t root;
|
||||
os_uint_t scl_clock;
|
||||
void* scl_port;
|
||||
os_uint_t scl_pin;
|
||||
os_uint_t sda_clock;
|
||||
void* sda_port;
|
||||
os_uint_t sda_pin;
|
||||
os_err_t (*put)(drv_softi2c_t* self, const uint8_t data);
|
||||
os_err_t (*get)(drv_softi2c_t* self, uint8_t* data);
|
||||
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);
|
||||
};
|
||||
|
||||
#define drv_softi2c_start(dev) drv_device_open(dev)
|
||||
#define drv_softi2c_stop(dev) drv_device_close(dev)
|
||||
#define drv_softi2c_put(dev, data) (dev)->put((drv_softi2c_t*)(dev)->handle, data)
|
||||
#define drv_softi2c_get(dev, data) (dev)->get((drv_softi2c_t*)(dev)->handle, data)
|
||||
|
||||
|
||||
#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))
|
||||
|
||||
#endif /*INCLUDED_DRV_SOFTI2C_H*/
|
||||
|
||||
Reference in New Issue
Block a user