Nut/OS  4.10.3
API Reference
x12rtc.h File Reference
#include <dev/rtc.h>
#include <compiler.h>
Include dependency graph for x12rtc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int X12Init (void) NUT_DEPRECATED
 Initialize the interface to an Intersil X12xx hardware clock.
int X12RtcGetClock (struct _tm *tm) NUT_DEPRECATED
 Get date and time from an X12xx hardware clock.
int X12RtcSetClock (CONST struct _tm *tm) NUT_DEPRECATED
 Set an X12xx hardware clock.
int X12RtcGetAlarm (int idx, struct _tm *tm, int *aflgs) NUT_DEPRECATED
 Get alarm date and time of an X12xx hardware clock.
int X12RtcSetAlarm (int idx, CONST struct _tm *tm, int aflgs) NUT_DEPRECATED
 Set alarm of an X12xx hardware clock.
int X12RtcGetStatus (uint32_t *sflgs) NUT_DEPRECATED
 Query RTC status flags.
int X12RtcClearStatus (uint32_t sflgs) NUT_DEPRECATED
 Clear RTC status flags.
int X12RtcReadRegs (uint8_t addr, uint8_t *buff, size_t len)
 Read RTC registers.
int X12RtcWrite (int nv, CONST uint8_t *buff, size_t len)
 Write to RTC registers.
int X12EepromRead (unsigned int addr, void *buff, size_t len)
 Read contents from non-volatile EEPROM.
int X12EepromWrite (unsigned int addr, CONST void *buff, size_t len)
 Store buffer contents in non-volatile EEPROM.

Variables

NUTRTC rtcX12x6

Non-Volatile Alarm Registers

#define X12RTC_SCA0   0x00
 Alarm 0 second.
#define X12RTC_SCA1   0x08
 Alarm 1 second.
#define X12RTC_SCA_ESC   0x80
 Second alarm enabled.
#define X12RTC_MNA0   0x01
 Alarm 0 minute.
#define X12RTC_MNA1   0x09
 Alarm 1 minute.
#define X12RTC_MNA_EMN   0x80
 Minute alarm enabled.
#define X12RTC_HRA0   0x02
 Alarm 0 hour.
#define X12RTC_HRA1   0x0A
 Alarm 1 hour.
#define X12RTC_HRA_EHR   0x80
 Hour alarm enabled.
#define X12RTC_DTA0   0x03
 Alarm 0 day of month.
#define X12RTC_DTA1   0x0B
 Alarm 1 day of month.
#define X12RTC_DTA_EDT   0x80
 Day of month alarm enabled.
#define X12RTC_MOA0   0x04
 Alarm 0 month.
#define X12RTC_MOA1   0x0C
 Alarm 1 month.
#define X12RTC_MOA_EMO   0x80
 Month alarm enabled.
#define X12RTC_YRA0   0x05
 Currently unused alarm 0 register.
#define X12RTC_YRA1   0x0D
 Currently unused alarm 1 register.
#define X12RTC_DWA0   0x06
 Alarm 0 weekday.
#define X12RTC_DWA1   0x0E
 Alarm 1 weekday.
#define X12RTC_DWA_EDW   0x80
 Weekday alarm enabled.
#define X12RTC_Y2K0   0x07
 Alarm 0 .
#define X12RTC_Y2K1   0x0F
 Alarm 1 .

Non-Volatile Control Registers

#define X12RTC_BL   0x10
 Block protection and watchdog register.
#define X12RTC_BL_WD   0x18
 Watchdog configuration.
#define X12RTC_BL_WD_1750   0x00
 Timeout after 1.75 seconds.
#define X12RTC_BL_WD_750   0x08
 Timeout after 750 milliseconds.
#define X12RTC_BL_WD_250   0x10
 Timeout after 250 milliseconds.
#define X12RTC_BL_WD_OFF   0x18
 Disabled.
#define X12RTC_BL_BP   0xE0
 Block protection.
#define X12RTC_BL_BP_NONE   0x00
 No protection.
#define X12RTC_BL_BP_UQUAD   0x20
 Upper quarter protected.
#define X12RTC_BL_BP_UHALF   0x40
 Upper half protected.
#define X12RTC_BL_BP_FULL   0x60
 Full array protected.
#define X12RTC_BL_BP_FIRST1   0x80
 First page protected.
#define X12RTC_BL_BP_FIRST2   0xA0
 First 2 pages protected.
#define X12RTC_BL_BP_FIRST3   0xC0
 First 4 pages protected.
#define X12RTC_BL_BP_FIRST8   0xE0
 First 8 pages protected.
#define X12RTC_INT   0x11
 Interrupt control and freq. output register.
#define X12RTC_INT_FO   0x14
 Programmable frequency output bits.
#define X12RTC_INT_FO_IRQ   0x00
 Alarm interrupt.
#define X12RTC_INT_FO_32KHZ   0x04
 32.768kHz.
#define X12RTC_INT_FO_100HZ   0x10
 100Hz.
#define X12RTC_INT_FO_1HZ   0x14
 1Hz.
#define X12RTC_INT_AL0E   0x20
 Alarm 0 interrupt enable.
#define X12RTC_INT_AL1E   0x40
 Alarm 1 interrupt enable.
#define X12RTC_INT_IM   0x80
 Repetitive alarm.
#define X12RTC_ATR   0x12
 Analog trimming register.
#define X12RTC_DTR   0x13
 Digital trimming register.
#define X12RTC_DTR_NONE   0x00
 0 PPM.
#define X12RTC_DTR_PLUS10   0x02
 +10 PPM.
#define X12RTC_DTR_PLUS20   0x01
 +20 PPM.
#define X12RTC_DTR_PLUS30   0x03
 +30 PPM.
#define X12RTC_DTR_MINUS10   0x06
 -10 PPM.
#define X12RTC_DTR_MINUS20   0x05
 -20 PPM.
#define X12RTC_DTR_MINUS30   0x07
 -30 PPM.

Volatile Date and Time Registers

#define X12RTC_SC   0x30
#define X12RTC_MN   0x31
#define X12RTC_HR   0x32
#define X12RTC_HR_MIL   0x80
#define X12RTC_DT   0x33
#define X12RTC_MO   0x34
#define X12RTC_YR   0x35
#define X12RTC_DW   0x36
#define X128xRTC_SSEC   0x37
#define X122xRTC_Y2K   0x37

Volatile Status Register

#define X12RTC_SR   0x3F
#define X12RTC_SR_RTCF   0x01
#define X12RTC_SR_WEL   0x02
#define X12RTC_SR_RWEL   0x04
#define X12RTC_SR_AL0   0x20
#define X12RTC_SR_AL1   0x40
#define X12RTC_SR_BAT   0x80

Define Documentation

#define X12RTC_SCA0   0x00

Alarm 0 second.

Definition at line 65 of file x12rtc.h.

#define X12RTC_SCA1   0x08

Alarm 1 second.

Definition at line 66 of file x12rtc.h.

#define X12RTC_SCA_ESC   0x80

Second alarm enabled.

Definition at line 67 of file x12rtc.h.

Referenced by X12RtcGetAlarm(), and X12RtcSetAlarm().

#define X12RTC_MNA0   0x01

Alarm 0 minute.

Definition at line 69 of file x12rtc.h.

#define X12RTC_MNA1   0x09

Alarm 1 minute.

Definition at line 70 of file x12rtc.h.

#define X12RTC_MNA_EMN   0x80

Minute alarm enabled.

Definition at line 71 of file x12rtc.h.

Referenced by X12RtcGetAlarm(), and X12RtcSetAlarm().

#define X12RTC_HRA0   0x02

Alarm 0 hour.

Definition at line 73 of file x12rtc.h.

#define X12RTC_HRA1   0x0A

Alarm 1 hour.

Definition at line 74 of file x12rtc.h.

#define X12RTC_HRA_EHR   0x80

Hour alarm enabled.

Definition at line 75 of file x12rtc.h.

Referenced by X12RtcGetAlarm(), and X12RtcSetAlarm().

#define X12RTC_DTA0   0x03

Alarm 0 day of month.

Definition at line 77 of file x12rtc.h.

#define X12RTC_DTA1   0x0B

Alarm 1 day of month.

Definition at line 78 of file x12rtc.h.

#define X12RTC_DTA_EDT   0x80

Day of month alarm enabled.

Definition at line 79 of file x12rtc.h.

Referenced by X12RtcGetAlarm(), and X12RtcSetAlarm().

#define X12RTC_MOA0   0x04

Alarm 0 month.

Definition at line 81 of file x12rtc.h.

#define X12RTC_MOA1   0x0C

Alarm 1 month.

Definition at line 82 of file x12rtc.h.

#define X12RTC_MOA_EMO   0x80

Month alarm enabled.

Definition at line 83 of file x12rtc.h.

Referenced by X12RtcGetAlarm(), and X12RtcSetAlarm().

#define X12RTC_YRA0   0x05

Currently unused alarm 0 register.

Definition at line 85 of file x12rtc.h.

#define X12RTC_YRA1   0x0D

Currently unused alarm 1 register.

Definition at line 86 of file x12rtc.h.

#define X12RTC_DWA0   0x06

Alarm 0 weekday.

Definition at line 88 of file x12rtc.h.

#define X12RTC_DWA1   0x0E

Alarm 1 weekday.

Definition at line 89 of file x12rtc.h.

#define X12RTC_DWA_EDW   0x80

Weekday alarm enabled.

Definition at line 90 of file x12rtc.h.

Referenced by X12RtcGetAlarm(), and X12RtcSetAlarm().

#define X12RTC_Y2K0   0x07

Alarm 0 .

Definition at line 92 of file x12rtc.h.

#define X12RTC_Y2K1   0x0F

Alarm 1 .

Definition at line 93 of file x12rtc.h.

#define X12RTC_BL   0x10

Block protection and watchdog register.

Definition at line 98 of file x12rtc.h.

#define X12RTC_BL_WD   0x18

Watchdog configuration.

Definition at line 100 of file x12rtc.h.

#define X12RTC_BL_WD_1750   0x00

Timeout after 1.75 seconds.

Definition at line 101 of file x12rtc.h.

#define X12RTC_BL_WD_750   0x08

Timeout after 750 milliseconds.

Definition at line 102 of file x12rtc.h.

#define X12RTC_BL_WD_250   0x10

Timeout after 250 milliseconds.

Definition at line 103 of file x12rtc.h.

#define X12RTC_BL_WD_OFF   0x18

Disabled.

Definition at line 104 of file x12rtc.h.

#define X12RTC_BL_BP   0xE0

Block protection.

Definition at line 106 of file x12rtc.h.

#define X12RTC_BL_BP_NONE   0x00

No protection.

Definition at line 107 of file x12rtc.h.

#define X12RTC_BL_BP_UQUAD   0x20

Upper quarter protected.

Definition at line 108 of file x12rtc.h.

#define X12RTC_BL_BP_UHALF   0x40

Upper half protected.

Definition at line 109 of file x12rtc.h.

#define X12RTC_BL_BP_FULL   0x60

Full array protected.

Definition at line 110 of file x12rtc.h.

#define X12RTC_BL_BP_FIRST1   0x80

First page protected.

Definition at line 111 of file x12rtc.h.

#define X12RTC_BL_BP_FIRST2   0xA0

First 2 pages protected.

Definition at line 112 of file x12rtc.h.

#define X12RTC_BL_BP_FIRST3   0xC0

First 4 pages protected.

Definition at line 113 of file x12rtc.h.

#define X12RTC_BL_BP_FIRST8   0xE0

First 8 pages protected.

Definition at line 114 of file x12rtc.h.

#define X12RTC_INT   0x11

Interrupt control and freq. output register.

Definition at line 116 of file x12rtc.h.

#define X12RTC_INT_FO   0x14

Programmable frequency output bits.

Definition at line 118 of file x12rtc.h.

#define X12RTC_INT_FO_IRQ   0x00

Alarm interrupt.

Definition at line 119 of file x12rtc.h.

#define X12RTC_INT_FO_32KHZ   0x04

32.768kHz.

Definition at line 120 of file x12rtc.h.

#define X12RTC_INT_FO_100HZ   0x10

100Hz.

Definition at line 121 of file x12rtc.h.

#define X12RTC_INT_FO_1HZ   0x14

1Hz.

Definition at line 122 of file x12rtc.h.

#define X12RTC_INT_AL0E   0x20

Alarm 0 interrupt enable.

Definition at line 124 of file x12rtc.h.

#define X12RTC_INT_AL1E   0x40

Alarm 1 interrupt enable.

Definition at line 125 of file x12rtc.h.

#define X12RTC_INT_IM   0x80

Repetitive alarm.

Definition at line 126 of file x12rtc.h.

#define X12RTC_ATR   0x12

Analog trimming register.

Definition at line 128 of file x12rtc.h.

#define X12RTC_DTR   0x13

Digital trimming register.

Definition at line 130 of file x12rtc.h.

#define X12RTC_DTR_NONE   0x00

0 PPM.

Definition at line 131 of file x12rtc.h.

#define X12RTC_DTR_PLUS10   0x02

+10 PPM.

Definition at line 132 of file x12rtc.h.

#define X12RTC_DTR_PLUS20   0x01

+20 PPM.

Definition at line 133 of file x12rtc.h.

#define X12RTC_DTR_PLUS30   0x03

+30 PPM.

Definition at line 134 of file x12rtc.h.

#define X12RTC_DTR_MINUS10   0x06

-10 PPM.

Definition at line 135 of file x12rtc.h.

#define X12RTC_DTR_MINUS20   0x05

-20 PPM.

Definition at line 136 of file x12rtc.h.

#define X12RTC_DTR_MINUS30   0x07

-30 PPM.

Definition at line 137 of file x12rtc.h.

#define X12RTC_SC   0x30

Seconds register, 0 - 59.

Definition at line 142 of file x12rtc.h.

Referenced by X12RtcGetClock(), and X12RtcSetClock().

#define X12RTC_MN   0x31

Minutes register, 0 - 59.

Definition at line 143 of file x12rtc.h.

#define X12RTC_HR   0x32

Hours register, 0 - 23.

Definition at line 144 of file x12rtc.h.

#define X12RTC_HR_MIL   0x80

Use 24h format.

Definition at line 145 of file x12rtc.h.

#define X12RTC_DT   0x33

Day register, 1 - 31.

Definition at line 146 of file x12rtc.h.

#define X12RTC_MO   0x34

Month register, 1 - 12.

Definition at line 147 of file x12rtc.h.

#define X12RTC_YR   0x35

Year register, 0 - 99.

Definition at line 148 of file x12rtc.h.

#define X12RTC_DW   0x36

Day of the weeks register, 0 - 6.

Definition at line 149 of file x12rtc.h.

#define X128xRTC_SSEC   0x37

X1286 1/100 second register, 0 - 99 (read only).

Definition at line 150 of file x12rtc.h.

Referenced by X12Init().

#define X122xRTC_Y2K   0x37

X1226 epoch register, 19 or 20.

Definition at line 151 of file x12rtc.h.

#define X12RTC_SR   0x3F

Status register.

Definition at line 156 of file x12rtc.h.

Referenced by X12RtcGetStatus().

#define X12RTC_SR_RTCF   0x01

Power failure.

Definition at line 157 of file x12rtc.h.

#define X12RTC_SR_WEL   0x02

Memory write enable.

Definition at line 158 of file x12rtc.h.

#define X12RTC_SR_RWEL   0x04

Register write enable.

Definition at line 159 of file x12rtc.h.

#define X12RTC_SR_AL0   0x20

Alarm 0 indicator.

Definition at line 160 of file x12rtc.h.

#define X12RTC_SR_AL1   0x40

Alarm 1 indicator.

Definition at line 161 of file x12rtc.h.

#define X12RTC_SR_BAT   0x80

Operating from battery.

Definition at line 162 of file x12rtc.h.


Function Documentation

int X12Init ( void  )

Initialize the interface to an Intersil X12xx hardware clock.

Deprecated:
New applications must use NutRegisterRtc().
Returns:
0 on success or -1 in case of an error.

Definition at line 552 of file x12rtc.c.

References NutSleep(), printf, TwInit(), X128xRTC_SSEC, X12RtcGetStatus(), and X12RtcReadRegs().

Here is the call graph for this function:

int X12RtcGetClock ( struct _tm tm)

Get date and time from an X12xx hardware clock.

Deprecated:
New applications must use NutRtcGetTime().
Parameters:
tmPoints to a structure that receives the date and time information.
Returns:
0 on success or -1 in case of an error.
Examples:
ftpd/ftpserv.c.

Definition at line 245 of file x12rtc.c.

References BCD2BIN, _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, _tm::tm_year, X12RTC_SC, and X12RtcReadRegs().

Here is the call graph for this function:

int X12RtcSetClock ( CONST struct _tm tm)

Set an X12xx hardware clock.

Deprecated:
New applications must use NutRtcSetTime().

New time will be taken over at the beginning of the next second.

Parameters:
tmPoints to a structure which contains the date and time information.
Returns:
0 on success or -1 in case of an error.
Examples:
ftpd/ftpserv.c.

Definition at line 282 of file x12rtc.c.

References BIN2BCD, memset(), X12RTC_SC, and X12RtcWrite().

Here is the call graph for this function:

int X12RtcGetAlarm ( int  idx,
struct _tm tm,
int *  aflgs 
)

Get alarm date and time of an X12xx hardware clock.

Deprecated:
New applications must use NutRtcGetAlarm().
Parameters:
idxZero based index. Two alarms are supported.
tmPoints to a structure that receives the date and time information.
aflgsPoints to an unsigned long that receives the enable flags.
Returns:
0 on success or -1 in case of an error.

Definition at line 326 of file x12rtc.c.

References BCD2BIN, memset(), RTC_ALARM_HOUR, RTC_ALARM_MDAY, RTC_ALARM_MINUTE, RTC_ALARM_MONTH, RTC_ALARM_SECOND, RTC_ALARM_WDAY, _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, X12RTC_DTA_EDT, X12RTC_DWA_EDW, X12RTC_HRA_EHR, X12RTC_MNA_EMN, X12RTC_MOA_EMO, X12RTC_SCA_ESC, and X12RtcReadRegs().

Here is the call graph for this function:

int X12RtcSetAlarm ( int  idx,
CONST struct _tm tm,
int  aflgs 
)

Set alarm of an X12xx hardware clock.

Deprecated:
New applications must use NutRtcSetAlarm().
Parameters:
idxZero based index. Two alarms are supported.
tmPoints to a structure which contains the date and time information. May be NULL to clear the alarm.
aflgsEach bit enables a specific comparision.
  • Bit 0: Seconds
  • Bit 1: Minutes
  • Bit 2: Hours
  • Bit 3: Day of month
  • Bit 4: Month
  • Bit 7: Day of week (Sunday is zero)
Returns:
0 on success or -1 in case of an error.

Definition at line 380 of file x12rtc.c.

References BIN2BCD, memset(), RTC_ALARM_HOUR, RTC_ALARM_MDAY, RTC_ALARM_MINUTE, RTC_ALARM_MONTH, RTC_ALARM_SECOND, RTC_ALARM_WDAY, X12RTC_DTA_EDT, X12RTC_DWA_EDW, X12RTC_HRA_EHR, X12RTC_MNA_EMN, X12RTC_MOA_EMO, X12RTC_SCA_ESC, and X12RtcWrite().

Here is the call graph for this function:

int X12RtcGetStatus ( uint32_t sflgs)

Query RTC status flags.

Deprecated:
New applications must use NutRtcGetStatus().
Parameters:
sflgsPoints to an unsigned long that receives the status flags.
  • Bit 0: Power fail.
  • Bit 5: Alarm 0 occured.
  • Bit 6: Alarm 1 occured.
Returns:
0 on success or -1 in case of an error.
Examples:
ftpd/ftpserv.c.

Definition at line 421 of file x12rtc.c.

References X12RTC_SR, and X12RtcReadRegs().

Referenced by X12Init().

Here is the call graph for this function:

int X12RtcClearStatus ( uint32_t  sflgs)

Clear RTC status flags.

Deprecated:
New applications must use NutRtcClearStatus().
Parameters:
sflgsStatus flags to clear.
Returns:
Always 0.

Definition at line 442 of file x12rtc.c.

int X12RtcReadRegs ( uint8_t  reg,
uint8_t buff,
size_t  cnt 
)

Read RTC registers.

Parameters:
regThe first register to read.
buffPointer to a buffer that receives the register contents.
cntThe number of registers to read.
Returns:
0 on success or -1 in case of an error.

Definition at line 180 of file x12rtc.c.

References I2C_SLA_RTC, NUT_WAIT_INFINITE, printf, putchar(), and TwMasterTransact().

Referenced by X12Init(), X12RtcGetAlarm(), X12RtcGetClock(), and X12RtcGetStatus().

Here is the call graph for this function:

int X12RtcWrite ( int  nv,
CONST uint8_t buff,
size_t  cnt 
)

Write to RTC registers.

Parameters:
nvMust be set to 1 when writing to non-volatile registers. In this case the routine will poll for write cycle completion before returning to the caller. Set to zero if writing to volatile registers.
buffThis buffer must contain all bytes to be transfered to the RTC chip, including the register address.
cntNumber of valid bytes in the buffer.
Returns:
0 on success or -1 in case of an error.

Definition at line 213 of file x12rtc.c.

References I2C_SLA_RTC, NUT_WAIT_INFINITE, printf, putchar(), and TwMasterTransact().

Referenced by X12RtcSetAlarm(), and X12RtcSetClock().

Here is the call graph for this function:

int X12EepromRead ( unsigned int  addr,
void *  buff,
size_t  len 
)

Read contents from non-volatile EEPROM.

Parameters:
addrStart location.
buffPoints to a buffer that receives the contents.
lenNumber of bytes to read.
Returns:
0 on success or -1 in case of an error.

Definition at line 469 of file x12rtc.c.

References I2C_SLA_EEPROM, NUT_WAIT_INFINITE, and TwMasterTransact().

Referenced by NutNvMemLoad().

Here is the call graph for this function:

int X12EepromWrite ( unsigned int  addr,
CONST void *  buff,
size_t  len 
)

Store buffer contents in non-volatile EEPROM.

The EEPROM of the X122x has a capacity of 512 bytes, while the X1286 is able to store 32 kBytes.

Parameters:
addrStorage start location.
buffPoints to a buffer that contains the bytes to store.
lenNumber of valid bytes in the buffer.
Returns:
0 on success or -1 in case of an error.

Definition at line 494 of file x12rtc.c.

References CONST, EEPROM_PAGE_SIZE, free(), I2C_SLA_EEPROM, malloc(), memcpy(), NUT_WAIT_INFINITE, and TwMasterTransact().

Referenced by NutNvMemSave().

Here is the call graph for this function:


Variable Documentation

Definition at line 449 of file x12rtc.c.