请教各位,刚接触LSM6DSO的FSM,本来想识别shake手势,结果在 lsm6dso_fsm.c里找不到shake手势的数组,并且是这种形式:
/* Program: glance */
const uint8_t lsm6so_prg_glance[] = {
0xb2, 0x10, 0x24, 0x20, 0x17, 0x17, 0x66, 0x32,
0x66, 0x3c, 0x20, 0x20, 0x02, 0x02, 0x08, 0x08,
0x00, 0x04, 0x0c, 0x00, 0xc7, 0x66, 0x33, 0x73,
0x77, 0x64, 0x88, 0x75, 0x99, 0x66, 0x33, 0x53,
0x44, 0xf5, 0x22, 0x00,
};
/* Program: motion */
const uint8_t lsm6so_prg_motion[] = {
0x51, 0x10, 0x16, 0x00, 0x00, 0x00, 0x66, 0x3c,
0x02, 0x00, 0x00, 0x7d, 0x00, 0xc7, 0x05, 0x99,
0x33, 0x53, 0x44, 0xf5, 0x22, 0x00,
};
而在另外一个代码里,找到一个这样的shake手势数组(unico转换出来的):
const ucf_line_t shake[] = {
{.address = 0x10, .data = 0x00,},
{.address = 0x11, .data = 0x00,},
{.address = 0x01, .data = 0x80,},
{.address = 0x04, .data = 0x00,},
{.address = 0x05, .data = 0x00,},
{.address = 0x5F, .data = 0x43,},
{.address = 0x46, .data = 0x01,},
{.address = 0x47, .data = 0x00,},
{.address = 0x0A, .data = 0x00,},
。。。。。
{.address = 0x09, .data = 0x00,},
{.address = 0x09, .data = 0x00,},
{.address = 0x09, .data = 0x01,},
{.address = 0x09, .data = 0x01,},
{.address = 0x09, .data = 0x00,},
{.address = 0x09, .data = 0x00,},
{.address = 0x09, .data = 0xE2,},
{.address = 0x09, .data = 0x00,},
{.address = 0x09, .data = 0x1E,},
{.address = 0x09, .data = 0x00,},
{.address = 0x09, .data = 0x13,},
。。。。
}
这两种数组格式都不一样,没法将这个 shake数组导入到上面那个工程里。
并且很奇怪,第二种数组连续多个address是一样的,是什么意义呢?这种方式能不能同时支持多个手势呢?找不到工程代码使用这种数组的例子。
谢谢大佬帮忙解答!
LSM6DSO 的Shake detection例程可以在官方的github页面找到,对应的链接是:
https://github.com/STMicroelectronics/STMems_Finite_State_Machine/tree/master/application_examples
第一种原始数组通过类似lsm6dsox_ln_pg_write的函数配置
第二种数组通过类似下边方法配置
LSM6DSO的examples里只提供了RAW方式的示例,第二种示例可以参考LSM6DSOX的代码
https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm6dsox_STdC/examples
"第二种数组连续多个address是一样的,是什么意义呢?"
可以参考下边文档,第49、50、52页有一个示例。
引用: littleshrimp 发表于 2021-7-23 15:14 LSM6DSO 的Shake detection例程可以在官方的github页面找到,对应的链接是: https://github.com/STMicr ...
厉害,玩的透彻!
引用: littleshrimp 发表于 2021-7-23 15:14 LSM6DSO 的Shake detection例程可以在官方的github页面找到,对应的链接是: https://github.com/STMicr ...
版主厉害,非常感谢 ,辛苦了!
另外,是否有方法可以将第二种数组转换成第一种数组呢?
因为我需要在 lsm6dso_fsm.c里处理 shake 手势,这个文件有多种手势处理,但就是缺了shake手势。
引用: littleshrimp 发表于 2021-7-23 15:44 "第二种数组连续多个address是一样的,是什么意义呢?" 可以参考下边文档,第49、50、52页有一个示 ...
原来是地址递增了。奇怪,为什么不干脆生成绝对地址呢。
引用: kinggate1 发表于 2021-7-23 19:47 版主厉害,非常感谢 ,辛苦了! 另外,是否有方法可以将第二种数组转换成第一种数组呢? 因为我需 ...
你可以参考一下lsm6dso_reg.c里的lsm6dso_ln_pg_write函数,再对照一下an5226文档和第二种数组同,应该就能弄明白它们两者的规律。
int32_t lsm6dso_ln_pg_write(stmdev_ctx_t *ctx, uint16_t address,
uint8_t *buf, uint8_t len)
{
lsm6dso_page_rw_t page_rw;
lsm6dso_page_sel_t page_sel;
lsm6dso_page_address_t page_address;
uint16_t addr_pointed;
int32_t ret;
uint8_t i ;
addr_pointed = address;
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
if (ret == 0)
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
page_rw.page_rw = 0x02; /* page_write enable*/
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1);
}
if (ret == 0)
{
page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU);
page_sel.not_used_01 = 1;
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1);
}
if (ret == 0)
{
page_address.page_addr = (uint8_t)(addr_pointed & 0x00FFU);
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS,
(uint8_t *)&page_address, 1);
}
if (ret == 0)
{
for (i = 0; ((i < len) && (ret == 0)); i++)
{
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_VALUE, &buf[i], 1);
addr_pointed++;
/* Check if page wrap */
if (((addr_pointed % 0x0100U) == 0x00U) && (ret == 0))
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *)&page_sel, 1);
if (ret == 0)
{
page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU);
page_sel.not_used_01 = 1;
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL,
(uint8_t *)&page_sel, 1);
}
}
}
page_sel.page_sel = 0;
page_sel.not_used_01 = 1;
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1);
}
if (ret == 0)
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
page_rw.page_rw = 0x00; /* page_write disable */
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
}
return ret;
}
引用: littleshrimp 发表于 2021-7-23 20:05 你可以参考一下lsm6dso_reg.c里的lsm6dso_ln_pg_write函数,再对照一下an5226文档和第二种数组同,应该就 ...
好的,我好好研究一下。