C# Class Raspberry.IO.Components.Clocks.Ds1307.Ds1307Connection

Provides functionality for the DS1307 Real-Time Clock.
The Clock Module needs to be modified to work with the Raspberry Pi according to this article: http://electronics.stackexchange.com/questions/98361/how-to-modify-ds1307-rtc-to-use-3-3v-for-raspberry-pi The Datasheet can be found here: http://www.alldatasheet.com/datasheet-pdf/pdf/58481/DALLAS/DS1307.html (the Memory Map is on Page 5. Note that the values in RAM are stored in Nibbles).
ファイルを表示 Open project: raspberry-sharp/raspberry-sharp-io Class Usage Examples

Public Methods

Method Description
DisableRtc ( ) : void

Disables the Clock. When the Clock is diabled, it not ticking.

Ds1307Connection ( Raspberry.IO.InterIntegratedCircuit.I2cDeviceConnection connection ) : System

Creates a new instance of the class using the provided I2C Connection.

EnableRtc ( ) : void

Enables the Clock.

GetDate ( ) : System.DateTime

Reads the Date and Time from the Ds1307 and returns it.

IsRtcEnabled ( ) : bool

Returns true, if the Clock is enabled, otherwise false is returned.

ResetToFactoryDefaults ( ) : void

Resets the Clock to the Factory Defaults.

SetDate ( System.DateTime date ) : void

Writes the provided Date and Time to the Ds1307.

SystemTimeToRtc ( ) : void

Writes the current System Date to the Clock.

Private Methods

Method Description
GetDate ( byte input ) : System.DateTime

Converts the provided bytes to a DateTime.

IntToNibble ( int number ) : byte

Converts the specified integer to a two-nibble-byte.

IsRtcEnabled ( byte seconds ) : bool

Returns true, if the Clock is enabled, otherwise false.

NibbleToInt ( byte nibble ) : int

Converts the specified two-nibble-byte to an integer.

ReadAll ( ) : byte[]

Reads 7 bytes from the Clock and returns them.

ReadSeconds ( ) : byte

Reads the Seconds-byte (first byte in the RAM) from the Clock and returns it.

SetEnabledDisableRtc ( byte seconds, bool disable ) : byte

Disables or enables the Clock.

The disable/enabled-Flag is stored in bit 7 within the seconds-byte.

Method Details

DisableRtc() public method

Disables the Clock. When the Clock is diabled, it not ticking.
public DisableRtc ( ) : void
return void

Ds1307Connection() public method

Creates a new instance of the class using the provided I2C Connection.
public Ds1307Connection ( Raspberry.IO.InterIntegratedCircuit.I2cDeviceConnection connection ) : System
connection Raspberry.IO.InterIntegratedCircuit.I2cDeviceConnection I2C Connection to the Clock.
return System

EnableRtc() public method

Enables the Clock.
public EnableRtc ( ) : void
return void

GetDate() public method

Reads the Date and Time from the Ds1307 and returns it.
public GetDate ( ) : System.DateTime
return System.DateTime

IsRtcEnabled() public method

Returns true, if the Clock is enabled, otherwise false is returned.
public IsRtcEnabled ( ) : bool
return bool

ResetToFactoryDefaults() public method

Resets the Clock to the Factory Defaults.
public ResetToFactoryDefaults ( ) : void
return void

SetDate() public method

Writes the provided Date and Time to the Ds1307.
public SetDate ( System.DateTime date ) : void
date System.DateTime The Date that should be set.
return void

SystemTimeToRtc() public method

Writes the current System Date to the Clock.
public SystemTimeToRtc ( ) : void
return void