uint8_t RTC_DS1307::isrunning(void) { Wire.beginTransmission(DS1307_ADDRESS); Wire_write((byte)0); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, 1); uint8_t ss = Wire_read(); return !(ss>>7); }
DateTime RTC_DS1307::now() { Wire.beginTransmission(DS1307_ADDRESS); Wire_write((byte)0); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, 7); uint8_t ss = bcd2bin(Wire_read() & 0x7F); uint8_t mm = bcd2bin(Wire_read()); uint8_t hh = bcd2bin(Wire_read()); Wire_read(); uint8_t d = bcd2bin(Wire_read()); uint8_t m = bcd2bin(Wire_read()); uint16_t y = bcd2bin(Wire_read()) + 2000; return DateTime (y, m, d, hh, mm, ss); }
DateTime RTC_DS1307::now() { Wire.beginTransmission(DS1307_ADDRESS); Wire_write(DS1307_Registers::Second); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, 7); uint8_t ss = bcd2bin(Wire_read() & 0x7F); uint8_t mm = bcd2bin(Wire_read()); uint8_t hh = bcd2bin(Wire_read()); Wire_read(); // ignore the day-of-week value uint8_t d = bcd2bin(Wire_read()); uint8_t m = bcd2bin(Wire_read()); uint16_t y = bcd2bin(Wire_read()) + 2000; return DateTime (y, m, d, hh, mm, ss); }
/* * Function calibrationDataRead * Desc Read the calibration data from HP03M EEPROM * Input none * Output none */ void HP03M::calibrationDataRead(void) { unsigned char calibrationData[18]; digitalWrite(xclr_pin,LOW); Wire.beginTransmission(HP03M_CalEEPROM_Address); Wire_write(0x10); Wire.endTransmission(); for(unsigned char i=0;i<18;i++) { Wire.requestFrom(HP03M_CalEEPROM_Address,1); while(Wire.available()) { calibrationData[i]= Wire_read(); } } coefficientFill(calibrationData); return; }
void rawTemperatureReadHelper(unsigned char *temperature) { Wire.beginTransmission(HP03M_ADC_Address); Wire_write(0xFF); Wire_write(0xE8); Wire.endTransmission(); delay(40); Wire.beginTransmission(HP03M_ADC_Address); Wire_write(0xFD); Wire.endTransmission(); for(unsigned char i=0;i<2;i++) { Wire.requestFrom(HP03M_ADC_Address, 1 ); while(Wire.available()) { temperature[i]= Wire_read(); } } Wire.endTransmission(); //End read, got the Temperature data }