Bernard Mentink / Mbed 2 deprecated MCS_LRF_EEP

Dependencies:   BLE_API mbed nRF51822

Fork of MCS_LRF by Farshad N

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ACA.cpp Source File

ACA.cpp

00001 //
00002 // This module implements ACA Charge mode for USB connected phones to external charge source.
00003 // A state-machine is required that runs when phone is attached/detached 
00004 //
00005 
00006 #include "ACA.h"
00007 
00008 // ACA Charger state machine
00009 #define IDLE_STATE      0
00010 #define WAIT_STATE      1
00011 
00012 static  int state=WAIT_STATE;
00013 static  int delay = 0;
00014 
00015 // Runs every 20ms for now
00016 // For now we just set the ID resistors to there default settings
00017 void ACAChargerTask()
00018 {
00019     switch(state)
00020     {
00021         case WAIT_STATE:
00022             disableVBUS = 1;    // disable VBUS
00023             ID_SW = 1;          // Enable 124k ID res
00024             ID_SW1 = 0; 
00025             delay++;
00026             if(delay==20) {     // delay 400ms
00027                 state = IDLE_STATE;
00028                 delay=0;
00029             }
00030         break;
00031         
00032         case IDLE_STATE:
00033              disableVBUS = 0;   //Enable VBUS, stay in this state till next power cycle
00034         break;
00035         
00036         
00037         default:
00038         break;
00039         
00040     }
00041 }
00042