File tree Expand file tree Collapse file tree 4 files changed +89
-0
lines changed
boards/common/particle-mesh Expand file tree Collapse file tree 4 files changed +89
-0
lines changed Original file line number Diff line number Diff line change 11ifneq (,$(filter saul_default,$(USEMODULE)))
22 USEMODULE += saul_gpio
3+ USEMODULE += saul_bat_voltage
34 USEMODULE += saul_pwm
45endif
56
Original file line number Diff line number Diff line change 11CPU_MODEL = nrf52840xxaa
22
33# Put defined MCU peripherals here (in alphabetical order)
4+ FEATURES_PROVIDED += board_bat_voltage
45FEATURES_PROVIDED += periph_i2c
56FEATURES_PROVIDED += periph_pwm
67FEATURES_PROVIDED += periph_spi
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2024 TU Dresden
3+ *
4+ * This file is subject to the terms and conditions of the GNU Lesser
5+ * General Public License v2.1. See the file LICENSE in the top level
6+ * directory for more details.
7+ */
8+
9+ /**
10+ * @ingroup boards_feather-nrf52840
11+ * @ingroup saul_bat_voltage
12+ * @{
13+ * @file
14+ * @brief Implementation of battery voltage convert function
15+ *
16+ * @author Martine S. Lenders <[email protected] > 17+ *
18+ * @}
19+ */
20+
21+ #ifdef MODULE_SAUL_BAT_VOLTAGE
22+ #include "saul/bat_voltage.h"
23+
24+ int16_t saul_bat_voltage_convert (int32_t adc_sample )
25+ {
26+ /* See https://community.particle.io/t/can-argon-or-xenon-read-the-battery-state/45554/6
27+ * and https://docs.particle.io/assets/images/xenon/schematic-main.png */
28+ return (int16_t )((adc_sample * 33L * 1403L ) / 10000L );
29+ }
30+
31+ #endif /* MODULE_SAUL_BAT_VOLTAGE */
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2024 TU Dresden
3+ *
4+ * This file is subject to the terms and conditions of the GNU Lesser
5+ * General Public License v2.1. See the file LICENSE in the top level
6+ * directory for more details.
7+ */
8+
9+ /**
10+ * @ingroup boards_common_particle-mesh
11+ * @{
12+ *
13+ * @file
14+ * @brief Configuration of SAUL mapped battery voltage information
15+ *
16+ * @author Martine S. Lenders <[email protected] > 17+ */
18+
19+ #ifndef BAT_VOLTAGE_PARAMS_H
20+ #define BAT_VOLTAGE_PARAMS_H
21+
22+ #include "saul/bat_voltage.h"
23+
24+ #ifdef __cplusplus
25+ extern "C" {
26+ #endif
27+
28+ /**
29+ * @brief Conversion function to convert ADC sample to battery voltage
30+ *
31+ * @param[in] adc_sample The raw ADC sample.
32+ *
33+ * @return Voltage value for phydat.
34+ */
35+ int16_t saul_bat_voltage_convert (int32_t adc_sample );
36+
37+ /**
38+ * @brief Battery voltage configuration
39+ */
40+ static const saul_bat_voltage_params_t saul_bat_voltage_params [] =
41+ {
42+ {
43+ .name = "BAT" ,
44+ .phydat_scale = -3 ,
45+ .line = ADC_LINE (3 ),
46+ .res = ADC_RES_10BIT ,
47+ .convert = saul_bat_voltage_convert ,
48+ },
49+ };
50+
51+ #ifdef __cplusplus
52+ }
53+ #endif
54+
55+ #endif /* BAT_VOLTAGE_PARAMS_H */
56+ /** @} */
You can’t perform that action at this time.
0 commit comments