Difference between revisions of "Unit DS1307"
Line 420: | Line 420: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCStart(RTC:PRTCDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCStart(RTC:PRTCDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceStart API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | Not intended to be called directly by applications, use RTCDeviceStart instead |
|- | |- | ||
|} | |} | ||
Line 432: | Line 432: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCStop(RTC:PRTCDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCStop(RTC:PRTCDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceStop API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | Not intended to be called directly by applications, use RTCDeviceStop instead |
|- | |- | ||
|} | |} | ||
Line 444: | Line 444: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCGetTime(RTC:PRTCDevice):Int64;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCGetTime(RTC:PRTCDevice):Int64;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceGetTime API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | Not intended to be called directly by applications, use RTCDeviceGetTime instead |
|- | |- | ||
|} | |} | ||
Line 456: | Line 456: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCSetTime(RTC:PRTCDevice; const Time:Int64):Int64;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCSetTime(RTC:PRTCDevice; const Time:Int64):Int64;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceSetTime API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | Not intended to be called directly by applications, use RTCDeviceSetTime instead |
|- | |- | ||
|} | |} |
Revision as of 01:35, 20 April 2017
Return to Unit Reference
Description
Maxim DS1307 Real Time Clock Driver unit
The Maxim DS1307 is an I2C interface, battery backed real time clock chip with full BCD clock and calendar and 56 bytes of software accessible NVRAM. The chip supports 12 or 24 hour format and is widely used in low cost RTC devices available from a range of suppliers.
This driver extends the real time clock API to include functions for directly reading and writing the NVRAM which could be used for storing device specific information and configuration or for non volatile storage of keys, passwords or tokens.
Constants
DS1307_*
DS1307_RTC_DESCRIPTION = 'Maxim DS1307 Real Time Clock';
|
Description of DS1307 device |
DS1307_MIN_TIME = 125911584000000000;
|
Time starts at 01/01/2000 00:00:00 (MM/DD/YY HH:MM:SS) |
DS1307_MAX_TIME = 157469183990000000;
|
Time ends at 12/31/2099 23:59:59 (MM/DD/YY HH:MM:SS) |
DS1307_CHIP_*
DS1307_CHIP_DS1307 = 0;
|
|
DS1307_CHIP_DS1337 = 1;
|
|
DS1307_CHIP_DS1338 = 2;
|
|
DS1307_CHIP_DS1339 = 3;
|
|
DS1307_CHIP_DS1340 = 4;
|
|
DS1307_CHIP_DS1388 = 5;
|
|
DS1307_CHIP_DS3231 = 6;
|
|
DS1307_CHIP_M41T00 = 7;
|
|
DS1307_CHIP_MCP794XX = 8;
|
|
DS1307_CHIP_RX8025 = 9;
|
DS1307_REG_*
DS1307_REG_SECONDS = $00;
|
00-59 |
DS1307_REG_MINUTE = $01;
|
00-59 |
DS1307_REG_HOUR = $02;
|
00-23 (or 1-12am,pm) |
DS1307_REG_WEEKDAY = $03;
|
01-07 |
DS1307_REG_DAY = $04;
|
01-31 |
DS1307_REG_MONTH = $05;
|
01-12 |
DS1307_REG_YEAR = $06;
|
00-99 |
DS1307_REG_*
DS1307_REG_CONTROL = $07;
|
Also DS1338 |
DS1337_REG_CONTROL = $0e;
|
|
DS1340_REG_CONTROL = $07;
|
|
DS1340_REG_FLAG = $09;
|
|
DS1337_REG_STATUS = $0f;
|
|
DS1339_REG_ALARM1_SECONDS = $07;
|
|
RX8025_REG_CONTROL1 = $0e;
|
|
RX8025_REG_CONTROL2 = $0f;
|
DS1307_REG_SECONDS_*
DS1307_REG_SECONDS_CH = $80;
|
Clock Halt bit (1 to Disable/0 to Enable the clock) |
DS1340_REG_SECONDS_nEOSC = $80;
|
|
MCP794XX_REG_SECONDS_ST = $80;
|
Clock Stop Bit (1 to Enable/0 to Disable the clock) |
DS1307_REG_HOUR_*
DS1307_REG_HOUR_12HR = $40;
|
12/24 hour bit (1 = 12 hour mode/0 = 24 hour mode) |
DS1307_REG_HOUR_PM = $20;
|
AM/PM bit (1 = PM/0 = AM) (Only in 12 hour mode) |
DS1340_REG_HOUR_CENTURY_EN = $80;
|
|
DS1340_REG_HOUR_CENTURY = $40;
|
MCP794XX_REG_WEEKDAY_*
MCP794XX_REG_WEEKDAY_VBATEN = $08;
|
Battery Backup Enabled (1 to Enable/0 to Disable) |
DS1337_REG_MONTH_*
DS1337_REG_MONTH_CENTURY = $80;
|
DS1307_REG_CONTROL_*
DS1307_REG_CONTROL_OUT = $80;
|
Output Control (Output level of SQW/OUT pin when SQWE = 0) |
DS1338_REG_CONTROL_OSF = $20;
|
|
DS1307_REG_CONTROL_SQWE = $10;
|
Square-Wave Enable (When set to 1, enables the oscillator output) |
DS1307_REG_CONTROL_RS1 = $02;
|
Rate Select 1 (See datasheet for values) |
DS1307_REG_CONTROL_RS0 = $01;
|
Rate Select 2 (See datasheet for values) |
DS1337_REG_CONTROL_*
DS1337_REG_CONTROL_nEOSC = $80;
|
|
DS1339_REG_CONTROL_BBSQI = $20;
|
|
DS3231_REG_CONTROL_BBSQW = $40;
|
same as BBSQI |
DS1337_REG_CONTROL_RS2 = $10;
|
|
DS1337_REG_CONTROL_RS1 = $08;
|
|
DS1337_REG_CONTROL_INTCN = $04;
|
|
DS1337_REG_CONTROL_A2IE = $02;
|
|
DS1337_REG_CONTROL_A1IE = $01;
|
DS1340_REG_CONTROL_*
DS1340_REG_CONTROL_OUT = $80;
|
|
DS1340_REG_CONTROL_FT = $40;
|
|
DS1340_REG_CONTROL_CALIB_SIGN = $20;
|
|
DS1340_REG_CONTROL_M_CALIBRATION = $1f;
|
DS1340_REG_FLAG_*
DS1340_REG_FLAG_OSF = $80;
|
DS1337_REG_STATUS_*
DS1337_REG_STATUS_OSF = $80;
|
|
DS1337_REG_STATUS_A2I = $02;
|
|
DS1337_REG_STATUS_A1I = $01;
|
RX8025_REG_CONTROL1_*
RX8025_REG_CONTROL1_2412 = $20;
|
RX8025_REG_CONTROL2_*
RX8025_REG_CONTROL2_PON = $10;
|
|
RX8025_REG_CONTROL2_VDET = $40;
|
|
RX8025_REG_CONTROL2_XST = $20;
|
Type definitions
DS1307 RTC time
PDS1307RTCTime = ^TDS1307RTCTime;
TDS1307RTCTime = array[0..6] of Byte;
DS1307 RTC device
PDS1307RTCDevice = ^TDS1307RTCDevice;
TDS1307RTCDevice = record
RTC Properties | |
RTC:TRTCDevice;
|
|
DS1307 Properties | |
I2C:PI2CDevice;
|
The I2C device this RTC is connected to |
Address:Word;
|
The I2C address of the device |
Chip:LongWord;
|
The chip type (eg DS1307_CHIP_DS1307) |
RTCReg:Byte;
|
The register offset for the RTC |
NVRAMReg:Byte;
|
The register offset for the NVRAM |
NVRAMSize:Byte;
|
The NVRAM size |
ControlReg:Byte;
|
The control register offset |
Statistics Properties | |
ReadCount:LongWord;
|
Number of direct RTC/NVRAM/Control reads to the device |
WriteCount:LongWord;
|
Number of direct RTC/NVRAM/Control writes to the device |
Public variables
None defined
Function declarations
Initialization functions
procedure DS1307Init;
Note | None documented |
---|
DS1307 RTC functions
function DS1307RTCStart(RTC:PRTCDevice):LongWord;
Note | Not intended to be called directly by applications, use RTCDeviceStart instead |
---|
function DS1307RTCStop(RTC:PRTCDevice):LongWord;
Note | Not intended to be called directly by applications, use RTCDeviceStop instead |
---|
function DS1307RTCGetTime(RTC:PRTCDevice):Int64;
Note | Not intended to be called directly by applications, use RTCDeviceGetTime instead |
---|
function DS1307RTCSetTime(RTC:PRTCDevice; const Time:Int64):Int64;
Note | Not intended to be called directly by applications, use RTCDeviceSetTime instead |
---|
DS1307 helper functions
function DS1307ReadRTC(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307WriteRTC(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307ReadNVRAM(RTC:PRTCDevice; Offset:Byte; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307WriteNVRAM(RTC:PRTCDevice; Offset:Byte; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307ReadControl(RTC:PRTCDevice; var Control:Byte):LongWord;
Note | None documented |
---|
function DS1307WriteControl(RTC:PRTCDevice; Control:Byte):LongWord;
Note | None documented |
---|
function DS1307DefaultRTCTime(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord):Boolean;
Note | None documented |
---|
function DS1307FileTimeToRTCTime(RTC:PRTCDevice; const FileTime:Int64; Buffer:Pointer; Size:LongWord):Boolean;
Note | None documented |
---|
function DS1307RTCTimeToFileTime(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord; var FileTime:Int64):Boolean;
Note | None documented |
---|
Return to Unit Reference