repo time

Dependencies:   mbed MAX14720 MAX30205 USBDevice

Committer:
darienf
Date:
Tue Apr 06 06:41:40 2021 +0000
Revision:
20:6d2af70c92ab
Parent:
18:b64938c813dc
another repo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dan 0:7dec7e9ac085 1 #include "mbed.h"
switches 14:4c4094890fde 2 #include "MAX14720.h"
switches 14:4c4094890fde 3
switches 14:4c4094890fde 4 // I2C Master 2
switches 14:4c4094890fde 5 I2C i2c2(I2C2_SDA, I2C2_SCL);
dan 0:7dec7e9ac085 6
switches 14:4c4094890fde 7 #define I2C_ADDR_PMIC (0x54)
switches 14:4c4094890fde 8 MAX14720 max14720(&i2c2,I2C_ADDR_PMIC);
switches 14:4c4094890fde 9
switches 14:4c4094890fde 10 DigitalOut led(LED1);
switches 14:4c4094890fde 11 InterruptIn button(SW1);
switches 14:4c4094890fde 12
switches 14:4c4094890fde 13 void turnOff()
switches 14:4c4094890fde 14 {
switches 17:9a467f9a0579 15 // Write the power down command to the PMIC
switches 14:4c4094890fde 16 max14720.shutdown();
switches 14:4c4094890fde 17 }
dan 0:7dec7e9ac085 18
switches 14:4c4094890fde 19 int main()
switches 14:4c4094890fde 20 {
switches 17:9a467f9a0579 21 // Assign turnOff function to falling edge of button
switches 14:4c4094890fde 22 button.fall(&turnOff);
switches 17:9a467f9a0579 23
switches 17:9a467f9a0579 24 // Turn LED signal on to make buck-boost output visible
switches 14:4c4094890fde 25 led = 0;
switches 17:9a467f9a0579 26
switches 17:9a467f9a0579 27 // Override the default value of boostEn to BOOST_ENABLED
switches 14:4c4094890fde 28 max14720.boostEn = MAX14720::BOOST_ENABLED;
switches 17:9a467f9a0579 29 // Note that writing the local value does directly affect the part
switches 17:9a467f9a0579 30 // The buck-boost regulator will remain off until init is called
switches 17:9a467f9a0579 31
switches 17:9a467f9a0579 32 // Call init to apply all settings to the PMIC
switches 18:b64938c813dc 33 if (max14720.init() == MAX14720_ERROR) {
switches 18:b64938c813dc 34 printf("Error initializing MAX14720");
switches 18:b64938c813dc 35 }
switches 17:9a467f9a0579 36
switches 17:9a467f9a0579 37 // Wait 1 second to see the buck-boost regulator turn on
switches 14:4c4094890fde 38 wait(1);
switches 17:9a467f9a0579 39
dan 0:7dec7e9ac085 40 while(1) {
switches 17:9a467f9a0579 41 // Turn off the buck-boost regulators
switches 14:4c4094890fde 42 max14720.boostSetMode(MAX14720::BOOST_DISABLED);
switches 17:9a467f9a0579 43 wait(0.5);
switches 17:9a467f9a0579 44
switches 17:9a467f9a0579 45 // Change the voltage of the buck-boost regulator and enable it
switches 17:9a467f9a0579 46 max14720.boostSetVoltage(2500);
switches 17:9a467f9a0579 47 max14720.boostSetMode(MAX14720::BOOST_ENABLED);
switches 14:4c4094890fde 48 wait(0.5);
switches 17:9a467f9a0579 49
switches 17:9a467f9a0579 50 // Change the voltage of the buck-boost regulator
switches 18:b64938c813dc 51 // Note that the MAX14720 cannot change the buck-boost voltage while
switches 17:9a467f9a0579 52 // it is enabled so if boostEn is set to BOOST_ENABLED, this
switches 17:9a467f9a0579 53 // function will disable it, change the voltage, and re-enable it.
switches 14:4c4094890fde 54 max14720.boostSetVoltage(5000);
switches 14:4c4094890fde 55 wait(0.5);
stevep 4:81cea7a352b0 56 }
dan 0:7dec7e9ac085 57 }