Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
src/adc.cpp
- Committer:
- mfwic
- Date:
- 2018-12-07
- Revision:
- 9:816b9a4e4f21
- Parent:
- 8:d3d7dca419b3
- Child:
- 11:01dcfb29fbc4
File content as of revision 9:816b9a4e4f21:
//-------------------------------------------------------------------------------
//
// Treehouse Designs Inc.
// Colorado Springs, Colorado
//
// Copyright (c) 2016 by Treehouse Designs Inc.
// Copyright (c) 2018 by Agility Power Systems Inc.
//
// This code is the property of Treehouse Designs, Inc. (Treehouse) and
// Agility Power Systems Inc. (Agility) and may not be redistributed
// in any form without prior written permission from
// both copyright holders, Treehouse and Agility.
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
//
//-------------------------------------------------------------------------------
//
// REVISION HISTORY:
//
// $Author: $
// $Rev: $
// $Date: $
// $URL: $
//
//-------------------------------------------------------------------------------
#include "mbed.h"
#include "adc.h"
#include "all_io.h"
#include "globals.h"
void initADC(void){
}
void getADCresults(void){
unsigned int v48x = 0;
unsigned int v24x = 0;
unsigned int v12x = 0;
unsigned int i48x = 0;
unsigned int i24x = 0;
unsigned int i12x = 0;
unsigned int loopCounter = LOOP_COUNTER;
for(unsigned int i=0;i<loopCounter;i++){
v48x = v48x + VIN48.read_u16();
v24x = v24x + VIN24.read_u16();
v12x = v12x + VIN12.read_u16();
i48x = i48x + IIN48.read_u16();
i24x = i24x + IIN24.read_u16();
i12x = i12x + IIN12.read_u16();
}
v48 = v48x/loopCounter;
v24 = v24x/loopCounter;
v12 = v12x/loopCounter;
i48 = i48x/loopCounter;
i24 = i24x/loopCounter;
i12 = i12x/loopCounter;
}
void getADCvolts(void){
unsigned int v48x = 0;
unsigned int v24x = 0;
unsigned int v12x = 0;
for(unsigned int i=0;i<100;i++){
v48x = v48x + VIN48.read_u16();
v24x = v24x + VIN24.read_u16();
v12x = v12x + VIN12.read_u16();
}
v48 = v48x/100;
v24 = v24x/100;
v12 = v12x/100;
}
void getADCamps(void){
unsigned int i48x = 0;
unsigned int i24x = 0;
unsigned int i12x = 0;
for(unsigned int i=0;i<100;i++){
i48x = i48x + IIN48.read_u16();
i24x = i24x + IIN24.read_u16();
i12x = i12x = IIN12.read_u16();
}
i48 = i48x/100;
i24 = i24x/100;
i12 = i12x/100;
}