Program to demonstrate how to configure the PMIC on the MAX32620HSP (MAXREFDES100#)

Dependencies:   MAX14720 mbed

Fork of HSP_PMIC_Demo by Greg Steiert

Revision:
14:4c4094890fde
Parent:
4:81cea7a352b0
Child:
17:9a467f9a0579
diff -r 2c5a871cf571 -r 4c4094890fde main.cpp
--- a/main.cpp	Sat Sep 17 08:46:24 2016 +0000
+++ b/main.cpp	Tue Oct 04 22:27:34 2016 +0000
@@ -1,12 +1,36 @@
 #include "mbed.h"
+#include "MAX14720.h"
+
+// I2C Master 2
+I2C i2c2(I2C2_SDA, I2C2_SCL);
 
-DigitalOut myled(LED1);
+#define  I2C_ADDR_PMIC   (0x54)
+MAX14720 max14720(&i2c2,I2C_ADDR_PMIC);
+
+DigitalOut led(LED1);
+InterruptIn button(SW1);
+
+void turnOff()
+{
+    max14720.shutdown();
+}
 
-int main() {
+int main()
+{
+    int result;
+    button.fall(&turnOff);
+    led = 0;
+    max14720.boostEn = MAX14720::BOOST_ENABLED;
+    result = max14720.init();
+    if (result == MAX14720_ERROR) printf("Error initializing MAX14720");
+    wait(1);
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        max14720.boostSetMode(MAX14720::BOOST_DISABLED);
+        max14720.boostEn = MAX14720::BOOST_ENABLED;
+        wait(0.5);
+        max14720.boostSetVoltage(2500);
+        wait(0.5);
+        max14720.boostSetVoltage(5000);
+        wait(0.5);
     }
 }