Max32630fthr

Dependents:   MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_IMU_HelloWorld

Files at this revision

API Documentation at this revision

Comitter:
switches
Date:
Wed Nov 16 01:01:28 2016 +0000
Child:
1:15e34492fbf1
Commit message:
Moving max32630fthr utilities into library

Changed in this revision

max32630fthr.cpp Show annotated file Show diff for this revision Revisions of this file
max32630fthr.h Show annotated file Show diff for this revision Revisions of this file
--- /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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max32630fthr.h	Wed Nov 16 01:01:28 2016 +0000
@@ -0,0 +1,7 @@
+// max32630fthr configuration utilities
+
+// max32630fthr initialization
+int max32630fthrInit();
+
+// max32630fthr pin voltage configuration
+int vddioh(PinName pin, bool en);
\ No newline at end of file