Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

DC_DC/DC_DC.cpp

Committer:
martydd3
Date:
2014-11-07
Revision:
21:2e83002d452d
Parent:
17:c9ce210f6654

File content as of revision 21:2e83002d452d:

#include "mbed.h"
#include "DC_DC.h"

FanPump *fanPump;
CANBuffer *tx_DC_Buffer;
bool status;

DigitalOut dc_pin(p20);

DC::DC(FanPump *fp, CANBuffer *can){
    status = false;
    dc_pin = !status;
    tx_DC_Buffer = can;
    fanPump = fp;
}

bool DC::is_on(){
    return status;
}

void DC::set(bool s){/*
    status = s;
    if(!status){
        fanPump->shutdown_all();    
    }
    
    dc_pin = !status;*/
}

void update_dcdc(const void *arg){
    char data[1] = {0};
    while(1){
        data[0] = status;
        CANMessage txMessage(TX_DC_DC_ID, data, 1);
        tx_DC_Buffer->txWrite(txMessage);
        
        Thread::wait(100);          //10 Hz update
    }
}

void DC::start_update(){
    Thread update_thread(update_dcdc);
}