Class Mcp7940m
I2C Real-Time Clock/Calendar with SRAM.
public class Mcp7940m
- Inheritance
-
Mcp7940m
- Derived
Constructors
Mcp7940m(I2cDevice, ClockSource)
Initializes a new instance of the Mcp7940m class.
public Mcp7940m(I2cDevice i2cDevice, ClockSource clockSource)
Parameters
i2cDevice
I2cDeviceThe I2C device to use for communication.
clockSource
ClockSourceThe oscillator configuration of the clock.
Exceptions
- ArgumentNullException
Thrown when
i2cDevice
isnull
.
Fields
DefaultI2cAddress
Default I2C address for the Mcp7940xx family.
public const byte DefaultI2cAddress = 111
Field Value
_i2cDevice
The underlying I2C device used for communication.
protected readonly I2cDevice _i2cDevice
Field Value
Properties
AlarmInterruptPolarity
Gets or sets the output polarity of the MFP pin when an alarm interrupt is asserted.
public PinValue AlarmInterruptPolarity { get; set; }
Property Value
GeneralPurposeOutput
Gets or sets the MFP pin level when in general purpose output mode.
public PinValue GeneralPurposeOutput { get; set; }
Property Value
Remarks
General purpose output can only be used when Alarm1, Alarm2 and square wave output are all disabled.
IsEnabledAlarm1
Gets a value indicating whether Alarm 1 is enabled.
public bool IsEnabledAlarm1 { get; }
Property Value
IsEnabledAlarm2
Gets a value indicating whether Alarm 2 is enabled.
public bool IsEnabledAlarm2 { get; }
Property Value
IsEnabledGeneralPurposeOutput
Gets a value indicating whether the general purpose output is enabled.
public bool IsEnabledGeneralPurposeOutput { get; }
Property Value
IsEnabledSquareWaveOutput
Gets a value indicating whether the square wave output is enabled.
public bool IsEnabledSquareWaveOutput { get; }
Property Value
IsHalted
Gets a value indicating whether the clocks oscillator has been halted.
public bool IsHalted { get; }
Property Value
IsTriggeredAlarm1
Gets a value indicating whether Alarm 1 is triggered.
public bool IsTriggeredAlarm1 { get; }
Property Value
IsTriggeredAlarm2
Gets a value indicating whether Alarm 2 is triggered.
public bool IsTriggeredAlarm2 { get; }
Property Value
SquareWaveOutputFrequency
Gets or sets the frequency of the square wave output on the MFP pin.
public SquareWaveFrequency SquareWaveOutputFrequency { get; set; }
Property Value
Methods
ClearTimeAdjustment()
Requests time trimming correction not be performed.
public void ClearTimeAdjustment()
DisableAlarm1()
Disables Alarm 1.
public void DisableAlarm1()
DisableAlarm2()
Disables Alarm 2.
public void DisableAlarm2()
DisableSquareWaveOutput()
Disables square wave output from the MFP pin.
public void DisableSquareWaveOutput()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
EnableAlarm1()
Enables Alarm 1.
public void EnableAlarm1()
Remarks
Alarm interrupt output can only be used when general purpose output and square wave output are both disabled.
EnableAlarm2()
Enables Alarm 2.
public void EnableAlarm2()
Remarks
Alarm interrupt output can only be used when general purpose output and square wave output are both disabled.
EnableSquareWaveOutput()
Enables square wave output from the MFP pin.
public void EnableSquareWaveOutput()
GetAlarm1()
Reads the settings of Alarm 1 from the device.
public Mcp7940m.Alarm GetAlarm1()
Returns
- Mcp7940m.Alarm
An Mcp7940m.Alarm object whose value is the current settings of Alarm 1.
GetAlarm2()
Reads the settings of Alarm 2 from the device.
public Mcp7940m.Alarm GetAlarm2()
Returns
- Mcp7940m.Alarm
An Mcp7940m.Alarm object whose value is the current settings of Alarm 2.
GetTime()
Gets a DateTime object that is set to the current date and time of the device.
public DateTime GetTime()
Returns
Halt(bool)
Stops the clocks oscillator.
public void Halt(bool blockUntilOscillatorInactive = false)
Parameters
blockUntilOscillatorInactive
boolDetermins if the function should block execution until the clocks oscillator is fully stopped.
ReadByteFromSRAM(byte)
Reads a single byte from the devices SRAM at the given address.
public byte ReadByteFromSRAM(byte address)
Parameters
address
byteThe address to read from.
Returns
- byte
The byte read from the device.
Remarks
Parameter address
must be in the range 0 to 63.
Exceptions
- ArgumentOutOfRangeException
Thrown when address falls outside of the addressable range for this device.
ResetAlarm1()
Clears the triggered state of Alarm 1.
public void ResetAlarm1()
ResetAlarm2()
Clears the triggered state of Alarm 2.
public void ResetAlarm2()
SetAlarm1(Alarm)
Sets Alarm 1 on the device.
public void SetAlarm1(Mcp7940m.Alarm alarm)
Parameters
SetAlarm2(Alarm)
Sets Alarm 2 on the device.
public void SetAlarm2(Mcp7940m.Alarm alarm)
Parameters
SetTime(DateTime)
Sets the time.
public void SetTime(DateTime time)
Parameters
time
DateTimeThe new time.
SetTimeAdjustment(int, SquareWaveFrequency, TrimmingMode)
Sets the time trimming correction to compensate for a clock frequency mismatch.
public void SetTimeAdjustment(int measuredFrequency, SquareWaveFrequency idealFrequency, TrimmingMode mode = TrimmingMode.NormalTrimMode)
Parameters
measuredFrequency
intThe measured frequency of the clocks external crystal oscillator from the MFP pin.
idealFrequency
SquareWaveFrequencyThe desired clock frequency.
mode
TrimmingModeThe rate that oscillator trimming adjustments are applied.
StartClock(bool)
Starts the clocks oscillator.
public void StartClock(bool blockUntilOscillatorActive = false)
Parameters
blockUntilOscillatorActive
boolDetermins if the function should block execution until the clocks oscillator is fully active.
WriteByteToSRAM(byte, byte)
Writes a single byte to the devices SRAM at the given address.
public void WriteByteToSRAM(byte address, byte value)
Parameters
Remarks
Parameter address
must be in the range 0 to 63.
Exceptions
- ArgumentOutOfRangeException
Thrown when address falls outside of the addressable range for this device.