This program controls the Power Management Circuit Board Revision A.

Dependencies:   PCAL955x mbed

Fork of PCAL9555_Hello by InetrfaceProducts NXP

main.cpp

Committer:
rvasquez6089
Date:
2017-03-30
Revision:
4:df821f0e9ad7
Parent:
3:42d01cfd6477

File content as of revision 4:df821f0e9ad7:

#include "mbed.h"
#include "PCAL9555.h"

PCAL9555    gpio_exp( PB_9, PB_8, 0x40 );    //  SDA, SCL, Slave_address(option)
GpioDigitalOut  Bat3EN( gpio_exp, X0_2 );
GpioDigitalOut  Bat2EN( gpio_exp, X0_1 );
GpioDigitalOut  Bat1EN( gpio_exp, X0_0 );
 
Serial pi(PA_11, PA_12);
DigitalOut EN33(PA_8);
DigitalOut EN_PI_PWR(PA_9);
DigitalOut EN_SERVO_PWR(PB_5);
DigitalOut EN_LIGHTS_PWR(PA_10);
DigitalOut BAT_PWR_EN(PB_10);
AnalogIn BatS1(PA_0);
AnalogIn BatS2(PA_3);

int main() {
    int i = 1;
    float BatS1V;
    float BatS2V;
    pi.printf("Hello World !\n");
    Bat3EN = 1;
    Bat2EN = 1;
    Bat1EN = 1;
    EN33 = 1;

    EN_SERVO_PWR = 1;
    //EN_LIGHTS_PWR = 1;
    //EN_PI_PWR = 1;
    BAT_PWR_EN = 1;
    while( 1 ) {
        wait(3);
        //BAT_PWR_EN = !BAT_PWR_EN;
        pi.printf("This program runs since %d seconds.\n", i++);
        BatS1V = BatS1*(3.30/0.25);
        BatS2V = BatS2*(3.30/0.25);
        pi.printf("Battery 1 Voltage = %d Battery 2 Voltage = %d", static_cast<int>(BatS1V),static_cast<int>(BatS2V));
 
        }
    }