///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR ANSI C/C++ Compiler V6.30.1.53127/W32 for ARM    08/Mar/2012  18:18:22 /
// Copyright 1999-2011 IAR Systems AB.                                        /
//                                                                            /
//    Cpu mode     =  thumb                                                   /
//    Endian       =  little                                                  /
//    Source file  =  D:\Profiles\b01252\My Documents\Freescale\P0\software\s /
//                    ample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_ /
//                    sc\src\drivers\pmc\pmc.c                                /
//    Command line =  "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\src\drivers\pmc\pmc.c" -D IAR -D TOWER -D           /
//                    TWR_K20D50M -lCN "D:\Profiles\b01252\My                 /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\FLASH_128KB_PFLASH\List\" -lB         /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\FLASH_128KB_PFLASH\List\" /
//                     -o "D:\Profiles\b01252\My                              /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\FLASH_128KB_PFLASH\Obj\" --no_cse     /
//                    --no_unroll --no_inline --no_code_motion --no_tbaa      /
//                    --no_clustering --no_scheduling --debug                 /
//                    --endian=little --cpu=Cortex-M4 -e --fpu=None           /
//                    --dlib_config "C:\Program Files\IAR Systems\Embedded    /
//                    Workbench 6.0_5\arm\INC\c\DLib_Config_Normal.h" -I      /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\common\" -I  /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\cpu\" -I     /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\cpu\headers\ /
//                    " -I "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\drivers\uart\" -I        /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\drivers\mcg\ /
//                    " -I "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\drivers\wdog\" -I        /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\drivers\rcm\ /
//                    " -I "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\drivers\lptmr\" -I       /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\platforms\"  /
//                    -I "D:\Profiles\b01252\My Documents\Freescale\P0\softwa /
//                    re\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50 /
//                    MHz_sc\build\iar\TWRK20D50M_Demo\..\" -I                /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\projects\TWR /
//                    K20D50M_Demo\" -I "D:\Profiles\b01252\My                /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \dma\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \adc16\" -I "D:\Profiles\b01252\My                      /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \i2c\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \tsi\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \adc_test\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \angle_calculation\" -I "D:\Profiles\b01252\My          /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \buzzer\" -I "D:\Profiles\b01252\My                     /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \fft_test\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \irda_test\" -I "D:\Profiles\b01252\My                  /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \cmt_test\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \protocol\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \task_mgr\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \TWRK20_specific\" -I "D:\Profiles\b01252\My            /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \rtc\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\CMSIS\DSP_Lib\Lib\interm /
//                    ediateFiles\" -I "D:\Profiles\b01252\My                 /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\CMSIS\DSP_Lib\Include\"  /
//                    -I "D:\Profiles\b01252\My Documents\Freescale\P0\softwa /
//                    re\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50 /
//                    MHz_sc\build\iar\TWRK20D50M_Demo\..\..\..\src\CMSIS\CM4 /
//                    \DeviceSupport\ARM\ARMCM4\" -I "D:\Profiles\b01252\My   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\CMSIS\CM4\CoreSupport\"  /
//                    -I "D:\Profiles\b01252\My Documents\Freescale\P0\softwa /
//                    re\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50 /
//                    MHz_sc\build\iar\TWRK20D50M_Demo\..\..\..\src\CMSIS\CM4 /
//                    \CoreSupportLiker Options-Library\" -I                  /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\CMSIS\DSP_Li /
//                    b\Lib\intermediateFiles\arm_cortexM4_math.lib\" -I      /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\build\" -Ol      /
//                    --use_c++_inline -I "C:\Program Files\IAR               /
//                    Systems\Embedded Workbench 6.0_5\arm\CMSIS\Include\"    /
//                    -D ARM_MATH_CM4                                         /
//    List file    =  D:\Profiles\b01252\My Documents\Freescale\P0\software\s /
//                    ample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_ /
//                    sc\build\iar\TWRK20D50M_Demo\FLASH_128KB_PFLASH\List\pm /
//                    c.s                                                     /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME pmc

        #define SHT_PROGBITS 0x1

        EXTERN printf

        PUBLIC LVD_Init
        PUBLIC LVD_Initalize
        PUBLIC i
        PUBLIC pmc_lvd_isr

// D:\Profiles\b01252\My Documents\Freescale\P0\software\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\src\drivers\pmc\pmc.c
//    1 /*
//    2  * File:        pmc.c
//    3  * Purpose:     Provides routines for entering low power modes.
//    4  *
//    5  * Notes:	Since the wakeup mechanism for low power modes
//    6  *              will be application specific, these routines
//    7  *              do not include code to setup interrupts to exit
//    8  *              from the low power modes. The desired means of
//    9  *              low power mode exit should be configured before
//   10  *              calling any of these functions.
//   11  *
//   12  *              These routines do not include protection to
//   13  *              prevent illegal state transitions in the mode
//   14  *              controller, and all routines that write to the
//   15  *              PMPROT register write a value to allow all
//   16  *              possible low power modes (it is write once, so
//   17  *              if only the currently requested mode is enabled
//   18  *              a different mode couldn't be enabled later on).
//   19  *              
//   20  */
//   21 
//   22 #include "common.h"
//   23 #include "pmc.h"
//   24 #include "mcg.h"
//   25 #include "uart.h"

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
//   26 int i;
i:
        DS8 4
//   27 
//   28 //******************************************************************************

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   29 void LVD_Initalize(unsigned char lvd_select, 
//   30                    unsigned char lvd_reset_enable,
//   31                    unsigned char lvd_int_enable, 
//   32                    unsigned char lvw_select,
//   33                    unsigned char lvw_int_enable){
LVD_Initalize:
        PUSH     {R4}
        LDR      R4,[SP, #+4]
//   34     PMC_LVDSC1 =  PMC_LVDSC1_LVDACK_MASK | 
//   35                  (lvd_reset_enable) |   //enable LVD Reset ?
//   36 	          lvd_int_enable |      //LVD Interrupt ?
//   37 	          PMC_LVDSC1_LVDV(lvd_select)   ;        //select high or low LVD
        ORRS     R1,R2,R1
        ANDS     R0,R0,#0x3
        ORRS     R0,R0,R1
        ORRS     R0,R0,#0x40
        LDR.N    R1,??DataTable2  ;; 0x4007d000
        STRB     R0,[R1, #+0]
//   38     PMC_LVDSC2  = PMC_LVDSC2_LVWACK_MASK | 
//   39                  (lvw_int_enable) |    //LVW interrupt?
//   40                   PMC_LVDSC2_LVWV(lvw_select);  // select LVW level 1,2,3 or 4
        ANDS     R0,R3,#0x3
        ORRS     R0,R0,R4
        ORRS     R0,R0,#0x40
        LDR.N    R1,??DataTable2_1  ;; 0x4007d001
        STRB     R0,[R1, #+0]
//   41 }                  
        POP      {R4}
        BX       LR               ;; return
//   42 //******************************************************************************
//   43 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   44 void LVD_Init(void)
//   45 {
//   46 /* setup LVD
//   47 Low-Voltage Detect Voltage Select
//   48 Selects the LVD trip point voltage (VLVD).
//   49 00 Low trip point selected (VLVD = VLVDL)
//   50 01 High trip point selected (VLVD = VLVDH)
//   51 10 Reserved
//   52 11 Reserved
//   53   */
//   54 //	PMC_LVDSC1 &= ~PMC_LVDSC1_LVDRE_MASK ;   //Disable LVD Reset
//   55 	PMC_LVDSC1 =  PMC_LVDSC1_LVDRE_MASK |   //enable LVD Reset
//   56 	             //  PMC_LVDSC1_LVDIE_MASK |
//   57 	               PMC_LVDSC1_LVDV(1);   //Enable LVD Reset High level
LVD_Init:
        LDR.N    R0,??DataTable2  ;; 0x4007d000
        MOVS     R1,#+17
        STRB     R1,[R0, #+0]
//   58 
//   59 //PMC_LVDSC1 |= PMC_LVDSC1_LVDV_MASK & 0x01;  
//   60 // PMC_LVDSC1 &= PMC_LVDSC1_LVDV_MASK & 0b00;  //Low Trip point 1.54 V
//   61  
//   62 //PMC_LVDSC2  = PMC_LVDSC2_LVWACK_MASK | 
//   63 //              PMC_LVDSC2_LVWV(0)|
//   64 //              PMC_LVDSC2_LVWIE_MASK;    
//   65 //PMC_LVDSC2  = 0x40; //0b01000000 low trip point LVWV
//   66 //PMC_LVDSC2  = PMC_LVDSC2_LVWACK_MASK | 
//   67 //              PMC_LVDSC2_LVWV(1)|
//   68 //              PMC_LVDSC2_LVWIE_MASK;    
//   69 //PMC_LVDSC2  = 0x41; //0b01000001 mid1 trip point LVWV
//   70 //PMC_LVDSC2  = PMC_LVDSC2_LVWACK_MASK | 
//   71 //              PMC_LVDSC2_LVWV(2)|
//   72 //              PMC_LVDSC2_LVWIE_MASK;    
//   73 //PMC_LVDSC2  = 0x42; //0b01000010 mid2 trip point LVWV
//   74 PMC_LVDSC2  = PMC_LVDSC2_LVWACK_MASK | 
//   75               PMC_LVDSC2_LVWV(3) ;
        LDR.N    R0,??DataTable2_1  ;; 0x4007d001
        MOVS     R1,#+67
        STRB     R1,[R0, #+0]
//   76               //PMC_LVDSC2_LVWIE_MASK ;    //enable warning interrupt
//   77 //PMC_LVDSC2  = 0x43; //0b01000011 high trip point LVWV   
//   78 
//   79 // ack to clear initial flags
//   80 PMC_LVDSC1 |= PMC_LVDSC1_LVDACK_MASK; 
        LDR.N    R0,??DataTable2  ;; 0x4007d000
        LDRB     R0,[R0, #+0]
        ORRS     R0,R0,#0x40
        LDR.N    R1,??DataTable2  ;; 0x4007d000
        STRB     R0,[R1, #+0]
//   81 PMC_LVDSC2 |= PMC_LVDSC2_LVWACK_MASK;
        LDR.N    R0,??DataTable2_1  ;; 0x4007d001
        LDRB     R0,[R0, #+0]
        ORRS     R0,R0,#0x40
        LDR.N    R1,??DataTable2_1  ;; 0x4007d001
        STRB     R0,[R1, #+0]
//   82 
//   83 /* 
//   84 LVWV if LVD high range selected
//   85 2.621
//   86 2.72
//   87 2.82
//   88 2.92
//   89 LVDV if LVD low range selected
//   90 1.74
//   91 1.84
//   92 1.94
//   93 
//   94 
//   95 */
//   96 }
        BX       LR               ;; return

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   97 void pmc_lvd_isr(void)
//   98 {
pmc_lvd_isr:
        PUSH     {R7,LR}
//   99  
//  100   if (PMC_LVDSC1 &PMC_LVDSC1_LVDF_MASK){
        LDR.N    R0,??DataTable2  ;; 0x4007d000
        LDRB     R0,[R0, #+0]
        LSLS     R0,R0,#+24
        BPL.N    ??pmc_lvd_isr_0
//  101    printf("[LVD_isr]LV DETECT interrupt occurred");
        LDR.N    R0,??DataTable2_2
        BL       printf
//  102   }
//  103   if (PMC_LVDSC2 &PMC_LVDSC2_LVWF_MASK){
??pmc_lvd_isr_0:
        LDR.N    R0,??DataTable2_1  ;; 0x4007d001
        LDRB     R0,[R0, #+0]
        LSLS     R0,R0,#+24
        BPL.N    ??pmc_lvd_isr_1
//  104    printf("[LVD_isr]LV WARNING interrupt occurred");
        LDR.N    R0,??DataTable2_3
        BL       printf
//  105   }
//  106  
//  107  // ack to clear initial flags
//  108  PMC_LVDSC1 |= PMC_LVDSC1_LVDACK_MASK; 
??pmc_lvd_isr_1:
        LDR.N    R0,??DataTable2  ;; 0x4007d000
        LDRB     R0,[R0, #+0]
        ORRS     R0,R0,#0x40
        LDR.N    R1,??DataTable2  ;; 0x4007d000
        STRB     R0,[R1, #+0]
//  109  PMC_LVDSC2 |= PMC_LVDSC2_LVWACK_MASK;
        LDR.N    R0,??DataTable2_1  ;; 0x4007d001
        LDRB     R0,[R0, #+0]
        ORRS     R0,R0,#0x40
        LDR.N    R1,??DataTable2_1  ;; 0x4007d001
        STRB     R0,[R1, #+0]
//  110 
//  111 }
        POP      {R0,PC}          ;; return

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable2:
        DC32     0x4007d000

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable2_1:
        DC32     0x4007d001

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable2_2:
        DC32     `?<Constant "[LVD_isr]LV DETECT in...">`

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable2_3:
        DC32     `?<Constant "[LVD_isr]LV WARNING i...">`

        SECTION `.iar_vfe_header`:DATA:REORDER:NOALLOC:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
        DC32 0

        SECTION __DLIB_PERTHREAD:DATA:REORDER:NOROOT(0)
        SECTION_TYPE SHT_PROGBITS, 0

        SECTION __DLIB_PERTHREAD_init:DATA:REORDER:NOROOT(0)
        SECTION_TYPE SHT_PROGBITS, 0

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "[LVD_isr]LV DETECT in...">`:
        DATA
        DC8 "[LVD_isr]LV DETECT interrupt occurred"
        DC8 0, 0

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "[LVD_isr]LV WARNING i...">`:
        DATA
        DC8 "[LVD_isr]LV WARNING interrupt occurred"
        DC8 0

        END
//  112 
//  113 
//  114 
//  115 
// 
//   4 bytes in section .bss
//  80 bytes in section .rodata
// 148 bytes in section .text
// 
// 148 bytes of CODE  memory
//  80 bytes of CONST memory
//   4 bytes of DATA  memory
//
//Errors: none
//Warnings: none
