This class provides APIs to all of the registers of the TI BQ24295 battery charger chip, as used on the u-blox C030 board. This class is not required to charge a battery connected to the C030 board, charging will begin automatically when a battery is connected. This class is only required if the user wishes to monitor the charger's state or change the charger's settings. The caller should instantiate an I2C interface and pass this to init(), which will initialise the chip and place it into its lowest power state. The chip may then be configured using the API calls. Once the chip is configured, battery charging can be enabled. If battery charging is disabled the chip will once more be put into its lowest power state.

Dependents:   example-battery-charger-bq24295 example-C030-out-of-box-demo example-C030-out-of-box-demo Amit

Revision:
3:340d65a1a133
Parent:
1:ed57b6ca43ab
Child:
5:bb17656c9b9d
--- a/TESTS/unit_tests/default/main.cpp	Tue Apr 11 09:56:38 2017 +0000
+++ b/TESTS/unit_tests/default/main.cpp	Tue Jun 06 12:59:11 2017 +0100
@@ -817,6 +817,50 @@
     TEST_ASSERT(pBatteryCharger->setChipThermalRegulationThreshold(originalTemperature));    
 }
 
+// Test that we can kick and set the watchdog
+void test_watchdog() {
+    BatteryChargerBq24295 * pBatteryCharger = new BatteryChargerBq24295();
+    int32_t initValue;
+    int32_t getValue = 0;
+    
+    // Call should fail if the battery charger has not been initialised
+    TEST_ASSERT_FALSE(pBatteryCharger->feedWatchdog());
+    TEST_ASSERT_FALSE(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_FALSE(pBatteryCharger->setWatchdog(0));
+    
+    // Initialise the battery charger
+    TEST_ASSERT(pBatteryCharger->init(gpI2C));
+    
+    // Save the initial value
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&initValue));
+
+    // Check that we can feed the watchdog
+    TEST_ASSERT(pBatteryCharger->feedWatchdog());
+    
+    // Check that we can set all the watchdog values
+    TEST_ASSERT(pBatteryCharger->setWatchdog(81));
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_EQUAL_INT32(160, getValue);
+    TEST_ASSERT(pBatteryCharger->setWatchdog(80));
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_EQUAL_INT32(80, getValue);
+    TEST_ASSERT(pBatteryCharger->setWatchdog(41));
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_EQUAL_INT32(80, getValue);
+    TEST_ASSERT(pBatteryCharger->setWatchdog(40));
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_EQUAL_INT32(40, getValue);
+    TEST_ASSERT(pBatteryCharger->setWatchdog(1));
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_EQUAL_INT32(40, getValue);
+    TEST_ASSERT(pBatteryCharger->setWatchdog(0));
+    TEST_ASSERT(pBatteryCharger->getWatchdog(&getValue));
+    TEST_ASSERT_EQUAL_INT32(0, getValue);
+
+    // Put the initial value back when we're done
+    TEST_ASSERT (pBatteryCharger->setWatchdog(initValue));
+}
+
 // Test that we can enable and disable shipping mode
 void test_shipping_mode() {
     BatteryChargerBq24295 * pBatteryCharger = new BatteryChargerBq24295();
@@ -919,6 +963,7 @@
     Case("Fast charging safety timer", test_fast_charging_safety_timer),
     Case("Boost limits", test_boost_limits),
     Case("Chip thermal regulation threshold", test_chip_thermal_regulation_threshold),
+    Case("Watchdog", test_watchdog),
     Case("Shipping mode", test_shipping_mode),
     Case("Advanced", test_advanced)
 };