repo time
Dependencies: mbed MAX14720 MAX30205 USBDevice
Revision 17:9a467f9a0579, committed 2016-10-06
- Comitter:
- switches
- Date:
- Thu Oct 06 17:11:37 2016 +0000
- Parent:
- 16:f5ef654b08f0
- Child:
- 18:b64938c813dc
- Commit message:
- Added comments to explain the code
Changed in this revision
| MAX14720.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MAX14720.lib Tue Oct 04 23:57:03 2016 +0000 +++ b/MAX14720.lib Thu Oct 06 17:11:37 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/switches/code/MAX14720/#2e4837c3b6e1 +https://developer.mbed.org/users/switches/code/MAX14720/#06450093da48
--- a/main.cpp Tue Oct 04 23:57:03 2016 +0000
+++ b/main.cpp Thu Oct 06 17:11:37 2016 +0000
@@ -12,24 +12,46 @@
void turnOff()
{
+ // Write the power down command to the PMIC
max14720.shutdown();
}
int main()
{
int result;
+
+ // Assign turnOff function to falling edge of button
button.fall(&turnOff);
+
+ // Turn LED signal on to make buck-boost output visible
led = 0;
+
+ // Override the default value of boostEn to BOOST_ENABLED
max14720.boostEn = MAX14720::BOOST_ENABLED;
+ // Note that writing the local value does directly affect the part
+ // The buck-boost regulator will remain off until init is called
+
+ // Call init to apply all settings to the PMIC
result = max14720.init();
if (result == MAX14720_ERROR) printf("Error initializing MAX14720");
+
+ // Wait 1 second to see the buck-boost regulator turn on
wait(1);
+
while(1) {
+ // Turn off the buck-boost regulators
max14720.boostSetMode(MAX14720::BOOST_DISABLED);
- max14720.boostEn = MAX14720::BOOST_ENABLED;
+ wait(0.5);
+
+ // Change the voltage of the buck-boost regulator and enable it
+ max14720.boostSetVoltage(2500);
+ max14720.boostSetMode(MAX14720::BOOST_ENABLED);
wait(0.5);
- max14720.boostSetVoltage(2500);
- wait(0.5);
+
+ // Change the voltage of the buck-boost regulator
+ // Note that the MAX14720 cannot change the buck-boost voltage while
+ // it is enabled so if boostEn is set to BOOST_ENABLED, this
+ // function will disable it, change the voltage, and re-enable it.
max14720.boostSetVoltage(5000);
wait(0.5);
}