当前位置:网站首页>【开发教程8】疯壳·开源蓝牙心率防水运动手环-三轴计步伐
【开发教程8】疯壳·开源蓝牙心率防水运动手环-三轴计步伐
2022-07-26 16:28:00 【efans_Mike】
蓝牙心率防水运动手环
——疯壳·智能穿戴开发系列
三轴计步伐
三轴记步
1相关简介
本次,我们将使用 DA14580 的硬件 I2C 读取三轴传感器的步数。
I2C 总线是一个为系统中电路通信提供支持的可编程控制总线,它是一个软件定义的两线通信协议。
两线 I2C 串行接口包括一个串行数据线(SDA)和一个串行时钟线(SCL);
支持两种通行速率,标准模式(0~100Kb/s)和快速模式(小于等于 400Kb/s);
时钟同步;
32 字节的发送接收 FIFO;
主机发送与接收操作;
7 或 10 位地址,7 或 10 位混合格式发送;
块发送模式;
默认从地址为 0x055;
中断或者轮询操作模式;
可编程的数据线保持时间;
本次使用的三轴传感器是 LIS2DS12。LIS2DS12 是一种超低功率高性能三轴线性加速度计,具有用户可选择的尺寸 2G/4G/8G/16G,能够测量输出数据速率从1Hz 到 6400Hz 的加速度。并且具有集成的 256 级先入先出(FIFO)缓冲器,让用户在存储数据时,限制主机处理器的干预。LIS2DS12 支持 SPI 和 I2C 两种接口, 我们这里采用的 I2C 接口。
2硬件设计
LIS2DS12 一共有 12 引脚。1 脚 SCL 是时钟信号。2 脚 CS 是 SPI/I2C 使能引脚。第 3 引脚是 SPI 的数据输出,由于这里用的 I2C,这个引脚空余。引脚 SDA 是 I2C 用来传送数据的。还有两个中断脚 INT1、INT2,打开之后,当 LIS2DS12 检测到步数,能产生中断电平。
图 1
3软件设计
首先,完成系统初始化,调用 system_init(),可以参考前面的电量检测。接 下 来 就 是 I2C 的 使 用 了 。 第 一 步 我 们 配 置 I2C 的 相 关 引 脚 。
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SCL_PIN, INPUT, PID_I2C_SCL, false);
GPIO_ConfigurePin(I2C_GPIO_PORT, I2C_SDA_PIN, INPUT, PID_I2C_SDA, false);
第二步,就是通过下面函数初始化 I2C。
代码1
完成 I2C 的初始化之后, 我们就可以通过 i2c_eeprom_read_byte(uint32_taddress, uint8_t *byte) 对 LIS2DS12 进 行 读 操 作 , 通 过
i2c_eeprom_write_byte(uint32_t address, uint8_t byte)对 LIS2DS12 进行写操作。
通过 I2C 的读写函数,对 LIS2DS12 寄存器进行读写,就能使用 LIS2DS12。详细资料可以查询 LIS2DS12 的 datasheet。
首先,我们是调用函数 status_t LIS2DS12_ACC_R_WHO_AM_I_BIT(u8_t *value) 读 取 设 备 ID , 判 定 是 否 为 正 确 的 设 备 。 然 后 , 我 们 调 用LIS2DS12_ACC_W_SOFT_RESET(LIS2DS12_ACC_SOFT_RESET_t newValue),软件初始化 LIS2DS12 设备。如果读取设备错误或者软件初始化不成功,DA14580 会进入一个空的死循环。最后,我们会进入 Loop_Test_Pedometer(),记步测试。
代码2
4 实验现象
首先,插好 Jlink 和 USB 转串口,然后打开打开串口调试助手。
(1)选择串口号,我们图中是 COM1,这个根据实际情况选择。
(2)配置串口参数,波特率为 115200,数据位 8,停止位 1,没有校验位和控制流,与下图一致。
(3)点击打开串口。
图 2
配置完串口之后,打开我们提供的代码。
(1)点击仿真按键。
图 3
(2)点击运行代码。
图 4
完成上述操作,就会看到串口调试助手区域 4 中会显示出步数,我们摇晃单片机,会发现串口调试助手打印出新的步数,并且步数在增加。
图 5
边栏推荐
- Matlab论文插图绘制模板第40期—带偏移扇区的饼图
- Comprehensively design an oppe homepage -- the design of the top and head
- DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库
- Draw a beautiful outline of the middle school playground and generate longitude and latitude data
- Analyzing method and proc in Ruby
- The difference and efficiency comparison of three methods of C # conversion integer
- Re7: reading papers fla/mlac learning to predict charges for critical cases with legal basis
- The process and harvest of developing browser plug-ins with clojurescript
- Digital currency of quantitative transactions - merge transaction by transaction data through timestamp and direction (large order consolidation)
- 综合设计一个OPPE主页--明星机型的设计
猜你喜欢

Singleton mode

基于sisotool极点配置PI参数及基于Plecs的三相电压源逆变器仿真

我的sql没问题为什么还是这么慢|MySQL加锁规则

Linux Installation mysql8.0.29 detailed tutorial

结构体和类使用的区别

Win11怎么自动清理回收站?

Understanding JS foundation and browser engine

Matlab paper illustration drawing template issue 40 - pie chart with offset sector

综合设计一个OPPE主页--导航栏的设计

操作系统迁移实战之在openEuler上部署MySQL数据库
随机推荐
Docker install redis? How to configure persistence policy?
TensorFlow Lite源码解析
DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库
2022-2023 topic recommendation of information management graduation project
2022-2023 信息管理毕业设计选题题目推荐
Re8:读论文 Hier-SPCNet: A Legal Statute Hierarchy-based Heterogeneous Network for Computing Legal Case
The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact
Trends in software testing tools in 2021
Re8: reading papers Hier spcnet: a legal stat hierarchy based heterogeneous network for computing legal case
该怎么写单元测试呢
[arm learning (9) ARM compiler understanding learning (armcc/armclang)]
Simulation of three-phase voltage source inverter based on SISOTOOL pole assignment PI parameters and pless
FTP protocol
Movable view component (it can be dragged up, down, left and right)
PXE高效批量网络装机
It turns out that cappuccino information security association does this. Let's have a look.
Marxan模型保护区优化与保护空缺甄选技术、InVEST生态系统中的应用
Win11系统如何一键进行重装?
Comprehensive design of an oppe homepage -- Design of navigation bar
TDengine 落地协鑫能科,数百亿数据压缩至 600GB