///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// 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\projects\TWRK20D50M_Demo\TSI\tsi.c               /
//    Command line =  "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\src\projects\TWRK20D50M_Demo\TSI\tsi.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\ts /
//                    i.s                                                     /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME tsi

        #define SHT_PROGBITS 0x1

        EXTERN disable_irq
        EXTERN enable_irq

        PUBLIC TSI_Deinit
        PUBLIC TSI_Init
        PUBLIC TSI_SelfCalibration
        PUBLIC TouchEvent
        PUBLIC g16ElectrodeBaseline
        PUBLIC g16ElectrodeTouch
        PUBLIC g32DebounceCounter
        PUBLIC lValidTouch
        PUBLIC tsi_delay
        PUBLIC tsi_isr

// D:\Profiles\b01252\My Documents\Freescale\P0\software\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\src\projects\TWRK20D50M_Demo\TSI\tsi.c
//    1 
//    2 #include "common.h"
//    3 #include "TSI.h"
//    4 
//    5 extern uint32 __VECTOR_RAM[];

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//    6 uint16 lValidTouch;
lValidTouch:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//    7 uint16 TouchEvent = 0;
TouchEvent:
        DS8 2
//    8 
//    9 

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
//   10 uint16  g16ElectrodeTouch[16] = {0};
g16ElectrodeTouch:
        DS8 32

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
//   11 uint16  g16ElectrodeBaseline[16] = {0};
g16ElectrodeBaseline:
        DS8 32
//   12 

        SECTION `.data`:DATA:REORDER:NOROOT(2)
//   13 uint32  g32DebounceCounter[16] = {DBOUNCE_COUNTS};
g32DebounceCounter:
        DATA
        DC32 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
//   14 
//   15 /********************************************************************************
//   16  *   TSI_Init: Initializes TSI module
//   17  * Notes:
//   18  *    -
//   19  ********************************************************************************/

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   20 void TSI_Init(void)
//   21 {
TSI_Init:
        PUSH     {R7,LR}
//   22     SIM_SCGC5 |= (SIM_SCGC5_TSI_MASK);
        LDR.N    R0,??DataTable3  ;; 0x40048038
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x20
        LDR.N    R1,??DataTable3  ;; 0x40048038
        STR      R0,[R1, #+0]
//   23     enable_irq(INT_TSI0-16);
        MOVS     R0,#+37
        BL       enable_irq
//   24     
//   25     /*  Ensures pin configured for TSI operation
//   26     
//   27     */
//   28     PORTB_PCR0 = PORT_PCR_MUX(0);
        LDR.N    R0,??DataTable3_1  ;; 0x4004a000
        MOVS     R1,#+0
        STR      R1,[R0, #+0]
//   29     PORTB_PCR1 = PORT_PCR_MUX(0);
        LDR.N    R0,??DataTable3_2  ;; 0x4004a004
        MOVS     R1,#+0
        STR      R1,[R0, #+0]
//   30 
//   31     
//   32     TSI0_GENCS |= ((TSI_GENCS_NSCN(10))|(TSI_GENCS_PS(3)));
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x530000
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//   33     TSI0_SCANC |= ((TSI_SCANC_EXTCHRG(3))|(TSI_SCANC_REFCHRG(31))/*|(TSI_SCANC_DELVOL(7))|*/| (TSI_SCANC_SMOD(0))|(TSI_SCANC_AMPSC(0)));
        LDR.N    R0,??DataTable3_4  ;; 0x40045004
        LDR      R0,[R0, #+0]
        LDR.N    R1,??DataTable3_5  ;; 0xf030000
        ORRS     R0,R1,R0
        LDR.N    R1,??DataTable3_4  ;; 0x40045004
        STR      R0,[R1, #+0]
//   34     
//   35     ELECTRODE_ENABLE_REG = ELECTRODE0_EN_MASK |ELECTRODE1_EN_MASK | ELECTRODE2_EN_MASK |ELECTRODE3_EN_MASK;
        LDR.N    R0,??DataTable3_6  ;; 0x40045008
        MOVS     R1,#+65
        STR      R1,[R0, #+0]
//   36     
//   37     
//   38     
//   39     /* Init TSI interrupts */
//   40     TSI0_GENCS |= (TSI_GENCS_TSIEN_MASK);  //Enables TSI
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x80
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//   41 
//   42 
//   43 
//   44 }
        POP      {R0,PC}          ;; return
//   45 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   46 void TSI_Deinit(void)
//   47 {
TSI_Deinit:
        PUSH     {R7,LR}
//   48     disable_irq(INT_TSI0-16);
        MOVS     R0,#+37
        BL       disable_irq
//   49     TSI0_GENCS &= ~(TSI_GENCS_TSIEN_MASK);
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        BICS     R0,R0,#0x80
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//   50     SIM_SCGC5 &= ~(SIM_SCGC5_TSI_MASK);
        LDR.N    R0,??DataTable3  ;; 0x40048038
        LDR      R0,[R0, #+0]
        BICS     R0,R0,#0x20
        LDR.N    R1,??DataTable3  ;; 0x40048038
        STR      R0,[R1, #+0]
//   51 }
        POP      {R0,PC}          ;; return
//   52 
//   53 /********************************************************************************
//   54  *   delay: delay
//   55  * Notes:
//   56  *    - 
//   57  ********************************************************************************/

        SECTION `.text`:CODE:NOROOT(2)
        THUMB
//   58 void tsi_delay(uint32 i)
//   59 {
//   60   uint32 cnt;
//   61   for(cnt=0;cnt<i;cnt++)  //delay
tsi_delay:
        MOVS     R1,#+0
        B.N      ??tsi_delay_0
//   62   {
//   63     asm("nop");
??tsi_delay_1:
        nop              
//   64   }
        ADDS     R1,R1,#+1
??tsi_delay_0:
        CMP      R1,R0
        BCC.N    ??tsi_delay_1
//   65 }
        BX       LR               ;; return
//   66 
//   67 /********************************************************************************
//   68  *   TSI_SelfCalibration: Simple auto calibration version
//   69  * Notes:
//   70  *    - Very simple, only sums a prefixed amount to the current baseline
//   71  ********************************************************************************/

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   72 void TSI_SelfCalibration(void)
//   73 {
TSI_SelfCalibration:
        PUSH     {R7,LR}
//   74     TSI0_GENCS |= TSI_GENCS_SWTS_MASK;
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        MOV      R1,#+256
        ORRS     R0,R1,R0
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//   75     while(!TSI0_GENCS & TSI_GENCS_EOSF_MASK){};
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??TSI_SelfCalibration_0
        MOVS     R0,#+1
        B.N      ??TSI_SelfCalibration_1
??TSI_SelfCalibration_0:
        MOVS     R0,#+0
//   76     
//   77     tsi_delay(100000);
??TSI_SelfCalibration_1:
        LDR.N    R0,??DataTable3_7  ;; 0x186a0
        BL       tsi_delay
//   78     
//   79     g16ElectrodeBaseline[ELECTRODE0] = ELECTRODE0_COUNT;
        LDR.N    R0,??DataTable3_8
        LDR.N    R1,??DataTable3_9  ;; 0x40045100
        LDR      R1,[R1, #+0]
        STRH     R1,[R0, #+0]
//   80     ELECTRODE0_OUTRG = (uint32)((g16ElectrodeBaseline[ELECTRODE0]+ELECTRODE0_OUTRG_VAL));
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+0]
        ADDS     R0,R0,#+61440
        LDR.N    R1,??DataTable3_10  ;; 0x40045120
        STR      R0,[R1, #+0]
//   81     g16ElectrodeTouch[ELECTRODE0] = g16ElectrodeBaseline[ELECTRODE0] + ELECTRODE0_TOUCH;
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+0]
        ADDW     R0,R0,#+512
        LDR.N    R1,??DataTable3_11
        STRH     R0,[R1, #+0]
//   82     
//   83     g16ElectrodeBaseline[ELECTRODE1] = ELECTRODE1_COUNT;
        LDR.N    R0,??DataTable3_8
        LDR.N    R1,??DataTable3_12  ;; 0x4004510c
        LDR      R1,[R1, #+0]
        STRH     R1,[R0, #+2]
//   84     ELECTRODE1_OUTRG = (uint32)((g16ElectrodeBaseline[ELECTRODE1]+ELECTRODE1_OUTRG_VAL));
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+2]
        ADDS     R0,R0,#+61440
        LDR.N    R1,??DataTable3_10  ;; 0x40045120
        STR      R0,[R1, #+0]
//   85     g16ElectrodeTouch[ELECTRODE1] = g16ElectrodeBaseline[ELECTRODE1] + ELECTRODE1_TOUCH;
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+2]
        ADDW     R0,R0,#+512
        LDR.N    R1,??DataTable3_11
        STRH     R0,[R1, #+2]
//   86     
//   87     g16ElectrodeBaseline[ELECTRODE2] = ELECTRODE2_COUNT;
        LDR.N    R0,??DataTable3_8
        LDR.N    R1,??DataTable3_13  ;; 0x4004511c
        LDR      R1,[R1, #+0]
        LSRS     R1,R1,#+16
        STRH     R1,[R0, #+4]
//   88     ELECTRODE2_OUTRG = (uint32)((g16ElectrodeBaseline[ELECTRODE2]+ELECTRODE2_OUTRG_VAL));
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+4]
        ADDS     R0,R0,#+61440
        LDR.N    R1,??DataTable3_10  ;; 0x40045120
        STR      R0,[R1, #+0]
//   89     g16ElectrodeTouch[ELECTRODE2] = g16ElectrodeBaseline[ELECTRODE2] + ELECTRODE2_TOUCH;
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+4]
        ADDW     R0,R0,#+512
        LDR.N    R1,??DataTable3_11
        STRH     R0,[R1, #+4]
//   90     
//   91     g16ElectrodeBaseline[ELECTRODE3] = ELECTRODE3_COUNT;
        LDR.N    R0,??DataTable3_8
        LDR.N    R1,??DataTable3_13  ;; 0x4004511c
        LDR      R1,[R1, #+0]
        STRH     R1,[R0, #+6]
//   92     ELECTRODE3_OUTRG = (uint32)((g16ElectrodeBaseline[ELECTRODE3]+ELECTRODE3_OUTRG_VAL));
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+6]
        ADDS     R0,R0,#+61440
        LDR.N    R1,??DataTable3_10  ;; 0x40045120
        STR      R0,[R1, #+0]
//   93     g16ElectrodeTouch[ELECTRODE3] = g16ElectrodeBaseline[ELECTRODE3] + ELECTRODE3_TOUCH;
        LDR.N    R0,??DataTable3_8
        LDRH     R0,[R0, #+6]
        ADDW     R0,R0,#+512
        LDR.N    R1,??DataTable3_11
        STRH     R0,[R1, #+6]
//   94     
//   95     DISABLE_TSI;
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        BICS     R0,R0,#0x80
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//   96 
//   97 }
        POP      {R0,PC}          ;; return
//   98 
//   99 /********************************************************************************
//  100  *   TSI_isr: TSI interrupt subroutine
//  101  * Notes:
//  102  *    - lValidTouch        
//  103                1
//  104                2 
//  105                4
//  106                8
//  107  ********************************************************************************/
//  108 
//  109 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  110 void tsi_isr(void)
//  111 {
//  112 
//  113 
//  114   uint16 l16Counter;
//  115 
//  116   TSI0_GENCS |= TSI_GENCS_OUTRGF_MASK;
tsi_isr:
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x4000
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//  117   TSI0_GENCS |= TSI_GENCS_EOSF_MASK;
        LDR.N    R0,??DataTable3_3  ;; 0x40045000
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x8000
        LDR.N    R1,??DataTable3_3  ;; 0x40045000
        STR      R0,[R1, #+0]
//  118 
//  119 
//  120   /* Process electrode 0 */
//  121   l16Counter = ELECTRODE0_COUNT;
        LDR.N    R0,??DataTable3_9  ;; 0x40045100
        LDR      R0,[R0, #+0]
//  122   if(l16Counter>g16ElectrodeTouch[ELECTRODE0])
        LDR.N    R1,??DataTable3_11
        LDRH     R1,[R1, #+0]
        UXTH     R0,R0            ;; ZeroExt  R0,R0,#+16,#+16
        CMP      R1,R0
        BCS.N    ??tsi_isr_0
//  123   {
//  124     TouchEvent |= (1<<ELECTRODE0);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x1
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  125     g32DebounceCounter[ELECTRODE0]--;
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable3_15
        STR      R0,[R1, #+0]
//  126     if(!g32DebounceCounter[ELECTRODE0])
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??tsi_isr_1
//  127     {
//  128       lValidTouch |= ((1<<ELECTRODE0));
        LDR.N    R0,??DataTable3_16
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x1
        LDR.N    R1,??DataTable3_16
        STRH     R0,[R1, #+0]
//  129       TouchEvent &= ~(1<<ELECTRODE0);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65534
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
        B.N      ??tsi_isr_1
//  130     }
//  131   }
//  132   else
//  133   {
//  134     TouchEvent &= ~(1<<ELECTRODE0);
??tsi_isr_0:
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65534
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  135     g32DebounceCounter[ELECTRODE0] = DBOUNCE_COUNTS;
        LDR.N    R0,??DataTable3_15
        MOVS     R1,#+16
        STR      R1,[R0, #+0]
//  136   }
//  137   /***********************/
//  138 
//  139   /* Process electrode 1 */
//  140   l16Counter = ELECTRODE1_COUNT;
??tsi_isr_1:
        LDR.N    R0,??DataTable3_12  ;; 0x4004510c
        LDR      R0,[R0, #+0]
//  141   if(l16Counter>g16ElectrodeTouch[ELECTRODE1])
        LDR.N    R1,??DataTable3_11
        LDRH     R1,[R1, #+2]
        UXTH     R0,R0            ;; ZeroExt  R0,R0,#+16,#+16
        CMP      R1,R0
        BCS.N    ??tsi_isr_2
//  142   {
//  143     TouchEvent |= (1<<ELECTRODE1);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x2
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  144     g32DebounceCounter[ELECTRODE1]--;
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+4]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable3_15
        STR      R0,[R1, #+4]
//  145     if(!g32DebounceCounter[ELECTRODE1])
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+4]
        CMP      R0,#+0
        BNE.N    ??tsi_isr_3
//  146     {
//  147       lValidTouch |= ((1<<ELECTRODE1));
        LDR.N    R0,??DataTable3_16
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x2
        LDR.N    R1,??DataTable3_16
        STRH     R0,[R1, #+0]
//  148       TouchEvent &= ~(1<<ELECTRODE1);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65533
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
        B.N      ??tsi_isr_3
//  149     }
//  150   }
//  151   else
//  152   {
//  153     TouchEvent &= ~(1<<ELECTRODE1);
??tsi_isr_2:
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65533
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  154     g32DebounceCounter[ELECTRODE1] = DBOUNCE_COUNTS;
        LDR.N    R0,??DataTable3_15
        MOVS     R1,#+16
        STR      R1,[R0, #+4]
//  155   }
//  156   /***********************/
//  157 
//  158   /* Process electrode 2 */
//  159   l16Counter = ELECTRODE2_COUNT;
??tsi_isr_3:
        LDR.N    R0,??DataTable3_13  ;; 0x4004511c
        LDR      R0,[R0, #+0]
        LSRS     R0,R0,#+16
//  160   if(l16Counter>g16ElectrodeTouch[ELECTRODE2])
        LDR.N    R1,??DataTable3_11
        LDRH     R1,[R1, #+4]
        UXTH     R0,R0            ;; ZeroExt  R0,R0,#+16,#+16
        CMP      R1,R0
        BCS.N    ??tsi_isr_4
//  161   {
//  162     TouchEvent |= (1<<ELECTRODE2);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x4
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  163     g32DebounceCounter[ELECTRODE2]--;
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+8]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable3_15
        STR      R0,[R1, #+8]
//  164     if(!g32DebounceCounter[ELECTRODE2])
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+8]
        CMP      R0,#+0
        BNE.N    ??tsi_isr_5
//  165     {
//  166       lValidTouch |= ((1<<ELECTRODE2));
        LDR.N    R0,??DataTable3_16
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x4
        LDR.N    R1,??DataTable3_16
        STRH     R0,[R1, #+0]
//  167       TouchEvent &= ~(1<<ELECTRODE2);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65531
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
        B.N      ??tsi_isr_5
//  168     }
//  169   }
//  170   else
//  171   {
//  172     TouchEvent &= ~(1<<ELECTRODE2);
??tsi_isr_4:
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65531
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  173     g32DebounceCounter[ELECTRODE2] = DBOUNCE_COUNTS;
        LDR.N    R0,??DataTable3_15
        MOVS     R1,#+16
        STR      R1,[R0, #+8]
//  174   }
//  175   /***********************/
//  176 
//  177   /* Process electrode 3 */
//  178   l16Counter = ELECTRODE3_COUNT;
??tsi_isr_5:
        LDR.N    R0,??DataTable3_13  ;; 0x4004511c
        LDR      R0,[R0, #+0]
//  179   if(l16Counter>g16ElectrodeTouch[ELECTRODE3])
        LDR.N    R1,??DataTable3_11
        LDRH     R1,[R1, #+6]
        UXTH     R0,R0            ;; ZeroExt  R0,R0,#+16,#+16
        CMP      R1,R0
        BCS.N    ??tsi_isr_6
//  180   {
//  181     TouchEvent |= (1<<ELECTRODE3);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x8
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  182     g32DebounceCounter[ELECTRODE3]--;
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+12]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable3_15
        STR      R0,[R1, #+12]
//  183     if(!g32DebounceCounter[ELECTRODE3])
        LDR.N    R0,??DataTable3_15
        LDR      R0,[R0, #+12]
        CMP      R0,#+0
        BNE.N    ??tsi_isr_7
//  184     {
//  185       lValidTouch |= ((1<<ELECTRODE3));
        LDR.N    R0,??DataTable3_16
        LDRH     R0,[R0, #+0]
        ORRS     R0,R0,#0x8
        LDR.N    R1,??DataTable3_16
        STRH     R0,[R1, #+0]
//  186       TouchEvent &= ~(1<<ELECTRODE3);
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65527
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
        B.N      ??tsi_isr_7
//  187     }
//  188   }
//  189   else
//  190   {
//  191     TouchEvent &= ~(1<<ELECTRODE3);
??tsi_isr_6:
        LDR.N    R0,??DataTable3_14
        LDRH     R0,[R0, #+0]
        MOVW     R1,#+65527
        ANDS     R0,R1,R0
        LDR.N    R1,??DataTable3_14
        STRH     R0,[R1, #+0]
//  192     g32DebounceCounter[ELECTRODE3] = DBOUNCE_COUNTS;
        LDR.N    R0,??DataTable3_15
        MOVS     R1,#+16
        STR      R1,[R0, #+12]
//  193   }
//  194 
//  195  // TSI0_STATUS = 0xFFFFFFFF;
//  196 }
??tsi_isr_7:
        BX       LR               ;; return

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        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

        END
//  197 
// 
//  68 bytes in section .bss
//  64 bytes in section .data
// 768 bytes in section .text
// 
// 768 bytes of CODE memory
// 132 bytes of DATA memory
//
//Errors: none
//Warnings: none
