mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Update docs
This commit is contained in:
@@ -370,125 +370,135 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
<a name="l00353"></a>00353 <a class="code" href="classDS3232RTC.html#a9acebf12c5cecdd6d84e0ff9ed41765a" title="Writes value to offset within the realtime clock's non-volatile memory.">RTC::writeByte</a>(offset, value);
|
||||
<a name="l00354"></a>00354 }
|
||||
<a name="l00355"></a>00355
|
||||
<a name="l00370"></a><a class="code" href="classDS3232RTC.html#ab91e79271a1f8e75b07bddbb04445dc9">00370</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#ab91e79271a1f8e75b07bddbb04445dc9" title="Enables the generation of interrupts for alarms 0 and 1.">DS3232RTC::enableAlarmInterrupts</a>()
|
||||
<a name="l00371"></a>00371 {
|
||||
<a name="l00372"></a>00372 <span class="keywordflow">if</span> (_oneHzPin == 255 && _isRealTime) {
|
||||
<a name="l00373"></a>00373 updateAlarmInterrupts();
|
||||
<a name="l00374"></a>00374 alarmInterrupts = <span class="keyword">true</span>;
|
||||
<a name="l00375"></a>00375 }
|
||||
<a name="l00376"></a>00376 }
|
||||
<a name="l00377"></a>00377
|
||||
<a name="l00383"></a><a class="code" href="classDS3232RTC.html#a225b8c62d617aa1b7be7d20e8a033be9">00383</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#a225b8c62d617aa1b7be7d20e8a033be9" title="Disables the generation of interrupts for alarms 0 and 1.">DS3232RTC::disableAlarmInterrupts</a>()
|
||||
<a name="l00384"></a>00384 {
|
||||
<a name="l00385"></a>00385 <span class="keywordflow">if</span> (alarmInterrupts) {
|
||||
<a name="l00386"></a>00386 uint8_t value = readRegister(DS3232_CONTROL);
|
||||
<a name="l00387"></a>00387 value &= ~(DS3232_INTCN | DS3232_A2IE | DS3232_A1IE);
|
||||
<a name="l00388"></a>00388 writeRegister(DS3232_CONTROL, value);
|
||||
<a name="l00389"></a>00389 alarmInterrupts = <span class="keyword">false</span>;
|
||||
<a name="l00390"></a>00390 }
|
||||
<a name="l00391"></a>00391 }
|
||||
<a name="l00392"></a>00392
|
||||
<a name="l00406"></a><a class="code" href="classDS3232RTC.html#a79649f100a4562b9c1ba7c69e85cbca3">00406</a> <span class="keywordtype">int</span> <a class="code" href="classDS3232RTC.html#a79649f100a4562b9c1ba7c69e85cbca3" title="Determines which of alarms 0 or 1 have fired since the last call.">DS3232RTC::firedAlarm</a>()
|
||||
<a name="l00407"></a>00407 {
|
||||
<a name="l00408"></a>00408 <span class="keywordflow">if</span> (!_isRealTime)
|
||||
<a name="l00409"></a>00409 <span class="keywordflow">return</span> -1;
|
||||
<a name="l00410"></a>00410 uint8_t value = readRegister(DS3232_STATUS);
|
||||
<a name="l00411"></a>00411 <span class="keywordtype">int</span> alarm;
|
||||
<a name="l00412"></a>00412 <span class="keywordflow">if</span> (value & DS3232_A1F) {
|
||||
<a name="l00413"></a>00413 <span class="keywordflow">if</span> (value & DS3232_A2F)
|
||||
<a name="l00414"></a>00414 alarm = 2;
|
||||
<a name="l00415"></a>00415 <span class="keywordflow">else</span>
|
||||
<a name="l00416"></a>00416 alarm = 0;
|
||||
<a name="l00417"></a>00417 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (value & DS3232_A2F) {
|
||||
<a name="l00418"></a>00418 alarm = 1;
|
||||
<a name="l00419"></a>00419 } <span class="keywordflow">else</span> {
|
||||
<a name="l00420"></a>00420 alarm = -1;
|
||||
<a name="l00421"></a>00421 }
|
||||
<a name="l00422"></a>00422 <span class="keywordflow">if</span> (alarm != -1) {
|
||||
<a name="l00423"></a>00423 value &= ~(DS3232_A1F | DS3232_A2F);
|
||||
<a name="l00424"></a>00424 writeRegister(DS3232_STATUS, value);
|
||||
<a name="l00425"></a>00425 }
|
||||
<a name="l00426"></a>00426 <span class="keywordflow">return</span> alarm;
|
||||
<a name="l00427"></a>00427 }
|
||||
<a name="l00428"></a>00428
|
||||
<a name="l00434"></a><a class="code" href="classDS3232RTC.html#a3966de6f4241d86f198a8b9dd5e7e59a">00434</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#a3966de6f4241d86f198a8b9dd5e7e59a" title="Enables the 32 kHz output on the DS3232 chip.">DS3232RTC::enable32kHzOutput</a>()
|
||||
<a name="l00435"></a>00435 {
|
||||
<a name="l00436"></a>00436 <span class="keywordflow">if</span> (_isRealTime) {
|
||||
<a name="l00437"></a>00437 uint8_t value = readRegister(DS3232_STATUS);
|
||||
<a name="l00438"></a>00438 value |= DS3232_BB32KHZ | DS3232_EN32KHZ;
|
||||
<a name="l00439"></a>00439 writeRegister(DS3232_STATUS, value);
|
||||
<a name="l00440"></a>00440 }
|
||||
<a name="l00441"></a>00441 }
|
||||
<a name="l00442"></a>00442
|
||||
<a name="l00448"></a><a class="code" href="classDS3232RTC.html#ada732bae42fc2833e59ae293aa27ddcb">00448</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#ada732bae42fc2833e59ae293aa27ddcb" title="Disables the 32 kHz output on the DS3232 chip.">DS3232RTC::disable32kHzOutput</a>()
|
||||
<a name="l00449"></a>00449 {
|
||||
<a name="l00450"></a>00450 <span class="keywordflow">if</span> (_isRealTime) {
|
||||
<a name="l00451"></a>00451 uint8_t value = readRegister(DS3232_STATUS);
|
||||
<a name="l00452"></a>00452 value &= ~(DS3232_BB32KHZ | DS3232_EN32KHZ);
|
||||
<a name="l00453"></a>00453 writeRegister(DS3232_STATUS, value);
|
||||
<a name="l00454"></a>00454 }
|
||||
<a name="l00455"></a>00455 }
|
||||
<a name="l00456"></a>00456
|
||||
<a name="l00457"></a>00457 <span class="keywordtype">void</span> DS3232RTC::initAlarms()
|
||||
<a name="l00458"></a>00458 {
|
||||
<a name="l00459"></a>00459 uint8_t value = readRegister(DS3232_ALARM_MAGIC);
|
||||
<a name="l00460"></a>00460 <span class="keywordflow">if</span> (value != (0xB0 + <a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3" title="Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().">ALARM_COUNT</a>)) {
|
||||
<a name="l00461"></a>00461 <span class="comment">// This is the first time we have used this clock chip,</span>
|
||||
<a name="l00462"></a>00462 <span class="comment">// so initialize all alarms to their default state.</span>
|
||||
<a name="l00463"></a>00463 <a class="code" href="structRTCAlarm.html" title="Stores alarm information from a realtime clock chip.">RTCAlarm</a> alarm;
|
||||
<a name="l00464"></a>00464 alarm.<a class="code" href="structRTCAlarm.html#a75bdc42acd3ab3ad495680c6b6a34692" title="Hour of the day for the alarm (0-23).">hour</a> = 6; <span class="comment">// Default to 6am for alarms.</span>
|
||||
<a name="l00465"></a>00465 alarm.<a class="code" href="structRTCAlarm.html#ad9a75ceb4b4b3474baa66dd5466e62fe" title="Minute of the hour for the alarm (0-59).">minute</a> = 0;
|
||||
<a name="l00466"></a>00466 alarm.<a class="code" href="structRTCAlarm.html#a0f2ef7363cb60a26642d5295b77ca19e" title="Additional flags for the alarm.">flags</a> = 0;
|
||||
<a name="l00467"></a>00467 <span class="keywordflow">for</span> (uint8_t index = 0; index < <a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3" title="Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().">ALARM_COUNT</a>; ++index)
|
||||
<a name="l00468"></a>00468 <a class="code" href="classDS3232RTC.html#a8b0a65e0ac479aec8fad6ca3147dbe75" title="Updates the details of the alarm with index alarmNum from value.">writeAlarm</a>(index, &alarm);
|
||||
<a name="l00469"></a>00469 writeRegister(DS3232_ALARM_MAGIC, 0xB0 + ALARM_COUNT);
|
||||
<a name="l00470"></a>00470
|
||||
<a name="l00471"></a>00471 <span class="comment">// Also clear the rest of NVRAM so that it is in a known state.</span>
|
||||
<a name="l00472"></a>00472 <span class="comment">// Otherwise we'll have whatever garbage was present at power-on.</span>
|
||||
<a name="l00473"></a>00473 _bus-><a class="code" href="classI2CMaster.html#a01960fc821cb25e4c88c26d2c6107e35" title="Starts a write operation by sending a start condition and the I2C control byte.">startWrite</a>(DS3232_I2C_ADDRESS);
|
||||
<a name="l00474"></a>00474 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(DS3232_NVRAM);
|
||||
<a name="l00475"></a>00475 <span class="keywordflow">for</span> (uint8_t index = DS3232_NVRAM; index < DS3232_ALARMS; ++index)
|
||||
<a name="l00476"></a>00476 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(0);
|
||||
<a name="l00477"></a>00477 _bus-><a class="code" href="classI2CMaster.html#ab29f63551ddeb032a91505d1c0b8ac41" title="Ends the current write operation.">endWrite</a>();
|
||||
<a name="l00478"></a>00478 }
|
||||
<a name="l00479"></a>00479 }
|
||||
<a name="l00356"></a><a class="code" href="classDS3232RTC.html#a0faf40c25ab019a326a60f301c2bb41b">00356</a> <span class="keywordtype">int</span> <a class="code" href="classDS3232RTC.html#a0faf40c25ab019a326a60f301c2bb41b" title="Reads the value of the temperature sensor and returns the temperature in quarters of a degree celcius...">DS3232RTC::readTemperature</a>()
|
||||
<a name="l00357"></a>00357 {
|
||||
<a name="l00358"></a>00358 <span class="keywordflow">if</span> (_isRealTime) {
|
||||
<a name="l00359"></a>00359 <span class="keywordflow">return</span> (((<span class="keywordtype">int</span>)(<span class="keywordtype">signed</span> <span class="keywordtype">char</span>)readRegister(DS3232_TEMP_MSB)) << 2) |
|
||||
<a name="l00360"></a>00360 (readRegister(DS3232_TEMP_LSB) >> 6);
|
||||
<a name="l00361"></a>00361 } <span class="keywordflow">else</span> {
|
||||
<a name="l00362"></a>00362 <span class="keywordflow">return</span> <a class="code" href="classRTC.html#a9ed5480b362a83f1f45c4d3bcf7c3bf8" title="Value that is returned from readTemperature() if the realtime clock chip cannot determine the tempera...">NO_TEMPERATURE</a>;
|
||||
<a name="l00363"></a>00363 }
|
||||
<a name="l00364"></a>00364 }
|
||||
<a name="l00365"></a>00365
|
||||
<a name="l00380"></a><a class="code" href="classDS3232RTC.html#ab91e79271a1f8e75b07bddbb04445dc9">00380</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#ab91e79271a1f8e75b07bddbb04445dc9" title="Enables the generation of interrupts for alarms 0 and 1.">DS3232RTC::enableAlarmInterrupts</a>()
|
||||
<a name="l00381"></a>00381 {
|
||||
<a name="l00382"></a>00382 <span class="keywordflow">if</span> (_oneHzPin == 255 && _isRealTime) {
|
||||
<a name="l00383"></a>00383 updateAlarmInterrupts();
|
||||
<a name="l00384"></a>00384 alarmInterrupts = <span class="keyword">true</span>;
|
||||
<a name="l00385"></a>00385 }
|
||||
<a name="l00386"></a>00386 }
|
||||
<a name="l00387"></a>00387
|
||||
<a name="l00393"></a><a class="code" href="classDS3232RTC.html#a225b8c62d617aa1b7be7d20e8a033be9">00393</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#a225b8c62d617aa1b7be7d20e8a033be9" title="Disables the generation of interrupts for alarms 0 and 1.">DS3232RTC::disableAlarmInterrupts</a>()
|
||||
<a name="l00394"></a>00394 {
|
||||
<a name="l00395"></a>00395 <span class="keywordflow">if</span> (alarmInterrupts) {
|
||||
<a name="l00396"></a>00396 uint8_t value = readRegister(DS3232_CONTROL);
|
||||
<a name="l00397"></a>00397 value &= ~(DS3232_INTCN | DS3232_A2IE | DS3232_A1IE);
|
||||
<a name="l00398"></a>00398 writeRegister(DS3232_CONTROL, value);
|
||||
<a name="l00399"></a>00399 alarmInterrupts = <span class="keyword">false</span>;
|
||||
<a name="l00400"></a>00400 }
|
||||
<a name="l00401"></a>00401 }
|
||||
<a name="l00402"></a>00402
|
||||
<a name="l00416"></a><a class="code" href="classDS3232RTC.html#a79649f100a4562b9c1ba7c69e85cbca3">00416</a> <span class="keywordtype">int</span> <a class="code" href="classDS3232RTC.html#a79649f100a4562b9c1ba7c69e85cbca3" title="Determines which of alarms 0 or 1 have fired since the last call.">DS3232RTC::firedAlarm</a>()
|
||||
<a name="l00417"></a>00417 {
|
||||
<a name="l00418"></a>00418 <span class="keywordflow">if</span> (!_isRealTime)
|
||||
<a name="l00419"></a>00419 <span class="keywordflow">return</span> -1;
|
||||
<a name="l00420"></a>00420 uint8_t value = readRegister(DS3232_STATUS);
|
||||
<a name="l00421"></a>00421 <span class="keywordtype">int</span> alarm;
|
||||
<a name="l00422"></a>00422 <span class="keywordflow">if</span> (value & DS3232_A1F) {
|
||||
<a name="l00423"></a>00423 <span class="keywordflow">if</span> (value & DS3232_A2F)
|
||||
<a name="l00424"></a>00424 alarm = 2;
|
||||
<a name="l00425"></a>00425 <span class="keywordflow">else</span>
|
||||
<a name="l00426"></a>00426 alarm = 0;
|
||||
<a name="l00427"></a>00427 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (value & DS3232_A2F) {
|
||||
<a name="l00428"></a>00428 alarm = 1;
|
||||
<a name="l00429"></a>00429 } <span class="keywordflow">else</span> {
|
||||
<a name="l00430"></a>00430 alarm = -1;
|
||||
<a name="l00431"></a>00431 }
|
||||
<a name="l00432"></a>00432 <span class="keywordflow">if</span> (alarm != -1) {
|
||||
<a name="l00433"></a>00433 value &= ~(DS3232_A1F | DS3232_A2F);
|
||||
<a name="l00434"></a>00434 writeRegister(DS3232_STATUS, value);
|
||||
<a name="l00435"></a>00435 }
|
||||
<a name="l00436"></a>00436 <span class="keywordflow">return</span> alarm;
|
||||
<a name="l00437"></a>00437 }
|
||||
<a name="l00438"></a>00438
|
||||
<a name="l00444"></a><a class="code" href="classDS3232RTC.html#a3966de6f4241d86f198a8b9dd5e7e59a">00444</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#a3966de6f4241d86f198a8b9dd5e7e59a" title="Enables the 32 kHz output on the DS3232 chip.">DS3232RTC::enable32kHzOutput</a>()
|
||||
<a name="l00445"></a>00445 {
|
||||
<a name="l00446"></a>00446 <span class="keywordflow">if</span> (_isRealTime) {
|
||||
<a name="l00447"></a>00447 uint8_t value = readRegister(DS3232_STATUS);
|
||||
<a name="l00448"></a>00448 value |= DS3232_BB32KHZ | DS3232_EN32KHZ;
|
||||
<a name="l00449"></a>00449 writeRegister(DS3232_STATUS, value);
|
||||
<a name="l00450"></a>00450 }
|
||||
<a name="l00451"></a>00451 }
|
||||
<a name="l00452"></a>00452
|
||||
<a name="l00458"></a><a class="code" href="classDS3232RTC.html#ada732bae42fc2833e59ae293aa27ddcb">00458</a> <span class="keywordtype">void</span> <a class="code" href="classDS3232RTC.html#ada732bae42fc2833e59ae293aa27ddcb" title="Disables the 32 kHz output on the DS3232 chip.">DS3232RTC::disable32kHzOutput</a>()
|
||||
<a name="l00459"></a>00459 {
|
||||
<a name="l00460"></a>00460 <span class="keywordflow">if</span> (_isRealTime) {
|
||||
<a name="l00461"></a>00461 uint8_t value = readRegister(DS3232_STATUS);
|
||||
<a name="l00462"></a>00462 value &= ~(DS3232_BB32KHZ | DS3232_EN32KHZ);
|
||||
<a name="l00463"></a>00463 writeRegister(DS3232_STATUS, value);
|
||||
<a name="l00464"></a>00464 }
|
||||
<a name="l00465"></a>00465 }
|
||||
<a name="l00466"></a>00466
|
||||
<a name="l00467"></a>00467 <span class="keywordtype">void</span> DS3232RTC::initAlarms()
|
||||
<a name="l00468"></a>00468 {
|
||||
<a name="l00469"></a>00469 uint8_t value = readRegister(DS3232_ALARM_MAGIC);
|
||||
<a name="l00470"></a>00470 <span class="keywordflow">if</span> (value != (0xB0 + <a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3" title="Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().">ALARM_COUNT</a>)) {
|
||||
<a name="l00471"></a>00471 <span class="comment">// This is the first time we have used this clock chip,</span>
|
||||
<a name="l00472"></a>00472 <span class="comment">// so initialize all alarms to their default state.</span>
|
||||
<a name="l00473"></a>00473 <a class="code" href="structRTCAlarm.html" title="Stores alarm information from a realtime clock chip.">RTCAlarm</a> alarm;
|
||||
<a name="l00474"></a>00474 alarm.<a class="code" href="structRTCAlarm.html#a75bdc42acd3ab3ad495680c6b6a34692" title="Hour of the day for the alarm (0-23).">hour</a> = 6; <span class="comment">// Default to 6am for alarms.</span>
|
||||
<a name="l00475"></a>00475 alarm.<a class="code" href="structRTCAlarm.html#ad9a75ceb4b4b3474baa66dd5466e62fe" title="Minute of the hour for the alarm (0-59).">minute</a> = 0;
|
||||
<a name="l00476"></a>00476 alarm.<a class="code" href="structRTCAlarm.html#a0f2ef7363cb60a26642d5295b77ca19e" title="Additional flags for the alarm.">flags</a> = 0;
|
||||
<a name="l00477"></a>00477 <span class="keywordflow">for</span> (uint8_t index = 0; index < <a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3" title="Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().">ALARM_COUNT</a>; ++index)
|
||||
<a name="l00478"></a>00478 <a class="code" href="classDS3232RTC.html#a8b0a65e0ac479aec8fad6ca3147dbe75" title="Updates the details of the alarm with index alarmNum from value.">writeAlarm</a>(index, &alarm);
|
||||
<a name="l00479"></a>00479 writeRegister(DS3232_ALARM_MAGIC, 0xB0 + ALARM_COUNT);
|
||||
<a name="l00480"></a>00480
|
||||
<a name="l00481"></a>00481 uint8_t DS3232RTC::readRegister(uint8_t reg)
|
||||
<a name="l00482"></a>00482 {
|
||||
<a name="l00483"></a>00483 _bus-><a class="code" href="classI2CMaster.html#a01960fc821cb25e4c88c26d2c6107e35" title="Starts a write operation by sending a start condition and the I2C control byte.">startWrite</a>(DS3232_I2C_ADDRESS);
|
||||
<a name="l00484"></a>00484 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(reg);
|
||||
<a name="l00485"></a>00485 <span class="keywordflow">if</span> (!_bus-><a class="code" href="classI2CMaster.html#a4e5f1a1a4c2242699be5a35fc4872fde" title="Starts a read operation for count bytes by sending the start condition and the I2C control byte...">startRead</a>(DS3232_I2C_ADDRESS, 1))
|
||||
<a name="l00486"></a>00486 <span class="keywordflow">return</span> 0; <span class="comment">// RTC chip is not responding.</span>
|
||||
<a name="l00487"></a>00487 <span class="keywordflow">return</span> _bus-><a class="code" href="classI2CMaster.html#a49eeebb57f6bc06de39973fe836369cd" title="Reads a single byte from the I2C bus.">read</a>();
|
||||
<a name="l00488"></a>00488 }
|
||||
<a name="l00489"></a>00489
|
||||
<a name="l00490"></a>00490 <span class="keywordtype">bool</span> DS3232RTC::writeRegister(uint8_t reg, uint8_t value)
|
||||
<a name="l00491"></a>00491 {
|
||||
<a name="l00492"></a>00492 _bus-><a class="code" href="classI2CMaster.html#a01960fc821cb25e4c88c26d2c6107e35" title="Starts a write operation by sending a start condition and the I2C control byte.">startWrite</a>(DS3232_I2C_ADDRESS);
|
||||
<a name="l00493"></a>00493 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(reg);
|
||||
<a name="l00494"></a>00494 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(value);
|
||||
<a name="l00495"></a>00495 <span class="keywordflow">return</span> _bus-><a class="code" href="classI2CMaster.html#ab29f63551ddeb032a91505d1c0b8ac41" title="Ends the current write operation.">endWrite</a>();
|
||||
<a name="l00496"></a>00496 }
|
||||
<a name="l00497"></a>00497
|
||||
<a name="l00498"></a>00498 <span class="preprocessor">#define DS3232_ALARM1_FLAGS (DS3232_ALARMS + 2)</span>
|
||||
<a name="l00499"></a>00499 <span class="preprocessor"></span><span class="preprocessor">#define DS3232_ALARM2_FLAGS (DS3232_ALARMS + DS3232_ALARM_SIZE + 2)</span>
|
||||
<a name="l00500"></a>00500 <span class="preprocessor"></span>
|
||||
<a name="l00501"></a>00501 <span class="keywordtype">void</span> DS3232RTC::updateAlarmInterrupts()
|
||||
<a name="l00502"></a>00502 {
|
||||
<a name="l00503"></a>00503 <span class="keywordtype">bool</span> alarm1Enabled = ((readRegister(DS3232_ALARM1_FLAGS) & 0x01) != 0);
|
||||
<a name="l00504"></a>00504 <span class="keywordtype">bool</span> alarm2Enabled = ((readRegister(DS3232_ALARM2_FLAGS) & 0x01) != 0);
|
||||
<a name="l00505"></a>00505 uint8_t value = readRegister(DS3232_CONTROL);
|
||||
<a name="l00506"></a>00506 value |= DS3232_INTCN;
|
||||
<a name="l00507"></a>00507 <span class="keywordflow">if</span> (alarm1Enabled)
|
||||
<a name="l00508"></a>00508 value |= DS3232_A1IE;
|
||||
<a name="l00509"></a>00509 <span class="keywordflow">else</span>
|
||||
<a name="l00510"></a>00510 value &= ~DS3232_A1IE;
|
||||
<a name="l00511"></a>00511 <span class="keywordflow">if</span> (alarm2Enabled)
|
||||
<a name="l00512"></a>00512 value |= DS3232_A2IE;
|
||||
<a name="l00513"></a>00513 <span class="keywordflow">else</span>
|
||||
<a name="l00514"></a>00514 value &= ~DS3232_A2IE;
|
||||
<a name="l00515"></a>00515 writeRegister(DS3232_CONTROL, value);
|
||||
<a name="l00516"></a>00516 }
|
||||
<a name="l00481"></a>00481 <span class="comment">// Also clear the rest of NVRAM so that it is in a known state.</span>
|
||||
<a name="l00482"></a>00482 <span class="comment">// Otherwise we'll have whatever garbage was present at power-on.</span>
|
||||
<a name="l00483"></a>00483 _bus-><a class="code" href="classI2CMaster.html#a01960fc821cb25e4c88c26d2c6107e35" title="Starts a write operation by sending a start condition and the I2C control byte.">startWrite</a>(DS3232_I2C_ADDRESS);
|
||||
<a name="l00484"></a>00484 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(DS3232_NVRAM);
|
||||
<a name="l00485"></a>00485 <span class="keywordflow">for</span> (uint8_t index = DS3232_NVRAM; index < DS3232_ALARMS; ++index)
|
||||
<a name="l00486"></a>00486 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(0);
|
||||
<a name="l00487"></a>00487 _bus-><a class="code" href="classI2CMaster.html#ab29f63551ddeb032a91505d1c0b8ac41" title="Ends the current write operation.">endWrite</a>();
|
||||
<a name="l00488"></a>00488 }
|
||||
<a name="l00489"></a>00489 }
|
||||
<a name="l00490"></a>00490
|
||||
<a name="l00491"></a>00491 uint8_t DS3232RTC::readRegister(uint8_t reg)
|
||||
<a name="l00492"></a>00492 {
|
||||
<a name="l00493"></a>00493 _bus-><a class="code" href="classI2CMaster.html#a01960fc821cb25e4c88c26d2c6107e35" title="Starts a write operation by sending a start condition and the I2C control byte.">startWrite</a>(DS3232_I2C_ADDRESS);
|
||||
<a name="l00494"></a>00494 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(reg);
|
||||
<a name="l00495"></a>00495 <span class="keywordflow">if</span> (!_bus-><a class="code" href="classI2CMaster.html#a4e5f1a1a4c2242699be5a35fc4872fde" title="Starts a read operation for count bytes by sending the start condition and the I2C control byte...">startRead</a>(DS3232_I2C_ADDRESS, 1))
|
||||
<a name="l00496"></a>00496 <span class="keywordflow">return</span> 0; <span class="comment">// RTC chip is not responding.</span>
|
||||
<a name="l00497"></a>00497 <span class="keywordflow">return</span> _bus-><a class="code" href="classI2CMaster.html#a49eeebb57f6bc06de39973fe836369cd" title="Reads a single byte from the I2C bus.">read</a>();
|
||||
<a name="l00498"></a>00498 }
|
||||
<a name="l00499"></a>00499
|
||||
<a name="l00500"></a>00500 <span class="keywordtype">bool</span> DS3232RTC::writeRegister(uint8_t reg, uint8_t value)
|
||||
<a name="l00501"></a>00501 {
|
||||
<a name="l00502"></a>00502 _bus-><a class="code" href="classI2CMaster.html#a01960fc821cb25e4c88c26d2c6107e35" title="Starts a write operation by sending a start condition and the I2C control byte.">startWrite</a>(DS3232_I2C_ADDRESS);
|
||||
<a name="l00503"></a>00503 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(reg);
|
||||
<a name="l00504"></a>00504 _bus-><a class="code" href="classI2CMaster.html#a0bf6b84cb1e2b3a37a4a0260d0b6f960" title="Writes a single byte value on the I2C bus.">write</a>(value);
|
||||
<a name="l00505"></a>00505 <span class="keywordflow">return</span> _bus-><a class="code" href="classI2CMaster.html#ab29f63551ddeb032a91505d1c0b8ac41" title="Ends the current write operation.">endWrite</a>();
|
||||
<a name="l00506"></a>00506 }
|
||||
<a name="l00507"></a>00507
|
||||
<a name="l00508"></a>00508 <span class="preprocessor">#define DS3232_ALARM1_FLAGS (DS3232_ALARMS + 2)</span>
|
||||
<a name="l00509"></a>00509 <span class="preprocessor"></span><span class="preprocessor">#define DS3232_ALARM2_FLAGS (DS3232_ALARMS + DS3232_ALARM_SIZE + 2)</span>
|
||||
<a name="l00510"></a>00510 <span class="preprocessor"></span>
|
||||
<a name="l00511"></a>00511 <span class="keywordtype">void</span> DS3232RTC::updateAlarmInterrupts()
|
||||
<a name="l00512"></a>00512 {
|
||||
<a name="l00513"></a>00513 <span class="keywordtype">bool</span> alarm1Enabled = ((readRegister(DS3232_ALARM1_FLAGS) & 0x01) != 0);
|
||||
<a name="l00514"></a>00514 <span class="keywordtype">bool</span> alarm2Enabled = ((readRegister(DS3232_ALARM2_FLAGS) & 0x01) != 0);
|
||||
<a name="l00515"></a>00515 uint8_t value = readRegister(DS3232_CONTROL);
|
||||
<a name="l00516"></a>00516 value |= DS3232_INTCN;
|
||||
<a name="l00517"></a>00517 <span class="keywordflow">if</span> (alarm1Enabled)
|
||||
<a name="l00518"></a>00518 value |= DS3232_A1IE;
|
||||
<a name="l00519"></a>00519 <span class="keywordflow">else</span>
|
||||
<a name="l00520"></a>00520 value &= ~DS3232_A1IE;
|
||||
<a name="l00521"></a>00521 <span class="keywordflow">if</span> (alarm2Enabled)
|
||||
<a name="l00522"></a>00522 value |= DS3232_A2IE;
|
||||
<a name="l00523"></a>00523 <span class="keywordflow">else</span>
|
||||
<a name="l00524"></a>00524 value &= ~DS3232_A2IE;
|
||||
<a name="l00525"></a>00525 writeRegister(DS3232_CONTROL, value);
|
||||
<a name="l00526"></a>00526 }
|
||||
</pre></div></div>
|
||||
</div>
|
||||
<!-- window showing the filter options -->
|
||||
@@ -505,7 +515,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<hr class="footer"/><address class="footer"><small>Generated on Fri May 25 2012 16:23:36 for ArduinoLibs by 
|
||||
<hr class="footer"/><address class="footer"><small>Generated on Mon May 28 2012 20:55:50 for ArduinoLibs by 
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user