Skip to content

Commit f01d4f6

Browse files
kimmansfieldjohnlange2
authored andcommitted
Add gecko_adc driver usage to tmo_shell
These changes add the gecko_adc driver usage into tmo_shell. Signed-off-by: Kim Mansfield <[email protected]>
1 parent 20aa821 commit f01d4f6

11 files changed

+439
-358
lines changed

samples/tmo_shell/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ target_sources(app PRIVATE src/buzzer_test.c)
2727
target_sources(app PRIVATE src/led_test.c)
2828
target_sources(app PRIVATE src/misc_test.c)
2929
target_sources(app PRIVATE src/tmo_file.c)
30-
target_sources(app PRIVATE src/tmo_adc.c)
3130
target_sources(app PRIVATE src/tmo_bq24250.c)
3231
target_sources(app PRIVATE src/tmo_battery_ctrl.c)
3332
target_sources(app PRIVATE src/tmo_sntp.c)

samples/tmo_shell/boards/tmo_dev_edge.overlay

+39
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,42 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
#include <zephyr/dt-bindings/adc/adc.h>
7+
#include <zephyr/dt-bindings/gpio/gpio.h>
8+
9+
/ {
10+
zephyr,user {
11+
/* adjust channel number according to pinmux in board.dts */
12+
io-channels = <&adc 0>, <&adc 1>;
13+
battsense-gpios = <&gpiok 0 GPIO_ACTIVE_HIGH>;
14+
};
15+
};
16+
17+
&gpiok {
18+
hog1 {
19+
gpio-hog;
20+
gpios = <0 GPIO_ACTIVE_HIGH>;
21+
output-high;
22+
};
23+
};
24+
25+
&adc {
26+
#address-cells = <1>;
27+
#size-cells = <0>;
28+
29+
channel@0 {
30+
reg = <0>;
31+
zephyr,gain = "ADC_GAIN_1_3";
32+
zephyr,reference = "ADC_REF_INTERNAL";
33+
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 32)>;
34+
zephyr,resolution = <12>;
35+
};
36+
37+
channel@1 {
38+
reg = <1>;
39+
zephyr,gain = "ADC_GAIN_1_3";
40+
zephyr,reference = "ADC_REF_INTERNAL";
41+
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 32)>;
42+
zephyr,resolution = <12>;
43+
};
44+
};

samples/tmo_shell/prj.conf

+1
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,4 @@ CONFIG_LOG_PRINTK=n
160160
CONFIG_TMO_TEST_MFG_CHECK_GOLDEN=y
161161
CONFIG_TMO_TEST_MFG_CHECK_ACCESS_CODE=y
162162
CONFIG_DFU_GECKO_LIB=y
163+
CONFIG_ADC_GECKO=y

samples/tmo_shell/src/misc_test.c

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include <zephyr/shell/shell.h>
1313
#include <zephyr/shell/shell_uart.h>
1414

15+
#if DT_NODE_EXISTS(DT_NODELABEL(sonycxd5605))
16+
#include "tmo_gnss.h"
17+
#endif
18+
1519
#define I2C_0 DT_NODE_FULL_NAME(DT_NODELABEL(i2c0))
1620
#define I2C_1 DT_NODE_FULL_NAME(DT_NODELABEL(i2c1))
1721

samples/tmo_shell/src/tmo_adc.c

-200
This file was deleted.

samples/tmo_shell/src/tmo_adc.h

-15
This file was deleted.

samples/tmo_shell/src/tmo_battery_ctrl.c

+5
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,8 @@ int get_battery_charging_status(uint8_t *charging, uint8_t *vbus, uint8_t *attac
9292

9393
return status;
9494
}
95+
96+
uint8_t battery_millivolts_to_percent(uint32_t millivolts) {
97+
float curBv = get_remaining_capacity((float) millivolts / 1000);
98+
return (uint8_t) (curBv + 0.5);
99+
} // Calculate input voltage in mV

samples/tmo_shell/src/tmo_battery_ctrl.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ float get_remaining_capacity(float battery_voltage);
3636
bool is_battery_charging(void);
3737
int get_battery_charging_status(uint8_t *charging, uint8_t *vbus, uint8_t *attached, uint8_t *fault);
3838

39+
uint8_t battery_millivolts_to_percent(uint32_t millivolts);
3940
#endif

0 commit comments

Comments
 (0)