library for MAX9611 /9612 Current-Sense Amplifiers
Diff: max9611.cpp
- Revision:
- 8:1e392bc95666
- Parent:
- 7:012f5b39405e
--- a/max9611.cpp Wed Jan 28 12:00:25 2015 +0000 +++ b/max9611.cpp Wed Jan 28 17:53:26 2015 +0000 @@ -41,12 +41,12 @@ uint8_t retVal=0; uint8_t controlReg1=0; uint8_t controlReg2=0; - controlReg1=(mode<<5|lr<<4|shdn<<3|mux); controlReg2=(watchdogDelay<<3|watchdogRetryDelay<<2); retVal+= write(CONTROL_REGISTER_1_ADRR,&controlReg1,1); retVal+= write(CONTROL_REGISTER_2_ADRR,&controlReg2,1); if(retVal!=2) return false; + mMuxReg= mux; return true; } @@ -74,10 +74,10 @@ uint16_t rawCSAVal=0; if(!read(CSA_DATA_BYTE_MSB_ADRR, rawData,2)) return false; rawCSAVal= get12BitData(rawData[0],rawData[1]); - mRawInt = rawCSAVal; + //mRawInt = rawCSAVal; //debug if(rawCSAVal<=mCsaCurrentValueOffset) mCurrentSenseAmplifierOutput=0; - else mCurrentSenseAmplifierOutput= (float)(rawCSAVal)*(0.269); + else mCurrentSenseAmplifierOutput= (float)(rawCSAVal)*(getCSACurrentCoeffmA()); // to get result in [mA] return true; }