///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR ANSI C/C++ Compiler V6.30.1.53127/W32 for ARM    08/Mar/2012  18:18:20 /
// 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\I2C\hal_dev_mma8451.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\I2C\hal_dev_mma8451.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\ha /
//                    l_dev_mma8451.s                                         /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME hal_dev_mma8451

        #define SHT_PROGBITS 0x1

        EXTERN i2c_get_ack
        EXTERN i2c_give_nack
        EXTERN i2c_read_byte
        EXTERN i2c_repeated_start
        EXTERN i2c_set_rx_mode
        EXTERN i2c_start
        EXTERN i2c_stop
        EXTERN i2c_wait
        EXTERN i2c_write_byte

        PUBLIC hal_dev_mma8451_read_reg
        PUBLIC hal_dev_mma8451_write_reg

// D:\Profiles\b01252\My Documents\Freescale\P0\software\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\src\projects\TWRK20D50M_Demo\I2C\hal_dev_mma8451.c
//    1 
//    2 
//    3 #include "common.h"
//    4 #include "hal_i2c.h"
//    5 
//    6 
//    7 
//    8 #define MMA8451_I2C_ADDRESS (0x1d<<1)
//    9 #define I2C0_B I2C0_BASE_PTR
//   10 
//   11 
//   12 // this delay is very important, it may cause w-r operation failure.

        SECTION `.text`:CODE:NOROOT(2)
        THUMB
//   13 static void pause(void)
//   14 {
//   15     int n;
//   16     for(n=0; n<40; n++)
pause:
        MOVS     R0,#+0
        B.N      ??pause_0
//   17         asm("nop");
??pause_1:
        nop              
        ADDS     R0,R0,#+1
??pause_0:
        CMP      R0,#+40
        BLT.N    ??pause_1
//   18 }
        BX       LR               ;; return

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   19 uint8 hal_dev_mma8451_read_reg(uint8 addr)
//   20 {
hal_dev_mma8451_read_reg:
        PUSH     {R4,LR}
        MOVS     R4,R0
//   21     uint8 result;
//   22 
//   23     i2c_start(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_start
//   24     i2c_write_byte(I2C0_B, MMA8451_I2C_ADDRESS | I2C_WRITE);
        MOVS     R1,#+58
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_write_byte
//   25     
//   26     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   27     i2c_get_ack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_get_ack
//   28 
//   29     i2c_write_byte(I2C0_B, addr);
        MOVS     R1,R4
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_write_byte
//   30     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   31     i2c_get_ack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_get_ack
//   32 
//   33     i2c_repeated_start(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_repeated_start
//   34     i2c_write_byte(I2C0_B, MMA8451_I2C_ADDRESS | I2C_READ);
        MOVS     R1,#+59
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_write_byte
//   35     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   36     i2c_get_ack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_get_ack
//   37 
//   38     i2c_set_rx_mode(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_set_rx_mode
//   39 
//   40     i2c_give_nack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_give_nack
//   41     result = i2c_read_byte(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_read_byte
        MOVS     R4,R0
//   42     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   43 
//   44     i2c_stop(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_stop
//   45     result = i2c_read_byte(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_read_byte
        MOVS     R4,R0
//   46     pause();
        BL       pause
//   47     return result;
        MOVS     R0,R4
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        POP      {R4,PC}          ;; return
//   48 }

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   49 void hal_dev_mma8451_write_reg(uint8 addr, uint8 data)
//   50 {
hal_dev_mma8451_write_reg:
        PUSH     {R3-R5,LR}
        MOVS     R4,R0
        MOVS     R5,R1
//   51     i2c_start(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_start
//   52 
//   53     i2c_write_byte(I2C0_B, MMA8451_I2C_ADDRESS|I2C_WRITE);
        MOVS     R1,#+58
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_write_byte
//   54     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   55     i2c_get_ack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_get_ack
//   56 
//   57     i2c_write_byte(I2C0_B, addr);
        MOVS     R1,R4
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_write_byte
//   58     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   59     i2c_get_ack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_get_ack
//   60 
//   61     i2c_write_byte(I2C0_B, data);
        MOVS     R1,R5
        UXTB     R1,R1            ;; ZeroExt  R1,R1,#+24,#+24
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_write_byte
//   62     i2c_wait(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_wait
//   63     i2c_get_ack(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_get_ack
//   64 
//   65     i2c_stop(I2C0_B);
        LDR.N    R0,??DataTable1  ;; 0x40066000
        BL       i2c_stop
//   66     pause();
        BL       pause
//   67 }
        POP      {R0,R4,R5,PC}    ;; return

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

        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
//   68 
//   69 
//   70 
//   71 
//   72 
// 
// 234 bytes in section .text
// 
// 234 bytes of CODE memory
//
//Errors: none
//Warnings: none
