3 个版本
0.1.4 | 2024年7月5日 |
---|---|
0.1.3 | 2024年7月2日 |
0.1.2 |
|
0.1.1 |
|
0.1.0 |
|
#481 在 嵌入式开发 中
每月下载 187 次
在 lsm303dlhc-ng 中使用
60KB
901 行代码
STMicroelectronics LSM303DLHC 电子罗盘寄存器
LSM303DLHC 的 I²C 寄存器的类型映射。
提供读取和修改传感器寄存器的函数和命名字段。例如
fn configure_sensor(sensor: &mut LSM303DLHC) {
// configure the accelerometer to operate at 400 Hz
sensor.write_register(
ControlRegister1A::new()
.with_output_data_rate(AccelOdr::Hz400)
.with_low_power_enable(false)
.with_x_enable(true)
.with_y_enable(true)
.with_z_enable(true),
)?;
// Reset other accelerometer control registers.
sensor.write_register(ControlRegister2A::new())?;
sensor.write_register(ControlRegister3A::new())?;
sensor.write_register(ControlRegister4A::new())?;
sensor.write_register(ControlRegister5A::new())?;
sensor.write_register(ControlRegister6A::new())?;
// Configure the magnetometer to operate in continuous mode.
sensor.write_register(
ModeRegisterM::new()
.with_sleep_mode(false)
.with_single_conversion(false),
)?;
// Enable the temperature sensor.
sensor.write_register(
CraRegisterM::new()
.with_temp_en(true)
.with_data_output_rate(MagOdr::Hz75),
)?;
}
行为准则
我们遵守 贡献者守则,并要求您也这样做。
许可证
版权所有 © 2024 Markus Mayer
根据您的选择,使用以下任何一个许可证进行三重授权:
- 欧洲联盟公共许可证,版本 1.2,(LICENSE-EUPL 或 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
- Apache 许可证,版本 2.0,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可证 (LICENSE-MIT 或 https://open-source.org.cn/licenses/MIT)
本作品包含 Jorge Aparicio 的 lsm303dlhc crate 的部分,在 MIT 和 Apache 2.0 许可证下提供。
依赖项
~0.3–0.8MB
~20K SLoC