- 在CMakeLists.txt中添加battery_module.c源文件 - 在设备树中添加电压分压器配置和ADC通道设置 - 添加传感器和ADC相关的Kconfig配置 - 实现电池模块功能,包括电压采样、电源管理事件处理 - 支持电池电压定期采样和日志输出
96 lines
1.7 KiB
Plaintext
96 lines
1.7 KiB
Plaintext
/dts-v1/;
|
|
#include <nordic/nrf52840_qiaa.dtsi>
|
|
#include "mini_keyboard-pinctrl.dtsi"
|
|
#include <zephyr/dt-bindings/adc/adc.h>
|
|
|
|
/ {
|
|
model = "Mini keyboard";
|
|
compatible = "atguigu,mini-keyboard";
|
|
|
|
chosen {
|
|
zephyr,sram = &sram0;
|
|
zephyr,flash = &flash0;
|
|
zephyr,code-partition = &slot0_partition;
|
|
};
|
|
|
|
aliases {
|
|
led0 = &myled0;
|
|
};
|
|
|
|
leds {
|
|
compatible = "gpio-leds";
|
|
myled0: led_0 {
|
|
gpios = <&gpio1 2 GPIO_ACTIVE_LOW>;
|
|
};
|
|
};
|
|
|
|
vbatt: vbatt {
|
|
compatible = "voltage-divider";
|
|
io-channels = <&adc 7>;
|
|
output-ohms = <100000>;
|
|
full-ohms = <200000>;
|
|
power-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
|
|
power-on-sample-delay-us = <200>;
|
|
};
|
|
};
|
|
|
|
&flash0 {
|
|
partitions {
|
|
compatible = "fixed-partitions";
|
|
#address-cells = <1>;
|
|
#size-cells = <1>;
|
|
|
|
boot_partition: partition@0 {
|
|
label = "mcuboot";
|
|
reg = <0x00000000 DT_SIZE_K(48)>;
|
|
};
|
|
|
|
slot0_partition: partition@c000 {
|
|
label = "image-0";
|
|
reg = <0x0000c000 DT_SIZE_K(472)>;
|
|
};
|
|
|
|
slot1_partition: partition@82000 {
|
|
label = "image-1";
|
|
reg = <0x00082000 DT_SIZE_K(472)>;
|
|
};
|
|
|
|
storage_partition: partition@f8000 {
|
|
label = "storage";
|
|
reg = <0x000f8000 DT_SIZE_K(32)>;
|
|
};
|
|
};
|
|
};
|
|
|
|
&uicr {
|
|
nfct-pins-as-gpios;
|
|
};
|
|
|
|
&adc {
|
|
status = "okay";
|
|
#address-cells = <1>;
|
|
#size-cells = <0>;
|
|
|
|
channel@7 {
|
|
reg = <7>;
|
|
zephyr,gain = "ADC_GAIN_1_4";
|
|
zephyr,reference = "ADC_REF_INTERNAL";
|
|
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40)>;
|
|
zephyr,input-positive = <NRF_SAADC_AIN7>;
|
|
zephyr,resolution = <14>;
|
|
zephyr,oversampling = <4>;
|
|
};
|
|
};
|
|
|
|
&gpio0 {
|
|
status = "okay";
|
|
};
|
|
|
|
&gpio1 {
|
|
status = "okay";
|
|
};
|
|
|
|
&gpiote {
|
|
status = "okay";
|
|
};
|