samples: charger: Demos new output limit properties

Adds use of CHARGER_PROP_DISCHARGE_CURRENT_NOTIFICATION and
CHARGER_PROP_SYSTEM_VOLTAGE_NOTIFICATION_UV to the charger
sample application.

Signed-off-by: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com>
This commit is contained in:
Ricardo Rivera-Matos 2024-01-18 15:56:38 -06:00 committed by Fabio Baltieri
parent 83997a3ca7
commit 5868c701ef
3 changed files with 76 additions and 0 deletions

View file

@ -19,6 +19,37 @@ config CHARGER_INIT_PRIORITY
help
Battery charger initialization priority.
config CHARGER_HAS_DISCHARGE_CURRENT_NOTIFICATIONS
bool
help
This symbol is y if the charger supports discharge
current notifications.
config CHARGER_HAS_SYSTEM_VOLTAGE_NOTIFICATIONS
bool
help
This symbol is y if the charger supports system
voltage notifications.
menu "Discharge current notifications"
config CHARGER_DISCHARGE_CURRENT_NOTIFICATIONS
bool "Support discharge current notifications"
depends on CHARGER_HAS_DISCHARGE_CURRENT_NOTIFICATIONS
help
Enables support for discharge current notifications
endmenu
menu "System voltage notification"
config CHARGER_SYSTEM_VOLTAGE_NOTIFICATIONS
bool "Support system voltage notifications"
depends on CHARGER_HAS_SYSTEM_VOLTAGE_NOTIFICATIONS
help
Enables support for system voltage notifications
endmenu
source "drivers/charger/Kconfig.sbs_charger"
source "drivers/charger/Kconfig.bq24190"
source "drivers/charger/Kconfig.bq25180"

View file

@ -0,0 +1,22 @@
# Private config options for charger sample app
# Copyright (c) 2024 Cirrus Logic, Inc.
# SPDX-License-Identifier: Apache-2.0
mainmenu "Charger application"
if CHARGER_DISCHAGRE_CURRENT_NOTIFICATIONS
config APP_DISCHARGE_CURRENT_NOTIFICATION_THRESHOLD_UA
int "Discharge notification threshold in µA"
config APP_DISCHARGE_CURRENT_NOTIFICATION_DURATION_US
int "Excess discharge duration in µsec"
endif # CHARGER_DISCHAGRE_CURRENT_NOTIFICATIONS
config APP_SYSTEM_VOLTAGE_NOTIFICATION_THRESHOLD_UV
int "System voltage notification falling threshold in µV"
depends on CHARGER_SYSTEM_VOLTAGE_NOTIFICATIONS
source "Kconfig.zephyr"

View file

@ -32,6 +32,29 @@ int main(void)
printk("Found device \"%s\", getting charger data\n", chgdev->name);
#ifdef CONFIG_CHARGER_DISCHARGE_CURRENT_NOTIFICATIONS
val.discharge_current_notification.current_ua =
CONFIG_APP_DISCHARGE_CURRENT_NOTIFICATION_THRESHOLD_UA;
val.discharge_current_notification.severity = CHARGER_SEVERITY_WARNING;
val.discharge_current_notification.duration_us =
CONFIG_APP_DISCHARGE_CURRENT_NOTIFICATION_DURATION_US;
ret = charger_set_prop(chgdev, CHARGER_PROP_DISCHARGE_CURRENT_NOTIFICATION, &val);
if (ret < 0) {
return ret;
}
#endif
#ifdef CONFIG_CHARGER_SYSTEM_VOLTAGE_NOTIFICATIONS
val.system_voltage_notification =
CONFIG_APP_SYSTEM_VOLTAGE_NOTIFICATION_THRESHOLD_UV;
ret = charger_set_prop(chgdev, CHARGER_PROP_SYSTEM_VOLTAGE_NOTIFICATION_UV, &val);
if (ret < 0) {
return ret;
}
#endif
while (1) {
/* Poll until external power is presented to the charger */
do {