请问大家谁用过st公司的IIS2DH三轴加速度计 请问st公司提供的驱动文件怎么使用?提供的函数中未提到SPI通信的任何内容
下面文件中的stmdev_ctx_t 结构体什么意思?
typedef struct {
stmdev_write_ptr write_reg;
stmdev_read_ptr read_reg;
void *handle;
}stmdev_ctx_t;
typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, uint8_t *, uint16_t);
typedef int32_t (*stmdev_read_ptr) (void *, uint8_t, uint8_t *, uint16_t);
怎么理解提供的两个基础函数:
int32_t iis2dh_read_reg(stmdev_ctx_t *ctx, uint8_t reg, uint8_t *data,uint16_t len)
{
int32_t ret;
ret = ctx->read_reg(ctx->handle, reg, data, len);
return ret;
}
和
int32_t iis2dh_write_reg(stmdev_ctx_t *ctx, uint8_t reg,uint8_t *data,uint16_t len)
{
int32_t ret;
ret = ctx->write_reg(ctx->handle, reg, data, len);
return ret;
}
我看里面提供的函数还声明一下内容:
stmdev_ctx_t dev_ctx;
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
dev_ctx.handle = &SENSOR_BUS;
跪求各位大佬指导感谢感谢
|