ch1 test1

Dependencies:   MAX14690

Revision:
0:8926602da648
Child:
1:15e34492fbf1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max32630fthr.cpp	Wed Nov 16 01:01:28 2016 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "max3263x.h"
+#include "ioman_regs.h"
+#include "PinNames.h"
+#include "max32630fthr.h"
+
+#define MAX14690_I2C_ADDR    0x50
+
+
+int max32630fthrInit()
+{
+    I2C __i2cm2(P5_7, P6_0);
+    char data[5];
+    data[0] = 0x14; // I2C address for first register (LDO2 CFG)
+    data[1] = 0x00; // Dissable LDO2
+    data[2] = 0x19; // Set voltage to 3.3V
+    data[3] = 0x00; // Dissable LDO3
+    data[4] = 0x19; // Set voltage to 3.3V
+    __i2cm2.write(MAX14690_I2C_ADDR, data, 5);
+    data[1] = 0x02; // Enable LDO2
+    data[3] = 0x02; // Enable LDO3
+    __i2cm2.write(MAX14690_I2C_ADDR, data, 5);
+    return 0;
+}
+
+int vddioh(PinName pin, bool en)
+{
+    __IO uint32_t *use_vddioh = &((mxc_ioman_regs_t *)MXC_IOMAN)->use_vddioh_0;
+
+    if (pin == NOT_CONNECTED) {
+        return -1;
+    }
+
+    use_vddioh += PINNAME_TO_PORT(pin) >> 2;
+    if (en) {
+        *use_vddioh |= (1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3)));
+    } else {
+        *use_vddioh &= ~(1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3)));
+    }
+
+    return 0;
+}