Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Branch:
- Lib_Development
- Revision:
- 2:ef0ee9c2a551
- Parent:
- 0:bf54a250aa28
--- a/main.cpp Thu Jan 07 05:35:31 2021 +0000
+++ b/main.cpp Fri Mar 12 09:25:43 2021 +0800
@@ -1,23 +1,86 @@
+// ********************************************************************************************
+// PMIC Buck1/Buck2 Monitor
#include "mbed.h"
#include "ThisThread.h"
+#include "MAX14690.h"
+#include "mxc_sys.h"
+//#include "max32630fthr.h"
+//#include "ESP8266Interface.h"
-DigitalOut rLED(LED1);
-DigitalOut gLED(LED2);
+
+
+//MAX32630FTHR fthr(MAX32630FTHR::VIO_3V3);
+
+DigitalOut rLED(LED1);
-// main() runs in its own thread in the OS
-// (note the calls to Thread::wait below for delays)
-int main()
-{
- printf("SD Card Example\n");
- gLED = LED_ON;
- rLED = LED_ON;
+InterruptIn pBUTTON(SW1);
+AnalogIn monPMIC(AIN_0);
+MAX14690 pmic(P5_7,P6_0);
+
+const int address = 0x50;
+char command;
- ThisThread::sleep_for(1000ms);
- rLED = LED_OFF;
-
- while (true) {
- gLED = !gLED;
- ThisThread::sleep_for(500ms);
+void monSwitch(){
+ if (command == 0x03) {
+ command = 0x04; // MONRatioCfg 00 | MONtHiZ 0 | MONCTR 100 (0000 0100)(0x04) Connect MON to Buck2
+ }
+ else {
+ command = 0x03; // MONRatioCfg 00 | MONtHiZ 0 | MONCTR 011 (0000 0100)(0x03) Connect MON to Buck1
}
}
+int main()
+{
+char ldo3[2];
+
+printf("\n\n");
+pmic.setLDO(pmic.LDO3, true, 3.3);
+
+ldo3[0] = pmic.readStatus(0x16);
+ldo3[1] = pmic.readStatus(0x17);
+
+printf("Register [%02X] Content : %02X \n", 0x16, ldo3[0]);
+printf("Register [%02X] Content : %02X \n", 0x17, ldo3[1]);
+
+rLED = LED_OFF;
+
+while(true){
+
+}
+
+
+
+/*
+ char cmd[3];
+ char readback[3];
+ int voltage;
+ char regadr;
+ cmd[0] = 0x19; // MonCFG address
+ cmd[1] = 0x03; // Connect MON pin to Buck1 Output
+
+ pBUTTON.rise(&monSwitch);
+
+ ThisThread::sleep_for(1000ms);
+
+ printf("\n\n\n\n");
+ cmd[0] = 0;
+ while (true) {
+ rLED = LED_ON;
+
+ cmd[1] = command;
+ //pmic.write(address, cmd, 2);
+ //ThisThread::sleep_for(2ms);
+ //pmic.write(address, cmd, 1);
+ //pmic.read(address, readback, 1);
+
+ //voltage = ctoint(readback[0]);
+ printf("Register [%02X] Content : %02X \n", cmd[0], readback[0]);
+ //monPMIC.set_reference_voltage(1.2); //Reference Voltage is 1.25V | Resistive Partition is 4:1
+ //voltage = 1000 * monPMIC.read_voltage();
+ //printf("Voltage : %i mV\n",voltage);
+ //rLED = LED_OFF
+ cmd[0] = cmd[0] +1;
+ ThisThread::sleep_for(5000ms);
+ }
+ */
+}