; generated by Component: ARM Compiler 5.04 update 1 (build 49) Tool: ArmCC [5040049]
; commandline ArmCC [--list --split_sections --debug -c --asm --interleave -o.\obj\coretimerlib.o --asm_dir=.\lst\ --list_dir=.\lst\ --depend=.\obj\coretimerlib.d --cpu=Cortex-M0 --apcs=interwork -I..\..\..\..\Library\CMSIS\Include -I..\..\..\..\Library\Device\Nuvoton\NM1120\Include -I..\..\..\..\Library\StdDriver\inc -I.\source -IC:\Keil_v5\ARM\RV31\INC -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\3.20.4\CMSIS\Include -D__MICROLIB --omf_browse=.\obj\coretimerlib.crf source\CoreTimerLib.c]
                          THUMB

                          AREA ||i.CoreTimerLibIsTimerExpired||, CODE, READONLY, ALIGN=2

                  CoreTimerLibIsTimerExpired PROC
;;;228    **************************************************************************************/
;;;229    TBool CoreTimerLibIsTimerExpired(TS_Core_TimerLib_Timer* a_psTimer)
000000  b570              PUSH     {r4-r6,lr}
;;;230    {
000002  4604              MOV      r4,r0
;;;231       TWord wCurrentTickCount;
;;;232       TBool bReturnVal;
;;;233       TWord wTimeElapsedTicks;
;;;234    
;;;235       //Since a stopped timer is _never_ expired, we start with false
;;;236       bReturnVal = FALSE;
000004  2500              MOVS     r5,#0
;;;237    
;;;238       //The timer is only considered expired if the timer is currently running.
;;;239       if (CoreTimerLibIsTimerRunning(a_psTimer))
000006  f7fffffe          BL       CoreTimerLibIsTimerRunning
00000a  2800              CMP      r0,#0
00000c  d018              BEQ      |L1.64|
;;;240       {
;;;241          	//Read the system tick count and store it for calculations later in this function
;;;242          	wCurrentTickCount = CoreTimebaseGetSystemTickCount();
00000e  f7fffffe          BL       CoreTimebaseGetSystemTickCount
;;;243    
;;;244          	//Calculate the amount of time that has elapsed in ticks
;;;245    			if (wCurrentTickCount >= a_psTimer->wStartTime)
000012  6821              LDR      r1,[r4,#0]
000014  4281              CMP      r1,r0
000016  d801              BHI      |L1.28|
;;;246    			{
;;;247    				//We can safely subtract without wrapping
;;;248    				
;;;249    				//Calculate the elapsed time in ticks
;;;250    				wTimeElapsedTicks = (wCurrentTickCount - a_psTimer->wStartTime);
000018  1a41              SUBS     r1,r0,r1
00001a  e002              B        |L1.34|
                  |L1.28|
;;;251    			}
;;;252    			else
;;;253    			{
;;;254    				//We must handle wrapping
;;;255    				
;;;256    				//Calculate the elapsed time in ticks
;;;257    				wTimeElapsedTicks = ((TWord)MAX_TIMER1_PERIOD - a_psTimer->wStartTime) + wCurrentTickCount;
00001c  4a0a              LDR      r2,|L1.72|
00001e  1a51              SUBS     r1,r2,r1
000020  1809              ADDS     r1,r1,r0
                  |L1.34|
;;;258    			}
;;;259    
;;;260    			//We need to change the start time to the current time
;;;261    			//so the  next expiration check counts from the current time
;;;262    			//rather than the original start of the timer.
;;;263    			a_psTimer->wStartTime = wCurrentTickCount;
;;;264    
;;;265          	//If we have some ticks to subtract, attempt to subtract them
;;;266          if (wTimeElapsedTicks >= a_psTimer->sDuration.wTicks)
000022  6020              STR      r0,[r4,#0]
000024  6860              LDR      r0,[r4,#4]
000026  4288              CMP      r0,r1
000028  d808              BHI      |L1.60|
;;;267    		  {
;;;268    				//We do not have enough ticks remaining to subtract from
;;;269    				//We want to get the duration down to 0. If we do that, we
;;;270    				//need to subtract off the number of ticks we just zeroed
;;;271    				//out from the total number of ticks that have expired.
;;;272    				wTimeElapsedTicks = wTimeElapsedTicks - a_psTimer->sDuration.wTicks;
00002a  1a09              SUBS     r1,r1,r0
;;;273    				a_psTimer->sDuration.wTicks = 0;
00002c  2000              MOVS     r0,#0
;;;274    				
;;;275    				//Duration ticks is now at 0, but expired may still have some time left in it
;;;276    				//Check for remaining seconds
;;;277    				if (a_psTimer->sDuration.wSeconds > 0)
00002e  6060              STR      r0,[r4,#4]
000030  68a0              LDR      r0,[r4,#8]
000032  2800              CMP      r0,#0
000034  d006              BEQ      |L1.68|
000036  1e40              SUBS     r0,r0,#1
;;;278    				{
;;;279    					//We have remaining seconds, so we take one second from this
;;;280    					//value and copy it to the millisecond duration
;;;281    					a_psTimer->sDuration.wSeconds--;
;;;282    					a_psTimer->sDuration.wTicks = (TWord)dTimebaseNumTicksPerSec;
000038  60a0              STR      r0,[r4,#8]
00003a  4804              LDR      r0,|L1.76|
                  |L1.60|
;;;283    					
;;;284    					a_psTimer->sDuration.wTicks = a_psTimer->sDuration.wTicks - wTimeElapsedTicks;
;;;285    			  }
;;;286    				else
;;;287    				{
;;;288    					//Both ticks and seconds are at 0 -- the timer is expired,
;;;289    					//so we flag it
;;;290    					bReturnVal = TRUE;
;;;291    				}
;;;292    		  }
;;;293          else
;;;294    		  {
;;;295    				//Else (wTimeElapsedTicks < a_psTimer->wDurationTicks)
;;;296    				//We can subtract the expired time from the duration ticks
;;;297    				a_psTimer->sDuration.wTicks = a_psTimer->sDuration.wTicks - wTimeElapsedTicks;
00003c  1a40              SUBS     r0,r0,r1
00003e  6060              STR      r0,[r4,#4]
                  |L1.64|
;;;298    		  }
;;;299       }
;;;300    
;;;301       //Finally, return the result
;;;302       return(bReturnVal);
000040  4628              MOV      r0,r5
;;;303    }
000042  bd70              POP      {r4-r6,pc}
                  |L1.68|
000044  2501              MOVS     r5,#1                 ;290
000046  e7fb              B        |L1.64|
;;;304    
                          ENDP

                  |L1.72|
                          DCD      0x00ffffff
                  |L1.76|
                          DCD      0x00f42400

                          AREA ||i.CoreTimerLibIsTimerRunning||, CODE, READONLY, ALIGN=2

                  CoreTimerLibIsTimerRunning PROC
;;;179    **************************************************************************************/
;;;180    TBool CoreTimerLibIsTimerRunning(const TS_Core_TimerLib_Timer* a_psTimer)
000000  6840              LDR      r0,[r0,#4]
;;;181    {
;;;182       //Running timers are <= CORE_TIMERLIB_TIMER_STOPPED
;;;183       return(a_psTimer->sDuration.wTicks != (TWord)CORE_TIMERLIB_TIMER_STOPPED);
000002  4903              LDR      r1,|L2.16|
000004  4288              CMP      r0,r1
000006  d001              BEQ      |L2.12|
000008  2001              MOVS     r0,#1
;;;184    }
00000a  4770              BX       lr
                  |L2.12|
00000c  2000              MOVS     r0,#0                 ;183
00000e  4770              BX       lr
;;;185    
                          ENDP

                  |L2.16|
                          DCD      0x00ffffff

                          AREA ||i.CoreTimerLibIsTimerStopped||, CODE, READONLY, ALIGN=2

                  CoreTimerLibIsTimerStopped PROC
;;;200    **************************************************************************************/
;;;201    TBool CoreTimerLibIsTimerStopped(const TS_Core_TimerLib_Timer* a_psTimer)
000000  6840              LDR      r0,[r0,#4]
;;;202    {
;;;203       //Stopped timers are = CORE_TIMERLIB_TIMER_STOPPED
;;;204       return(a_psTimer->sDuration.wTicks == (TWord)CORE_TIMERLIB_TIMER_STOPPED);
000002  4903              LDR      r1,|L3.16|
000004  4288              CMP      r0,r1
000006  d101              BNE      |L3.12|
000008  2001              MOVS     r0,#1
;;;205    }
00000a  4770              BX       lr
                  |L3.12|
00000c  2000              MOVS     r0,#0                 ;204
00000e  4770              BX       lr
;;;206    
                          ENDP

                  |L3.16|
                          DCD      0x00ffffff

                          AREA ||i.CoreTimerLibTimerInit||, CODE, READONLY, ALIGN=2

                  CoreTimerLibTimerInit PROC
;;;63     **************************************************************************************/
;;;64     void CoreTimerLibTimerInit(TS_Core_TimerLib_Timer* a_psTimer)
000000  4901              LDR      r1,|L4.8|
;;;65     {
;;;66     	 //Initialize the timer to stopped by setting the duration times to
;;;67        //the stopped value.
;;;68     	 a_psTimer->sDuration.wSeconds = (TWord)CORE_TIMERLIB_TIMER_STOPPED;
;;;69        a_psTimer->sDuration.wTicks   = (TWord)CORE_TIMERLIB_TIMER_STOPPED;
000002  6081              STR      r1,[r0,#8]
000004  6041              STR      r1,[r0,#4]
;;;70     }
000006  4770              BX       lr
;;;71     
                          ENDP

                  |L4.8|
                          DCD      0x00ffffff

                          AREA ||i.CoreTimerLibTimerStart||, CODE, READONLY, ALIGN=1

                  CoreTimerLibTimerStart PROC
;;;90     **************************************************************************************/
;;;91     void CoreTimerLibTimerStart(TS_Core_TimerLib_Timer* a_psTimer, const TWord a_wDurationSeconds, const TWord a_wDurationMilliseconds)
000000  b570              PUSH     {r4-r6,lr}
;;;92     {
000002  4615              MOV      r5,r2
000004  460e              MOV      r6,r1
000006  4604              MOV      r4,r0
;;;93     	TWord wTemp;
;;;94     	//If the given seconds and milliseconds are out of range, we will just set
;;;95     	//the timer to the maximum value.
;;;96     	//Store the current time ticks as the start time of this timer
;;;97     	a_psTimer->wStartTime = CoreTimebaseGetSystemTickCount();
000008  f7fffffe          BL       CoreTimebaseGetSystemTickCount
;;;98     
;;;99     	//Determine the number of seconds to be specified by the user
;;;100      wTemp = (a_wDurationMilliseconds/(TWord)dTimebaseNumMsPerSec);
00000c  217d              MOVS     r1,#0x7d
00000e  6020              STR      r0,[r4,#0]
000010  00c9              LSLS     r1,r1,#3
000012  4628              MOV      r0,r5
000014  f7fffffe          BL       __aeabi_uidivmod
000018  460d              MOV      r5,r1
00001a  4601              MOV      r1,r0
;;;101    										    
;;;102    	//Store the user specified duration
;;;103    	a_psTimer->sDuration.wSeconds = AddWithoutOverflowUInt16(a_wDurationSeconds, wTemp);
00001c  4630              MOV      r0,r6
00001e  f7fffffe          BL       AddWithoutOverflowUInt16
;;;104    	a_psTimer->sDuration.wTicks   = (a_wDurationMilliseconds % dTimebaseNumMsPerSec) * (TWord)dTimebaseNumTicksPerMs;
000022  60a0              STR      r0,[r4,#8]
000024  207d              MOVS     r0,#0x7d
000026  4629              MOV      r1,r5                 ;103
000028  01c0              LSLS     r0,r0,#7
00002a  4341              MULS     r1,r0,r1
00002c  6061              STR      r1,[r4,#4]
;;;105    }
00002e  bd70              POP      {r4-r6,pc}
;;;106    
                          ENDP


                          AREA ||i.CoreTimerLibTimerStart01||, CODE, READONLY, ALIGN=1

                  CoreTimerLibTimerStart01 PROC
;;;107    //////////////100us
;;;108    void CoreTimerLibTimerStart01(TS_Core_TimerLib_Timer* a_psTimer, const TWord a_wDurationSeconds, const TWord a_wDurationMilliseconds)
000000  b570              PUSH     {r4-r6,lr}
;;;109    {
000002  4615              MOV      r5,r2
000004  460e              MOV      r6,r1
000006  4604              MOV      r4,r0
;;;110    	TWord wTemp;
;;;111    	//If the given seconds and milliseconds are out of range, we will just set
;;;112    	//the timer to the maximum value.
;;;113    	//Store the current time ticks as the start time of this timer
;;;114    	a_psTimer->wStartTime = CoreTimebaseGetSystemTickCount();
000008  f7fffffe          BL       CoreTimebaseGetSystemTickCount
;;;115    
;;;116    	//Determine the number of seconds to be specified by the user
;;;117      wTemp = (a_wDurationMilliseconds/(TWord)dTimebaseNumMsPerSec);
00000c  217d              MOVS     r1,#0x7d
00000e  6020              STR      r0,[r4,#0]
000010  00c9              LSLS     r1,r1,#3
000012  4628              MOV      r0,r5
000014  f7fffffe          BL       __aeabi_uidivmod
000018  460d              MOV      r5,r1
00001a  4601              MOV      r1,r0
;;;118    										    
;;;119    	//Store the user specified duration
;;;120    	a_psTimer->sDuration.wSeconds = AddWithoutOverflowUInt16(a_wDurationSeconds, wTemp);
00001c  4630              MOV      r0,r6
00001e  f7fffffe          BL       AddWithoutOverflowUInt16
;;;121    	a_psTimer->sDuration.wTicks   = (a_wDurationMilliseconds % dTimebaseNumMsPerSec) * (TWord)dTimebaseNumTicksPer100Us;
000022  60a0              STR      r0,[r4,#8]
000024  2019              MOVS     r0,#0x19
000026  4629              MOV      r1,r5                 ;120
000028  0180              LSLS     r0,r0,#6
00002a  4341              MULS     r1,r0,r1
00002c  6061              STR      r1,[r4,#4]
;;;122    }
00002e  bd70              POP      {r4-r6,pc}
;;;123    
                          ENDP


                          AREA ||i.CoreTimerLibTimerStartMeasurement||, CODE, READONLY, ALIGN=2

                  CoreTimerLibTimerStartMeasurement PROC
;;;137    **************************************************************************************/
;;;138    void CoreTimerLibTimerStartMeasurement(TS_Core_TimerLib_Timer* a_psTimer)
000000  b510              PUSH     {r4,lr}
;;;139    {
;;;140       //Simply start a timer with MAX_DURATION_SECONDS time
;;;141       CoreTimerLibTimerStart(a_psTimer, (TWord)dCoreTimerlibMaxDurationSec, (TWord)dCoreTimerlibMzxDurationMS);
000002  227d              MOVS     r2,#0x7d
000004  00d2              LSLS     r2,r2,#3
000006  4902              LDR      r1,|L7.16|
000008  f7fffffe          BL       CoreTimerLibTimerStart
;;;142    }
00000c  bd10              POP      {r4,pc}
;;;143    
                          ENDP

00000e  0000              DCW      0x0000
                  |L7.16|
                          DCD      0x0000ea60

                          AREA ||i.CoreTimerLibTimerStop||, CODE, READONLY, ALIGN=2

                  CoreTimerLibTimerStop PROC
;;;157    **************************************************************************************/
;;;158    void CoreTimerLibTimerStop(TS_Core_TimerLib_Timer* a_psTimer)
000000  4901              LDR      r1,|L8.8|
;;;159    {
;;;160       //To stop a timer, set the durations to the stopped value
;;;161       a_psTimer->sDuration.wSeconds = (TWord)CORE_TIMERLIB_TIMER_STOPPED;
;;;162       a_psTimer->sDuration.wTicks = (TWord)CORE_TIMERLIB_TIMER_STOPPED;
000002  6081              STR      r1,[r0,#8]
000004  6041              STR      r1,[r0,#4]
;;;163    }
000006  4770              BX       lr
;;;164    
                          ENDP

                  |L8.8|
                          DCD      0x00ffffff

;*** Start embedded assembler ***

#line 1 "source\\CoreTimerLib.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___14_CoreTimerLib_c_7e587af0____REV16|
#line 118 "..\\..\\..\\..\\Library\\CMSIS\\Include\\core_cmInstr.h"
|__asm___14_CoreTimerLib_c_7e587af0____REV16| PROC
#line 119

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___14_CoreTimerLib_c_7e587af0____REVSH|
#line 132
|__asm___14_CoreTimerLib_c_7e587af0____REVSH| PROC
#line 133

 revsh r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***
