You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2018/12/07 01:39:13 UTC
[mynewt-core] branch master updated: Battery - Optional Start Delay
(#1555)
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 49f8a35 Battery - Optional Start Delay (#1555)
49f8a35 is described below
commit 49f8a35da1a0cebdaec99a800c3bf37c6799eda8
Author: brolan-juul <33...@users.noreply.github.com>
AuthorDate: Thu Dec 6 17:39:09 2018 -0800
Battery - Optional Start Delay (#1555)
* Adding an optional delay before polling begins. This allows for certain fuel guages necessary bootup time.
* Consolidating function to avoid duplicating code.
---
hw/battery/include/battery/battery.h | 12 ++++++++++++
hw/battery/src/battery.c | 9 ++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/hw/battery/include/battery/battery.h b/hw/battery/include/battery/battery.h
index 0b1093a..50500a3 100644
--- a/hw/battery/include/battery/battery.h
+++ b/hw/battery/include/battery/battery.h
@@ -221,6 +221,18 @@ char *battery_prop_get_name(const struct battery_property *prop, char *buf,
*/
int battery_set_poll_rate_ms(struct os_dev *battery, uint32_t poll_rate);
+/**
+ * Set the battery poll rate with a starting delay
+ *
+ * @param The battery
+ * @param The poll rate in milliseconds
+ * @param Start delay before beginning to poll in milliseconds
+ *
+ * @return 0 on success, non-zero error code on failure.
+ */
+int battery_set_poll_rate_ms_delay(struct os_dev *battery, uint32_t poll_rate,
+ uint32_t start_delay);
+
// =================================================================
// ========================== BATTERY MANAGER ======================
// =================================================================
diff --git a/hw/battery/src/battery.c b/hw/battery/src/battery.c
index e3f2ac3..2b13266 100644
--- a/hw/battery/src/battery.c
+++ b/hw/battery/src/battery.c
@@ -485,6 +485,13 @@ battery_mgr_poll_battery(struct battery *battery)
int
battery_set_poll_rate_ms(struct os_dev *battery, uint32_t poll_rate)
{
+ return battery_set_poll_rate_ms_delay(battery, poll_rate, 0);
+}
+
+int
+battery_set_poll_rate_ms_delay(struct os_dev *battery, uint32_t poll_rate,
+ uint32_t start_delay)
+{
struct battery *bat = (struct battery *)battery;
if (bat == NULL) {
@@ -499,7 +506,7 @@ battery_set_poll_rate_ms(struct os_dev *battery, uint32_t poll_rate)
bat->b_poll_rate = poll_rate;
bat->b_next_run = os_time_get();
- os_callout_reset(&battery_manager.bm_poll_callout, 0);
+ os_callout_reset(&battery_manager.bm_poll_callout, start_delay);
return 0;
}