///////////////////////////////////////////////////////////////////////////////
//
// 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.c
//    Command line =  
//        F:\2-Lora\Code\stm8l151K6T6-WLAN\BSP\bsp.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.s
//
///////////////////////////////////////////////////////////////////////////////

        EXTERN ?b0
        EXTERN ?b1
        EXTERN ?w0
        EXTERN ?w1
        EXTERN ADC_Cmd
        EXTERN ADC_Init
        EXTERN ADC_SamplingTimeConfig
        EXTERN CLK_PeripheralClockConfig
        EXTERN FixedParaDeal
        EXTERN IWDG_Enable
        EXTERN IWDG_ReloadCounter
        EXTERN IWDG_SetPrescaler
        EXTERN IWDG_SetReload
        EXTERN IWDG_WriteAccessCmd
        EXTERN SoftDelayMs
        EXTERN SpiInit1
        EXTERN bsp_clk_init
        EXTERN bsp_gpio_init
        EXTERN bsp_time4_init
        EXTERN bsp_usart_init
        EXTERN printf

        PUBLIC AdcInit
        PUBLIC FeedWatchDog
        PUBLIC WatchDogInit
        PUBLIC bsp_init

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

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//    2 void AdcInit(void)
//    3 {
//    4         CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
AdcInit:
        MOV       S:?b0, #0x1
        LD        A, #0x10
        CALL      L:CLK_PeripheralClockConfig
//    5 	ADC_Init(ADC1,ADC_ConversionMode_Single,ADC_Resolution_12Bit,ADC_Prescaler_1);
        CLR       S:?b1
        CLR       S:?b0
        CLR       A
        LDW       X, #0x5340
        CALL      L:ADC_Init
//    6 	ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_384Cycles);
        MOV       S:?b0, #0x7
        CLR       A
        LDW       X, #0x5340
        CALL      L:ADC_SamplingTimeConfig
//    7 	ADC_Cmd(ADC1,ENABLE); 
        LD        A, #0x1
        LDW       X, #0x5340
        CALL      L:ADC_Cmd
//    8         ADC_Cmd(ADC1,DISABLE);      
        CLR       A
        LDW       X, #0x5340
        JP        L:ADC_Cmd
//    9 }

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   10 void bsp_init(void)
//   11 {
//   12       disableInterrupts();
bsp_init:
        SIM
//   13       bsp_clk_init();
        CALL      L:bsp_clk_init
//   14       bsp_time4_init();
        CALL      L:bsp_time4_init
//   15       bsp_usart_init();
        CALL      L:bsp_usart_init
//   16       SpiInit1();
        CALL      L:SpiInit1
//   17       bsp_gpio_init();
        CALL      L:bsp_gpio_init
//   18       SoftDelayMs(10);
        LDW       X, #0xa
        LDW       S:?w1, X
        CLRW      X
        LDW       S:?w0, X
        CALL      L:SoftDelayMs
//   19       FixedParaDeal();
        CALL      L:FixedParaDeal
//   20       SoftDelayMs(10);
        LDW       X, #0xa
        LDW       S:?w1, X
        CLRW      X
        LDW       S:?w0, X
        CALL      L:SoftDelayMs
//   21       printf("AT+RST:OK!\r\n");
        LDW       X, #?_0
        CALL      L:printf
//   22       WatchDogInit();
        CALL      L:WatchDogInit
//   23       enableInterrupts();
        RIM
//   24 }
        RET
//   25 
//   26 

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   27 void WatchDogInit(void)
//   28 {
//   29     IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);//允许操作独立看门狗
WatchDogInit:
        LD        A, #0x55
        CALL      L:IWDG_WriteAccessCmd
//   30     IWDG_SetPrescaler(IWDG_Prescaler_256);//看门狗预分频
        LD        A, #0x6
        CALL      L:IWDG_SetPrescaler
//   31     IWDG_SetReload(IWDG_500MS_REST);//设置看门狗复位时间
        LD        A, #0xfa
        CALL      L:IWDG_SetReload
//   32     IWDG_Enable();//启动独立看门狗
        JP        L:IWDG_Enable
//   33 }
//   34 

        SECTION `.near_func.text`:CODE:REORDER:NOROOT(0)
        CODE
//   35 void FeedWatchDog(void)
//   36 {
//   37     IWDG_ReloadCounter();//看门狗复位 正常使用时不想发生看门狗复位，就执行
FeedWatchDog:
        JP        L:IWDG_ReloadCounter
//   38 }

        SECTION VREGS:DATA:REORDER:NOROOT(0)

        SECTION `.near.rodata`:CONST:REORDER:NOROOT(0)
?_0:
        DC8 "AT+RST:OK!\015\012"

        END
//   39   
//   40   
//   41   
//   42   
// 
//  13 bytes in section .near.rodata
// 119 bytes in section .near_func.text
// 
// 119 bytes of CODE  memory
//  13 bytes of CONST memory
//
//Errors: none
//Warnings: none
