///////////////////////////////////////////////////////////////////////////////
//
// IAR C/C++ Compiler V2.10.4.157 for STM8                10/Aug/2020  13:50:17
// Copyright 2010-2015 IAR Systems AB.
//
//    Source file  =  F:\2-Lora\Code\stm8l151K6T6-WLAN\BSP\bsp_gpio.c
//    Command line =  
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\BSP\bsp_gpio.c -e -Ol --no_cse
//        --no_unroll --no_inline --no_code_motion --no_tbaa --no_cross_call
//        --debug --code_model small --data_model medium -o
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\Debug\Obj\ --dlib_config
//        E:\IAR\stm8\LIB\dlstm8smf.h -lB
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\Debug\List\ -I
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\FWLIB\inc\ -I
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\FWLIB\src\ -I
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\USER\ -I
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\BSP\ -I
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\radio\ -I
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\SX1278\ --vregs 16
//    List file    =  F:\2-Lora\Code\stm8l151K6T6-WLAN\Debug\List\bsp_gpio.s
//
///////////////////////////////////////////////////////////////////////////////

        EXTERN ?b0
        EXTERN ?dec32_l0_l0
        EXTERN ?inc32_l0_l0
        EXTERN ?load32_0x_l0
        EXTERN ?load32_l0_0x
        EXTERN ?mul32_l0_l0_dl
        EXTERN ?w0
        EXTERN ?w1
        EXTERN GPIO_Init
        EXTERN GPIO_ToggleBits
        EXTERN GPIO_WriteBit
        EXTERN bsp_DelayMS

        PUBLIC BeepCheck
        PUBLIC BeepStart
        PUBLIC BeepStop
        PUBLIC LedStr
        PUBLIC LedTest
        PUBLIC UserBeep
        PUBLIC bsp_beep_one
        PUBLIC bsp_beep_two
        PUBLIC bsp_gpio_init

// F:\2-Lora\Code\stm8l151K6T6-WLAN\BSP\bsp_gpio.c
//    1 #include "bsp_gpio.h"
//    2 /***************GPIO_init***************/

        SECTION `.near.bss`:DATA:REORDER:NOROOT(0)
//    3 USERSTR LedStr;
LedStr:
        DS8 5

        SECTION `.near.bss`:DATA:REORDER:NOROOT(0)
//    4 struct BEEP_STR UserBeep;
UserBeep:
        DS8 6

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//    5 void bsp_gpio_init(void)
//    6 {
//    7       //LED灯初始化
//    8 //      GPIOB->DDR = 0x02;
//    9 //      GPIOB->CR1 = 0x02;
//   10 //      GPIOB->CR2 = 0x02;
//   11 //      GPIOB->ODR = 0x02;
//   12 
//   13       GPIO_Init(LED_GPIO,LED1_PIN,GPIO_Mode_Out_PP_Low_Fast);
bsp_gpio_init:
        MOV       S:?b0, #0xe0
        LD        A, #0x20
        LDW       X, #0x5000
        CALL      L:GPIO_Init
//   14       GPIO_Init(LED_GPIO,LED2_PIN,GPIO_Mode_Out_PP_Low_Fast);
        MOV       S:?b0, #0xe0
        LD        A, #0x10
        LDW       X, #0x5000
        CALL      L:GPIO_Init
//   15       //蜂鸣器pin初始化
//   16       GPIO_Init(LIMIT_GPIO,LIMIT_PIN,GPIO_Mode_In_FL_No_IT);
        CLR       S:?b0
        LD        A, #0x1
        LDW       X, #0x5005
        CALL      L:GPIO_Init
//   17       GPIO_Init(BEEP_GPIO,BEEP_PIN,GPIO_Mode_Out_PP_Low_Slow);
        MOV       S:?b0, #0xc0
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_Init
//   18 }
//   19 

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   20 void LedTest(void)
//   21 {
//   22      if(!LEDTEST)return;
//   23      if(LedStr.Cnt>0)return;
LedTest:
        LDW       X, #LedStr + 1
        CALL      L:?load32_l0_0x
        LDW       X, S:?w0
        CPW       X, #0x0
        JRNE      L:??LedTest_0
        LDW       X, S:?w1
        CPW       X, #0x0
??LedTest_0:
        JRNE      L:??LedTest_1
//   24      LedStr.Cnt = 1000;
        LDW       X, #0x0
        LDW       L:LedStr + 1, X
        LDW       X, #0x3e8
        LDW       L:LedStr + 3, X
//   25      GPIO_ToggleBits(LED_GPIO,LED1_PIN);
        LD        A, #0x20
        LDW       X, #0x5000
        CALL      L:GPIO_ToggleBits
//   26 }
??LedTest_1:
        RET
//   27 /*
//   28 if(time_count4==0)
//   29           {
//   30               time_count4 = 4000;
//   31           }
//   32           else if(time_count4<=10)
//   33           {
//   34               GPIO_WriteBit(GPIOB,GPIO_Pin_3,SET);
//   35           }
//   36           else
//   37           {
//   38               GPIO_WriteBit(GPIOB,GPIO_Pin_3,RESET);
//   39           }
//   40 */

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   41 void bsp_beep_one(void)
//   42 {
//   43       GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,SET);
bsp_beep_one:
        MOV       S:?b0, #0x1
        LD        A, #0x2
        LDW       X, #0x500f
        CALL      L:GPIO_WriteBit
//   44       bsp_DelayMS(50);
        LDW       X, #0x32
        CALL      L:bsp_DelayMS
//   45       GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,RESET);
        CLR       S:?b0
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_WriteBit
//   46 }
//   47 

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   48 void bsp_beep_two(void)
//   49 {
//   50       GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,SET);
bsp_beep_two:
        MOV       S:?b0, #0x1
        LD        A, #0x2
        LDW       X, #0x500f
        CALL      L:GPIO_WriteBit
//   51       bsp_DelayMS(BEEPTIMR);
        LDW       X, #0x32
        CALL      L:bsp_DelayMS
//   52       GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,RESET);
        CLR       S:?b0
        LD        A, #0x2
        LDW       X, #0x500f
        CALL      L:GPIO_WriteBit
//   53       bsp_DelayMS(BEEPTIMR*2);
        LDW       X, #0x64
        CALL      L:bsp_DelayMS
//   54       GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,SET);
        MOV       S:?b0, #0x1
        LD        A, #0x2
        LDW       X, #0x500f
        CALL      L:GPIO_WriteBit
//   55       bsp_DelayMS(BEEPTIMR);
        LDW       X, #0x32
        CALL      L:bsp_DelayMS
//   56       GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,RESET);
        CLR       S:?b0
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_WriteBit
//   57 }
//   58 
//   59 

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   60 void BeepCheck(void)
//   61 {
//   62     static uint32_t tim_cnt = 0;
//   63     if(UserBeep.BeepFlag==1)
BeepCheck:
        LD        A, L:UserBeep
        CP        A, #0x1
        JREQ      ??lb_0
        JP        L:??BeepCheck_0
//   64     {
//   65         if(UserBeep.times==0)
??lb_0:
        LDW       X, #UserBeep + 2
        CALL      L:?load32_l0_0x
        LDW       X, S:?w0
        CPW       X, #0x0
        JRNE      L:??BeepCheck_1
        LDW       X, S:?w1
        CPW       X, #0x0
??BeepCheck_1:
        JRNE      L:??BeepCheck_2
//   66         {
//   67           UserBeep.BeepFlag = 0;
        MOV       L:UserBeep, #0x0
//   68           tim_cnt = 0;
        LDW       X, #0x0
        LDW       L:??tim_cnt, X
        LDW       X, #0x0
        LDW       L:??tim_cnt + 2, X
//   69           GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,RESET);
        CLR       S:?b0
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_WriteBit
//   70           return ;
//   71         }
//   72         tim_cnt++;
??BeepCheck_2:
        LDW       X, #??tim_cnt
        CALL      L:?load32_l0_0x
        CALL      L:?inc32_l0_l0
        LDW       X, #??tim_cnt
        CALL      L:?load32_0x_l0
//   73         if(UserBeep.Model==0)
        LD        A, L:UserBeep + 1
        CP        A, #0x0
        JRNE      L:??BeepCheck_3
//   74         {
//   75           if(tim_cnt>=10)
        LDW       X, #??tim_cnt
        CALL      L:?load32_l0_0x
        LDW       X, S:?w0
        CPW       X, #0x0
        JRNE      L:??BeepCheck_4
        LDW       X, S:?w1
        CPW       X, #0xa
??BeepCheck_4:
        JRNC      ??lb_1
        JP        L:??BeepCheck_0
//   76           {
//   77             if(UserBeep.times--);
??lb_1:
        LDW       X, #UserBeep + 2
        CALL      L:?load32_l0_0x
        CALL      L:?dec32_l0_l0
        LDW       X, #UserBeep + 2
        CALL      L:?load32_0x_l0
//   78             tim_cnt = 0;
        LDW       X, #0x0
        LDW       L:??tim_cnt, X
        LDW       X, #0x0
        LDW       L:??tim_cnt + 2, X
//   79             GPIO_ToggleBits(BEEP_GPIO,BEEP_PIN);
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_ToggleBits
//   80           }
//   81         }
//   82         else if(UserBeep.Model==1)
??BeepCheck_3:
        LD        A, L:UserBeep + 1
        CP        A, #0x1
        JRNE      L:??BeepCheck_0
//   83         {
//   84           if(tim_cnt==50)
        LDW       X, #??tim_cnt
        CALL      L:?load32_l0_0x
        LDW       X, S:?w0
        CPW       X, #0x0
        JRNE      L:??BeepCheck_5
        LDW       X, S:?w1
        CPW       X, #0x32
??BeepCheck_5:
        JRNE      L:??BeepCheck_6
//   85           {
//   86             if(UserBeep.times--);
        LDW       X, #UserBeep + 2
        CALL      L:?load32_l0_0x
        CALL      L:?dec32_l0_l0
        LDW       X, #UserBeep + 2
        CALL      L:?load32_0x_l0
//   87             GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,SET);
        MOV       S:?b0, #0x1
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_WriteBit
//   88           }
//   89           else if(tim_cnt==200)
??BeepCheck_6:
        LDW       X, #??tim_cnt
        CALL      L:?load32_l0_0x
        LDW       X, S:?w0
        CPW       X, #0x0
        JRNE      L:??BeepCheck_7
        LDW       X, S:?w1
        CPW       X, #0xc8
??BeepCheck_7:
        JRNE      L:??BeepCheck_0
//   90           {
//   91             tim_cnt = 0;
        LDW       X, #0x0
        LDW       L:??tim_cnt, X
        LDW       X, #0x0
        LDW       L:??tim_cnt + 2, X
//   92             if(UserBeep.times--);
        LDW       X, #UserBeep + 2
        CALL      L:?load32_l0_0x
        CALL      L:?dec32_l0_l0
        LDW       X, #UserBeep + 2
        CALL      L:?load32_0x_l0
//   93             GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,RESET);
        CLR       S:?b0
        LD        A, #0x2
        LDW       X, #0x500f
        CALL      L:GPIO_WriteBit
//   94           }
//   95 
//   96         }
//   97     }
//   98 }
??BeepCheck_0:
        RET

        SECTION `.near.bss`:DATA:REORDER:NOROOT(0)
??tim_cnt:
        DS8 4

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   99 void BeepStart(uint32_t times,bool Model)
//  100 {
//  101     UserBeep.BeepFlag = 1;
BeepStart:
        MOV       L:UserBeep, #0x1
//  102     UserBeep.Model = Model;
        LD        L:UserBeep + 1, A
//  103     UserBeep.times = 2*times;
        CALL      L:?mul32_l0_l0_dl
        DATA
        DC32      0x2
        CODE
        LDW       X, #UserBeep + 2
        JP        L:?load32_0x_l0
//  104 }
//  105 

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//  106 void BeepStop(void)
//  107 {
//  108     UserBeep.BeepFlag = 0;
BeepStop:
        MOV       L:UserBeep, #0x0
//  109     GPIO_WriteBit(BEEP_GPIO,BEEP_PIN,RESET);
        CLR       S:?b0
        LD        A, #0x2
        LDW       X, #0x500f
        JP        L:GPIO_WriteBit
//  110 }

        SECTION VREGS:DATA:REORDER:NOROOT(0)

        END
// 
//  15 bytes in section .near.bss
// 459 bytes in section .near_func.text
// 
// 459 bytes of CODE memory
//  15 bytes of DATA memory
//
//Errors: none
//Warnings: 3
