; TASKING TriCore C compiler v1.5r1 Build 322 SN 00090364
; options: -e -A1 -g -O0 -Id:\ctri\include -s -N8 -zTC112_COR1 -zTC112_COR4
;          -zTC112_COR10 -zTC112_COR13 -zTC112_COR14 -zTC112_COR16 -zTC112_COR17
	.name	"rtcdrv"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "rtcdrv.c"
; file "rtcdrv.c":
;    1 |/* ----- file RTC.C ----- */
;    2 |
;    3 |/* Use it for interfacing the Real-Time Clock (rtc,RTC) */
;    4 |
;    5 |#include "main.h"
	.symb	FILE, "main.h"
	.symb	TYPE, 257, "uword", 'T', #18
	.symb	FILE, "TC1775BRegs.h"
	.symb	ENDF
	.symb	FILE, "IO.H"
	.symb	ENDF
	.symb	FILE, "ASC0.H"
	.symb	TYPE, 258, "ushort", 'T', #5
	.symb	ENDF
	.symb	FILE, "ASC1.H"
	.symb	ENDF
	.symb	FILE, "CAN.H"
	.symb	TYPE, 259, "ubyte", 'T', #3
	.symb	TYPE, 260, 'Z', #3, 7
	.symb	TYPE, 262, 'S', 20,\
		 "usMsgCfg", #5, 0,\
		 "uwID", #18, 2,\
		 "uwMask", #18, 6,\
		 "ubData", #260, 10,\
		 "usCounter", #5, 18
	.symb	TYPE, 263, "TCAN_SWObj", 'T', #262
	.symb	ENDF
	.symb	ENDF
;    6 |#include "i2c_bus.h"
	.symb	FILE, "i2c_bus.h"
	.symb	ENDF
;    7 |
;    8 |// defines
;    9 | #define  SUNDAY      0
;   10 | #define  MONDAY      1
;   11 | #define  TUESDAY     2
;   12 | #define  WEDNESDAY   3
;   13 | #define  THURSDAY    4
;   14 | #define  FRIDAY      5
;   15 | #define  SATURDAY    6
;   16 |
;   17 | #define  RTC_SUCCESSFUL       0x00
;   18 | #define  RTC_NOT_INITIALIZED  0xFD
;   19 | #define  RTC_WRITE_ERROR      0xFE
;   20 | #define  RTC_READ_ERROR       0xFF
;   21 |
;   22 |// prototyp deklarationen
;   23 |BYTE RTCPutRAM(BYTE *SourcePtr, BYTE DeviceID, BYTE DestAddr, WORD Size);
;   24 |BYTE RTCGetRAM(BYTE *DestPtr, BYTE DeviceID, BYTE SourceAddr, WORD Size);
;   25 |
;   26 |// Typ definitionen
;   27 |typedef struct REAL_TIME {
;   28 |    BCD8  WeekDay;                      /* day of week (sun=0 to sat=6)      */
;   29 |    BCD16 Year;                         /* year within century               */
;   30 |    BCD8  Month;
;   31 |    BCD8  Day;                          /* day of month                      */
;   32 |    BCD8  Hour;
;   33 |    BCD8  Minute;
;   34 |    BCD8  Second;
;   35 | } REAL_TIME;
;   36 |
;   37 |typedef struct RTC_REAL_TIME {
;   38 |   BCD8  Second;
;   39 |   BCD8  Minute;
;   40 |   BCD8  Hour;                         /* hour & control                    */
;   41 |   BCD8  Day;
;   42 |   BCD8  WeekDay;
;   43 |   BCD8  MonthCentury;                // Bit 7 = Century-Bit
;   44 |   BCD8  Year;                        // year 0-99 years within an century
;   45 |} RTC_REAL_TIME;
;   46 |
;   47 |
;   48 |
;   49 |typedef struct RTC_ALARM_TIME {
;   50 |   BCD8  Minute;
;   51 |   BCD8  Hour;                         
;   52 |   BCD8  Day;
;   53 |   BCD8  WeekDay;                       
;   54 |} RTC_ALARM_TIME;
;   55 |
;   56 |
;   57 |/****************************************************************************/
;   58 |
;   59 |// Miscellaneous functions                                                  
;   60 |// function to convert a BCD value to integer                               
;   61 |short BCD2INT(BCD16 BCDValue) {
	.sdecl	"code.rtcdrv",CODE
	.sect	"code.rtcdrv"
	.align	4
	.symb	LINE, 61
	.symb	TYPE, 264, 'X', 8, #4, 26, 1, #5
	.symb	GFUN, "BCD2INT", BCD2INT, #264, 0, 16, 0
	.symb	ALAB, BCD2INT, #264
BCD2INT:
	.symb	SOFF, 16
	.symb	LTIM, "BCDValue", 4, 0, 0x8cd
	.symb	IDEN, "BCDValue", 4, #5, 0, 0x80d
	.symb	IDEN, "Result", -12, #4, 131, 0x5
	.symb	LTIM, "BCDValue", 4, 0, 0x84d
	.symb	LTIM, "BCDValue", -16, 131, 0x8c5
	.symb	LTIM, "BCDValue", -16, 131, 0x845
	.symb	LTIM, "BCDValue", 15, 0, 0x8cd
	.symb	LTIM, "BCDValue", 15, 0, 0x84d
	.symb	LTIM, "BCDValue", 7, 0, 0x8cd
	.symb	LTIM, "BCDValue", 7, 0, 0x84d
	.symb	LTIM, "BCDValue", 7, 0, 0x8cd
	.symb	LTIM, "BCDValue", 7, 0, 0x84d
	.symb	LTIM, "BCDValue", 7, 0, 0x8cd
	.symb	LTIM, "BCDValue", 7, 0, 0x84d
	nop
	sub16.a	sp,#16
;   62 |   short   Result;
	.symb	LINE, 62
	st16.h	[sp],d4				; BCDValue
;   63 |
;   64 |   Result = BCDValue & 0x000F;
	.symb	LINE, 64
	ld.hu	d15,[sp]			; BCDValue
	and	d15,d15,#15
	st16.h	[sp]4,d15			; Result
;   65 |   Result += (((BCDValue & 0x00F0) >> 4) * 10);
	.symb	LINE, 65
	ld16.h	d15,[sp]4			; Result
	ld.hu	d7,[sp]				; BCDValue
	and	d7,d7,#240
	sha16	d7,#-4
	mul	d7,d7,#10
	add16	d15,d7				; Result
	st16.h	[sp]4,d15			; Result
;   66 |   Result += (((BCDValue & 0x0F00) >> 8) * 100);
	.symb	LINE, 66
	ld16.h	d15,[sp]4			; Result
	ld.hu	d7,[sp]				; BCDValue
	mov	d6,#3840			; 3840
	and16	d7,d6
	sha16	d7,#-8
	mul	d7,d7,#100
	add16	d15,d7				; Result
	st16.h	[sp]4,d15			; Result
;   67 |   Result += (((BCDValue & 0xF000) >> 12) * 1000);
	.symb	LINE, 67
	ld16.h	d15,[sp]4			; Result
	ld.hu	d7,[sp]				; BCDValue
	mov.u	d6,#61440			; 61440
	and16	d7,d6
	sha	d7,d7,#-12
	mov	d6,#1000			; 1000
	mul16	d7,d6
	add16	d15,d7				; Result
	st16.h	[sp]4,d15			; Result
;   68 |   return(Result);
	.symb	LINE, 68
	ld.h	d2,[sp]4			; Result
;   69 |}
	.symb	LINE, 69
_17:
	ret16
	.symb	EFUN
;   70 |
;   71 |// function to convert a BCD value to integer                               
;   72 |
;   73 |BCD16 INT2BCD(short INTValue) {
	.symb	LINE, 73
	.symb	TYPE, 265, 'X', 8, #5, 26, 1, #4
	.symb	GFUN, "INT2BCD", INT2BCD, #265, 0, 16, 0
	.symb	ALAB, INT2BCD, #265
INT2BCD:
	.symb	SOFF, 16
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	IDEN, "INTValue", 4, #4, 0, 0x80d
	.symb	IDEN, "Result", -12, #5, 131, 0x5
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", -16, 131, 0x8c5
	.symb	LTIM, "INTValue", -16, 131, 0x845
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", -16, 131, 0x8c5
	.symb	LTIM, "INTValue", -16, 131, 0x845
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", -16, 131, 0x8c5
	.symb	LTIM, "INTValue", -16, 131, 0x845
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	LTIM, "INTValue", -16, 131, 0x8c5
	.symb	LTIM, "INTValue", -16, 131, 0x845
	.symb	LTIM, "INTValue", 4, 0, 0x8cd
	nop
	sub16.a	sp,#16
;   74 |   BCD16 Result;
	.symb	LINE, 74
	st16.h	[sp],d4				; INTValue
;   75 |
;   76 |   Result = INTValue % 10;
	.symb	LINE, 76
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	st.h	[sp]4,d3			; Result
;   77 |   INTValue = INTValue / 10;
	.symb	LINE, 77
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	st16.h	[sp],d2				; INTValue
;   78 |   Result |= ((INTValue % 10) << 4);
	.symb	LINE, 78
	ld.hu	d15,[sp]4			; Result
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	sha16	d3,#4
	or16	d15,d3				; Result
	st16.h	[sp]4,d15			; Result
;   79 |   INTValue = INTValue / 10;
	.symb	LINE, 79
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	st16.h	[sp],d2				; INTValue
;   80 |   Result |= ((INTValue % 10) << 8);
	.symb	LINE, 80
	ld.hu	d15,[sp]4			; Result
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	sha	d3,d3,#8
	or16	d15,d3				; Result
	st16.h	[sp]4,d15			; Result
;   81 |   INTValue = INTValue / 10;
	.symb	LINE, 81
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	st16.h	[sp],d2				; INTValue
;   82 |   Result |= ((INTValue % 10) << 12);
	.symb	LINE, 82
	ld.hu	d15,[sp]4			; Result
	ld16.h	d4,[sp]				; INTValue
	mov	d5,#10				; 10
	callg	__rt_sdivmod
	sha	d3,d3,#12
	or16	d15,d3				; Result
	st16.h	[sp]4,d15			; Result
;   83 |   return(Result);
	.symb	LINE, 83
	ld.hu	d2,[sp]4			; Result
;   84 |}
	.symb	LINE, 84
_18:
	ret16
	.symb	LTIM, "INTValue", 4, 0, 0x84d
	.symb	EFUN
;   85 |
;   86 |
;   87 |/****************************************************************************/
;   88 |
;   89 |void RTCInit(void)
;   90 |{
	.symb	LINE, 90
	.symb	TYPE, 266, 'X', 8, #1, 26, 0
	.symb	GFUN, "RTCInit", RTCInit, #266, 0, 0, 0
	.symb	ALAB, RTCInit, #266
RTCInit:
	.symb	SOFF, 0
;   91 |     I2CInit();
	.symb	LINE, 91
	callg	I2CInit
;   92 |}
	.symb	LINE, 92
	ret16
	.symb	EFUN
	.symb	TYPE, 267, "REAL_TIME", 'S', 10,\
		 "WeekDay", #3, 0,\
		 "Year", #5, 2,\
		 "Month", #3, 4,\
		 "Day", #3, 5,\
		 "Hour", #3, 6,\
		 "Minute", #3, 7,\
		 "Second", #3, 8
	.symb	TYPE, 268, "REAL_TIME", 'T', #267
;   93 |
;   94 |/****************************************************************************/
;   95 |
;   96 |BYTE RTCSetTime(REAL_TIME *RealTime, BYTE DeviceID) {
	.symb	LINE, 96
	.symb	TYPE, 269, "RTC_REAL_TIME", 'S', 8,\
		 "Second", #3, 0,\
		 "Minute", #3, 1,\
		 "Hour", #3, 2,\
		 "Day", #3, 3,\
		 "WeekDay", #3, 4,\
		 "MonthCentury", #3, 5,\
		 "Year", #3, 6
	.symb	TYPE, 270, "RTC_REAL_TIME", 'T', #269
	.symb	TYPE, 273, 'P', #267
	.symb	TYPE, 271, 'X', 8, #3, 26, 2, #273, #3
	.symb	GFUN, "RTCSetTime", RTCSetTime, #271, 0, 32, 0
	.symb	ALAB, RTCSetTime, #271
RTCSetTime:
	.symb	SOFF, 32
	.symb	LTIM, "RealTime", 20, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	IDEN, "RealTime", 20, #273, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "Time", -24, #269, 131, 0x5
	.symb	IDEN, "TransferByte", -16, #3, 131, 0x5
	.symb	IDEN, "Result", -12, #3, 131, 0x5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -32, 131, 0x8c5
	.symb	LTIM, "RealTime", 20, 0, 0x84d
	.symb	LTIM, "RealTime", -28, 131, 0x8c5
	.symb	LTIM, "RealTime", -28, 131, 0x845
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	nop
	sub16.a	sp,#32
;   97 |   RTC_REAL_TIME  Time;
;   98 |   BYTE           TransferByte;
;   99 |   BYTE           Result;
	.symb	LINE, 99
	st16.b	[sp],d4				; DeviceID
	st.a	[sp]4,a4			; RealTime
;  100 |
;  101 |   Time.Second        = (*RealTime).Second;
	.symb	LINE, 101
	ld.a	a7,[sp]4			; RealTime
	ld.bu	d15,[a7]8
	st16.b	[sp]8,d15
;  102 |   Time.Minute        = (*RealTime).Minute;
	.symb	LINE, 102
	ld.a	a7,[sp]4			; RealTime
	ld.bu	d15,[a7]7
	st16.b	[sp]9,d15
;  103 |   Time.Hour          = (*RealTime).Hour;
	.symb	LINE, 103
	ld.a	a7,[sp]4			; RealTime
	ld.bu	d15,[a7]6
	st16.b	[sp]10,d15
;  104 |   Time.Day           = (*RealTime).Day;
	.symb	LINE, 104
	ld.a	a7,[sp]4			; RealTime
	ld.bu	d15,[a7]5
	st16.b	[sp]11,d15
;  105 |   Time.WeekDay       = (*RealTime).WeekDay;
	.symb	LINE, 105
	ld.a	a7,[sp]4			; RealTime
	ld16.bu	d15,[a7]
	st16.b	[sp]12,d15
;  106 |   Time.MonthCentury  = (*RealTime).Month;
	.symb	LINE, 106
	ld.a	a7,[sp]4			; RealTime
	ld.bu	d15,[a7]4
	st16.b	[sp]13,d15
;  107 |   if ((*RealTime).Year < INT2BCD(2000))
	.symb	LINE, 107
	ld.a	a7,[sp]4			; RealTime
	ld.hu	d14,[a7]2
	mov	d4,#2000			; 2000
	callg	INT2BCD
	jge	d14,d2,_19
;  108 |      Time.Year = (*RealTime).Year - INT2BCD(1900);
	.symb	LINE, 108
	ld.a	a7,[sp]4			; RealTime
	ld.hu	d14,[a7]2
	mov	d4,#1900			; 1900
	callg	INT2BCD
	sub16	d14,d2
	st.b	[sp]14,d14
	j	_20
_19:
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
;  109 |   else
;  110 |   {
;  111 |      Time.Year = (*RealTime).Year - INT2BCD(2000);   
	.symb	LINE, 111
	nop
	ld.a	a7,[sp]4			; RealTime
	ld.hu	d14,[a7]2
	mov	d4,#2000			; 2000
	callg	INT2BCD
	sub16	d14,d2
	st.b	[sp]14,d14
;  112 |      Time.MonthCentury |= 0x80;
	.symb	LINE, 112
	ld16.bu	d15,[sp]13
	or	d15,d15,#128
	st16.b	[sp]13,d15
;  113 |   }
	.symb	LINE, 113
_20:
	.symb	LTIM, "DeviceID", -32, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  114 |
;  115 |   TransferByte = 0x20;                /* new value for control register to */
	.symb	LINE, 115
	mov16	d15,#32				; TransferByte
	st.b	[sp]16,d15			; TransferByte
;  116 |                                       /* stop RTC & prepare setting of time*/
;  117 |   if ((Result = RTCPutRAM(&TransferByte, DeviceID, 0x00, 1)) !=
;  118 |       RTC_SUCCESSFUL)                 /* write control register to RTC     */
	.symb	LINE, 118
	lea	a4,[sp]16
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	callg	RTCPutRAM
	st.b	[sp]20,d2			; Result
	jeq	d2,#0,_21			; Result
;  119 |      return(Result);
	.symb	LINE, 119
	ld.bu	d2,[sp]20			; Result
	ret16
_21:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  120 |
;  121 |   if ((Result = RTCPutRAM((BYTE*) &Time, DeviceID, 0x02, sizeof(Time))) !=
;  122 |       RTC_SUCCESSFUL)                 /* write time to RTC                 */
	.symb	LINE, 122
	nop
	lea	a4,[sp]8
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#2				; 2
	mov	d6,#8				; 8
	callg	RTCPutRAM
	st.b	[sp]20,d2			; Result
	jeq	d2,#0,_22			; Result
;  123 |      return(Result);
	.symb	LINE, 123
	ld.bu	d2,[sp]20			; Result
	ret16
_22:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  124 |
;  125 |   TransferByte = 0x00;                /* value for alarm control register  */
	.symb	LINE, 125
	mov16	d15,#0				; TransferByte
	st.b	[sp]16,d15			; TransferByte
;  126 |   if ((Result = RTCPutRAM(&TransferByte, DeviceID, 0x01, 1)) !=
;  127 |       RTC_SUCCESSFUL)
	.symb	LINE, 127
	lea	a4,[sp]16
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#1				; 1
	mov16	d6,#1				; 1
	callg	RTCPutRAM
	st.b	[sp]20,d2			; Result
	jeq	d2,#0,_23			; Result
;  128 |                                       /* write alarm control register      */
;  129 |      return(Result);
	.symb	LINE, 129
	ld.bu	d2,[sp]20			; Result
	ret16
_23:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  130 |
;  131 |   TransferByte = 0x00;                /* new value for control register to */
	.symb	LINE, 131
	mov16	d15,#0				; TransferByte
	st.b	[sp]16,d15			; TransferByte
;  132 |                                       /* start RTC & enable alarm          */
;  133 |   if ((Result = RTCPutRAM(&TransferByte, DeviceID, 0x00, 1)) !=
;  134 |       RTC_SUCCESSFUL)
	.symb	LINE, 134
	lea	a4,[sp]16
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	callg	RTCPutRAM
	st.b	[sp]20,d2			; Result
	jeq	d2,#0,_24			; Result
;  135 |                                       /* write control register to RTC     */
;  136 |      return(Result);
	.symb	LINE, 136
	ld.bu	d2,[sp]20			; Result
	ret16
_24:
;  137 |
;  138 |   return(RTC_SUCCESSFUL);             /* successful operation              */
	.symb	LINE, 138
	mov16	d2,#0				; 0
;  139 |}
	.symb	LINE, 139
_28:
	ret16
	.symb	EFUN
;  140 |
;  141 |/****************************************************************************/
;  142 |
;  143 |BYTE RTCGetTime(REAL_TIME *RealTime, BYTE DeviceID) {
	.symb	LINE, 143
	.symb	TYPE, 274, 'X', 8, #3, 26, 2, #273, #3
	.symb	GFUN, "RTCGetTime", RTCGetTime, #274, 0, 32, 0
	.symb	ALAB, RTCGetTime, #274
RTCGetTime:
	.symb	SOFF, 32
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "RealTime", 20, 0, 0x8cd
	.symb	IDEN, "RealTime", 20, #273, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "Time", -24, #269, 131, 0x5
	.symb	IDEN, "TransferByte", -16, #3, 131, 0x5
	.symb	IDEN, "Result", -12, #3, 131, 0x5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -32, 131, 0x8c5
	.symb	LTIM, "RealTime", 20, 0, 0x84d
	.symb	LTIM, "RealTime", -28, 131, 0x8c5
	.symb	LTIM, "DeviceID", -32, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	nop
	sub16.a	sp,#32
;  144 |   RTC_REAL_TIME  Time;
;  145 |   BYTE           TransferByte;
;  146 |   BYTE           Result;
	.symb	LINE, 146
	st16.b	[sp],d4				; DeviceID
	st.a	[sp]4,a4			; RealTime
;  147 |
;  148 |   if ((Result = RTCGetRAM(&TransferByte, DeviceID, 0x00, 1)) !=
;  149 |       RTC_SUCCESSFUL)
	.symb	LINE, 149
	lea	a4,[sp]16
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	callg	RTCGetRAM
	st.b	[sp]20,d2			; Result
	jeq	d2,#0,_29			; Result
;  150 |                                       /* get control register              */
;  151 |      return(Result);
	.symb	LINE, 151
	ld.bu	d2,[sp]20			; Result
	ret16
_29:
;  152 |
;  153 |   if(TransferByte & 0x20)
	.symb	LINE, 153
	nop
	ld.bu	d15,[sp]16			; TransferByte
	and	d15,d15,#32
	jeq	d15,#0,_30
;  154 |      return(RTC_NOT_INITIALIZED);     /* rtc was not initialized !         */
	.symb	LINE, 154
	mov	d2,#253				; 253
	ret16
_30:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  155 |   
;  156 |   if ((RTCGetRAM((BYTE*) &Time, DeviceID, 0x02, sizeof(Time))) !=
;  157 |       RTC_SUCCESSFUL)
	.symb	LINE, 157
	nop
	lea	a4,[sp]8
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#2				; 2
	mov	d6,#8				; 8
	callg	RTCGetRAM
	jeq	d2,#0,_31
;  158 |                                       /* read time from RTC                */
;  159 |      return(Result);
	.symb	LINE, 159
	ld.bu	d2,[sp]20			; Result
	ret16
_31:
	.symb	LTIM, "RealTime", -28, 131, 0x845
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
;  160 |
;  161 |   (*RealTime).WeekDay = Time.WeekDay & 0x07;
	.symb	LINE, 161
	nop
	ld16.bu	d15,[sp]12
	and	d15,d15,#7
	ld.a	a7,[sp]4			; RealTime
	st16.b	[a7],d15			; RealTime
;  162 |   (*RealTime).Month   = Time.MonthCentury & 0x1F;
	.symb	LINE, 162
	ld16.bu	d15,[sp]13
	and	d15,d15,#31
	ld.a	a7,[sp]4			; RealTime
	st.b	[a7]4,d15			; RealTime
;  163 |   if (Time.MonthCentury & 0x80)
	.symb	LINE, 163
	ld16.bu	d15,[sp]13
	and	d15,d15,#128
	jeq	d15,#0,_32
;  164 |      (*RealTime).Year = Time.Year + INT2BCD(2000);
	.symb	LINE, 164
	ld.bu	d14,[sp]14
	mov	d4,#2000			; 2000
	callg	INT2BCD
	add16	d14,d2
	ld.a	a7,[sp]4			; RealTime
	st.h	[a7]2,d14			; RealTime
	j	_33
_32:
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
;  165 |   else
;  166 |      (*RealTime).Year = Time.Year + INT2BCD(1900);
	.symb	LINE, 166
	nop
	ld.bu	d14,[sp]14
	mov	d4,#1900			; 1900
	callg	INT2BCD
	add16	d14,d2
	ld.a	a7,[sp]4			; RealTime
	st.h	[a7]2,d14			; RealTime
_33:
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	LTIM, "RealTime", 23, 0, 0x8cd
;  167 |
;  168 |   (*RealTime).Hour    = Time.Hour   & 0x3F;
	.symb	LINE, 168
	nop
	ld16.bu	d15,[sp]10
	and	d15,d15,#63
	ld.a	a7,[sp]4			; RealTime
	st.b	[a7]6,d15			; RealTime
;  169 |   (*RealTime).Minute  = Time.Minute & 0x7F;
	.symb	LINE, 169
	ld16.bu	d15,[sp]9
	and	d15,d15,#127
	ld.a	a7,[sp]4			; RealTime
	st.b	[a7]7,d15			; RealTime
;  170 |   (*RealTime).Second  = Time.Second & 0x7F;
	.symb	LINE, 170
	ld16.bu	d15,[sp]8
	and	d15,d15,#127
	ld.a	a7,[sp]4			; RealTime
	st.b	[a7]8,d15			; RealTime
;  171 |
;  172 |   return(RTC_SUCCESSFUL);
	.symb	LINE, 172
	mov16	d2,#0				; 0
;  173 |}
	.symb	LINE, 173
_36:
	ret16
	.symb	LTIM, "RealTime", 23, 0, 0x84d
	.symb	EFUN
;  174 |
;  175 |/****************************************************************************/
;  176 |
;  177 |BYTE RTCSetAlarm(REAL_TIME *AlarmTime, BYTE DeviceID) {
	.symb	LINE, 177
	.symb	TYPE, 275, "RTC_ALARM_TIME", 'S', 4,\
		 "Minute", #3, 0,\
		 "Hour", #3, 1,\
		 "Day", #3, 2,\
		 "WeekDay", #3, 3
	.symb	TYPE, 276, "RTC_ALARM_TIME", 'T', #275
	.symb	TYPE, 277, 'X', 8, #3, 26, 2, #273, #3
	.symb	GFUN, "RTCSetAlarm", RTCSetAlarm, #277, 0, 32, 0
	.symb	ALAB, RTCSetAlarm, #277
RTCSetAlarm:
	.symb	SOFF, 32
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 20, 0, 0x8cd
	.symb	IDEN, "AlarmTime", 20, #273, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "Time", -24, #275, 131, 0x5
	.symb	IDEN, "TransferByte", -20, #3, 131, 0x5
	.symb	IDEN, "Result", -16, #3, 131, 0x5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -32, 131, 0x8c5
	.symb	LTIM, "AlarmTime", 20, 0, 0x84d
	.symb	LTIM, "AlarmTime", -28, 131, 0x8c5
	.symb	LTIM, "DeviceID", -32, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	nop
	sub16.a	sp,#32
;  178 |   RTC_ALARM_TIME Time;
;  179 |   BYTE           TransferByte;
;  180 |   BYTE           Result;
	.symb	LINE, 180
	st16.b	[sp],d4				; DeviceID
	st.a	[sp]4,a4			; AlarmTime
;  181 |
;  182 |   if ((Result = RTCGetRAM(&TransferByte, DeviceID, 0x00, 1)) !=
;  183 |       RTC_SUCCESSFUL)
	.symb	LINE, 183
	lea	a4,[sp]12
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	callg	RTCGetRAM
	st.b	[sp]16,d2			; Result
	jeq	d2,#0,_37			; Result
;  184 |      return(Result);
	.symb	LINE, 184
	ld.bu	d2,[sp]16			; Result
	ret16
_37:
;  185 |
;  186 |   if(TransferByte & 0x20)
	.symb	LINE, 186
	nop
	ld16.bu	d15,[sp]12			; TransferByte
	and	d15,d15,#32
	jeq	d15,#0,_38
;  187 |      return(RTC_NOT_INITIALIZED);     /* rtc was not initialized !         */
	.symb	LINE, 187
	mov	d2,#253				; 253
	ret16
_38:
	.symb	LTIM, "AlarmTime", -28, 131, 0x845
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
;  188 |
;  189 |   Time.Minute  = (*AlarmTime).Minute;
	.symb	LINE, 189
	nop
	ld.a	a7,[sp]4			; AlarmTime
	ld.bu	d15,[a7]7
	st16.b	[sp]8,d15
;  190 |   Time.Hour    = (*AlarmTime).Hour;
	.symb	LINE, 190
	ld.a	a7,[sp]4			; AlarmTime
	ld.bu	d15,[a7]6
	st16.b	[sp]9,d15
;  191 |   Time.Day     = (*AlarmTime).Day;   /* Year is ignored by RTC            */
	.symb	LINE, 191
	ld.a	a7,[sp]4			; AlarmTime
	ld.bu	d15,[a7]5
	st16.b	[sp]10,d15
;  192 |   Time.WeekDay = (*AlarmTime).WeekDay;
	.symb	LINE, 192
	ld.a	a7,[sp]4			; AlarmTime
	ld16.bu	d15,[a7]
	st16.b	[sp]11,d15
;  193 |
;  194 |   if ((Result = RTCPutRAM((BYTE*)&Time, DeviceID, 0x09, sizeof(Time))) !=
;  195 |       RTC_SUCCESSFUL)                 /* write alarm time into RTC         */
	.symb	LINE, 195
	lea	a4,[sp]8
	ld16.bu	d4,[sp]				; DeviceID
	mov	d5,#9				; 9
	mov16	d6,#4				; 4
	callg	RTCPutRAM
	st.b	[sp]16,d2			; Result
	jeq	d2,#0,_39			; Result
;  196 |      return(Result);
	.symb	LINE, 196
	ld.bu	d2,[sp]16			; Result
	ret16
_39:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  197 |
;  198 |   TransferByte = 0x00;                /* set alarm control                 */
	.symb	LINE, 198
	mov16	d15,#0				; TransferByte
	st16.b	[sp]12,d15			; TransferByte
;  199 |   if ((Result = RTCPutRAM(&TransferByte, DeviceID, 0x01, 1)) !=
;  200 |       RTC_SUCCESSFUL)                 /* write alarm control to RTC        */
	.symb	LINE, 200
	lea	a4,[sp]12
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#1				; 1
	mov16	d6,#1				; 1
	callg	RTCPutRAM
	st.b	[sp]16,d2			; Result
	jeq	d2,#0,_40			; Result
;  201 |      return(Result);
	.symb	LINE, 201
	ld.bu	d2,[sp]16			; Result
	ret16
_40:
;  202 |
;  203 |   return(RTC_SUCCESSFUL);
	.symb	LINE, 203
	mov16	d2,#0				; 0
;  204 |}
	.symb	LINE, 204
_44:
	ret16
	.symb	EFUN
;  205 |
;  206 |/****************************************************************************/
;  207 |
;  208 |BYTE RTCGetAlarm(REAL_TIME *AlarmTime, BYTE DeviceID) {
	.symb	LINE, 208
	.symb	TYPE, 278, 'X', 8, #3, 26, 2, #273, #3
	.symb	GFUN, "RTCGetAlarm", RTCGetAlarm, #278, 0, 32, 0
	.symb	ALAB, RTCGetAlarm, #278
RTCGetAlarm:
	.symb	SOFF, 32
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 20, 0, 0x8cd
	.symb	IDEN, "AlarmTime", 20, #273, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "Time", -24, #275, 131, 0x5
	.symb	IDEN, "TransferByte", -20, #3, 131, 0x5
	.symb	IDEN, "Result", -16, #3, 131, 0x5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -32, 131, 0x8c5
	.symb	LTIM, "AlarmTime", 20, 0, 0x84d
	.symb	LTIM, "AlarmTime", -28, 131, 0x8c5
	.symb	LTIM, "DeviceID", -32, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	nop
	sub16.a	sp,#32
;  209 |   RTC_ALARM_TIME Time;
;  210 |   BYTE           TransferByte;
;  211 |   BYTE           Result;
	.symb	LINE, 211
	st16.b	[sp],d4				; DeviceID
	st.a	[sp]4,a4			; AlarmTime
;  212 |
;  213 |
;  214 |   if ((Result = RTCGetRAM(&TransferByte, DeviceID, 0x00, 1)) !=
;  215 |       RTC_SUCCESSFUL)
	.symb	LINE, 215
	lea	a4,[sp]12
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	callg	RTCGetRAM
	st.b	[sp]16,d2			; Result
	jeq	d2,#0,_45			; Result
;  216 |                                       /* get control register              */
;  217 |      return(Result);
	.symb	LINE, 217
	ld.bu	d2,[sp]16			; Result
	ret16
_45:
;  218 |
;  219 |   if(TransferByte & 0x20)
	.symb	LINE, 219
	nop
	ld16.bu	d15,[sp]12			; TransferByte
	and	d15,d15,#32
	jeq	d15,#0,_46
;  220 |      return(RTC_NOT_INITIALIZED);     /* rtc was not initialized !         */
	.symb	LINE, 220
	mov	d2,#253				; 253
	ret16
_46:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  221 |   
;  222 |   if ((RTCGetRAM((BYTE*) &Time, DeviceID, 0x09, sizeof(Time))) !=
;  223 |       RTC_SUCCESSFUL)
	.symb	LINE, 223
	nop
	lea	a4,[sp]8
	ld16.bu	d4,[sp]				; DeviceID
	mov	d5,#9				; 9
	mov16	d6,#4				; 4
	callg	RTCGetRAM
	jeq	d2,#0,_47
;  224 |                                       /* read alarm time from RTC          */
;  225 |      return(Result);
	.symb	LINE, 225
	ld.bu	d2,[sp]16			; Result
	ret16
_47:
	.symb	LTIM, "AlarmTime", -28, 131, 0x845
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	LTIM, "AlarmTime", 23, 0, 0x8cd
;  226 |
;  227 |   (*AlarmTime).Minute  = Time.Minute & 0x7F;
	.symb	LINE, 227
	nop
	ld16.bu	d15,[sp]8
	and	d15,d15,#127
	ld.a	a7,[sp]4			; AlarmTime
	st.b	[a7]7,d15			; AlarmTime
;  228 |   (*AlarmTime).Hour    = Time.Hour & 0x3F;
	.symb	LINE, 228
	ld16.bu	d15,[sp]9
	and	d15,d15,#63
	ld.a	a7,[sp]4			; AlarmTime
	st.b	[a7]6,d15			; AlarmTime
;  229 |   (*AlarmTime).Day     = Time.Day & 0x3F;
	.symb	LINE, 229
	ld16.bu	d15,[sp]10
	and	d15,d15,#63
	ld.a	a7,[sp]4			; AlarmTime
	st.b	[a7]5,d15			; AlarmTime
;  230 |   (*AlarmTime).WeekDay = Time.WeekDay & 0x07;
	.symb	LINE, 230
	ld16.bu	d15,[sp]11
	and	d15,d15,#7
	ld.a	a7,[sp]4			; AlarmTime
	st16.b	[a7],d15			; AlarmTime
;  231 |
;  232 |   return(RTC_SUCCESSFUL);
	.symb	LINE, 232
	mov16	d2,#0				; 0
;  233 |}
	.symb	LINE, 233
_50:
	ret16
	.symb	LTIM, "AlarmTime", 23, 0, 0x84d
	.symb	EFUN
;  234 |
;  235 |/****************************************************************************/
;  236 |
;  237 |BYTE RTCGetAlarmStatus(BYTE *AlarmStatus, BYTE DeviceID) {
	.symb	LINE, 237
	.symb	TYPE, 281, 'P', #3
	.symb	TYPE, 279, 'X', 8, #3, 26, 2, #281, #3
	.symb	GFUN, "RTCGetAlarmStatus", RTCGetAlarmStatus, #279, 0, 16, 0
	.symb	ALAB, RTCGetAlarmStatus, #279
RTCGetAlarmStatus:
	.symb	SOFF, 16
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "AlarmStatus", 20, 0, 0x8cd
	.symb	IDEN, "AlarmStatus", 20, #281, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "TransferByte", -8, #3, 131, 0x5
	.symb	IDEN, "Result", -4, #3, 131, 0x5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -16, 131, 0x8c5
	.symb	LTIM, "AlarmStatus", 20, 0, 0x84d
	.symb	LTIM, "AlarmStatus", -12, 131, 0x8c5
	.symb	LTIM, "DeviceID", -16, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	nop
	sub16.a	sp,#16
;  238 |   BYTE        TransferByte;           /* state of control-register in RTC  */
;  239 |   BYTE        Result;
	.symb	LINE, 239
	st16.b	[sp],d4				; DeviceID
	st.a	[sp]4,a4			; AlarmStatus
;  240 |
;  241 |
;  242 |
;  243 |   if ((Result = RTCGetRAM(&TransferByte, DeviceID, 0x00, 1)) !=
;  244 |       RTC_SUCCESSFUL)
	.symb	LINE, 244
	lea	a4,[sp]8
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	callg	RTCGetRAM
	st.b	[sp]12,d2			; Result
	jeq	d2,#0,_51			; Result
;  245 |                                       /* read control register from RTC    */
;  246 |      return(Result);
	.symb	LINE, 246
	ld.bu	d2,[sp]12			; Result
	ret16
_51:
;  247 |
;  248 |   if(TransferByte & 0x20)
	.symb	LINE, 248
	nop
	ld16.bu	d15,[sp]8			; TransferByte
	and	d15,d15,#32
	jeq	d15,#0,_52
;  249 |      return(RTC_NOT_INITIALIZED);     /* rtc was not initialized !         */
	.symb	LINE, 249
	mov	d2,#253				; 253
	ret16
_52:
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
;  250 |
;  251 |   if ((Result = RTCGetRAM(&TransferByte, DeviceID, 0x01, 1)) !=
;  252 |       RTC_SUCCESSFUL)
	.symb	LINE, 252
	nop
	lea	a4,[sp]8
	ld16.bu	d4,[sp]				; DeviceID
	mov16	d5,#1				; 1
	mov16	d6,#1				; 1
	callg	RTCGetRAM
	st.b	[sp]12,d2			; Result
	jeq	d2,#0,_53			; Result
;  253 |                                       /* read control register from RTC    */
;  254 |      return(Result);
	.symb	LINE, 254
	ld.bu	d2,[sp]12			; Result
	ret16
_53:
	.symb	LTIM, "AlarmStatus", -12, 131, 0x845
	.symb	LTIM, "AlarmStatus", 23, 0, 0x8cd
;  255 |
;  256 |   if(!(TransferByte & 0x08))          /* return state of alarm flag        */
	.symb	LINE, 256
	nop
	ld16.bu	d15,[sp]8			; TransferByte
	and	d15,d15,#8
	jne	d15,#0,_54
;  257 |      *AlarmStatus = 0x00;
	.symb	LINE, 257
	ld.a	a7,[sp]4			; AlarmStatus
	mov16	d15,#0				; 0
	st16.b	[a7],d15			; AlarmStatus
	j	_55
_54:
	.symb	LTIM, "AlarmStatus", 23, 0, 0x84d
	.symb	LTIM, "AlarmStatus", 23, 0, 0x8cd
;  258 |   else 
;  259 |      *AlarmStatus = 0x01;
	.symb	LINE, 259
	nop
	ld.a	a7,[sp]4			; AlarmStatus
	mov16	d15,#1				; 1
	st16.b	[a7],d15			; AlarmStatus
_55:
;  260 |
;  261 |   return(RTC_SUCCESSFUL);
	.symb	LINE, 261
	mov16	d2,#0				; 0
;  262 |}
	.symb	LINE, 262
_58:
	ret16
	.symb	LTIM, "AlarmStatus", 23, 0, 0x84d
	.symb	EFUN
;  263 |
;  264 |/****************************************************************************/
;  265 |
;  266 |BYTE RTCPutRAM(BYTE *SourcePtr, BYTE DeviceID, BYTE DestAddr, WORD Size)
;  267 |{
	.symb	LINE, 267
	.symb	TYPE, 282, 'X', 8, #3, 26, 4, #281, #3, #3, #5
	.symb	GFUN, "RTCPutRAM", RTCPutRAM, #282, 0, 32, 0
	.symb	ALAB, RTCPutRAM, #282
RTCPutRAM:
	.symb	SOFF, 32
	.symb	LTIM, "SourcePtr", 20, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DestAddr", 5, 0, 0x8cd
	.symb	LTIM, "Size", 6, 0, 0x8cd
	.symb	IDEN, "SourcePtr", 20, #281, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "DestAddr", 5, #3, 0, 0x80d
	.symb	IDEN, "Size", 6, #5, 0, 0x80d
	.symb	IDEN, "i", -16, #3, 131, 0x5
	.symb	LTIM, "Size", 6, 0, 0x84d
	.symb	LTIM, "Size", -32, 131, 0x8c5
	.symb	LTIM, "DestAddr", 5, 0, 0x84d
	.symb	LTIM, "DestAddr", -28, 131, 0x8c5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -24, 131, 0x8c5
	.symb	LTIM, "SourcePtr", 20, 0, 0x84d
	.symb	LTIM, "SourcePtr", -20, 131, 0x8c5
	nop
	sub16.a	sp,#32
;  268 |
;  269 |    BYTE  i;
	.symb	LINE, 269
	st16.h	[sp],d6				; Size
	st.b	[sp]4,d5			; DestAddr
	st.b	[sp]8,d4			; DeviceID
	st.a	[sp]12,a4			; SourcePtr
;  270 |
;  271 |    for ( i=0; i<Size; i++ )
	.symb	LINE, 271
	mov16	d15,#0				; i
	st.b	[sp]16,d15			; i
	j	_61
_59:
	.symb	LTIM, "SourcePtr", -20, 131, 0x845
	.symb	LTIM, "SourcePtr", 20, 0, 0x8cd
	.symb	LTIM, "DeviceID", -24, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "DestAddr", -28, 131, 0x845
	.symb	LTIM, "DestAddr", 5, 0, 0x8cd
	.symb	LTIM, "DestAddr", 5, 0, 0x84d
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "SourcePtr", 20, 0, 0x84d
;  272 |    {
;  273 |        if (I2CWrite( SourcePtr, DeviceID, (WORD)DestAddr, 0x0001, ADDR_8BIT )
;  274 |           != I2C_SUCCESSFUL)
	.symb	LINE, 274
	nop
	ld.a	a4,[sp]12			; SourcePtr
	ld.bu	d4,[sp]8			; DeviceID
	ld.bu	d5,[sp]4			; DestAddr
	mov16	d6,#1				; 1
	mov16	d7,#0				; 0
	callg	I2CWrite
	jeq	d2,#0,_60
;  275 |           return (RTC_WRITE_ERROR);
	.symb	LINE, 275
	mov	d2,#254				; 254
	ret16
_60:
	.symb	LTIM, "DestAddr", 15, 0, 0x8cd
	.symb	LTIM, "DestAddr", 15, 0, 0x84d
	.symb	LTIM, "DestAddr", -28, 131, 0x8c5
	.symb	LTIM, "SourcePtr", 23, 0, 0x8cd
	.symb	LTIM, "SourcePtr", 23, 0, 0x84d
	.symb	LTIM, "SourcePtr", 23, 0, 0x8cd
	.symb	LTIM, "SourcePtr", 23, 0, 0x84d
	.symb	LTIM, "SourcePtr", -20, 131, 0x8c5
;  276 |        DestAddr++;
	.symb	LINE, 276
	nop
	ld16.bu	d15,[sp]4			; DestAddr
	add16	d15,#1				; DestAddr
	st16.b	[sp]4,d15			; DestAddr
;  277 |        SourcePtr++;	
	.symb	LINE, 277
	ld.a	a7,[sp]12			; SourcePtr
	add16.a	a7,#1				; SourcePtr
	st.a	[sp]12,a7			; SourcePtr
	.symb	LINE, 271
	ld.bu	d15,[sp]16			; i
	add16	d15,#1				; i
	st.b	[sp]16,d15			; i
_61:
	.symb	LTIM, "Size", -32, 131, 0x845
	.symb	LTIM, "Size", 7, 0, 0x8cd
	nop
	ld.bu	d15,[sp]16			; i
	ld.hu	d7,[sp]				; Size
	jlt	d15,d7,_59
;  278 |    }
;  279 |  
;  280 |  return (RTC_SUCCESSFUL);
	.symb	LINE, 280
	mov16	d2,#0				; 0
;  281 |
;  282 |}
	.symb	LINE, 282
_62:
	ret16
	.symb	LTIM, "Size", 7, 0, 0x84d
	.symb	LTIM, "SourcePtr", -20, 131, 0x845
	.symb	LTIM, "DestAddr", -28, 131, 0x845
	.symb	EFUN
;  283 |
;  284 |/****************************************************************************/
;  285 |
;  286 |BYTE RTCGetRAM(BYTE *DestPtr, BYTE DeviceID, BYTE SourceAddr, WORD Size)
;  287 |{
	.symb	LINE, 287
	.symb	TYPE, 283, 'X', 8, #3, 26, 4, #281, #3, #3, #5
	.symb	GFUN, "RTCGetRAM", RTCGetRAM, #283, 0, 32, 0
	.symb	ALAB, RTCGetRAM, #283
RTCGetRAM:
	.symb	SOFF, 32
	.symb	LTIM, "DestPtr", 20, 0, 0x8cd
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "SourceAddr", 5, 0, 0x8cd
	.symb	LTIM, "Size", 6, 0, 0x8cd
	.symb	IDEN, "DestPtr", 20, #281, 0, 0x80d
	.symb	IDEN, "DeviceID", 4, #3, 0, 0x80d
	.symb	IDEN, "SourceAddr", 5, #3, 0, 0x80d
	.symb	IDEN, "Size", 6, #5, 0, 0x80d
	.symb	IDEN, "i", -16, #3, 131, 0x5
	.symb	LTIM, "Size", 6, 0, 0x84d
	.symb	LTIM, "Size", -32, 131, 0x8c5
	.symb	LTIM, "SourceAddr", 5, 0, 0x84d
	.symb	LTIM, "SourceAddr", -28, 131, 0x8c5
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DeviceID", -24, 131, 0x8c5
	.symb	LTIM, "DestPtr", 20, 0, 0x84d
	.symb	LTIM, "DestPtr", -20, 131, 0x8c5
	nop
	sub16.a	sp,#32
;  288 |     BYTE	i;
	.symb	LINE, 288
	st16.h	[sp],d6				; Size
	st.b	[sp]4,d5			; SourceAddr
	st.b	[sp]8,d4			; DeviceID
	st.a	[sp]12,a4			; DestPtr
;  289 |
;  290 |     for ( i=0; i<Size; i++ )
	.symb	LINE, 290
	mov16	d15,#0				; i
	st.b	[sp]16,d15			; i
	j	_65
_63:
	.symb	LTIM, "DestPtr", -20, 131, 0x845
	.symb	LTIM, "DestPtr", 20, 0, 0x8cd
	.symb	LTIM, "DeviceID", -24, 131, 0x845
	.symb	LTIM, "DeviceID", 4, 0, 0x8cd
	.symb	LTIM, "SourceAddr", -28, 131, 0x845
	.symb	LTIM, "SourceAddr", 5, 0, 0x8cd
	.symb	LTIM, "SourceAddr", 5, 0, 0x84d
	.symb	LTIM, "DeviceID", 4, 0, 0x84d
	.symb	LTIM, "DestPtr", 20, 0, 0x84d
;  291 |     {
;  292 |         if (I2CRead( DestPtr, DeviceID, (WORD)SourceAddr, (WORD)0x0001, ADDR_8BIT )
;  293 |            != I2C_SUCCESSFUL)
	.symb	LINE, 293
	nop
	ld.a	a4,[sp]12			; DestPtr
	ld.bu	d4,[sp]8			; DeviceID
	ld.bu	d5,[sp]4			; SourceAddr
	mov16	d6,#1				; 1
	mov16	d7,#0				; 0
	callg	I2CRead
	jeq	d2,#0,_64
;  294 |            return (RTC_READ_ERROR);
	.symb	LINE, 294
	mov	d2,#255				; 255
	ret16
_64:
	.symb	LTIM, "DestPtr", 23, 0, 0x8cd
	.symb	LTIM, "DestPtr", 23, 0, 0x84d
	.symb	LTIM, "DestPtr", 23, 0, 0x8cd
	.symb	LTIM, "DestPtr", 23, 0, 0x84d
	.symb	LTIM, "DestPtr", -20, 131, 0x8c5
	.symb	LTIM, "SourceAddr", 15, 0, 0x8cd
	.symb	LTIM, "SourceAddr", 15, 0, 0x84d
	.symb	LTIM, "SourceAddr", -28, 131, 0x8c5
;  295 |         DestPtr++;
	.symb	LINE, 295
	nop
	ld.a	a7,[sp]12			; DestPtr
	add16.a	a7,#1				; DestPtr
	st.a	[sp]12,a7			; DestPtr
;  296 |         SourceAddr++;
	.symb	LINE, 296
	ld16.bu	d15,[sp]4			; SourceAddr
	add16	d15,#1				; SourceAddr
	st16.b	[sp]4,d15			; SourceAddr
	.symb	LINE, 290
	ld.bu	d15,[sp]16			; i
	add16	d15,#1				; i
	st.b	[sp]16,d15			; i
_65:
	.symb	LTIM, "Size", -32, 131, 0x845
	.symb	LTIM, "Size", 7, 0, 0x8cd
	nop
	ld.bu	d15,[sp]16			; i
	ld.hu	d7,[sp]				; Size
	jlt	d15,d7,_63
;  297 |    }
;  298 |
;  299 |   return(RTC_SUCCESSFUL);
	.symb	LINE, 299
	mov16	d2,#0				; 0
;  300 |}
	.symb	LINE, 300
_66:
	ret16
	.symb	LTIM, "Size", 7, 0, 0x84d
	.symb	LTIM, "SourceAddr", -28, 131, 0x845
	.symb	LTIM, "DestPtr", -20, 131, 0x845
	.symb	EFUN
;  301 |
;  302 |/****************************************************************************/
;  303 |
;  304 |/* ----- end RTC.C ----- */
	.symb	ENDF
	.symb	TYPE, 284, 'X', 8, #3, 26, 5, #281, #3, #5, #5, #3
	.symb	ALAB, I2CRead, #284
	.symb	TYPE, 285, 'X', 8, #3, 26, 5, #281, #3, #5, #5, #3
	.symb	ALAB, I2CWrite, #285
	.symb	TYPE, 286, 'X', 8, #1, 26, 0
	.symb	ALAB, I2CInit, #286
	.global	BCD2INT
	.global	INT2BCD
	.global	RTCGetAlarm
	.global	RTCGetAlarmStatus
	.global	RTCGetRAM
	.global	RTCGetTime
	.global	RTCInit
	.global	RTCPutRAM
	.global	RTCSetAlarm
	.global	RTCSetTime
	.extern	(CODE) I2CInit
	.extern	(CODE) I2CRead
	.extern	(CODE) I2CWrite
	.extern	(CODE) __rt_sdivmod
	.calls	"RTCGetAlarm", "RTCGetRAM"
	.calls	"RTCGetAlarmStatus", "RTCGetRAM"
	.calls	"RTCGetRAM", "I2CRead"
	.calls	"RTCGetTime", "INT2BCD"
	.calls	"RTCGetTime", "RTCGetRAM"
	.calls	"RTCInit", "I2CInit"
	.calls	"RTCPutRAM", "I2CWrite"
	.calls	"RTCSetAlarm", "RTCGetRAM"
	.calls	"RTCSetAlarm", "RTCPutRAM"
	.calls	"RTCSetTime", "INT2BCD"
	.calls	"RTCSetTime", "RTCPutRAM"
