; TASKING TriCore C compiler v1.5r1 Build 322 SN 00090364
; options: -e -A1 -g -O1 -Id:\ctri\include -s -N8 -zTC112_COR1 -zTC112_COR4
;          -zTC112_COR10 -zTC112_COR13 -zTC112_COR14 -zTC112_COR16 -zTC112_COR17
	.name	"rtc"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "rtc.c"
; file "rtc.c":
;    1 |//****************************************************************************
;    2 |// @Module        Real Time Clock (RTC)
;    3 |// @Filename      RTC.C
;    4 |// @Project       eWebDemo.dav
;    5 |//----------------------------------------------------------------------------
;    6 |// @Controller    Infineon TC1775 B-Step
;    7 |//
;    8 |// @Compiler      Tasking
;    9 |//
;   10 |// @Codegenerator 2.2
;   11 |//
;   12 |// @Description   This file contains functions that use the RTC module.
;   13 |//
;   14 |//----------------------------------------------------------------------------
;   15 |// @Date          20.06.2002 14:16:16
;   16 |//
;   17 |//****************************************************************************
;   18 |
;   19 |// USER CODE BEGIN (RTC_General,1)
;   20 |
;   21 |// USER CODE END
;   22 |
;   23 |
;   24 |
;   25 |//****************************************************************************
;   26 |// @Project Includes
;   27 |//****************************************************************************
;   28 |
;   29 |#include "MAIN.H"
	.symb	FILE, "MAIN.H"
	.symb	TYPE, 257, "uword", 'T', #18
	.symb	FILE, "TC1775BRegs.h"
	.symb	ENDF
	.symb	FILE, "GPTU.H"
	.symb	ENDF
	.symb	FILE, "RTC.H"
	.symb	ENDF
	.symb	ENDF
;   30 |
;   31 |// USER CODE BEGIN (RTC_General,2)
;   32 |
;   33 |// USER CODE END
;   34 |
;   35 |
;   36 |//****************************************************************************
;   37 |// @Macros
;   38 |//****************************************************************************
;   39 |
;   40 |// USER CODE BEGIN (RTC_General,3)
;   41 |
;   42 |// USER CODE END
;   43 |
;   44 |
;   45 |//****************************************************************************
;   46 |// @Defines
;   47 |//****************************************************************************
;   48 |
;   49 |// USER CODE BEGIN (RTC_General,4)
;   50 |
;   51 |// USER CODE END
;   52 |
;   53 |
;   54 |//****************************************************************************
;   55 |// @Typedefs
;   56 |//****************************************************************************
;   57 |
;   58 |// USER CODE BEGIN (RTC_General,5)
;   59 |
;   60 |// USER CODE END
;   61 |
;   62 |
;   63 |//****************************************************************************
;   64 |// @Imported Global Variables
;   65 |//****************************************************************************
;   66 |
;   67 |// USER CODE BEGIN (RTC_General,6)
;   68 |
;   69 |// USER CODE END
;   70 |
;   71 |
;   72 |//****************************************************************************
;   73 |// @Global Variables
;   74 |//****************************************************************************
;   75 |
;   76 |// USER CODE BEGIN (RTC_General,7)
;   77 |
;   78 |// USER CODE END
;   79 |
;   80 |
;   81 |//****************************************************************************
;   82 |// @External Prototypes
;   83 |//****************************************************************************
;   84 |
;   85 |// USER CODE BEGIN (RTC_General,8)
;   86 |
;   87 |// USER CODE END
;   88 |
;   89 |
;   90 |//****************************************************************************
;   91 |// @Prototypes Of Local Functions
;   92 |//****************************************************************************
;   93 |
;   94 |// USER CODE BEGIN (RTC_General,9)
;   95 |
;   96 |// USER CODE END
;   97 |
;   98 |
;   99 |//****************************************************************************
;  100 |// @Function      void RTC_vInit(void) 
;  101 |//
;  102 |//----------------------------------------------------------------------------
;  103 |// @Description   This is the initialization function of the RTC function 
;  104 |//                library. It is assumed that the SFRs used by this library 
;  105 |//                are in its reset state. 
;  106 |//
;  107 |//----------------------------------------------------------------------------
;  108 |// @Returnvalue   None
;  109 |//
;  110 |//----------------------------------------------------------------------------
;  111 |// @Parameters    None
;  112 |//
;  113 |//----------------------------------------------------------------------------
;  114 |// @Date          20.06.2002
;  115 |//
;  116 |//****************************************************************************
;  117 |
;  118 |// USER CODE BEGIN (Init,1)
;  119 |
;  120 |// USER CODE END
;  121 |
;  122 |void RTC_vInit(void)
;  123 |{
	.sdecl	"code.rtc",CODE
	.sect	"code.rtc"
	.align	4
	.symb	LINE, 123
	.symb	TYPE, 258, 'g', 0, 1
	.symb	TYPE, 259, 'g', 0, 1
	.symb	TYPE, 260, 'g', 0, 1
	.symb	TYPE, 261, 'g', 0, 1
	.symb	TYPE, 262, 'g', 0, 1
	.symb	TYPE, 263, 'g', 0, 1
	.symb	TYPE, 264, 'g', 0, 1
	.symb	TYPE, 265, 'g', 0, 1
	.symb	TYPE, 266, 'g', 0, 1
	.symb	TYPE, 267, 'g', 0, 1
	.symb	TYPE, 268, 'g', 0, 1
	.symb	TYPE, 269, 'g', 0, 1
	.symb	TYPE, 270, 'g', 0, 1
	.symb	TYPE, 271, 'g', 0, 1
	.symb	TYPE, 272, 'g', 0, 1
	.symb	TYPE, 273, 'g', 0, 1
	.symb	TYPE, 274, 'g', 0, 1
	.symb	TYPE, 275, 'g', 0, 1
	.symb	TYPE, 276, 'g', 0, 1
	.symb	TYPE, 277, 'g', 0, 1
	.symb	TYPE, 278, 'g', 0, 1
	.symb	TYPE, 279, 'g', 0, 1
	.symb	TYPE, 280, 'g', 0, 1
	.symb	TYPE, 281, 'g', 0, 1
	.symb	TYPE, 282, 'g', 0, 1
	.symb	TYPE, 283, 'g', 0, 1
	.symb	TYPE, 284, 'g', 0, 1
	.symb	TYPE, 285, 'g', 0, 1
	.symb	TYPE, 286, 'g', 0, 1
	.symb	TYPE, 287, 'g', 0, 1
	.symb	TYPE, 288, 'g', 0, 1
	.symb	TYPE, 289, 'g', 0, 1
	.symb	TYPE, 290, 'S', 4,\
		 "bit0", #258, 0,\
		 "bit1", #259, 1,\
		 "bit2", #260, 2,\
		 "bit3", #261, 3,\
		 "bit4", #262, 4,\
		 "bit5", #263, 5,\
		 "bit6", #264, 6,\
		 "bit7", #265, 7,\
		 "bit8", #266, 8,\
		 "bit9", #267, 9,\
		 "bit10", #268, 10,\
		 "bit11", #269, 11,\
		 "bit12", #270, 12,\
		 "bit13", #271, 13,\
		 "bit14", #272, 14,\
		 "bit15", #273, 15,\
		 "bit16", #274, 16,\
		 "bit17", #275, 17,\
		 "bit18", #276, 18,\
		 "bit19", #277, 19,\
		 "bit20", #278, 20,\
		 "bit21", #279, 21,\
		 "bit22", #280, 22,\
		 "bit23", #281, 23,\
		 "bit24", #282, 24,\
		 "bit25", #283, 25,\
		 "bit26", #284, 26,\
		 "bit27", #285, 27,\
		 "bit28", #286, 28,\
		 "bit29", #287, 29,\
		 "bit30", #288, 30,\
		 "bit31", #289, 31
	.symb	TYPE, 291, "T_Reg32", 'T', #290
	.symb	TYPE, 292, 'X', 8, #1, 26, 0
	.symb	GFUN, "RTC_vInit", RTC_vInit, #292, 0, 0, 0
	.symb	ALAB, RTC_vInit, #292
RTC_vInit:
	mov16	d15,#-2				; -2
	.symb	SOFF, 0
;  124 |  // USER CODE BEGIN (Init,2)
;  125 |
;  126 |  // USER CODE END
;  127 |
;  128 |  SCU_CON_RTCACCEN  =  1;        // enable access to control bits
	.symb	LINE, 128
	st.t	-268435374,#0,#1
;  129 |
;  130 |  ///  -----------------------------------------------------------------------
;  131 |  ///  Configuration of the Module Clock:
;  132 |  ///  -----------------------------------------------------------------------
;  133 |  ///  - enable the RTC module
;  134 |  ///  - the RTC module is stopped during sleep mode
;  135 |
;  136 |  MAIN_vResetENDINIT();
	.symb	LINE, 136
	ld.w	d4,-268435424
	and16	d4,d15
	callg	MAIN_vWriteWDTCON0
;  137 |  RTC_CLC        =  0x00000000;  // load clock control register
	.symb	LINE, 137
	mov16	d15,#0
	st.w	-268435200,d15
;  138 |  MAIN_vSetENDINIT();
	.symb	LINE, 138
	ld.w	d4,-268435424
	or	d4,d4,#1
	callg	MAIN_vWriteWDTCON0
;  139 |
;  140 |  ///  -----------------------------------------------------------------------
;  141 |  ///  Configuration of the RTC Counter:
;  142 |  ///  -----------------------------------------------------------------------
;  143 |  ///  - RTC OSC frequency is 32,768 kHz
;  144 |  ///  - the input clock is divided by factor 8
;  145 |
;  146 |  while(!RTC_CON_ACCPOS);      // wait until access is possible
	.symb	LINE, 146
_3:
	ld.bu	d15,-268435183
	jz.t	d15:7,_3
;  147 |  RTC_CON        =  0x0002;      // load RTC control register
	.symb	LINE, 147
	mov16	d15,#2
	st.w	-268435184,d15
;  148 |
;  149 |  ///  - overflow period on T14:  1,0000 [s]
;  150 |  ///  - overflow period on CNT0: 1,0000 [min]
;  151 |  ///  - overflow period on CNT1: 1,0000 [h]
;  152 |  ///  - overflow period on CNT2: 1,0000 [days]
;  153 |  ///  - overflow period on CNT3: 1,0000 [years]
;  154 |
;  155 |  RTC_T14        =  0xF000F000;  // load T14 count/reload register
	.symb	LINE, 155
	mov.u	d15,#0xf000
	addih	d15,d15,#0xf000
	st.w	-268435180,d15
;  156 |  RTC_CNT        =  0xA4E813C4;  // load RTC count register
	.symb	LINE, 156
	mov.u	d15,#0x13c4			; -1528294460
	addih	d15,d15,#0xa4e8			; -1528294460
	st.w	-268435176,d15
;  157 |  RTC_REL        =  0xA4E813C4;  // load RTC reload register
	.symb	LINE, 157
	st.w	-268435172,d15
;  158 |
;  159 |  ///  -----------------------------------------------------------------------
;  160 |  ///  Configuration of the used RTC Interrupts:
;  161 |  ///  -----------------------------------------------------------------------
;  162 |  RTC_ISNC       =  0x00000001;  // load RTC interrupt sub node register
	.symb	LINE, 162
	mov16	d15,#1
	st.w	-268435168,d15
;  163 |
;  164 |  RTC_CON_RUN    =  1;           // starts the counter
	.symb	LINE, 164
	st.t	-268435184,#0,#1
;  165 |
;  166 |  // USER CODE BEGIN (Init,3)
;  167 |
;  168 |  // USER CODE END
;  169 |
;  170 |} //  End of function RTC_vInit
	.symb	LINE, 170
	ret16
	.symb	EFUN
;  171 |
;  172 |
;  173 |//****************************************************************************
;  174 |// @Function      void RTC_vRTCRun(void) 
;  175 |//
;  176 |//----------------------------------------------------------------------------
;  177 |// @Description   This function starts the RTC timer.
;  178 |//
;  179 |//----------------------------------------------------------------------------
;  180 |// @Returnvalue   None
;  181 |//
;  182 |//----------------------------------------------------------------------------
;  183 |// @Parameters    None
;  184 |//
;  185 |//----------------------------------------------------------------------------
;  186 |// @Date          20.06.2002
;  187 |//
;  188 |//****************************************************************************
;  189 |
;  190 |// USER CODE BEGIN (RTCRun,1)
;  191 |
;  192 |// USER CODE END
;  193 |
;  194 |void RTC_vRTCRun(void)
;  195 |{
	.symb	LINE, 195
	.symb	TYPE, 293, 'X', 8, #1, 26, 0
	.symb	GFUN, "RTC_vRTCRun", RTC_vRTCRun, #293, 0, 0, 0
	.symb	ALAB, RTC_vRTCRun, #293
RTC_vRTCRun:
	.symb	SOFF, 0
;  196 |
;  197 |  RTC_CON_RUN = 1;
	.symb	LINE, 197
	st.t	-268435184,#0,#1
;  198 |
;  199 |} //  End of function RTC_vRTCRun
	.symb	LINE, 199
	ret16
	.symb	EFUN
;  200 |
;  201 |
;  202 |//****************************************************************************
;  203 |// @Function      uword RTC_uwGetTime(void) 
;  204 |//
;  205 |//----------------------------------------------------------------------------
;  206 |// @Description   This function returns the contents of the RTC timer (CNT).
;  207 |//
;  208 |//----------------------------------------------------------------------------
;  209 |// @Returnvalue   Value of the timer
;  210 |//
;  211 |//----------------------------------------------------------------------------
;  212 |// @Parameters    None
;  213 |//
;  214 |//----------------------------------------------------------------------------
;  215 |// @Date          20.06.2002
;  216 |//
;  217 |//****************************************************************************
;  218 |
;  219 |// USER CODE BEGIN (GetTime,1)
;  220 |
;  221 |// USER CODE END
;  222 |
;  223 |uword RTC_uwGetTime(void)
;  224 |{
	.symb	LINE, 224
	.symb	TYPE, 294, 'X', 8, #18, 26, 0
	.symb	GFUN, "RTC_uwGetTime", RTC_uwGetTime, #294, 0, 0, 0
	.symb	ALAB, RTC_uwGetTime, #294
RTC_uwGetTime:
	.symb	SOFF, 0
;  225 |  return(RTC_CNT);
	.symb	LINE, 225
	ld.w	d2,-268435176
;  226 |
;  227 |} //  End of function RTC_uwGetTime
	.symb	LINE, 227
	ret16
	.symb	EFUN
;  228 |
;  229 |
;  230 |//****************************************************************************
;  231 |// @Function      void RTC_vReset(void) 
;  232 |//
;  233 |//----------------------------------------------------------------------------
;  234 |// @Description   This function loads the RTC timer (CNT) and the reload 
;  235 |//                register (REL) with the value 0x00000000.
;  236 |//
;  237 |//----------------------------------------------------------------------------
;  238 |// @Returnvalue   None
;  239 |//
;  240 |//----------------------------------------------------------------------------
;  241 |// @Parameters    None
;  242 |//
;  243 |//----------------------------------------------------------------------------
;  244 |// @Date          20.06.2002
;  245 |//
;  246 |//****************************************************************************
;  247 |
;  248 |// USER CODE BEGIN (Reset,1)
;  249 |
;  250 |// USER CODE END
;  251 |
;  252 |void RTC_vReset(void)
;  253 |{
	.symb	LINE, 253
	.symb	TYPE, 295, 'X', 8, #1, 26, 0
	.symb	GFUN, "RTC_vReset", RTC_vReset, #295, 0, 0, 0
	.symb	ALAB, RTC_vReset, #295
RTC_vReset:
;  254 |  RTC_CNT = 0x00000000;
	.symb	LINE, 254
	mov16	d15,#0				; 0
	.symb	SOFF, 0
	st.w	-268435176,d15
;  255 |  RTC_REL = 0x00000000;
	.symb	LINE, 255
	st.w	-268435172,d15
;  256 |
;  257 |} //  End of function RTC_vReset
	.symb	LINE, 257
	ret16
	.symb	EFUN
;  258 |
;  259 |
;  260 |
;  261 |
;  262 |// USER CODE BEGIN (RTC_General,10)
;  263 |
;  264 |// USER CODE END
;  265 |
	.symb	ENDF
	.symb	TYPE, 296, 'X', 8, #1, 26, 1, #18
	.symb	ALAB, MAIN_vWriteWDTCON0, #296
	.global	RTC_uwGetTime
	.global	RTC_vInit
	.global	RTC_vRTCRun
	.global	RTC_vReset
	.extern	(CODE) MAIN_vWriteWDTCON0
	.calls	"RTC_vInit", "MAIN_vWriteWDTCON0"
