Skip to content

Commit

Permalink
tests: drivers: build_all: fuel_gauge: Add devices to build test
Browse files Browse the repository at this point in the history
Add build tests for the following devices.

- maxim,max17048
- ti,bq27z746
- sbs,sbs-gauge-new-api
- zephyr,fuel-gauge-composite

Signed-off-by: TOKITA Hiroshi <[email protected]>
  • Loading branch information
soburi committed Sep 27, 2024
1 parent ab63deb commit c11271b
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/drivers/build_all/fuel_gauge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 TOKITA Hiroshi
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(build_all)

target_sources(app PRIVATE src/main.c)
65 changes: 65 additions & 0 deletions tests/drivers/build_all/fuel_gauge/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/i2c/i2c.h>

/ {
test {
#address-cells = <1>;
#size-cells = <1>;

test_gpio: gpio@deadbeef {
compatible = "vnd,gpio";
gpio-controller;
reg = <0xdeadbeef 0x1000>;
#gpio-cells = <0x2>;
status = "okay";
};

test_i2c: i2c@11112222 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "vnd,i2c";
reg = <0x11112222 0x1000>;
status = "okay";
clock-frequency = <I2C_BITRATE_STANDARD>;

#include "i2c.dtsi"
};

test_adc: adc@adc0adc0 {
compatible = "vnd,adc";
reg = <0xadc0adc0 0x1000>;
#io-channel-cells = <1>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_VDD_1";
zephyr,acquisition-time = <0>;
};
};

test_vbatt: vbatt {
compatible = "voltage-divider";
io-channels = <&test_adc 0>;
output-ohms = <180000>;
full-ohms = <(1500000 + 180000)>;
power-gpios = <&gpio0 16 0>;
};

test_fuel_gauge: fuel_gauge {
compatible = "zephyr,fuel-gauge-composite";
status = "okay";
battery-voltage = <&test_vbatt>;
device-chemistry = "lithium-ion-polymer";
ocv-capacity-table-0 = <0>;
charge-full-design-microamp-hours = <1350000>;
};
};
};
26 changes: 26 additions & 0 deletions tests/drivers/build_all/fuel_gauge/i2c.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
* SPDX-License-Identifier: Apache-2.0
*/

/****************************************
* PLEASE KEEP REG ADDRESSES SEQUENTIAL *
***************************************/

max17048@0 {
compatible = "maxim,max17048";
reg = <0x0>;
status = "okay";
};

bq27z746@1 {
compatible = "ti,bq27z746";
reg = <0x1>;
status = "okay";
};

sbs-gauge-new-api@2 {
compatible = "sbs,sbs-gauge-new-api";
reg = <0x2>;
status = "okay";
};
3 changes: 3 additions & 0 deletions tests/drivers/build_all/fuel_gauge/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_FUEL_GAUGE=y
CONFIG_SENSOR=y
CONFIG_GPIO=y
9 changes: 9 additions & 0 deletions tests/drivers/build_all/fuel_gauge/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
* SPDX-License-Identifier: Apache-2.0
*/

int main(void)
{
return 0;
}
21 changes: 21 additions & 0 deletions tests/drivers/build_all/fuel_gauge/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024 TOKITA hiroshi
# SPDX-License-Identifier: Apache-2.0

tests:
drivers.fuel_gauge.build:
tags:
- drivers
- fuel_gauge
build_only: true
platform_allow:
- native_sim

drivers.fuel_gauge.emul.build:
tags:
- drivers
- fuel_gauge
build_only: true
platform_allow:
- native_sim
extra_configs:
- CONFIG_EMUL=y

0 comments on commit c11271b

Please sign in to comment.