驱动优化

This commit is contained in:
2026-05-19 22:34:08 +08:00
parent add7af4222
commit c9efc32d32
8 changed files with 52 additions and 22 deletions
+28
View File
@@ -0,0 +1,28 @@
#ifndef INCLUDED_DRV_SPI_H
#define INCLUDED_DRV_SPI_H
#ifndef INCLUDED_DRV_DEVICE_H
#include <drv_device.h>
#endif /*INCLUDED_DRV_DEVICE_H*/
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
typedef struct {
drv_device_t device;
os_err_t (*cs_low)(void* handle);
os_err_t (*cs_high)(void* handle);
os_err_t (*put)(void* handle, uint8_t data);
os_err_t (*get)(void* handle, uint8_t* data);
os_err_t (*send_halfword)(void* handle, uint16_t data);
os_err_t (*read_halfword)(void* handle, uint16_t* data);
}drv_spi_t;
#define drv_spi_cs_low(dev) ((drv_spi_t*)(dev->handle))->cs_low((dev)->handle)
#define drv_spi_cs_high(dev) ((drv_spi_t*)(dev->handle))->cs_high((dev)->handle)
#define drv_spi_put(dev, data) ((drv_spi_t*)(dev->handle))->put((dev)->handle, data)
#define drv_spi_get(dev, data) ((drv_spi_t*)(dev->handle))->get((dev)->handle, data)
#define drv_spi_send_halfword(dev, data) ((drv_spi_t*)(dev->handle))->send_halfword((dev)->handle, data)
#define drv_spi_read_halfword(dev, data) ((drv_spi_t*)(dev->handle))->read_halfword((dev)->handle, data)
#endif /*INCLUDED_DRV_SPI_H*/