; generated by ARM C/C++ Compiler, 4.1 [Build 713]
; commandline ArmCC [--list --split_sections --debug -c --asm --interleave -o.\Obj\usb_pwr.o --asm_dir=.\List\ --list_dir=.\List\ --depend=.\Obj\usb_pwr.d --cpu=Cortex-M3 --apcs=interwork -O3 -I.\usb_library\inc -IC:\Keil\ARM\CMSIS\Include -IC:\Keil\ARM\INC\ST\STM32F10x -D__MICROLIB -DVECT_TAB_FLASH --omf_browse=.\Obj\usb_pwr.crf usb_pwr.c]
                          THUMB

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

                  PowerOff PROC
;;;77     *******************************************************************************/
;;;78     RESULT PowerOff()
000000  b510              PUSH     {r4,lr}
;;;79     {
;;;80       /* disable all ints and force USB reset */
;;;81       _SetCNTR(CNTR_FRES);
000002  4c06              LDR      r4,|L1.28|
000004  2001              MOVS     r0,#1
000006  6020              STR      r0,[r4,#0]
;;;82       /* clear interrupt status register */
;;;83       _SetISTR(0);
000008  1d21              ADDS     r1,r4,#4
00000a  2000              MOVS     r0,#0
00000c  6008              STR      r0,[r1,#0]
;;;84       /* Disable the Pull-Up*/
;;;85       USB_Cable_Config(DISABLE);
00000e  f7fffffe          BL       USB_Cable_Config
;;;86       /* switch-off device */
;;;87       _SetCNTR(CNTR_FRES + CNTR_PDWN);
000012  2003              MOVS     r0,#3
000014  6020              STR      r0,[r4,#0]
;;;88       /* sw variables reset */
;;;89       /* ... */
;;;90     
;;;91       return USB_SUCCESS;
000016  2000              MOVS     r0,#0
;;;92     }
000018  bd10              POP      {r4,pc}
;;;93     
                          ENDP

00001a  0000              DCW      0x0000
                  |L1.28|
                          DCD      0x40005c40

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

                  PowerOn PROC
;;;47     *******************************************************************************/
;;;48     RESULT PowerOn(void)
000000  b510              PUSH     {r4,lr}
;;;49     {
;;;50       u16 wRegVal;
;;;51     
;;;52       /*** cable plugged-in ? ***/
;;;53       USB_Cable_Config(ENABLE);
000002  2001              MOVS     r0,#1
000004  f7fffffe          BL       USB_Cable_Config
;;;54     
;;;55       /*** CNTR_PWDN = 0 ***/
;;;56       wRegVal = CNTR_FRES;
;;;57       _SetCNTR(wRegVal);
000008  4806              LDR      r0,|L2.36|
00000a  2101              MOVS     r1,#1                 ;56
00000c  6001              STR      r1,[r0,#0]
;;;58     
;;;59       /*** CNTR_FRES = 0 ***/
;;;60       wInterrupt_Mask = 0;
00000e  2100              MOVS     r1,#0
000010  4a05              LDR      r2,|L2.40|
;;;61       _SetCNTR(wInterrupt_Mask);
000012  6001              STR      r1,[r0,#0]
;;;62       /*** Clear pending interrupts ***/
;;;63       _SetISTR(0);
000014  1d03              ADDS     r3,r0,#4
000016  6019              STR      r1,[r3,#0]
;;;64       /*** Set interrupt mask ***/
;;;65       wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
000018  f44f51e0          MOV      r1,#0x1c00
00001c  8011              STRH     r1,[r2,#0]
;;;66       _SetCNTR(wInterrupt_Mask);
00001e  6001              STR      r1,[r0,#0]
;;;67     
;;;68       return USB_SUCCESS;
000020  2000              MOVS     r0,#0
;;;69     }
000022  bd10              POP      {r4,pc}
;;;70     
                          ENDP

                  |L2.36|
                          DCD      0x40005c40
                  |L2.40|
                          DCD      wInterrupt_Mask

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

                  Resume PROC
;;;171    *******************************************************************************/
;;;172    void Resume(RESUME_STATE eResumeSetVal)
000000  b570              PUSH     {r4-r6,lr}
;;;173    {
;;;174      u16 wCNTR;
;;;175    
;;;176      if (eResumeSetVal != RESUME_ESOF)
;;;177        ResumeS.eState = eResumeSetVal;
000002  4c1c              LDR      r4,|L3.116|
000004  2807              CMP      r0,#7                 ;176
000006  d000              BEQ      |L3.10|
000008  7020              STRB     r0,[r4,#0]
                  |L3.10|
;;;178    
;;;179      switch (ResumeS.eState)
00000a  7821              LDRB     r1,[r4,#0]  ; ResumeS
;;;180      {
;;;181        case RESUME_EXTERNAL:
;;;182          Resume_Init();
;;;183          ResumeS.eState = RESUME_OFF;
00000c  2606              MOVS     r6,#6
;;;184          break;
;;;185        case RESUME_INTERNAL:
;;;186          Resume_Init();
;;;187          ResumeS.eState = RESUME_START;
00000e  2504              MOVS     r5,#4
;;;188          break;
;;;189        case RESUME_LATER:
;;;190          ResumeS.bESOFcnt = 2;
;;;191          ResumeS.eState = RESUME_WAIT;
;;;192          break;
;;;193        case RESUME_WAIT:
;;;194          ResumeS.bESOFcnt--;
;;;195          if (ResumeS.bESOFcnt == 0)
;;;196            ResumeS.eState = RESUME_START;
;;;197          break;
;;;198        case RESUME_START:
;;;199          wCNTR = _GetCNTR();
000010  4819              LDR      r0,|L3.120|
000012  2906              CMP      r1,#6                 ;179
000014  d22c              BCS      |L3.112|
000016  e8dff001          TBB      [pc,r1]               ;179
00001a  0306              DCB      0x03,0x06
00001c  090e1620          DCB      0x09,0x0e,0x16,0x20
000020  f7fffffe          BL       Resume_Init
000024  e024              B        |L3.112|
000026  f7fffffe          BL       Resume_Init
00002a  e00a              B        |L3.66|
00002c  2002              MOVS     r0,#2                 ;190
00002e  7060              STRB     r0,[r4,#1]            ;190
000030  2003              MOVS     r0,#3                 ;191
000032  7020              STRB     r0,[r4,#0]            ;191
                  |L3.52|
;;;200          wCNTR |= CNTR_RESUME;
;;;201          _SetCNTR(wCNTR);
;;;202          ResumeS.eState = RESUME_ON;
;;;203          ResumeS.bESOFcnt = 10;
;;;204          break;
;;;205        case RESUME_ON:
;;;206          ResumeS.bESOFcnt--;
;;;207          if (ResumeS.bESOFcnt == 0)
;;;208          {
;;;209            wCNTR = _GetCNTR();
;;;210            wCNTR &= (~CNTR_RESUME);
;;;211            _SetCNTR(wCNTR);
;;;212            ResumeS.eState = RESUME_OFF;
;;;213          }
;;;214          break;
;;;215        case RESUME_OFF:
;;;216        case RESUME_ESOF:
;;;217        default:
;;;218          ResumeS.eState = RESUME_OFF;
;;;219          break;
;;;220      }
;;;221    }
000034  bd70              POP      {r4-r6,pc}
000036  7860              LDRB     r0,[r4,#1]            ;194  ; ResumeS
000038  1e40              SUBS     r0,r0,#1              ;194
00003a  7060              STRB     r0,[r4,#1]            ;194
00003c  7860              LDRB     r0,[r4,#1]            ;195  ; ResumeS
00003e  2800              CMP      r0,#0                 ;195
000040  d1f8              BNE      |L3.52|
                  |L3.66|
000042  7025              STRB     r5,[r4,#0]            ;196
000044  bd70              POP      {r4-r6,pc}
000046  6801              LDR      r1,[r0,#0]            ;199
000048  b289              UXTH     r1,r1                 ;199
00004a  f0410110          ORR      r1,r1,#0x10           ;200
00004e  6001              STR      r1,[r0,#0]            ;201
000050  2005              MOVS     r0,#5                 ;202
000052  7020              STRB     r0,[r4,#0]            ;202
000054  200a              MOVS     r0,#0xa               ;203
000056  7060              STRB     r0,[r4,#1]            ;203
                  |L3.88|
000058  bd70              POP      {r4-r6,pc}
00005a  7861              LDRB     r1,[r4,#1]            ;206  ; ResumeS
00005c  1e49              SUBS     r1,r1,#1              ;206
00005e  7061              STRB     r1,[r4,#1]            ;206
000060  7861              LDRB     r1,[r4,#1]            ;207  ; ResumeS
000062  2900              CMP      r1,#0                 ;207
000064  d1f8              BNE      |L3.88|
000066  6801              LDR      r1,[r0,#0]            ;209
000068  b289              UXTH     r1,r1                 ;209
00006a  f0210110          BIC      r1,r1,#0x10           ;210
00006e  6001              STR      r1,[r0,#0]            ;211
                  |L3.112|
000070  7026              STRB     r6,[r4,#0]            ;218
000072  bd70              POP      {r4-r6,pc}
;;;222    
                          ENDP

                  |L3.116|
                          DCD      ||area_number.10||
                  |L3.120|
                          DCD      0x40005c40

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

                  Resume_Init PROC
;;;134    *******************************************************************************/
;;;135    void Resume_Init(void)
000000  b510              PUSH     {r4,lr}
;;;136    {
;;;137      u16 wCNTR;
;;;138    
;;;139      /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
;;;140      /* restart the clocks */
;;;141      /* ...  */
;;;142    
;;;143      /* CNTR_LPMODE = 0 */
;;;144      wCNTR = _GetCNTR();
000002  4c06              LDR      r4,|L4.28|
000004  6820              LDR      r0,[r4,#0]
000006  b280              UXTH     r0,r0
;;;145      wCNTR &= (~CNTR_LPMODE);
000008  f0200004          BIC      r0,r0,#4
;;;146      _SetCNTR(wCNTR);
00000c  6020              STR      r0,[r4,#0]
;;;147    
;;;148      /* restore full power */
;;;149      /* ... on connected devices */
;;;150      Leave_LowPowerMode();
00000e  f7fffffe          BL       Leave_LowPowerMode
;;;151    
;;;152      /* reset FSUSP bit */
;;;153      _SetCNTR(IMR_MSK);
000012  f44f403f          MOV      r0,#0xbf00
000016  6020              STR      r0,[r4,#0]
;;;154    
;;;155      /* reverse suspend preparation */
;;;156      /* ... */
;;;157    
;;;158    }
000018  bd10              POP      {r4,pc}
;;;159    
                          ENDP

00001a  0000              DCW      0x0000
                  |L4.28|
                          DCD      0x40005c40

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

                  Suspend PROC
;;;100    *******************************************************************************/
;;;101    void Suspend(void)
000000  4806              LDR      r0,|L5.28|
;;;102    {
;;;103      u16 wCNTR;
;;;104      /* suspend preparation */
;;;105      /* ... */
;;;106    
;;;107      /* macrocell enters suspend mode */
;;;108      wCNTR = _GetCNTR();
000002  6801              LDR      r1,[r0,#0]
000004  b289              UXTH     r1,r1
;;;109      wCNTR |= CNTR_FSUSP;
000006  f0410108          ORR      r1,r1,#8
;;;110      _SetCNTR(wCNTR);
00000a  6001              STR      r1,[r0,#0]
;;;111    
;;;112      /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
;;;113      /* power reduction */
;;;114      /* ... on connected devices */
;;;115    
;;;116    
;;;117      /* force low-power mode in the macrocell */
;;;118      wCNTR = _GetCNTR();
00000c  6801              LDR      r1,[r0,#0]
00000e  b289              UXTH     r1,r1
;;;119      wCNTR |= CNTR_LPMODE;
000010  f0410104          ORR      r1,r1,#4
;;;120      _SetCNTR(wCNTR);
000014  6001              STR      r1,[r0,#0]
;;;121    
;;;122      /* switch-off the clocks */
;;;123      /* ... */
;;;124      Enter_LowPowerMode();
000016  f7ffbffe          B.W      Enter_LowPowerMode
;;;125    
;;;126    }
;;;127    
                          ENDP

00001a  0000              DCW      0x0000
                  |L5.28|
                          DCD      0x40005c40

                          AREA ||.data||, DATA, ALIGN=0

                  bDeviceState
000000  00                DCB      0x00

                          AREA ||area_number.9||, DATA, ALIGN=0

                          EXPORTAS ||area_number.9||, ||.data||
                  fSuspendEnabled
000000  01                DCB      0x01

                          AREA ||area_number.10||, DATA, ALIGN=0

                          EXPORTAS ||area_number.10||, ||.data||
                  ResumeS
000000  0000              DCB      0x00,0x00
