Corrected STOPED -> STOPPED

This commit is contained in:
Nicolas Sanz 2013-03-22 17:06:42 -03:00
parent 80585467df
commit d737eb0198
2 changed files with 10 additions and 10 deletions

View File

@ -23,12 +23,12 @@ void idDHT11::init(int pin, int intNumber, void (*callback_wrapper) ()) {
temp = 0; temp = 0;
pinMode(pin, OUTPUT); pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH); digitalWrite(pin, HIGH);
state = STOPED; state = STOPPED;
status = IDDHTLIB_ERROR_NOTSTARTED; status = IDDHTLIB_ERROR_NOTSTARTED;
} }
int idDHT11::acquire() { int idDHT11::acquire() {
if (state == STOPED || state == ACQUIRED) { if (state == STOPPED || state == ACQUIRED) {
//set the state machine for interruptions analisis of the signal //set the state machine for interruptions analisis of the signal
state = RESPONSE; state = RESPONSE;
@ -62,7 +62,7 @@ void idDHT11::isrCallback() {
us = newUs; us = newUs;
if (delta>6000) { if (delta>6000) {
status = IDDHTLIB_ERROR_TIMEOUT; status = IDDHTLIB_ERROR_TIMEOUT;
state = STOPED; state = STOPPED;
detachInterrupt(intNumber); detachInterrupt(intNumber);
return; return;
} }
@ -75,14 +75,14 @@ void idDHT11::isrCallback() {
} else { } else {
detachInterrupt(intNumber); detachInterrupt(intNumber);
status = IDDHTLIB_ERROR_TIMEOUT; status = IDDHTLIB_ERROR_TIMEOUT;
state = STOPED; state = STOPPED;
} }
break; break;
case DATA: case DATA:
if(delta<10) { if(delta<10) {
detachInterrupt(intNumber); detachInterrupt(intNumber);
status = IDDHTLIB_ERROR_DELTA; status = IDDHTLIB_ERROR_DELTA;
state = STOPED; state = STOPPED;
// return; // return;
} else if(60<delta && delta<135) { //valid in timing } else if(60<delta && delta<135) { //valid in timing
if(delta>90) //is a one if(delta>90) //is a one
@ -98,7 +98,7 @@ void idDHT11::isrCallback() {
uint8_t sum = bits[0] + bits[2]; uint8_t sum = bits[0] + bits[2];
if (bits[4] != sum) { if (bits[4] != sum) {
status = IDDHTLIB_ERROR_CHECKSUM; status = IDDHTLIB_ERROR_CHECKSUM;
state = STOPED; state = STOPPED;
} else { } else {
status = IDDHTLIB_OK; status = IDDHTLIB_OK;
state = ACQUIRED; state = ACQUIRED;
@ -109,7 +109,7 @@ void idDHT11::isrCallback() {
} else { } else {
detachInterrupt(intNumber); detachInterrupt(intNumber);
status = IDDHTLIB_ERROR_TIMEOUT; status = IDDHTLIB_ERROR_TIMEOUT;
state = STOPED; state = STOPPED;
} }
break; break;
default: default:
@ -117,7 +117,7 @@ void idDHT11::isrCallback() {
} }
} }
bool idDHT11::acquiring() { bool idDHT11::acquiring() {
if (state != ACQUIRED && state != STOPED) if (state != ACQUIRED && state != STOPPED)
return true; return true;
return false; return false;
} }

View File

@ -33,7 +33,7 @@
#define IDDHTLIB_ERROR_DELTA -4 #define IDDHTLIB_ERROR_DELTA -4
#define IDDHTLIB_ERROR_NOTSTARTED -5 #define IDDHTLIB_ERROR_NOTSTARTED -5
#define IDDHT11_CHECK_STATE if(state == STOPED) \ #define IDDHT11_CHECK_STATE if(state == STOPPED) \
return status; \ return status; \
else if(state != ACQUIRED) \ else if(state != ACQUIRED) \
return IDDHTLIB_ERROR_ACQUIRING; return IDDHTLIB_ERROR_ACQUIRING;
@ -58,7 +58,7 @@ private:
void (*isrCallback_wrapper)(void); void (*isrCallback_wrapper)(void);
enum states{RESPONSE=0,DATA=1,ACQUIRED=2,STOPED=3,ACQUIRING=4}; enum states{RESPONSE=0,DATA=1,ACQUIRED=2,STOPPED=3,ACQUIRING=4};
volatile states state; volatile states state;
volatile int status; volatile int status;
volatile byte bits[5]; volatile byte bits[5];