///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR ANSI C/C++ Compiler V6.30.1.53127/W32 for ARM    08/Mar/2012  18:18:21 /
// 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\TWRK20D50M_Demo.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\TWRK20D50M_Demo.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\iar\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\ia /
//                    r\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\iar\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\TW /
//                    RK20D50M_Demo.s                                         /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME TWRK20D50M_Demo

        #define SHT_PROGBITS 0x1

        EXTERN C_MAJ_SCALE
        EXTERN PIT_init
        EXTERN TWR_GPIO_init
        EXTERN TouchEvent
        EXTERN adc_test_init
        EXTERN angle_calculation
        EXTERN arr_medianasClap
        EXTERN base_time125m
        EXTERN buzzer_ftm_init
        EXTERN buzzer_off
        EXTERN buzzer_on
        EXTERN clap_counter
        EXTERN clap_detected
        EXTERN clap_energy
        EXTERN cmt_init
        EXTERN detect_fall_detection
        EXTERN energy_scaled
        EXTERN fall_input
        EXTERN hal_dev_mma8451_read_reg
        EXTERN hal_dev_mma8451_write_reg
        EXTERN hal_i2c_init
        EXTERN input_rise
        EXTERN irda_test_init
        EXTERN median
        EXTERN median_energy
        EXTERN printf
        EXTERN ptr_next_task
        EXTERN rtc_init
        EXTERN set_out_module
        EXTERN ti_accel_sampling
        EXTERN ti_delay
        EXTERN ti_fall
        EXTERN ti_test_leds
        EXTERN ti_tone_wait
        EXTERN tone
        EXTERN tone_counter
        EXTERN tone_detected
        EXTERN tone_enable
        EXTERN tone_filter_init
        EXTERN tsi_test_init
        EXTERN tsi_test_service
        EXTERN uart_app_init
        EXTERN xz_mag
        EXTERN yz_angle

        PUBLIC accel_init
        PUBLIC accel_read
        PUBLIC accel_x
        PUBLIC accel_y
        PUBLIC accel_z
        PUBLIC bufferCount
        PUBLIC main
        PUBLIC resultx
        PUBLIC resulty
        PUBLIC resultz
        PUBLIC switch_test
        PUBLIC tone_accel_demo
        PUBLIC vfn_null
        PUBLIC vfn_test_accel

// D:\Profiles\b01252\My Documents\Freescale\P0\software\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\src\projects\TWRK20D50M_Demo\TWRK20D50M_Demo.c
//    1 /**
//    2   \mainpage 
//    3   \n Copyright (c) 2011 Freescale
//    4   \n Freescale 
//    5   \brief        Shows different features of the TWR-K20D50M
//    6   \brief        press buttons, touch electrode  toggle LEDs
//    7   \brief        tilt board to create tones (I2C, accelerometer)
//    8   \todo         clap() and board answer with a tone (ADC + microphone)
//    9   \author   	Freescale Semiconductor
//   10   \author    
//   11   \version      1.1
//   12   \date         January 10,2012
//   13 
//   14   
//   15   Put here all the information needed of the Project. Basic configuration as well as information on
//   16   the project definition will be very useful 
//   17 */
//   18 /****************************************************************************************************/
//   19 /*                                                                                                  */
//   20 /* All software, source code, included documentation, and any implied know-how are property of      */
//   21 /* Freescale Semiconductor and therefore considered CONFIDENTIAL INFORMATION.                       */
//   22 /* This confidential information is disclosed FOR DEMONSTRATION PURPOSES ONLY.                      */
//   23 /*                                                                                                  */
//   24 /* All Confidential Information remains the property of Freescale Semiconductor and will not be     */
//   25 /* copied or reproduced without the express written permission of the Discloser, except for copies  */
//   26 /* that are absolutely necessary in order to fulfill the Purpose.                                   */
//   27 /*                                                                                                  */
//   28 /* Services performed by FREESCALE in this matter are performed AS IS and without any warranty.     */
//   29 /* CUSTOMER retains the final decision relative to the total design and functionality of the end    */
//   30 /* product.                                                                                         */
//   31 /* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the success of this project.*/
//   32 /*                                                                                                  */
//   33 /* FREESCALE disclaims all warranties, express, implied or statutory including, but not limited to, */
//   34 /* implied warranty of merchantability or fitness for a particular purpose on any hardware,         */
//   35 /* software ore advise supplied to the project by FREESCALE, and or any product resulting from      */
//   36 /* FREESCALE services.                                                                              */
//   37 /* In no event shall FREESCALE be liable for incidental or consequential damages arising out of     */
//   38 /* this agreement. CUSTOMER agrees to hold FREESCALE harmless against any and all claims demands or */
//   39 /* actions by anyone on account of any damage,or injury, whether commercial, contractual, or        */
//   40 /* tortuous, rising directly or indirectly as a result of the advise or assistance supplied CUSTOMER*/ 
//   41 /* in connectionwith product, services or goods supplied under this Agreement.                      */
//   42 /*                                                                                                  */
//   43 /****************************************************************************************************/
//   44 
//   45 /*****************************************************************************************************
//   46 * Include files
//   47 *****************************************************************************************************/
//   48 #include "common.h"
//   49 #include "TWR_K20D50M_DEF.h"
//   50 #include "buzzer.h"
//   51 #include "rtc.h"
//   52 #include "hal_i2c.h"
//   53 #include "hal_dev_mma8451.h"
//   54 #include "adc_test.h"
//   55 #include "angle_cal.h"
//   56 #include "fft_test.h"
//   57 #include "irda_test.h"
//   58 #include "cmt_test.h"
//   59 #include "median.h"
//   60 //#include "freemaster.h"
//   61 #include "task_mgr.h"
//   62 #include "UART.h"
//   63 #include "protocol.h"
//   64 #include "tsi.h"
//   65 

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   66 uint16 bufferCount;
bufferCount:
        DS8 2
//   67 
//   68 void tsi_test_service(void);
//   69 void tsi_test_init(void);
//   70 
//   71 
//   72 /*****************************************************************************************************
//   73 * Declaration of module wide FUNCTIONs - NOT for use in other modules
//   74 *****************************************************************************************************/
//   75 void  switch_test(void);
//   76 void  accel_read(void);
//   77 void  accel_init(void);
//   78 void  vfn_test_accel(void);
//   79 void vfn_null(void);
//   80 
//   81 /*****************************************************************************************************
//   82 * Definition of module wide MACROs / #DEFINE-CONSTANTs - NOT for use in other modules
//   83 *****************************************************************************************************/
//   84 
//   85 /*****************************************************************************************************
//   86 * Declaration of module wide TYPEs - NOT for use in other modules
//   87 *****************************************************************************************************/
//   88 
//   89 /*****************************************************************************************************
//   90 * Definition of module wide VARIABLEs - NOT for use in other modules
//   91 *****************************************************************************************************/

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   92 signed short accel_x, accel_y, accel_z;
accel_x:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
accel_y:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
accel_z:
        DS8 2
//   93 

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   94 signed short resultx, resulty, resultz;
resultx:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
resulty:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
resultz:
        DS8 2
//   95 
//   96 
//   97 /*****************************************************************************************************
//   98 * Definition of module wide (CONST-) CONSTANTs - NOT for use in other modules
//   99 *****************************************************************************************************/
//  100 
//  101 /*****************************************************************************************************
//  102 * Code of project wide FUNCTIONS
//  103 *****************************************************************************************************/
//  104 
//  105 /**
//  106  * \brief   main
//  107  * \author  
//  108  * \param  none
//  109  * \return none
//  110  * \todo
//  111  * \warning
//  112  */  
//  113 

        SECTION `.text`:CODE:NOROOT(2)
        THUMB
//  114  int main (void)
//  115 {
main:
        PUSH     {R7,LR}
//  116   
//  117     static char aux_fall_input,aux_clap_detected,auxclapmed,aux_tone_detected;
//  118     static char fall_counter;
//  119     
//  120         TWR_GPIO_init();
        BL       TWR_GPIO_init
//  121   	printf("\n TWRK20D50M Demo Software Rev 1.4 \n");                
        LDR.W    R0,??DataTable5
        BL       printf
//  122         printf("\n >"); 
        ADR.N    R0,??DataTable1  ;; "\n >"
        BL       printf
//  123         uart_app_init();
        BL       uart_app_init
//  124         buzzer_ftm_init(); //buzzer init
        BL       buzzer_ftm_init
//  125         PIT_init();
        BL       PIT_init
//  126         rtc_init();
        BL       rtc_init
//  127         accel_init();
        BL       accel_init
//  128         adc_test_init();
        BL       adc_test_init
//  129         tsi_test_init();
        BL       tsi_test_init
//  130         irda_test_init();
        BL       irda_test_init
//  131         
//  132         tone_filter_init();
        BL       tone_filter_init
//  133         
//  134         next_task(vfn_null);
        LDR.W    R0,??DataTable5_1
        ADR.W    R1,vfn_null
        STR      R1,[R0, #+0]
//  135         ti_fall = 3000;  //waits a least 3 seconds before detect falls
        LDR.W    R0,??DataTable5_2
        MOVW     R1,#+3000
        STRH     R1,[R0, #+0]
//  136          
//  137         cmt_init();
        BL       cmt_init
//  138         EnableInterrupts;
        CPSIE i         
//  139         tone(_C7 ,300,10);
        MOVS     R2,#+10
        MOV      R1,#+300
        MOVS     R0,#+29
        BL       tone
//  140         while(tone_enable){};
??main_0:
        LDR.W    R0,??DataTable5_3
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??main_0
//  141         tone(_A5,300,10);
        MOVS     R2,#+10
        MOV      R1,#+300
        MOVS     R0,#+14
        BL       tone
//  142         while(tone_enable){};
??main_1:
        LDR.W    R0,??DataTable5_3
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??main_1
//  143 
//  144         cmt_init();
        BL       cmt_init
        B.N      ??main_2
//  145        
//  146  
//  147 	while(1)
//  148 	{
//  149           
//  150             ptr_next_task();  // do the actual function 
//  151             vfn_test_accel();
//  152             switch_test();
//  153             tsi_test_service(); 
//  154             /* tone detection */
//  155           if (input_rise(tone_detected,&aux_tone_detected) && !tone_enable && !ti_tone_wait)
//  156             {
//  157                ti_tone_wait = 800;
//  158                tone(_A5,180,10);
//  159                printf("\n\r tone detected %3i\n\r ",tone_counter);
//  160             } else  if (tone_detected==1 && !ti_tone_wait) tone_detected=0; 
//  161               
//  162             
//  163             
//  164            // Clap detection 
//  165            if (input_rise(clap_detected,&aux_clap_detected) && !tone_enable && !ti_tone_wait)
//  166             {
//  167                ti_tone_wait = 400;
//  168                tone(_A4,100,10);
//  169                printf("\n\r clap/snap detected  %3i \n\r ",clap_counter);
//  170                
//  171             } else  if (clap_detected==1 && !ti_tone_wait) clap_detected=0; 
??main_3:
        LDR.W    R0,??DataTable5_4
        LDRB     R0,[R0, #+0]
        CMP      R0,#+1
        BNE.N    ??main_4
        LDR.W    R0,??DataTable5_5
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??main_4
        LDR.W    R0,??DataTable5_4
        MOVS     R1,#+0
        STRB     R1,[R0, #+0]
//  172               
//  173         
//  174             
//  175             /*fall detection */ 
//  176          if (input_rise(fall_input,&aux_fall_input))
??main_4:
        LDR.W    R1,??DataTable5_6
        LDR.W    R0,??DataTable5_7
        LDRB     R0,[R0, #+0]
        BL       input_rise
        CMP      R0,#+0
        BEQ.N    ??main_5
//  177          {
//  178            printf("\n\r i'm falling!!! %i \n\r",fall_counter++);
        LDR.W    R0,??DataTable5_8
        LDRB     R1,[R0, #+0]
        ADDS     R0,R1,#+1
        LDR.W    R2,??DataTable5_8
        STRB     R0,[R2, #+0]
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        LDR.W    R0,??DataTable5_9
        BL       printf
//  179            ti_delay = 1500;
        LDR.W    R0,??DataTable5_10
        MOVW     R1,#+1500
        STR      R1,[R0, #+0]
//  180            tone(_A6,400,10);
        MOVS     R2,#+10
        MOV      R1,#+400
        MOVS     R0,#+26
        BL       tone
//  181          }
//  182          
//  183   if (input_rise(base_time125m&0x1,&auxclapmed))   
??main_5:
        LDR.W    R1,??DataTable5_11
        LDR.W    R0,??DataTable5_12
        LDRB     R0,[R0, #+0]
        ANDS     R0,R0,#0x1
        BL       input_rise
        CMP      R0,#+0
        BEQ.N    ??main_2
//  184    {
//  185     if (clap_energy>65535*2) clap_energy= 65535*2;
        LDR.W    R0,??DataTable5_13
        LDR      R0,[R0, #+0]
        LDR.W    R1,??DataTable5_14  ;; 0x1ffff
        CMP      R0,R1
        BLT.N    ??main_6
        LDR.W    R0,??DataTable5_13
        LDR.W    R1,??DataTable5_15  ;; 0x1fffe
        STR      R1,[R0, #+0]
//  186     energy_scaled = (clap_energy/2);
??main_6:
        LDR.W    R0,??DataTable5_13
        LDR      R0,[R0, #+0]
        MOVS     R1,#+2
        SDIV     R0,R0,R1
        LDR.W    R1,??DataTable5_16
        STRH     R0,[R1, #+0]
//  187     median_energy = median(energy_scaled, &arr_medianasClap[0]);
        LDR.W    R1,??DataTable5_17
        LDR.W    R0,??DataTable5_16
        LDRH     R0,[R0, #+0]
        BL       median
        LDR.W    R1,??DataTable5_18
        STRH     R0,[R1, #+0]
//  188    }
??main_2:
        LDR.W    R0,??DataTable5_1
        LDR      R0,[R0, #+0]
        BLX      R0
        BL       vfn_test_accel
        BL       switch_test
        BL       tsi_test_service
        LDR.W    R1,??DataTable5_19
        LDR.W    R0,??DataTable5_20
        LDRB     R0,[R0, #+0]
        BL       input_rise
        CMP      R0,#+0
        BEQ.N    ??main_7
        LDR.W    R0,??DataTable5_3
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??main_7
        LDR.W    R0,??DataTable5_5
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??main_7
        LDR.W    R0,??DataTable5_5
        MOV      R1,#+800
        STRH     R1,[R0, #+0]
        MOVS     R2,#+10
        MOVS     R1,#+180
        MOVS     R0,#+14
        BL       tone
        LDR.W    R0,??DataTable5_21
        LDRB     R1,[R0, #+0]
        LDR.W    R0,??DataTable5_22
        BL       printf
        B.N      ??main_8
??main_7:
        LDR.W    R0,??DataTable5_20
        LDRB     R0,[R0, #+0]
        CMP      R0,#+1
        BNE.N    ??main_8
        LDR.N    R0,??DataTable5_5
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??main_8
        LDR.W    R0,??DataTable5_20
        MOVS     R1,#+0
        STRB     R1,[R0, #+0]
??main_8:
        LDR.W    R1,??DataTable5_23
        LDR.N    R0,??DataTable5_4
        LDRB     R0,[R0, #+0]
        BL       input_rise
        CMP      R0,#+0
        BEQ.W    ??main_3
        LDR.N    R0,??DataTable5_3
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.W    ??main_3
        LDR.N    R0,??DataTable5_5
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.W    ??main_3
        LDR.N    R0,??DataTable5_5
        MOV      R1,#+400
        STRH     R1,[R0, #+0]
        MOVS     R2,#+10
        MOVS     R1,#+100
        MOVS     R0,#+2
        BL       tone
        LDR.N    R0,??DataTable5_24
        LDRB     R1,[R0, #+0]
        LDR.N    R0,??DataTable5_25
        BL       printf
        B.N      ??main_4
//  189 
//  190          
//  191          
//  192              
//  193         } 
//  194 }

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??aux_fall_input:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??aux_clap_detected:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??auxclapmed:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??aux_tone_detected:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??fall_counter:
        DS8 1
//  195 
//  196 
//  197 /*do nothing*/

        SECTION `.text`:CODE:NOROOT(2)
        THUMB
//  198 void vfn_null(void)
//  199 {
//  200 
//  201 }
vfn_null:
        BX       LR               ;; return
//  202 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  203 void vfn_test_accel(void)
//  204 {
vfn_test_accel:
        PUSH     {R7,LR}
//  205                if (ti_accel_sampling==0)
        LDR.N    R0,??DataTable5_26
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??vfn_test_accel_0
//  206              {
//  207                accel_read();              
        BL       accel_read
//  208                ti_accel_sampling = 10;            
        LDR.N    R0,??DataTable5_26
        MOVS     R1,#+10
        STR      R1,[R0, #+0]
//  209                } 
//  210 
//  211 }
??vfn_test_accel_0:
        POP      {R0,PC}          ;; return

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable1:
        DC8      "\n >"
//  212 
//  213 
//  214 
//  215 /**
//  216  * \brief   Turn on LED1 and turn off LED2 when SW2 is pressed, and invert when de-pressed
//  217  * \brief   Turn on LED3 and turn off LED4 when SW3 is pressed, and invert when de-pressed
//  218  * \author  b01252
//  219  * \param  none
//  220  * \return none
//  221  */  
//  222 
//  223 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  224 void  switch_test(void)
//  225 {
switch_test:
        PUSH     {R7,LR}
//  226   static char aux_sw1, aux_sw2, sw1_count, sw2_count;
//  227         if (input_rise(SW1_ON,&aux_sw1))
        LDR.N    R1,??DataTable5_27
        LDR.N    R0,??DataTable5_28  ;; 0x400ff090
        LDR      R0,[R0, #+0]
        UBFX     R0,R0,#+1,#+1
        ANDS     R0,R0,#0x1
        EORS     R0,R0,#0x1
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        BL       input_rise
        CMP      R0,#+0
        BEQ.N    ??switch_test_0
//  228            {
//  229               printf("\n\r push_button (SW3)  %i \n\r",sw1_count++);
        LDR.N    R0,??DataTable5_29
        LDRB     R1,[R0, #+0]
        ADDS     R0,R1,#+1
        LDR.N    R2,??DataTable5_29
        STRB     R0,[R2, #+0]
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        LDR.N    R0,??DataTable5_30
        BL       printf
//  230               tone(_C6,100,10);                    
        MOVS     R2,#+10
        MOVS     R1,#+100
        MOVS     R0,#+17
        BL       tone
//  231           }
//  232   
//  233   
//  234         if (input_rise(SW2_ON,&aux_sw2))
??switch_test_0:
        LDR.N    R1,??DataTable5_31
        LDR.N    R0,??DataTable5_28  ;; 0x400ff090
        LDR      R0,[R0, #+0]
        UBFX     R0,R0,#+2,#+1
        ANDS     R0,R0,#0x1
        EORS     R0,R0,#0x1
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        BL       input_rise
        CMP      R0,#+0
        BEQ.N    ??switch_test_1
//  235            {
//  236               printf("\n\r push_button (SW2) %i \n\r",sw2_count++);
        LDR.N    R0,??DataTable5_32
        LDRB     R1,[R0, #+0]
        ADDS     R0,R1,#+1
        LDR.N    R2,??DataTable5_32
        STRB     R0,[R2, #+0]
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        LDR.N    R0,??DataTable5_33
        BL       printf
//  237               tone(_E6,100,10);                    
        MOVS     R2,#+10
        MOVS     R1,#+100
        MOVS     R0,#+21
        BL       tone
//  238           }
//  239         
//  240         if (ti_test_leds==0)
??switch_test_1:
        LDR.N    R0,??DataTable5_34
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??switch_test_2
//  241         {   
//  242 /*          
//  243          if (SW1_ON) LED1_ON; else LED1_OFF;
//  244          if (SW2_ON) LED2_ON; else LED2_OFF;    
//  245          if (ELECTRODE1_ON) LED3_ON; LED3_OFF;
//  246          if (ELECTRODE2_ON) LED4_ON; LED4_OFF;
//  247   */
//  248          if (SW1_ON) LED3_ON; else LED3_OFF;
        LDR.N    R0,??DataTable5_28  ;; 0x400ff090
        LDR      R0,[R0, #+0]
        LSLS     R0,R0,#+30
        BMI.N    ??switch_test_3
        LDR.N    R0,??DataTable5_35  ;; 0x400ff084
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x80
        LDR.N    R1,??DataTable5_35  ;; 0x400ff084
        STR      R0,[R1, #+0]
        B.N      ??switch_test_4
??switch_test_3:
        LDR.N    R0,??DataTable5_36  ;; 0x400ff088
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x80
        LDR.N    R1,??DataTable5_36  ;; 0x400ff088
        STR      R0,[R1, #+0]
//  249          if (SW2_ON) LED4_ON; else LED4_OFF;    
??switch_test_4:
        LDR.N    R0,??DataTable5_28  ;; 0x400ff090
        LDR      R0,[R0, #+0]
        LSLS     R0,R0,#+29
        BMI.N    ??switch_test_5
        LDR.N    R0,??DataTable5_35  ;; 0x400ff084
        LDR      R0,[R0, #+0]
        MOV      R1,#+256
        ORRS     R0,R1,R0
        LDR.N    R1,??DataTable5_35  ;; 0x400ff084
        STR      R0,[R1, #+0]
        B.N      ??switch_test_6
??switch_test_5:
        LDR.N    R0,??DataTable5_36  ;; 0x400ff088
        LDR      R0,[R0, #+0]
        MOV      R1,#+256
        ORRS     R0,R1,R0
        LDR.N    R1,??DataTable5_36  ;; 0x400ff088
        STR      R0,[R1, #+0]
//  250          if (ELECTRODE1_ON) LED1_ON; LED1_OFF;
??switch_test_6:
        LDR.N    R0,??DataTable5_37
        LDRB     R0,[R0, #+0]
        LSLS     R0,R0,#+31
        BPL.N    ??switch_test_7
        LDR.N    R0,??DataTable5_36  ;; 0x400ff088
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x400
        LDR.N    R1,??DataTable5_36  ;; 0x400ff088
        STR      R0,[R1, #+0]
??switch_test_7:
        LDR.N    R0,??DataTable5_35  ;; 0x400ff084
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x400
        LDR.N    R1,??DataTable5_35  ;; 0x400ff084
        STR      R0,[R1, #+0]
//  251          if (ELECTRODE2_ON) LED2_ON; LED2_OFF;
        LDR.N    R0,??DataTable5_37
        LDRB     R0,[R0, #+0]
        LSLS     R0,R0,#+30
        BPL.N    ??switch_test_8
        LDR.N    R0,??DataTable5_36  ;; 0x400ff088
        LDR      R0,[R0, #+0]
        MOV      R1,#+512
        ORRS     R0,R1,R0
        LDR.N    R1,??DataTable5_36  ;; 0x400ff088
        STR      R0,[R1, #+0]
??switch_test_8:
        LDR.N    R0,??DataTable5_35  ;; 0x400ff084
        LDR      R0,[R0, #+0]
        MOV      R1,#+512
        ORRS     R0,R1,R0
        LDR.N    R1,??DataTable5_35  ;; 0x400ff084
        STR      R0,[R1, #+0]
//  252 
//  253           
//  254         
//  255 
//  256         }
//  257         
//  258 }        
??switch_test_2:
        POP      {R0,PC}          ;; return

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??aux_sw1:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??aux_sw2:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??sw1_count:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
??sw2_count:
        DS8 1
//  259 
//  260 
//  261 
//  262 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  263 void accel_init(void)
//  264 {
accel_init:
        PUSH     {R7,LR}
//  265     unsigned char tmp;
//  266     printf("****Accelerometor init ****\n");
        LDR.N    R0,??DataTable5_38
        BL       printf
//  267     //Initialize I2C modules
//  268     hal_i2c_init();
        BL       hal_i2c_init
//  269    //Configure MMA8451 sensor //MMA8451Q
//  270     tmp = hal_dev_mma8451_read_reg(0x2a);
        MOVS     R0,#+42
        BL       hal_dev_mma8451_read_reg
//  271     hal_dev_mma8451_write_reg(0x2a,tmp|0x01);
        ORRS     R1,R0,#0x1
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        MOVS     R0,#+42
        BL       hal_dev_mma8451_write_reg
//  272 }
        POP      {R0,PC}          ;; return
//  273 
//  274 
//  275 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  276 void tone_accel_demo(void)
//  277 {
tone_accel_demo:
        PUSH     {R7,LR}
//  278   
//  279     static int note,notez;
//  280         note  = yz_angle/100;  //9-9
        LDR.N    R0,??DataTable5_39
        LDR      R0,[R0, #+0]
        MOVS     R1,#+100
        SDIV     R0,R0,R1
        LDR.N    R1,??DataTable5_40
        STR      R0,[R1, #+0]
//  281     
//  282         if (!ti_delay && !tone_enable) buzzer_off();
        LDR.N    R0,??DataTable5_10
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??tone_accel_demo_0
        LDR.N    R0,??DataTable5_3
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??tone_accel_demo_0
        BL       buzzer_off
//  283         if (note != notez && xz_mag > 20 && !ti_delay)
??tone_accel_demo_0:
        LDR.N    R0,??DataTable5_40
        LDR      R0,[R0, #+0]
        LDR.N    R1,??DataTable5_41
        LDR      R1,[R1, #+0]
        CMP      R0,R1
        BEQ.N    ??tone_accel_demo_1
        LDR.N    R0,??DataTable5_42
        LDR      R0,[R0, #+0]
        CMP      R0,#+21
        BCC.N    ??tone_accel_demo_1
        LDR.N    R0,??DataTable5_10
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BNE.N    ??tone_accel_demo_1
//  284         {
//  285         if (note <-9) note=-9;
        LDR.N    R0,??DataTable5_40
        LDR      R0,[R0, #+0]
        CMN      R0,#+9
        BGE.N    ??tone_accel_demo_2
        LDR.N    R0,??DataTable5_40
        MVNS     R1,#+8
        STR      R1,[R0, #+0]
//  286          if (note >9)  note =9;
??tone_accel_demo_2:
        LDR.N    R0,??DataTable5_40
        LDR      R0,[R0, #+0]
        CMP      R0,#+10
        BLT.N    ??tone_accel_demo_3
        LDR.N    R0,??DataTable5_40
        MOVS     R1,#+9
        STR      R1,[R0, #+0]
//  287 
//  288          if (notez < note) notez++;
??tone_accel_demo_3:
        LDR.N    R0,??DataTable5_41
        LDR      R0,[R0, #+0]
        LDR.N    R1,??DataTable5_40
        LDR      R1,[R1, #+0]
        CMP      R0,R1
        BGE.N    ??tone_accel_demo_4
        LDR.N    R0,??DataTable5_41
        LDR      R0,[R0, #+0]
        ADDS     R0,R0,#+1
        LDR.N    R1,??DataTable5_41
        STR      R0,[R1, #+0]
//  289          if (notez > note) notez--;
??tone_accel_demo_4:
        LDR.N    R0,??DataTable5_40
        LDR      R0,[R0, #+0]
        LDR.N    R1,??DataTable5_41
        LDR      R1,[R1, #+0]
        CMP      R0,R1
        BGE.N    ??tone_accel_demo_5
        LDR.N    R0,??DataTable5_41
        LDR      R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable5_41
        STR      R0,[R1, #+0]
//  290          set_out_module(C_MAJ_SCALE[9 - notez]); 
??tone_accel_demo_5:
        LDR.N    R0,??DataTable5_41
        LDR      R0,[R0, #+0]
        RSBS     R0,R0,#+0
        LDR.N    R1,??DataTable5_43
        ADDS     R0,R1,R0, LSL #+1
        LDRH     R0,[R0, #+18]
        BL       set_out_module
//  291          ti_delay = 75;
        LDR.N    R0,??DataTable5_10
        MOVS     R1,#+75
        STR      R1,[R0, #+0]
//  292          buzzer_on();
        BL       buzzer_on
//  293         }
//  294         
//  295 
//  296         
//  297 }
??tone_accel_demo_1:
        POP      {R0,PC}          ;; return

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
??note:
        DS8 4

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
??notez:
        DS8 4
//  298 
//  299 /*if read available update  accel_x,accel_y and accel_z */

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  300 void accel_read(void)
//  301 {
accel_read:
        PUSH     {R7,LR}
//  302         if((hal_dev_mma8451_read_reg(0x00)&0xf) != 0)
        MOVS     R0,#+0
        BL       hal_dev_mma8451_read_reg
        MOVS     R1,#+15
        TST      R0,R1
        BEQ.N    ??accel_read_0
//  303         {
//  304 #if 0
//  305             accel_x   = hal_dev_mma8451_read_reg(0x01)<<8;
//  306             accel_x  |= hal_dev_mma8451_read_reg(0x02);
//  307             accel_x >>= 2;
//  308 
//  309             accel_y   = hal_dev_mma8451_read_reg(0x03)<<8;
//  310             accel_y  |= hal_dev_mma8451_read_reg(0x04);
//  311             accel_y >>= 2;
//  312 
//  313             accel_z   = hal_dev_mma8451_read_reg(0x05)<<8;
//  314             accel_z  |= hal_dev_mma8451_read_reg(0x06);
//  315             accel_z >>= 2;
//  316 #endif
//  317             resultx   = hal_dev_mma8451_read_reg(0x01)<<8;
        MOVS     R0,#+1
        BL       hal_dev_mma8451_read_reg
        LSLS     R0,R0,#+8
        LDR.N    R1,??DataTable5_44
        STRH     R0,[R1, #+0]
//  318             resultx  |= hal_dev_mma8451_read_reg(0x02);
        MOVS     R0,#+2
        BL       hal_dev_mma8451_read_reg
        LDR.N    R1,??DataTable5_44
        LDRH     R1,[R1, #+0]
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        ORRS     R0,R0,R1
        LDR.N    R1,??DataTable5_44
        STRH     R0,[R1, #+0]
//  319             resultx >>= 8;
        LDR.N    R0,??DataTable5_44
        LDRSH    R0,[R0, #+0]
        SXTH     R0,R0            ;; SignExt  R0,R0,#+16,#+16
        ASRS     R0,R0,#+8
        LDR.N    R1,??DataTable5_44
        STRH     R0,[R1, #+0]
//  320 
//  321             resulty   = hal_dev_mma8451_read_reg(0x03)<<8;
        MOVS     R0,#+3
        BL       hal_dev_mma8451_read_reg
        LSLS     R0,R0,#+8
        LDR.N    R1,??DataTable5_45
        STRH     R0,[R1, #+0]
//  322             resulty  |= hal_dev_mma8451_read_reg(0x04);
        MOVS     R0,#+4
        BL       hal_dev_mma8451_read_reg
        LDR.N    R1,??DataTable5_45
        LDRH     R1,[R1, #+0]
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        ORRS     R0,R0,R1
        LDR.N    R1,??DataTable5_45
        STRH     R0,[R1, #+0]
//  323             resulty >>= 8;
        LDR.N    R0,??DataTable5_45
        LDRSH    R0,[R0, #+0]
        SXTH     R0,R0            ;; SignExt  R0,R0,#+16,#+16
        ASRS     R0,R0,#+8
        LDR.N    R1,??DataTable5_45
        STRH     R0,[R1, #+0]
//  324 
//  325             resultz   = hal_dev_mma8451_read_reg(0x05)<<8;
        MOVS     R0,#+5
        BL       hal_dev_mma8451_read_reg
        LSLS     R0,R0,#+8
        LDR.N    R1,??DataTable5_46
        STRH     R0,[R1, #+0]
//  326             resultz  |= hal_dev_mma8451_read_reg(0x06);
        MOVS     R0,#+6
        BL       hal_dev_mma8451_read_reg
        LDR.N    R1,??DataTable5_46
        LDRH     R1,[R1, #+0]
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        ORRS     R0,R0,R1
        LDR.N    R1,??DataTable5_46
        STRH     R0,[R1, #+0]
//  327             resultz >>= 8;
        LDR.N    R0,??DataTable5_46
        LDRSH    R0,[R0, #+0]
        SXTH     R0,R0            ;; SignExt  R0,R0,#+16,#+16
        ASRS     R0,R0,#+8
        LDR.N    R1,??DataTable5_46
        STRH     R0,[R1, #+0]
//  328             
//  329             
//  330             
//  331             angle_calculation(); //-900  to  900            
        BL       angle_calculation
//  332             detect_fall_detection();
        BL       detect_fall_detection
//  333             
//  334             tone_accel_demo();
        BL       tone_accel_demo
//  335             
//  336             
//  337         }
//  338         
//  339     
//  340 }
??accel_read_0:
        POP      {R0,PC}          ;; return

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5:
        DC32     `?<Constant "\\n TWRK20D50M Demo Sof...">`

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

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

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

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

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

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

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

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

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5_9:
        DC32     `?<Constant "\\n\\r i\\'m falling!!! %i \\n\\r">`

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

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

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

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

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

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

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

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

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

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

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

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

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5_22:
        DC32     `?<Constant "\\n\\r tone detected %3i\\n\\r ">`

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

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

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5_25:
        DC32     `?<Constant "\\n\\r clap/snap detected...">`

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

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

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

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

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5_30:
        DC32     `?<Constant "\\n\\r push_button (SW3) ...">`

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

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

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5_33:
        DC32     `?<Constant "\\n\\r push_button (SW2) ...">`

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

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

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

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

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable5_38:
        DC32     `?<Constant "****Accelerometor ini...">`

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

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

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

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

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

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

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

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

        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 "\\n TWRK20D50M Demo Sof...">`:
        DATA
        DC8 "\012 TWRK20D50M Demo Software Rev 1.4 \012"
        DC8 0, 0, 0

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
        DATA
        DC8 "\012 >"

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "\\n\\r tone detected %3i\\n\\r ">`:
        DATA
        DC8 "\012\015 tone detected %3i\012\015 "

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "\\n\\r clap/snap detected...">`:
        DATA
        DC8 "\012\015 clap/snap detected  %3i \012\015 "
        DC8 0

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "\\n\\r i\\'m falling!!! %i \\n\\r">`:
        DATA
        DC8 "\012\015 i'm falling!!! %i \012\015"

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "\\n\\r push_button (SW3) ...">`:
        DATA
        DC8 "\012\015 push_button (SW3)  %i \012\015"

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "\\n\\r push_button (SW2) ...">`:
        DATA
        DC8 "\012\015 push_button (SW2) %i \012\015"
        DC8 0

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
`?<Constant "****Accelerometor ini...">`:
        DATA
        DC8 "****Accelerometor init ****\012"
        DC8 0, 0, 0

        END
//  341 
//  342 
//  343 
// 
//    31 bytes in section .bss
//   212 bytes in section .rodata
// 1 338 bytes in section .text
// 
// 1 338 bytes of CODE  memory
//   212 bytes of CONST memory
//    31 bytes of DATA  memory
//
//Errors: none
//Warnings: 1
