Skip to content

Commit

Permalink
Prepare changes to ADS1231: Fix newlines and whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jan 10, 2017
1 parent bb48616 commit 62487f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 deletions libraries/ADS1231/ADS1231.cpp
@@ -1,29 +1,29 @@
#include "ADS1231.h" //include the declaration for this class

static ADS1231_t ADS1231s[MAX_ADS1231]; // static array of ADS1231 structures
uint8_t ADS1231Count = 0; // the total number of attached ADS1231

//<<constructor>> setup the ADS1231
ADS1231::ADS1231(){
if( ADS1231Count < MAX_ADS1231) {
this->ADS1231Index = ADS1231Count++; // assign a ADS1231 index to this instance
}
else
this->ADS1231Index = INVALID_ADS1231 ; // too many servos
this->ADS1231Index = INVALID_ADS1231 ; // too many servos
}

//<<destructor>>
ADS1231::~ADS1231(){/*nothing to destruct*/}

//turn on resp. off the ads
void ADS1231::attach( uint8_t sclPin , uint8_t dataPin , uint8_t pwdnPin ) {
if( ADS1231Count < MAX_ADS1231) {
volatile uint8_t *out;
// store Pin numbers
ADS1231s[this->ADS1231Index].sclBit = digitalPinToBitMask(sclPin);
ADS1231s[this->ADS1231Index].sclPort = digitalPinToPort( sclPin);
ADS1231s[this->ADS1231Index].dataBit = digitalPinToBitMask(dataPin);
ADS1231s[this->ADS1231Index].dataPort = digitalPinToPort( dataPin);
ADS1231s[this->ADS1231Index].sclBit = digitalPinToBitMask(sclPin);
ADS1231s[this->ADS1231Index].sclPort = digitalPinToPort( sclPin);
ADS1231s[this->ADS1231Index].dataBit = digitalPinToBitMask(dataPin);
ADS1231s[this->ADS1231Index].dataPort = digitalPinToPort( dataPin);
ADS1231s[this->ADS1231Index].pwdnBit = digitalPinToBitMask(pwdnPin);
ADS1231s[this->ADS1231Index].pwdnPort = digitalPinToPort( pwdnPin);
// block interrupts
Expand All @@ -40,8 +40,8 @@
// initialize the power down pin as an output:
pinMode(pwdnPin, OUTPUT);
// reenable interrupts
SREG = oldSREG;
// reset ads1232 with a 10ms pulse on power down pin:
SREG = oldSREG;
// reset ads1232 with a 10ms pulse on power down pin:
power(LOW);
delay(10);
power(HIGH);
Expand All @@ -53,11 +53,11 @@
volatile uint8_t *out;
if( power_mode == LOW ) {
out = portOutputRegister(ADS1231s[this->ADS1231Index].pwdnPort);
*out &= ~ADS1231s[this->ADS1231Index].pwdnBit; // set pwdnPin low
*out &= ~ADS1231s[this->ADS1231Index].pwdnBit; // set pwdnPin low
}
else {
out = portOutputRegister(ADS1231s[this->ADS1231Index].pwdnPort);
*out |= ADS1231s[this->ADS1231Index].pwdnBit; // set pwdnPin high
*out |= ADS1231s[this->ADS1231Index].pwdnBit; // set pwdnPin high
}
}

Expand All @@ -68,7 +68,7 @@
else {
return HIGH; }
}

//read data from ads1231
long ADS1231::readData(){
long dataValue = 0;
Expand Down Expand Up @@ -97,8 +97,8 @@
void ADS1231::sclPulse(){
volatile uint8_t *out;
out = portOutputRegister(ADS1231s[this->ADS1231Index].sclPort);
*out |= ADS1231s[this->ADS1231Index].sclBit; // set sclPin high
*out |= ADS1231s[this->ADS1231Index].sclBit; // set sclPin high
// delayMicroseconds(1);
out = portOutputRegister(ADS1231s[this->ADS1231Index].sclPort);
*out &= ~ADS1231s[this->ADS1231Index].sclBit; // set sclPin low
*out &= ~ADS1231s[this->ADS1231Index].sclBit; // set sclPin low
}
8 changes: 4 additions & 4 deletions libraries/ADS1231/ADS1231.h
@@ -1,6 +1,6 @@
#ifndef ADS1231_H
#define ADS1231_H

#include <inttypes.h>
#include <Arduino.h> //It is very important to remember this! note that if you are using Arduino 1.0 IDE, change "WProgram.h" to "Arduino.h"

Expand All @@ -15,9 +15,9 @@
uint8_t dataPort ; // a pin number from 0 to 63
uint8_t pwdnBit ; // a pin number from 0 to 63
uint8_t pwdnPort ; // a pin number from 0 to 63
} ADS1231_t ;
} ADS1231_t ;



class ADS1231 {
public:
ADS1231();
Expand All @@ -31,5 +31,5 @@
private:
uint8_t ADS1231Index; // index into the channel data for this ADS1231
};

#endif

0 comments on commit 62487f1

Please sign in to comment.