#include <WaspRTC.h>
Public Member Functions | |
| WaspRTC () | |
| class constructor | |
| uint8_t | BCD2byte (uint8_t number) |
| It converts a number from BCD to byte. | |
| uint8_t | BCD2byte (uint8_t high, uint8_t low) |
| It converts a number from BCD to byte. | |
| uint8_t | byte2BCD (uint8_t theNumber) |
| It converts a number from int to BCD. | |
| void | resetVars () |
| It resets the variables used through the library. | |
| char * | getRTCarray () |
| It gets 'registerRTC' variable. | |
| char * | getTimestamp () |
| It gets date and time. | |
| void | writeRTC () |
| It writes the date and time set in the corresponding variables to the RTC. | |
| void | readRTC (uint8_t endAddress) |
| It reads from the RTC the date,time and optionally alarm1 and alarm2, setting the corresponding variables. | |
| void | writeRTCregister (uint8_t theAddress) |
| It writes to the RTC the selected registers stored in 'registersRTC'. | |
| void | readRTCregister (uint8_t theAddress) |
| It reads from the RTC the selected register, and stores it in 'registersRTC' variable. | |
| void | configureAlarmMode (uint8_t alarmNum, uint8_t alarmMode) |
| It configures the alarm mode and attaches the interruption. | |
| void | writeRTCalarm1 () |
| It writes Alarm1 to the RTC. | |
| void | writeRTCalarm2 () |
| It writes Alarm2 to the RTC. | |
| void | attachInt (void) |
| It attaches the interruption to the defined pin. | |
| void | detachInt (void) |
| It detaches the interruption from the defined pin. | |
| void | ON () |
| It opens I2C bus and powers the RTC. | |
| void | OFF () |
| It closes I2C and powers off the RTC module. | |
| void | begin () |
| It inits the I2C bus and the variables reading them from the RTC. | |
| void | close () |
| It closes I2C bus. | |
| void | setMode (uint8_t mode) |
| It sets Power Mode. | |
| uint8_t | getMode () |
| It gets Power Mode. | |
| void | setTime (const char *time) |
| It sets in the RTC the specified date and time. | |
| void | setTime (uint8_t year, uint8_t month, uint8_t date, uint8_t day_week, uint8_t hour, uint8_t minute, uint8_t second) |
| It sets in the RTC the specified date and time. | |
| char * | getTime () |
| It gets from the RTC the date and time, storing them in the corresponding variables. | |
| void | setTimeFromGPS () |
| It sets time and date from the GPS to the RTC. GPS has to be initialized first and got the time/date. | |
| void | setAlarm1 (const char *time, uint8_t offset, uint8_t mode) |
| It sets Alarm1 to the specified time. It also enables the corresponding RTC interruption. | |
| void | setAlarm1 (uint8_t day_date, uint8_t hour, uint8_t minute, uint8_t second, uint8_t offset, uint8_t mode) |
| It sets Alarm1 to the specified time. It also enables the corresponding RTC interruption. | |
| char * | getAlarm1 () |
| It gets Alarm1 date and time from the RTC, storing them in the corresponding variables. | |
| void | setAlarm2 (const char *time, uint8_t offset, uint8_t mode) |
| It sets Alarm2 to the specified time. It also enables the corresponding RTC interruption. | |
| void | setAlarm2 (uint8_t day_date, uint8_t hour, uint8_t minute, uint8_t offset, uint8_t mode) |
| It sets Alarm2 to the specified time. It also enables the corresponding RTC interruption. | |
| char * | getAlarm2 () |
| It gets Alarm2 date and time from the RTC, storing them in the corresponding variables. | |
| void | clearAlarmFlag () |
| It clears bits A1F and A2F, necessary to be able to catch interrupts after previous interrupts. | |
| uint8_t | getTemperature () |
| It gets the temperature from the RTC temperature sensor. | |
Data Fields | |
| uint8_t | registersRTC [RTC_DATA_SIZE] |
| Variable : Array for storing the value of the different RTC registers. | |
| uint8_t | year |
| Variable : It stores the value of the year. | |
| uint8_t | month |
| Variable : It stores the value of the month. | |
| uint8_t | day |
| Variable : It stores the value of the day of the week. | |
| uint8_t | hour |
| Variable : It stores the value of the hours. | |
| uint8_t | minute |
| Variable : It stores the value of the minutes. | |
| uint8_t | second |
| Variable : It stores the value of the seconds. | |
| uint8_t | date |
| Variable : It stores the value of the date(day of the week). | |
| uint8_t | second_alarm1 |
| Variable : It stores the value of the seconds for Alarm1. | |
| uint8_t | minute_alarm1 |
| Variable : It stores the value of the minutes for Alarm1. | |
| uint8_t | hour_alarm1 |
| Variable : It stores the value of the hours for Alarm1. | |
| uint8_t | day_alarm1 |
| Variable : It stores the value of the day of the week/date for Alarm1. | |
| uint8_t | minute_alarm2 |
| Variable : It stores the value of the minutes for Alarm2. | |
| uint8_t | hour_alarm2 |
| Variable : It stores the value of the hours for Alarm2. | |
| uint8_t | day_alarm2 |
| Variable : It stores the value of the day of the week/date for Alarm2. | |
| uint8_t | alarm1Mode |
| Variable : It stores the alarm mode for the Alarm 1. | |
| uint8_t | alarm2Mode |
| Variable : It stores the alarm mode for the Alarm 2. | |
| uint8_t | temp |
| Variable : It stores the value of the temperature. | |
| bool | tempNegative |
| Variable : It stores if the temperature is negative or possitive. | |
| uint8_t | _pwrMode |
| Variable : It stores the RTC power mode. | |
WaspRTC Class defines all the variables and functions used for managing the RTC
Definition at line 266 of file WaspRTC.h.
| WaspRTC::WaspRTC | ( | ) |
class constructor
It does nothing
| void |
Definition at line 32 of file WaspRTC.cpp.
| uint8_t WaspRTC::BCD2byte | ( | uint8_t | number | ) |
It converts a number from BCD to byte.
| uint8_t | number : number to convert |
Definition at line 1137 of file WaspRTC.cpp.
Referenced by readRTC(), setAlarm1(), setAlarm2(), and setTime().

| uint8_t WaspRTC::BCD2byte | ( | uint8_t | high, | |
| uint8_t | low | |||
| ) |
It converts a number from BCD to byte.
| uint8_t | high : higher part of the number to convert | |
| uint8_t | low : lower part of the number to convert |
Definition at line 1144 of file WaspRTC.cpp.
| uint8_t WaspRTC::byte2BCD | ( | uint8_t | theNumber | ) |
It converts a number from int to BCD.
| uint8_t | theNumber : number to convert |
Definition at line 1151 of file WaspRTC.cpp.
Referenced by writeRTC(), writeRTCalarm1(), and writeRTCalarm2().
01152 { 01153 return (theNumber%10 | ((theNumber-theNumber%10)/10)<<4); // note that binary operations have preference on the others 01154 }

| void WaspRTC::resetVars | ( | ) |
It resets the variables used through the library.
| void |
Definition at line 128 of file WaspRTC.cpp.
References alarm1Mode, alarm2Mode, date, day, day_alarm1, day_alarm2, hour, hour_alarm1, hour_alarm2, minute, minute_alarm1, minute_alarm2, month, second, second_alarm1, temp, tempNegative, and year.
Referenced by begin().
00129 { 00130 year = 0; 00131 month = 0; 00132 day = 0; 00133 hour = 0; 00134 minute = 0; 00135 second = 0; 00136 date = 0; 00137 second_alarm1 = 0; 00138 minute_alarm1 = 0; 00139 hour_alarm1 = 0; 00140 day_alarm1 = 0; 00141 minute_alarm2 = 0; 00142 hour_alarm2 = 0; 00143 day_alarm2 = 0; 00144 alarm1Mode = 0; 00145 alarm2Mode = 0; 00146 temp=0; 00147 tempNegative=false; 00148 }

| char * WaspRTC::getRTCarray | ( | ) |
It gets 'registerRTC' variable.
| void |
Definition at line 157 of file WaspRTC.cpp.
References registersRTC, and RTC_DATA_SIZE.
00158 { 00159 char aux[60]; 00160 for(uint8_t i = 0; i < RTC_DATA_SIZE; i++) { 00161 sprintf(aux, "%u", registersRTC[i]); 00162 } 00163 return aux; 00164 }
| char * WaspRTC::getTimestamp | ( | ) |
It gets date and time.
| void |
Definition at line 171 of file WaspRTC.cpp.
References date, day, DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7, hour, minute, month, second, and year.
Referenced by getTime().
00172 { 00173 char* aux="\0 " ; 00174 switch (day) { 00175 case 1: 00176 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_1, year, month, date, hour, minute, second); 00177 break; 00178 case 2: 00179 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_2, year, month, date, hour, minute, second); 00180 break; 00181 case 3: 00182 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_3, year, month, date, hour, minute, second); 00183 break; 00184 case 4: 00185 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_4, year, month, date, hour, minute, second); 00186 break; 00187 case 5: 00188 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_5, year, month, date, hour, minute, second); 00189 break; 00190 case 6: 00191 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_6, year, month, date, hour, minute, second); 00192 break; 00193 case 7: 00194 sprintf (aux, "%s, %d/%d/%d - %d:%d.%d", DAY_7, year, month, date, hour, minute, second); 00195 break; 00196 } 00197 return aux; 00198 }

| void WaspRTC::writeRTC | ( | ) |
It writes the date and time set in the corresponding variables to the RTC.
| void |
Definition at line 290 of file WaspRTC.cpp.
References TwoWire::beginTransmission(), byte2BCD(), date, day, TwoWire::endTransmission(), hour, minute, month, registersRTC, RTC_ADDRESS, RTC_DATE_ADDRESS, RTC_DAYS_ADDRESS, RTC_HOURS_ADDRESS, RTC_MINUTES_ADDRESS, RTC_MONTH_ADDRESS, RTC_SECONDS_ADDRESS, RTC_START_ADDRESS, RTC_YEAR_ADDRESS, second, TwoWire::send(), Wire, and year.
Referenced by setTime().
00291 { 00292 int timecount = 0; 00293 Wire.beginTransmission(RTC_ADDRESS); // transmit to device #104 (0x4A) 00294 // the address specified in the datasheet is 208 (0xD0) 00295 // but i2c adressing uses the high 7 bits so it's 104 00296 Wire.send(RTC_START_ADDRESS); // start from address zero 00297 00298 registersRTC[RTC_SECONDS_ADDRESS] = byte2BCD(second); 00299 registersRTC[RTC_MINUTES_ADDRESS] = byte2BCD(minute); 00300 registersRTC[RTC_HOURS_ADDRESS] = byte2BCD(hour); 00301 registersRTC[RTC_DAYS_ADDRESS] = day; 00302 registersRTC[RTC_DATE_ADDRESS] = byte2BCD(date); 00303 registersRTC[RTC_MONTH_ADDRESS] = byte2BCD(month); 00304 registersRTC[RTC_YEAR_ADDRESS] = byte2BCD(year); 00305 00306 for(timecount = 0; timecount <= 0x06; timecount++) { 00307 Wire.send(registersRTC[timecount]); 00308 } 00309 00310 Wire.endTransmission(); 00311 }


| void WaspRTC::readRTC | ( | uint8_t | endAddress | ) |
It reads from the RTC the date,time and optionally alarm1 and alarm2, setting the corresponding variables.
| uint8_t | endAddress : specifies the last RTC register we want to read |
Definition at line 213 of file WaspRTC.cpp.
References TwoWire::available(), B00000011, B00000111, B00001111, BCD2byte(), TwoWire::beginTransmission(), date, day, day_alarm1, day_alarm2, TwoWire::endTransmission(), hour, hour_alarm1, hour_alarm2, minute, minute_alarm1, minute_alarm2, month, TwoWire::receive(), registersRTC, TwoWire::requestFrom(), RTC_ADDRESS, RTC_DATA_SIZE, RTC_START_ADDRESS, second, second_alarm1, TwoWire::send(), Wire, and year.
Referenced by begin(), getAlarm1(), getAlarm2(), getTime(), setAlarm1(), and setAlarm2().
00214 { 00215 uint16_t timecount = 0; 00216 // ADDRESSING FROM MEMORY POSITION ZERO 00217 Wire.beginTransmission(RTC_ADDRESS); // transmit to device #104 (0x68) 00218 // the address specified in the datasheet is 208 (0xD0) 00219 // but i2c adressing uses the high 7 bits so it's 104 00220 Wire.send(RTC_START_ADDRESS); // start from address zero 00221 Wire.endTransmission(); 00222 00223 // START READING 00224 Wire.requestFrom(RTC_ADDRESS, RTC_DATA_SIZE); // transmit to device #104 (0x68) 00225 // the address specified in the datasheet is 208 (0xD0) 00226 // but i2c adressing uses the high 7 bits so it's 104 00227 00228 while(timecount <= endAddress) // slave may send less than requested 00229 { 00230 if (Wire.available()) { 00231 uint8_t c = Wire.receive(); // receive a byte as character 00232 registersRTC[timecount] = c; 00233 switch (timecount) { 00234 case 0: 00235 second = BCD2byte(c>>4, c&B00001111); 00236 break; 00237 case 1: 00238 minute = BCD2byte(c>>4, c&B00001111); 00239 break; 00240 case 2: 00241 hour = BCD2byte(c>>4, c&B00001111); 00242 break; 00243 case 3: 00244 day = c; 00245 break; 00246 case 4: 00247 date = BCD2byte(c>>4, c&B00001111); 00248 break; 00249 case 5: 00250 month = BCD2byte(c>>4, c&B00001111); 00251 break; 00252 case 6: 00253 year = BCD2byte(c>>4, c&B00001111); 00254 break; 00255 case 7: 00256 second_alarm1 = BCD2byte((c>>4)&B00000111, c&B00001111); 00257 break; 00258 case 8: 00259 minute_alarm1 = BCD2byte((c>>4)&B00000111, c&B00001111); 00260 break; 00261 case 9: 00262 hour_alarm1 = BCD2byte((c>>4)&B00000011, c&B00001111); 00263 break; 00264 case 10: 00265 day_alarm1 = BCD2byte((c>>4)&B00000011, c&B00001111); 00266 break; 00267 case 11: 00268 minute_alarm2 = BCD2byte((c>>4)&B00000111, c&B00001111); 00269 break; 00270 case 12: 00271 hour_alarm2 = BCD2byte((c>>4)&B00000011, c&B00001111); 00272 break; 00273 case 13: 00274 day_alarm2 = BCD2byte((c>>4)&B00000011, c&B00001111); 00275 break; 00276 } 00277 timecount++; 00278 } 00279 } 00280 00281 timecount = 0; 00282 }


| void WaspRTC::writeRTCregister | ( | uint8_t | theAddress | ) |
It writes to the RTC the selected registers stored in 'registersRTC'.
| uint8_t | theAddress : specifies the RTC register address where we want to start writing |
Definition at line 576 of file WaspRTC.cpp.
References TwoWire::beginTransmission(), TwoWire::endTransmission(), registersRTC, RTC_ADDRESS, TwoWire::send(), and Wire.
Referenced by clearAlarmFlag(), and configureAlarmMode().
00577 { 00578 // ADDRESSING FROM MEMORY POSITION RECEIVED AS PARAMETER 00579 Wire.beginTransmission(RTC_ADDRESS); // transmit to device #104 (0x68) 00580 // the address specified in the datasheet is 208 (0xD0) 00581 // but i2c adressing uses the high 7 bits so it's 104 00582 Wire.send(theAddress); // start from address theAddress 00583 00584 // START SENDING 00585 Wire.send(registersRTC[theAddress]); 00586 Wire.endTransmission(); 00587 }


| void WaspRTC::readRTCregister | ( | uint8_t | theAddress | ) |
It reads from the RTC the selected register, and stores it in 'registersRTC' variable.
| uint8_t | theAddress : specifies the RTC register address where we want to read from |
Definition at line 596 of file WaspRTC.cpp.
References TwoWire::available(), TwoWire::beginTransmission(), TwoWire::endTransmission(), TwoWire::receive(), registersRTC, TwoWire::requestFrom(), RTC_ADDRESS, TwoWire::send(), and Wire.
Referenced by getTemperature().
00597 { 00598 // ADDRESSING FROM MEMORY POSITION RECEIVED AS PARAMETER 00599 Wire.beginTransmission(RTC_ADDRESS); // transmit to device #104 (0x68) 00600 // the address specified in the datasheet is 208 (0xD0) 00601 // but i2c adressing uses the high 7 bits so it's 104 00602 Wire.send(theAddress); // start from address theAddress 00603 Wire.endTransmission(); 00604 00605 // START READING 00606 Wire.requestFrom(RTC_ADDRESS, 0x01); // transmit to device #104 (0x68) 00607 // the address specified in the datasheet is 208 (0xD0) 00608 // but i2c adressing uses the high 7 bits so it's 104 00609 while(!Wire.available()) {}; 00610 registersRTC[theAddress] = Wire.receive(); 00611 Wire.endTransmission(); 00612 }


| void WaspRTC::configureAlarmMode | ( | uint8_t | alarmNum, | |
| uint8_t | alarmMode | |||
| ) |
It configures the alarm mode and attaches the interruption.
| uint8_t | alarmNum : specifies the alarm we want to use | |
| uint8_t | alarmMode : specifies the alarm mode we want to use |
Definition at line 387 of file WaspRTC.cpp.
References attachInt(), B00000101, B00000110, B00111111, B01000000, B01111111, B10000000, B11111000, B11111100, B11111101, B11111110, detachInt(), registersRTC, RTC_ALM1_DAYS_ADDRESS, RTC_ALM1_HOURS_ADDRESS, RTC_ALM1_MINUTES_ADDRESS, RTC_ALM1_SECONDS_ADDRESS, RTC_ALM2_DAYS_ADDRESS, RTC_ALM2_HOURS_ADDRESS, RTC_ALM2_MINUTES_ADDRESS, RTC_CONTROL_ADDRESS, RTC_STATUS_ADDRESS, and writeRTCregister().
Referenced by setAlarm1(), and setAlarm2().
00388 { 00389 if (alarmNum == 1){ 00390 00391 registersRTC[RTC_CONTROL_ADDRESS] &= B11111101; // activate the INT/SQW output on alarm match 00392 registersRTC[RTC_CONTROL_ADDRESS] |= B00000101; 00393 writeRTCregister(RTC_CONTROL_ADDRESS); 00394 registersRTC[RTC_STATUS_ADDRESS] &= B11111100; // reset the alarm flags 00395 writeRTCregister(RTC_STATUS_ADDRESS); 00396 00397 switch (alarmMode){ 00398 case 0: // when day, hours, minutes and seconds match 00399 registersRTC[RTC_ALM1_SECONDS_ADDRESS] &= B01111111; // set A1M1 bit to 0 00400 writeRTCregister(RTC_ALM1_SECONDS_ADDRESS); 00401 00402 registersRTC[RTC_ALM1_MINUTES_ADDRESS] &= B01111111; // set A1M2 bit to 0 00403 writeRTCregister(RTC_ALM1_MINUTES_ADDRESS); 00404 00405 registersRTC[RTC_ALM1_HOURS_ADDRESS] &= B01111111; // set A1M3 bit to 0 00406 writeRTCregister(RTC_ALM1_HOURS_ADDRESS); 00407 00408 registersRTC[RTC_ALM1_DAYS_ADDRESS] &= B01111111; // set A1M4 bit to 0 00409 registersRTC[RTC_ALM1_DAYS_ADDRESS] |= B01000000; // set DY/DT bit to 1 00410 writeRTCregister(RTC_ALM1_DAYS_ADDRESS); 00411 00412 break; 00413 00414 case 1: // when date, hours, minutes and seconds match 00415 registersRTC[RTC_ALM1_SECONDS_ADDRESS] &= B01111111; // set A1M1 bit to 0 00416 writeRTCregister(RTC_ALM1_SECONDS_ADDRESS); 00417 00418 registersRTC[RTC_ALM1_MINUTES_ADDRESS] &= B01111111; // set A1M2 bit to 0 00419 writeRTCregister(RTC_ALM1_MINUTES_ADDRESS); 00420 00421 registersRTC[RTC_ALM1_HOURS_ADDRESS] &= B01111111; // set A1M3 bit to 0 00422 writeRTCregister(RTC_ALM1_HOURS_ADDRESS); 00423 00424 registersRTC[RTC_ALM1_DAYS_ADDRESS] &= B00111111; // set A1M4 bit to 0 and DY/DT to 0 00425 00426 writeRTCregister(RTC_ALM1_DAYS_ADDRESS); 00427 00428 break; 00429 case 2: // when hours, minutes and seconds match 00430 registersRTC[RTC_ALM1_SECONDS_ADDRESS] &= B01111111; // set A1M1 bit to 0 00431 writeRTCregister(RTC_ALM1_SECONDS_ADDRESS); 00432 00433 registersRTC[RTC_ALM1_MINUTES_ADDRESS] &= B01111111; // set A1M2 bit to 0 00434 writeRTCregister(RTC_ALM1_MINUTES_ADDRESS); 00435 00436 registersRTC[RTC_ALM1_HOURS_ADDRESS] &= B01111111; // set A1M3 bit to 0 00437 writeRTCregister(RTC_ALM1_HOURS_ADDRESS); 00438 00439 registersRTC[RTC_ALM1_DAYS_ADDRESS] |= B10000000; // set A1M4 bit to 1 00440 writeRTCregister(RTC_ALM1_DAYS_ADDRESS); 00441 00442 break; 00443 case 3: // when minutes and seconds match 00444 registersRTC[RTC_ALM1_SECONDS_ADDRESS] &= B01111111; // set A1M1 bit to 0 00445 writeRTCregister(RTC_ALM1_SECONDS_ADDRESS); 00446 00447 registersRTC[RTC_ALM1_MINUTES_ADDRESS] &= B01111111; // set A1M2 bit to 0 00448 writeRTCregister(RTC_ALM1_MINUTES_ADDRESS); 00449 00450 registersRTC[RTC_ALM1_HOURS_ADDRESS] |= B10000000; // set A1M3 bit to 1 00451 writeRTCregister(RTC_ALM1_HOURS_ADDRESS); 00452 00453 registersRTC[RTC_ALM1_DAYS_ADDRESS] |= B10000000; // set A1M4 bit to 1 00454 writeRTCregister(RTC_ALM1_DAYS_ADDRESS); 00455 break; 00456 case 4: // when seconds match 00457 registersRTC[RTC_ALM1_SECONDS_ADDRESS] &= B01111111; // set A1M1 bit to 0 00458 writeRTCregister(RTC_ALM1_SECONDS_ADDRESS); 00459 00460 registersRTC[RTC_ALM1_MINUTES_ADDRESS] |= B10000000; // set A1M2 bit to 1 00461 writeRTCregister(RTC_ALM1_MINUTES_ADDRESS); 00462 00463 registersRTC[RTC_ALM1_HOURS_ADDRESS] |= B10000000; // set A1M3 bit to 1 00464 writeRTCregister(RTC_ALM1_HOURS_ADDRESS); 00465 00466 registersRTC[RTC_ALM1_DAYS_ADDRESS] |= B10000000; // set A1M4 bit to 1 00467 writeRTCregister(RTC_ALM1_DAYS_ADDRESS); 00468 break; 00469 case 5: // once per second 00470 registersRTC[RTC_ALM1_SECONDS_ADDRESS] |= B10000000; // set A1M1 bit to 1 00471 writeRTCregister(RTC_ALM1_SECONDS_ADDRESS); 00472 00473 registersRTC[RTC_ALM1_MINUTES_ADDRESS] |= B10000000; // set A1M2 bit to 1 00474 writeRTCregister(RTC_ALM1_MINUTES_ADDRESS); 00475 00476 registersRTC[RTC_ALM1_HOURS_ADDRESS] |= B10000000; // set A1M3 bit to 1 00477 writeRTCregister(RTC_ALM1_HOURS_ADDRESS); 00478 00479 registersRTC[RTC_ALM1_DAYS_ADDRESS] |= B10000000; // set A1M4 bit to 1 00480 writeRTCregister(RTC_ALM1_DAYS_ADDRESS); 00481 break; 00482 case 6: // alarm1 OFF 00483 registersRTC[RTC_CONTROL_ADDRESS] &= B11111000; // de-activate the INT/SQW output on alarm match 00484 writeRTCregister(RTC_CONTROL_ADDRESS); 00485 detachInt(); 00486 break; 00487 } 00488 00489 } 00490 00491 if (alarmNum == 2){ 00492 00493 registersRTC[RTC_CONTROL_ADDRESS] &= B11111110; // activate the INT/SQW output on alarm match 00494 registersRTC[RTC_CONTROL_ADDRESS] |= B00000110; 00495 writeRTCregister(RTC_CONTROL_ADDRESS); 00496 registersRTC[RTC_STATUS_ADDRESS] &= B11111100; // reset the alarm flags 00497 writeRTCregister(RTC_STATUS_ADDRESS); 00498 00499 switch (alarmMode){ 00500 case 0: // when day, hours and minutes match 00501 registersRTC[RTC_ALM2_MINUTES_ADDRESS] &= B01111111; // set A2M2 bit to 0 00502 writeRTCregister(RTC_ALM2_MINUTES_ADDRESS); 00503 00504 registersRTC[RTC_ALM2_HOURS_ADDRESS] &= B01111111; // set A2M3 bit to 0 00505 writeRTCregister(RTC_ALM2_HOURS_ADDRESS); 00506 00507 registersRTC[RTC_ALM2_DAYS_ADDRESS] &= B01111111; // set A2M4 bit to 0 00508 registersRTC[RTC_ALM2_DAYS_ADDRESS] |= B01000000; // set DY/DT bit to 1 00509 writeRTCregister(RTC_ALM2_DAYS_ADDRESS); 00510 00511 break; 00512 00513 case 1: // when date,hours and minutes match 00514 registersRTC[RTC_ALM2_MINUTES_ADDRESS] &= B01111111; // set A2M2 bit to 0 00515 writeRTCregister(RTC_ALM2_MINUTES_ADDRESS); 00516 00517 registersRTC[RTC_ALM2_HOURS_ADDRESS] &= B01111111; // set A2M3 bit to 0 00518 writeRTCregister(RTC_ALM2_HOURS_ADDRESS); 00519 00520 registersRTC[RTC_ALM2_DAYS_ADDRESS] &= B00111111; // set A2M4 bit to 0 and DY/DT to 0 00521 writeRTCregister(RTC_ALM2_DAYS_ADDRESS); 00522 00523 break; 00524 case 2: // when hours and minutes match 00525 registersRTC[RTC_ALM2_MINUTES_ADDRESS] &= B01111111; // set A2M2 bit to 0 00526 writeRTCregister(RTC_ALM2_MINUTES_ADDRESS); 00527 00528 registersRTC[RTC_ALM2_HOURS_ADDRESS] &= B01111111; // set A2M3 bit to 0 00529 writeRTCregister(RTC_ALM2_HOURS_ADDRESS); 00530 00531 registersRTC[RTC_ALM2_DAYS_ADDRESS] |= B10000000; // set A2M4 bit to 1 00532 writeRTCregister(RTC_ALM2_DAYS_ADDRESS); 00533 00534 break; 00535 case 3: // when minutes match 00536 registersRTC[RTC_ALM2_MINUTES_ADDRESS] &= B01111111; // set A2M2 bit to 0 00537 writeRTCregister(RTC_ALM2_MINUTES_ADDRESS); 00538 00539 registersRTC[RTC_ALM2_HOURS_ADDRESS] |= B10000000; // set A2M3 bit to 1 00540 writeRTCregister(RTC_ALM2_HOURS_ADDRESS); 00541 00542 registersRTC[RTC_ALM2_DAYS_ADDRESS] |= B10000000; // set A2M4 bit to 1 00543 writeRTCregister(RTC_ALM2_DAYS_ADDRESS); 00544 00545 break; 00546 case 4: // Once per minute 00547 registersRTC[RTC_ALM2_MINUTES_ADDRESS] |= B10000000; // set A2M2 bit to 1 00548 writeRTCregister(RTC_ALM2_MINUTES_ADDRESS); 00549 00550 registersRTC[RTC_ALM2_HOURS_ADDRESS] |= B10000000; // set A2M3 bit to 1 00551 writeRTCregister(RTC_ALM2_HOURS_ADDRESS); 00552 00553 registersRTC[RTC_ALM2_DAYS_ADDRESS] |= B10000000; // set A2M4 bit to 1 00554 writeRTCregister(RTC_ALM2_DAYS_ADDRESS); 00555 00556 break; 00557 case 5: // alarm 2 OFF 00558 registersRTC[RTC_CONTROL_ADDRESS] &= B11111000; // de-activate the INT/SQW output on alarm match 00559 writeRTCregister(RTC_CONTROL_ADDRESS); 00560 detachInt(); 00561 break; 00562 } 00563 00564 } 00565 00566 attachInt(); 00567 }


| void WaspRTC::writeRTCalarm1 | ( | ) |
It writes Alarm1 to the RTC.
| void |
Definition at line 319 of file WaspRTC.cpp.
References TwoWire::beginTransmission(), byte2BCD(), day_alarm1, TwoWire::endTransmission(), hour_alarm1, minute_alarm1, registersRTC, RTC_ADDRESS, RTC_ALM1_DAYS_ADDRESS, RTC_ALM1_HOURS_ADDRESS, RTC_ALM1_MINUTES_ADDRESS, RTC_ALM1_SECONDS_ADDRESS, RTC_ALM1_START_ADDRESS, second_alarm1, TwoWire::send(), and Wire.
Referenced by setAlarm1().
00320 { 00321 byte timecount = 0; 00322 Wire.beginTransmission(RTC_ADDRESS); // transmit to device #104 (0x4A) 00323 // the address specified in the datasheet is 208 (0xD0) 00324 // but i2c adressing uses the high 7 bits so it's 104 00325 Wire.send(RTC_ALM1_START_ADDRESS); // start from address zero 00326 00327 registersRTC[RTC_ALM1_SECONDS_ADDRESS] = 0x7F & byte2BCD(second_alarm1); 00328 registersRTC[RTC_ALM1_MINUTES_ADDRESS] = 0x7F & byte2BCD(minute_alarm1); 00329 registersRTC[RTC_ALM1_HOURS_ADDRESS] = 0x7F & byte2BCD(hour_alarm1); 00330 registersRTC[RTC_ALM1_DAYS_ADDRESS] = 0X3F & byte2BCD(day_alarm1); 00331 00332 for(timecount = 7; timecount <= 0x0A; timecount++) { 00333 Wire.send(registersRTC[timecount]); 00334 } 00335 00336 Wire.endTransmission(); 00337 }


| void WaspRTC::writeRTCalarm2 | ( | ) |
It writes Alarm2 to the RTC.
| void |
Definition at line 345 of file WaspRTC.cpp.
References TwoWire::beginTransmission(), byte2BCD(), day_alarm2, TwoWire::endTransmission(), hour_alarm2, minute_alarm2, registersRTC, RTC_ADDRESS, RTC_ALM2_DAYS_ADDRESS, RTC_ALM2_HOURS_ADDRESS, RTC_ALM2_MINUTES_ADDRESS, RTC_ALM2_START_ADDRESS, TwoWire::send(), and Wire.
Referenced by setAlarm2().
00346 { 00347 byte timecount = 0; 00348 Wire.beginTransmission(RTC_ADDRESS); // transmit to device #104 (0x4A) 00349 // the address specified in the datasheet is 208 (0xD0) 00350 // but i2c adressing uses the high 7 bits so it's 104 00351 Wire.send(RTC_ALM2_START_ADDRESS); // start from address 0x0B 00352 00353 registersRTC[RTC_ALM2_MINUTES_ADDRESS] = 0x7F & byte2BCD(minute_alarm2); 00354 registersRTC[RTC_ALM2_HOURS_ADDRESS] = 0x7F & byte2BCD(hour_alarm2); 00355 registersRTC[RTC_ALM2_DAYS_ADDRESS] = 0x3F & byte2BCD(day_alarm2); 00356 00357 00358 for(timecount = 0X0B; timecount <= 0x0D; timecount++) { 00359 Wire.send(registersRTC[timecount]); 00360 } 00361 00362 Wire.endTransmission(); 00363 }


| void WaspRTC::attachInt | ( | void | ) |
It attaches the interruption to the defined pin.
| void |
Definition at line 1166 of file WaspRTC.cpp.
References enableInterrupts(), and RTC_INT.
Referenced by configureAlarmMode().
01167 { 01168 enableInterrupts(RTC_INT); 01169 }


| void WaspRTC::detachInt | ( | void | ) |
It detaches the interruption from the defined pin.
| void |
Definition at line 1176 of file WaspRTC.cpp.
References clearAlarmFlag(), disableInterrupts(), and RTC_INT.
Referenced by configureAlarmMode().
01177 { 01178 disableInterrupts(RTC_INT); 01179 clearAlarmFlag(); 01180 }


| void WaspRTC::ON | ( | void | ) |
| void WaspRTC::OFF | ( | void | ) |
| void WaspRTC::begin | ( | void | ) |
It inits the I2C bus and the variables reading them from the RTC.
| void |
Definition at line 70 of file WaspRTC.cpp.
References TwoWire::begin(), clearAlarmFlag(), readRTC(), resetVars(), RTC_ALARM2_ADDRESS, RTC_ON, setMode(), and Wire.
Referenced by ON().
00071 { 00072 // Powers RTC UP 00073 setMode(RTC_ON); 00074 clearAlarmFlag(); 00075 // Inits I2C bus 00076 Wire.begin(); 00077 // initialize the variables used to store the data 00078 // from the RTC 00079 resetVars(); 00080 readRTC(RTC_ALARM2_ADDRESS); 00081 }


| void WaspRTC::close | ( | void | ) |
It closes I2C bus.
| void |
Definition at line 92 of file WaspRTC.cpp.
References WaspPWR::closeI2C(), and PWR.
Referenced by WaspPWR::deepSleep(), WaspPWR::hibernate(), OFF(), and WaspSensorAgr::sleepAgr().


| void WaspRTC::setMode | ( | uint8_t | mode | ) |
It sets Power Mode.
| uint8_t | mode : RTC_ON or RTC_OFF |
Definition at line 101 of file WaspRTC.cpp.
References _pwrMode, digitalWrite(), HIGH, LOW, OUTPUT, pinMode(), RTC_OFF, RTC_ON, and RTC_PW.
Referenced by begin(), WaspACC::begin(), WaspPWR::hibernate(), OFF(), WaspSensorPrototyping::setBoardMode(), WaspSensorGas::setBoardMode(), WaspSensorEvent::setBoardMode(), and WaspSensorAgr::setBoardMode().
00102 { 00103 _pwrMode=mode; 00104 pinMode(RTC_PW,OUTPUT); 00105 switch(_pwrMode) 00106 { 00107 case RTC_ON : digitalWrite(RTC_PW,HIGH); 00108 break; 00109 case RTC_OFF : digitalWrite(RTC_PW,LOW); 00110 break; 00111 } 00112 }


| uint8_t WaspRTC::getMode | ( | void | ) |
It gets Power Mode.
| void |
Definition at line 119 of file WaspRTC.cpp.
References _pwrMode.
00120 { 00121 return _pwrMode; 00122 }
| void WaspRTC::setTime | ( | const char * | time | ) |
It sets in the RTC the specified date and time.
| const | char* time : the time and date to set in the RTC. It looks like "YY:MM:DD:dow:hh:mm:ss" |
Definition at line 623 of file WaspRTC.cpp.
References BCD2byte(), date, day, hour, minute, month, RTC, second, writeRTC(), and year.
Referenced by setTimeFromGPS().
00624 { 00625 uint8_t aux=0, aux2=0; 00626 00627 aux=(uint8_t) time[0] - 48; 00628 aux2=(uint8_t) time[1] - 48; 00629 year = RTC.BCD2byte(aux, aux2); 00630 aux=(uint8_t) time[3] - 48; 00631 aux2=(uint8_t) time[4] - 48; 00632 month = RTC.BCD2byte(aux, aux2); 00633 aux=(uint8_t) time[6] - 48; 00634 aux2=(uint8_t) time[7] - 48; 00635 date = RTC.BCD2byte(aux, aux2); 00636 aux=(uint8_t) time[9] - 48; 00637 aux2=(uint8_t) time[10] - 48; 00638 day = RTC.BCD2byte(aux, aux2); 00639 aux=(uint8_t) time[12] - 48; 00640 aux2=(uint8_t) time[13] - 48; 00641 hour = RTC.BCD2byte(aux, aux2); 00642 aux=(uint8_t) time[15] - 48; 00643 aux2=(uint8_t) time[16] - 48; 00644 minute = RTC.BCD2byte(aux, aux2); 00645 aux=(uint8_t) time[18] - 48; 00646 aux2=(uint8_t) time[19] - 48; 00647 second = RTC.BCD2byte(aux, aux2); 00648 writeRTC(); 00649 }


| void WaspRTC::setTime | ( | uint8_t | year, | |
| uint8_t | month, | |||
| uint8_t | date, | |||
| uint8_t | day_week, | |||
| uint8_t | hour, | |||
| uint8_t | minute, | |||
| uint8_t | second | |||
| ) |
It sets in the RTC the specified date and time.
| uint8_t | year : the year to set in the RTC | |
| uint8_t | month : the month to set in the RTC | |
| uint8_t | date : the date to set in the RTC | |
| uint8_t | day_week : the day of the week to set in the RTC | |
| uint8_t | hour : the hours to set in the RTC | |
| uint8_t | minute : the minutes to set in the RTC | |
| uint8_t | second : the seconds to set in the RTC |
Definition at line 659 of file WaspRTC.cpp.
References BCD2byte(), date, day, hour, minute, month, RTC, second, writeRTC(), and year.
00660 { 00661 uint8_t aux=0, aux2=0; 00662 if(_year<10) 00663 { 00664 aux=0; 00665 aux2=_year; 00666 year = RTC.BCD2byte(aux, aux2); 00667 } 00668 else if(_year>=10) 00669 { 00670 aux2=_year%10; 00671 aux=_year/10; 00672 year = RTC.BCD2byte(aux, aux2); 00673 } 00674 if(_month<10) 00675 { 00676 aux=0; 00677 aux2=_month; 00678 month = RTC.BCD2byte(aux, aux2); 00679 } 00680 else if(_month>=10) 00681 { 00682 aux2=_month%10; 00683 aux=_month/10; 00684 month = RTC.BCD2byte(aux, aux2); 00685 } 00686 if(_date<10) 00687 { 00688 aux=0; 00689 aux2=_date; 00690 date = RTC.BCD2byte(aux, aux2); 00691 } 00692 else if(_date>=10) 00693 { 00694 aux2=_date%10; 00695 aux=_date/10; 00696 date = RTC.BCD2byte(aux, aux2); 00697 } 00698 if(day_week<10) 00699 { 00700 aux=0; 00701 aux2=day_week; 00702 day = RTC.BCD2byte(aux, aux2); 00703 } 00704 else if(day_week>=10) 00705 { 00706 aux2=day_week%10; 00707 aux=day_week/10; 00708 day = RTC.BCD2byte(aux, aux2); 00709 } 00710 if(_hour<10) 00711 { 00712 aux=0; 00713 aux2=_hour; 00714 hour = RTC.BCD2byte(aux, aux2); 00715 } 00716 else if(_hour>=10) 00717 { 00718 aux2=_hour%10; 00719 aux=_hour/10; 00720 hour = RTC.BCD2byte(aux, aux2); 00721 } 00722 if(_minute<10) 00723 { 00724 aux=0; 00725 aux2=_minute; 00726 minute = RTC.BCD2byte(aux, aux2); 00727 } 00728 else if(_minute>=10) 00729 { 00730 aux2=_minute%10; 00731 aux=_minute/10; 00732 minute = RTC.BCD2byte(aux, aux2); 00733 } 00734 if(_second<10) 00735 { 00736 aux=0; 00737 aux2=_second; 00738 second = RTC.BCD2byte(aux, aux2); 00739 } 00740 else if(_second>=10) 00741 { 00742 aux2=_second%10; 00743 aux=_second/10; 00744 second = RTC.BCD2byte(aux, aux2); 00745 } 00746 writeRTC(); 00747 }

| char * WaspRTC::getTime | ( | void | ) |
It gets from the RTC the date and time, storing them in the corresponding variables.
| void |
Definition at line 756 of file WaspRTC.cpp.
References getTimestamp(), readRTC(), and RTC_DATE_ADDRESS_2.
00757 { 00758 readRTC(RTC_DATE_ADDRESS_2); 00759 return getTimestamp(); 00760 }

| void WaspRTC::setTimeFromGPS | ( | ) |
It sets time and date from the GPS to the RTC. GPS has to be initialized first and got the time/date.
| void |
Definition at line 769 of file WaspRTC.cpp.
References WaspGPS::dateGPS, day, GPS, hour, minute, month, RTC, second, setTime(), WaspGPS::timeGPS, and year.
00770 { 00771 int day, month, year, hour, minute, second = 0; 00772 00773 day = (GPS.dateGPS[0]-'0')*10 + (GPS.dateGPS[1]-'0'); 00774 00775 month = (GPS.dateGPS[2]-'0')*10 + (GPS.dateGPS[3]-'0'); 00776 00777 year = (GPS.dateGPS[4]-'0')*10 + (GPS.dateGPS[5]-'0'); 00778 00779 hour = (GPS.timeGPS[0]-'0')*10 + (GPS.timeGPS[1]-'0'); 00780 00781 minute = (GPS.timeGPS[2]-'0')*10 + (GPS.timeGPS[3]-'0'); 00782 00783 second = (GPS.timeGPS[4]-'0')*10 + (GPS.timeGPS[5]-'0'); 00784 00785 RTC.setTime(year, month, day, 1, hour, minute, second); 00786 }

| void WaspRTC::setAlarm1 | ( | const char * | time, | |
| uint8_t | offset, | |||
| uint8_t | mode | |||
| ) |
It sets Alarm1 to the specified time. It also enables the corresponding RTC interruption.
| const | char* time : the time to set for the Alarm 1. It looks like "DD:hh:mm:ss" | |
| uint8_t | offset : RTC_OFFSET or RTC_ABSOLUTE | |
| uint8_t | mode : RTC_ALM1_MODE1, RTC_ALM1_MODE2, RTC_ALM1_MODE3, RTC_ALM1_MODE4, RTC_ALM1_MODE5, RTC_ALM1_MODE6 |
Definition at line 826 of file WaspRTC.cpp.
References BCD2byte(), configureAlarmMode(), date, day, day_alarm1, hour, hour_alarm1, minute, minute_alarm1, readRTC(), RTC, RTC_ALM1_MODE1, RTC_DATE_ADDRESS_2, RTC_OFFSET, second, second_alarm1, and writeRTCalarm1().
Referenced by WaspPWR::deepSleep(), WaspPWR::hibernate(), and WaspSensorAgr::sleepAgr().
00827 { 00828 uint8_t aux=0, aux2=0; 00829 aux=(uint8_t) time[0] - 48; 00830 aux2=(uint8_t) time[1] - 48; 00831 day_alarm1 = BCD2byte(aux, aux2); 00832 aux=(uint8_t) time[3] - 48; 00833 aux2=(uint8_t) time[4] - 48; 00834 hour_alarm1 = BCD2byte(aux, aux2); 00835 aux=(uint8_t) time[6] - 48; 00836 aux2=(uint8_t) time[7] - 48; 00837 minute_alarm1 = BCD2byte(aux, aux2); 00838 aux=(uint8_t) time[9] - 48; 00839 aux2=(uint8_t) time[10] - 48; 00840 second_alarm1 = BCD2byte(aux, aux2); 00841 00842 if(offset==RTC_OFFSET) // add the date to the actual date 00843 { 00844 readRTC(RTC_DATE_ADDRESS_2); 00845 second_alarm1+=second; 00846 if(second_alarm1>=60) 00847 { 00848 second_alarm1-=60; 00849 minute_alarm1++; 00850 } 00851 minute_alarm1+=minute; 00852 if(minute_alarm1>=60) 00853 { 00854 minute_alarm1-=60; 00855 hour_alarm1++; 00856 } 00857 hour_alarm1+=hour; 00858 if(hour_alarm1>=24) 00859 { 00860 hour_alarm1-=24; 00861 day_alarm1++; 00862 } 00863 if(mode==RTC_ALM1_MODE1) day_alarm1+=day; 00864 else day_alarm1+=date; 00865 } 00866 00867 RTC.writeRTCalarm1(); 00868 RTC.configureAlarmMode(1,mode); 00869 }


| void WaspRTC::setAlarm1 | ( | uint8_t | day_date, | |
| uint8_t | hour, | |||
| uint8_t | minute, | |||
| uint8_t | second, | |||
| uint8_t | offset, | |||
| uint8_t | mode | |||
| ) |
It sets Alarm1 to the specified time. It also enables the corresponding RTC interruption.
| uint8_t | day_date : specifies the date or the day of the week to set the Alarm1 to | |
| uint8_t | hour : specifies the hour to set the Alarm1 to | |
| uint8_t | minute : specifies the minute to set the Alarm1 to | |
| uint8_t | second : specifies the second to set the Alarm1 to | |
| uint8_t | offset : RTC_OFFSET or RTC_ABSOLUTE | |
| uint8_t | mode : RTC_ALM1_MODE1, RTC_ALM1_MODE2, RTC_ALM1_MODE3, RTC_ALM1_MODE4, RTC_ALM1_MODE5, RTC_ALM1_MODE6 |
Definition at line 883 of file WaspRTC.cpp.
References BCD2byte(), configureAlarmMode(), date, day, day_alarm1, hour, hour_alarm1, minute, minute_alarm1, readRTC(), RTC, RTC_ALM1_MODE1, RTC_DATE_ADDRESS_2, RTC_OFFSET, second, second_alarm1, and writeRTCalarm1().
00884 { 00885 uint8_t aux=0, aux2=0; 00886 00887 if(day_date<10) 00888 { 00889 aux=0; 00890 aux2=day_date; 00891 day_alarm1 = BCD2byte(aux, aux2); 00892 } 00893 else if(day_date>=10) 00894 { 00895 aux2=day_date%10; 00896 aux=day_date/10; 00897 day_alarm1 = BCD2byte(aux, aux2); 00898 } 00899 if(_hour<10) 00900 { 00901 aux=0; 00902 aux2=_hour; 00903 hour_alarm1 = BCD2byte(aux, aux2); 00904 } 00905 else if(_hour>=10) 00906 { 00907 aux2=_hour%10; 00908 aux=_hour/10; 00909 hour_alarm1 = BCD2byte(aux, aux2); 00910 } 00911 if(_minute<10) 00912 { 00913 aux=0; 00914 aux2=_minute; 00915 minute_alarm1 = BCD2byte(aux, aux2); 00916 } 00917 else if(_minute>=10) 00918 { 00919 aux2=_minute%10; 00920 aux=_minute/10; 00921 minute_alarm1 = BCD2byte(aux, aux2); 00922 } 00923 if(_second<10) 00924 { 00925 aux=0; 00926 aux2=_second; 00927 second_alarm1 = BCD2byte(aux, aux2); 00928 } 00929 else if(_second>=10) 00930 { 00931 aux2=_second%10; 00932 aux=_second/10; 00933 second_alarm1 = BCD2byte(aux, aux2); 00934 } 00935 00936 if(offset==RTC_OFFSET) // add the date to the actual date 00937 { 00938 readRTC(RTC_DATE_ADDRESS_2); 00939 second_alarm1+=second; 00940 if(second_alarm1>=60) 00941 { 00942 second_alarm1-=60; 00943 minute_alarm1++; 00944 } 00945 minute_alarm1+=minute; 00946 if(minute_alarm1>=60) 00947 { 00948 minute_alarm1-=60; 00949 hour_alarm1++; 00950 } 00951 hour_alarm1+=hour; 00952 if(hour_alarm1>=24) 00953 { 00954 hour_alarm1-=24; 00955 day_alarm1++; 00956 } 00957 if(mode==RTC_ALM1_MODE1) day_alarm1+=day; 00958 else day_alarm1+=date; 00959 } 00960 00961 RTC.writeRTCalarm1(); 00962 RTC.configureAlarmMode(1,mode); 00963 }

| char * WaspRTC::getAlarm1 | ( | ) |
It gets Alarm1 date and time from the RTC, storing them in the corresponding variables.
| void |
Definition at line 972 of file WaspRTC.cpp.
References day, day_alarm1, hour_alarm1, minute_alarm1, month, readRTC(), RTC_ALARM1_ADDRESS, second_alarm1, and year.
00973 { 00974 char aux[40]; 00975 00976 readRTC(RTC_ALARM1_ADDRESS); 00977 sprintf (aux, "%d, %d:%d:%d - %d:%d:%d", day, year, month, day_alarm1, hour_alarm1, minute_alarm1, second_alarm1); 00978 return aux; 00979 }

| void WaspRTC::setAlarm2 | ( | const char * | time, | |
| uint8_t | offset, | |||
| uint8_t | mode | |||
| ) |
It sets Alarm2 to the specified time. It also enables the corresponding RTC interruption.
| const | char* time : the time to set for the Alarm 1. It looks like "DD:hh:mm" | |
| uint8_t | offset : RTC_OFFSET or RTC_ABSOLUTE | |
| uint8_t | mode : RTC_ALM2_MODE1, RTC_ALM2_MODE2, RTC_ALM2_MODE3, RTC_ALM2_MODE4, RTC_ALM2_MODE5 |
Definition at line 993 of file WaspRTC.cpp.
References BCD2byte(), configureAlarmMode(), date, day, day_alarm2, hour, hour_alarm2, minute, minute_alarm2, readRTC(), RTC, RTC_ALM2_MODE1, RTC_DATE_ADDRESS_2, RTC_OFFSET, and writeRTCalarm2().
00994 { 00995 uint8_t aux=0, aux2=0; 00996 00997 aux=(uint8_t) time[0] - 48; 00998 aux2=(uint8_t) time[1] - 48; 00999 day_alarm2 = BCD2byte(aux, aux2); 01000 aux=(uint8_t) time[3] - 48; 01001 aux2=(uint8_t) time[4] - 48; 01002 hour_alarm2 = BCD2byte(aux, aux2); 01003 aux=(uint8_t) time[6] - 48; 01004 aux2=(uint8_t) time[7] - 48; 01005 minute_alarm2 = BCD2byte(aux, aux2); 01006 01007 if(offset==RTC_OFFSET) // add the date to the actual date 01008 { 01009 readRTC(RTC_DATE_ADDRESS_2); 01010 minute_alarm2+=minute; 01011 if(minute_alarm2>=60) 01012 { 01013 minute_alarm2-=60; 01014 hour_alarm2++; 01015 } 01016 hour_alarm2+=hour; 01017 if(hour_alarm2>=24) 01018 { 01019 hour_alarm2-=24; 01020 day_alarm2++; 01021 } 01022 if(mode==RTC_ALM2_MODE1) day_alarm2+=day; 01023 else day_alarm2+=date; 01024 } 01025 01026 RTC.writeRTCalarm2(); 01027 RTC.configureAlarmMode(2,mode); 01028 }

| void WaspRTC::setAlarm2 | ( | uint8_t | day_date, | |
| uint8_t | hour, | |||
| uint8_t | minute, | |||
| uint8_t | offset, | |||
| uint8_t | mode | |||
| ) |
It sets Alarm2 to the specified time. It also enables the corresponding RTC interruption.
| uint8_t | day_date : specifies the date or the day of the week to set the Alarm2 to | |
| uint8_t | hour : specifies the hour to set the Alarm2 to | |
| uint8_t | minute : specifies the minute to set the Alarm2 to | |
| uint8_t | offset : RTC_OFFSET or RTC_ABSOLUTE | |
| uint8_t | mode : RTC_ALM2_MODE1, RTC_ALM2_MODE2, RTC_ALM2_MODE3, RTC_ALM2_MODE4, RTC_ALM2_MODE5 |
Definition at line 1042 of file WaspRTC.cpp.
References BCD2byte(), configureAlarmMode(), date, day, day_alarm2, hour, hour_alarm2, minute, minute_alarm2, readRTC(), RTC, RTC_ALM2_MODE1, RTC_DATE_ADDRESS_2, RTC_OFFSET, and writeRTCalarm2().
01043 { 01044 uint8_t aux=0, aux2=0; 01045 if(day_date<10) 01046 { 01047 aux=0; 01048 aux2=day_date; 01049 day_alarm2 = BCD2byte(aux, aux2); 01050 } 01051 else if(day_date>=10) 01052 { 01053 aux2=day_date%10; 01054 aux=day_date/10; 01055 day_alarm2 = BCD2byte(aux, aux2); 01056 } 01057 if(_hour<10) 01058 { 01059 aux=0; 01060 aux2=_hour; 01061 hour_alarm2 = BCD2byte(aux, aux2); 01062 } 01063 else if(_hour>=10) 01064 { 01065 aux2=_hour%10; 01066 aux=_hour/10; 01067 hour_alarm2 = BCD2byte(aux, aux2); 01068 } 01069 if(_minute<10) 01070 { 01071 aux=0; 01072 aux2=_minute; 01073 minute_alarm2 = BCD2byte(aux, aux2); 01074 } 01075 else if(_minute>=10) 01076 { 01077 aux2=_minute%10; 01078 aux=_minute/10; 01079 minute_alarm2 = BCD2byte(aux, aux2); 01080 } 01081 01082 if(offset==RTC_OFFSET) // add the date to the actual date 01083 { 01084 readRTC(RTC_DATE_ADDRESS_2); 01085 minute_alarm2+=minute; 01086 if(minute_alarm2>=60) 01087 { 01088 minute_alarm2-=60; 01089 hour_alarm2++; 01090 } 01091 hour_alarm2+=hour; 01092 if(hour_alarm2>=24) 01093 { 01094 hour_alarm2-=24; 01095 day_alarm2++; 01096 } 01097 if(mode==RTC_ALM2_MODE1) day_alarm2+=day; 01098 else day_alarm2+=date; 01099 } 01100 01101 RTC.writeRTCalarm2(); 01102 RTC.configureAlarmMode(2,mode); 01103 }

| char * WaspRTC::getAlarm2 | ( | ) |
It gets Alarm2 date and time from the RTC, storing them in the corresponding variables.
| void |
Definition at line 1112 of file WaspRTC.cpp.
References day, day_alarm2, hour_alarm2, minute_alarm2, month, readRTC(), RTC_ALARM2_ADDRESS, and year.
01113 { 01114 char aux[35]; 01115 01116 readRTC(RTC_ALARM2_ADDRESS); 01117 sprintf (aux, "%d, %d:%d:%d - %d:%d", day, year, month, day_alarm2, hour_alarm2, minute_alarm2); 01118 return aux; 01119 }

| void WaspRTC::clearAlarmFlag | ( | void | ) |
It clears bits A1F and A2F, necessary to be able to catch interrupts after previous interrupts.
| void |
Definition at line 1127 of file WaspRTC.cpp.
References B11111100, registersRTC, RTC, RTC_STATUS_ADDRESS, and writeRTCregister().
Referenced by begin(), WaspPWR::clearInts(), and detachInt().
01128 { 01129 RTC.registersRTC[RTC_STATUS_ADDRESS] &= B11111100; // reset the alarm flags in RT 01130 RTC.writeRTCregister(RTC_STATUS_ADDRESS); 01131 }


| uint8_t WaspRTC::getTemperature | ( | ) |
It gets the temperature from the RTC temperature sensor.
| void |
Definition at line 796 of file WaspRTC.cpp.
References B01111111, readRTCregister(), registersRTC, RTC_LSB_TEMP_ADDRESS, RTC_MSB_TEMP_ADDRESS, temp, and tempNegative.
00797 { 00798 readRTCregister(RTC_MSB_TEMP_ADDRESS); 00799 readRTCregister(RTC_LSB_TEMP_ADDRESS); 00800 temp = (registersRTC[RTC_MSB_TEMP_ADDRESS]&B01111111) + (registersRTC[RTC_LSB_TEMP_ADDRESS]>>6); 00801 00802 if (registersRTC[RTC_MSB_TEMP_ADDRESS]>>7 == 1) 00803 { 00804 tempNegative=true; 00805 ~(temp); 00806 temp++; 00807 } 00808 else tempNegative=false; 00809 00810 return temp; 00811 }

| uint8_t WaspRTC::registersRTC[RTC_DATA_SIZE] |
Variable : Array for storing the value of the different RTC registers.
Its size is defined by 'RTC_DATA_SIZE' constant
Definition at line 307 of file WaspRTC.h.
Referenced by clearAlarmFlag(), configureAlarmMode(), getRTCarray(), getTemperature(), readRTC(), readRTCregister(), writeRTC(), writeRTCalarm1(), writeRTCalarm2(), and writeRTCregister().
| uint8_t WaspRTC::year |
Variable : It stores the value of the year.
Definition at line 312 of file WaspRTC.h.
Referenced by getAlarm1(), getAlarm2(), getTimestamp(), readRTC(), resetVars(), setTime(), setTimeFromGPS(), and writeRTC().
| uint8_t WaspRTC::month |
Variable : It stores the value of the month.
Definition at line 317 of file WaspRTC.h.
Referenced by getAlarm1(), getAlarm2(), getTimestamp(), readRTC(), resetVars(), setTime(), setTimeFromGPS(), and writeRTC().
| uint8_t WaspRTC::day |
Variable : It stores the value of the day of the week.
Definition at line 322 of file WaspRTC.h.
Referenced by getAlarm1(), getAlarm2(), getTimestamp(), readRTC(), resetVars(), setAlarm1(), setAlarm2(), setTime(), setTimeFromGPS(), and writeRTC().
| uint8_t WaspRTC::hour |
Variable : It stores the value of the hours.
Definition at line 327 of file WaspRTC.h.
Referenced by getTimestamp(), readRTC(), resetVars(), setAlarm1(), setAlarm2(), setTime(), setTimeFromGPS(), and writeRTC().
| uint8_t WaspRTC::minute |
Variable : It stores the value of the minutes.
Definition at line 332 of file WaspRTC.h.
Referenced by getTimestamp(), readRTC(), resetVars(), setAlarm1(), setAlarm2(), setTime(), setTimeFromGPS(), and writeRTC().
| uint8_t WaspRTC::second |
Variable : It stores the value of the seconds.
Definition at line 337 of file WaspRTC.h.
Referenced by getTimestamp(), readRTC(), resetVars(), setAlarm1(), setTime(), setTimeFromGPS(), and writeRTC().
| uint8_t WaspRTC::date |
Variable : It stores the value of the date(day of the week).
Definition at line 342 of file WaspRTC.h.
Referenced by getTimestamp(), readRTC(), resetVars(), setAlarm1(), setAlarm2(), setTime(), and writeRTC().
| uint8_t WaspRTC::second_alarm1 |
Variable : It stores the value of the seconds for Alarm1.
Definition at line 347 of file WaspRTC.h.
Referenced by getAlarm1(), readRTC(), resetVars(), setAlarm1(), and writeRTCalarm1().
| uint8_t WaspRTC::minute_alarm1 |
Variable : It stores the value of the minutes for Alarm1.
Definition at line 352 of file WaspRTC.h.
Referenced by getAlarm1(), readRTC(), resetVars(), setAlarm1(), and writeRTCalarm1().
| uint8_t WaspRTC::hour_alarm1 |
Variable : It stores the value of the hours for Alarm1.
Definition at line 357 of file WaspRTC.h.
Referenced by getAlarm1(), readRTC(), resetVars(), setAlarm1(), and writeRTCalarm1().
| uint8_t WaspRTC::day_alarm1 |
Variable : It stores the value of the day of the week/date for Alarm1.
Definition at line 362 of file WaspRTC.h.
Referenced by getAlarm1(), readRTC(), resetVars(), setAlarm1(), and writeRTCalarm1().
| uint8_t WaspRTC::minute_alarm2 |
Variable : It stores the value of the minutes for Alarm2.
Definition at line 367 of file WaspRTC.h.
Referenced by getAlarm2(), readRTC(), resetVars(), setAlarm2(), and writeRTCalarm2().
| uint8_t WaspRTC::hour_alarm2 |
Variable : It stores the value of the hours for Alarm2.
Definition at line 372 of file WaspRTC.h.
Referenced by getAlarm2(), readRTC(), resetVars(), setAlarm2(), and writeRTCalarm2().
| uint8_t WaspRTC::day_alarm2 |
Variable : It stores the value of the day of the week/date for Alarm2.
Definition at line 377 of file WaspRTC.h.
Referenced by getAlarm2(), readRTC(), resetVars(), setAlarm2(), and writeRTCalarm2().
| uint8_t WaspRTC::alarm1Mode |
Variable : It stores the alarm mode for the Alarm 1.
Definition at line 382 of file WaspRTC.h.
Referenced by resetVars().
| uint8_t WaspRTC::alarm2Mode |
Variable : It stores the alarm mode for the Alarm 2.
Definition at line 387 of file WaspRTC.h.
Referenced by resetVars().
| uint8_t WaspRTC::temp |
Variable : It stores the value of the temperature.
Definition at line 392 of file WaspRTC.h.
Referenced by getTemperature(), and resetVars().
Variable : It stores if the temperature is negative or possitive.
Definition at line 397 of file WaspRTC.h.
Referenced by getTemperature(), and resetVars().
| uint8_t WaspRTC::_pwrMode |
1.5.6