Index: LPM_SLEEP/lpm_demo/prj/GCC/c.bat
===================================================================
--- /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/GCC/c.bat	(nonexistent)
+++ /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/GCC/c.bat	(working copy)
@@ -0,0 +1,3 @@
+cls
+make clean
+make
\ No newline at end of file
Index: LPM_SLEEP/lpm_demo/prj/GCC/makefile
===================================================================
--- /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/GCC/makefile	(nonexistent)
+++ /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/GCC/makefile	(working copy)
@@ -0,0 +1,240 @@
+
+ifeq ($(OS),Windows_NT)
+DIR = C:/gcc-arm-none-eabi-7-2018-q2-update-win32
+else
+DIR = /usr/gcc-arm-none-eabi-7-2018-q2-update
+endif
+
+ARCH = $(DIR)/bin/arm-none-eabi
+GCC = $(ARCH)-gcc
+LD = $(ARCH)-ld
+AS = $(ARCH)-as
+OBJCOPY = $(ARCH)-objcopy
+OBJDUMP = "$(ARCH)-objdump"
+LIB_PATH = ../../../../../Librarier
+USER_PATH = ../../user
+
+
+all : output/out.hex
+
+
+CORE_OBJS =  $(LIB_PATH)/startup/flash_start_gcc \
+             $(LIB_PATH)/core/system \
+             $(LIB_PATH)/core/bt_code \
+             $(LIB_PATH)/core/misc \
+             $(LIB_PATH)/sdk/yc_gpio \
+             $(LIB_PATH)/sdk/yc_uart \
+             $(LIB_PATH)/sdk/yc_lpm \
+             $(LIB_PATH)/sdk/yc_sysctrl \
+             $(LIB_PATH)/sdk/yc_bt \
+             $(LIB_PATH)/sdk/yc_systick \
+             $(LIB_PATH)/sdk/yc_ipc \
+             $(LIB_PATH)/sdk/yc_otp \
+			 $(LIB_PATH)/sdk/yc_trng \
+			 $(LIB_PATH)/sdk/yc_adc \
+			 $(LIB_PATH)/sdk/yc_power \
+			 $(LIB_PATH)/sdk/yc_ssc \
+             $(LIB_PATH)/sdk/yc_timer
+
+
+USER_OBJS = $(USER_PATH)/main
+
+
+OBJS = $(CORE_OBJS) $(USER_OBJS)
+
+INC_DIR = -I $(LIB_PATH)/core \
+          -I $(LIB_PATH)/sdk
+
+
+CFLAG =  -mthumb -mcpu=cortex-m0 -c -g -Os $(INC_DIR) $(DEF) -fno-toplevel-reorder -ffunction-sections -fdata-sections
+LDFLAG = -T output/ld.script -Map=output/memmap  $(LIB_PATH)/sdk/libyc_qspi.a -lc -lm -lgcc -L "$(DIR)/lib/gcc/arm-none-eabi/7.3.1/thumb/v6-m"  -L "$(DIR)/arm-none-eabi/lib/thumb/v6-m"
+
+define ldscript =
+/* Linker script to configure memory regions.
+ * Need modifying for a specific board.
+ *   FLASH.ORIGIN: starting address of flash
+ *   FLASH.LENGTH: length of flash
+ *   RAM.ORIGIN: starting address of RAM bank 0
+ *   RAM.LENGTH: length of RAM bank 0
+ */
+MEMORY
+{
+  FLASH (rx) : ORIGIN = 0x1000000, LENGTH = 0x80000 /* 512K */
+  RAM (rwx) : ORIGIN = 0x20000, LENGTH = 0x10000 /* 64K */
+}
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ *   Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ *   __exidx_start
+ *   __exidx_end
+ *   __copy_table_start__
+ *   __copy_table_end__
+ *   __zero_table_start__
+ *   __zero_table_end__
+ *   __etext
+ *   __data_start__
+ *   __preinit_array_start
+ *   __preinit_array_end
+ *   __init_array_start
+ *   __init_array_end
+ *   __fini_array_start
+ *   __fini_array_end
+ *   __data_end__
+ *   __bss_start__
+ *   __bss_end__
+ *   __end__
+ *   end
+ *   __HeapLimit
+ *   __StackLimit
+ *   __StackTop
+ *   __stack
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+	.text :
+	{
+		*flash_start*.o
+		*(.text*)
+
+		KEEP(*(.init))
+		KEEP(*(.fini))
+
+		/* .ctors */
+		*crtbegin.o(.ctors)
+		*crtbegin?.o(.ctors)
+		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+		*(SORT(.ctors.*))
+		*(.ctors)
+
+		/* .dtors */
+ 		*crtbegin.o(.dtors)
+ 		*crtbegin?.o(.dtors)
+ 		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ 		*(SORT(.dtors.*))
+ 		*(.dtors)
+
+		*(.rodata*)
+
+		KEEP(*(.eh_frame*))
+	} > FLASH
+
+
+
+	.ARM.extab :
+	{
+		*(.ARM.extab* .gnu.linkonce.armextab.*)
+	} > FLASH
+
+
+	.ARM.exidx :
+	{
+		*(.ARM.exidx* .gnu.linkonce.armexidx.*)
+	} > FLASH
+
+	 . = ALIGN(4);
+	__exidx_start = .;
+
+	__etext = .;
+
+	.data : AT (__etext)
+	{
+		__data_start__ = .;
+		*(vtable)
+		*(.data*)
+
+		. = ALIGN(4);
+		/* preinit data */
+		PROVIDE_HIDDEN (__preinit_array_start = .);
+		KEEP(*(.preinit_array))
+		PROVIDE_HIDDEN (__preinit_array_end = .);
+
+		. = ALIGN(4);
+		/* init data */
+		PROVIDE_HIDDEN (__init_array_start = .);
+		KEEP(*(SORT(.init_array.*)))
+		KEEP(*(.init_array))
+		PROVIDE_HIDDEN (__init_array_end = .);
+
+
+		. = ALIGN(4);
+		/* finit data */
+		PROVIDE_HIDDEN (__fini_array_start = .);
+		KEEP(*(SORT(.fini_array.*)))
+		KEEP(*(.fini_array))
+		PROVIDE_HIDDEN (__fini_array_end = .);
+
+		KEEP(*(.jcr*))
+		. = ALIGN(4);
+		/* All data end */
+		__data_end__ = .;
+
+	} > RAM
+
+	.bss :
+	{
+		. = ALIGN(4);
+		__bss_start__ = .;
+		*(.bss*)
+		*(COMMON)
+		. = ALIGN(4);
+		__bss_end__ = .;
+	} > RAM
+
+	.heap (COPY):
+	{
+		__end__ = .;
+		PROVIDE(end = .);
+		*(.heap*)
+		__HeapLimit = .;
+	} > RAM
+
+	/* .stack_dummy section doesn't contains any symbols. It is only
+	 * used for linker to calculate size of stack sections, and assign
+	 * values to stack symbols later */
+	.stack_dummy (COPY):
+	{
+		*(.stack*)
+	} > RAM
+
+	/* Set stack top to end of RAM, and stack limit move down by
+	 * size of stack_dummy section */
+	__StackTop = ORIGIN(RAM) + LENGTH(RAM);
+	__StackLimit = __StackTop - SIZEOF(.stack_dummy);
+	PROVIDE(__stack = __StackTop);
+
+	/* Check if data + heap + stack exceeds RAM limit */
+	ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
+endef
+
+
+output/out.hex : output/out
+	$(OBJCOPY) $^ -O ihex $@
+
+
+output/out : $(addprefix output/, $(addsuffix .o, $(OBJS)))
+	$(file >output/ld.script, $(ldscript))
+	$(LD) $(addprefix output/obj/,$(addsuffix .o, $(notdir $(OBJS)))) -o $@ $(LDFLAG)
+	$(OBJDUMP) -S $@ > output/disasm
+
+output/%.o : %.c
+	$(GCC) $< $(CFLAG) -o output/obj/$(notdir $@)
+
+output/%.o : %.s
+	$(AS) $^ -mthumb -mcpu=cortex-m0 -o output/obj/$(notdir $@)
+
+
+clean :
+ifeq ($(OS),Windows_NT)
+	del /Q output\*.*
+	del /Q output\obj\*.*
+else
+	rm -rf output/*
+	rm -rf output/obj/*
+endif
Index: LPM_SLEEP/lpm_demo/prj/MDK/Objects/YC3121_keil.sct
===================================================================
--- /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/MDK/Objects/YC3121_keil.sct	(nonexistent)
+++ /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/MDK/Objects/YC3121_keil.sct	(working copy)
@@ -0,0 +1,55 @@
+; *************************************************************
+; *** Scatter-Loading Description File generated by uVision ***
+; *************************************************************
+
+LR_IROM1 0x00000000 0x0001fff  {    ; load region size_region
+  ER_IROM1 0x00000000 0x00001fff  {  ; load address = execution address
+   startup.o (RESET, +First)
+   startup.o (|.text|,+RO)
+;   *(InRoot$$Sections)
+  }
+  ;ER_IROM2 0x4000   {
+  ;rom_main.o (+RO)
+  ;}
+  
+  ;ER_IROM3 0x100000 {
+	  ;*(InRoot$$Sections)
+  ;}
+	
+  ;ER_IROM4 0x100400   {
+  ;flash_start.o (+RO)
+  ;.ANY (+RO) 
+  ;}
+  
+  ;RW_IRAM1 0x000d0000 0x0010000  {  ; RW data
+   ;.ANY (+RW +ZI)
+  ;}
+  
+;  ARM_LIB_STACK 0xE0000 EMPTY -0x10000{}
+}
+
+;LR_IROM2 0x4000 0x4000{
+;	ER_IROM2 0x4000 {
+;	  rom_main.o (+RO)
+;	}
+;}
+
+LR_IROM3 0x1000200 0x200{
+	ER_IROM3 0x1000200 {
+	  flash_start.o (|.flash_start|,+RO)
+	}
+}
+
+LR_IROM4 0x1000400 0x1000000{
+	ER_IROM4 0x1000400 {
+;	  flash_start.o (|.flash_start|,+RO)
+	  *(InRoot$$Sections)
+	  .ANY (+RO)
+	}
+	
+	
+	 RW_IRAM2 0x00020000 0x010000  {  ; RW data
+	.ANY (+RW +ZI)
+	}
+}
+
Index: LPM_SLEEP/lpm_demo/prj/MDK/YC3121_Keil.uvprojx
===================================================================
--- /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/MDK/YC3121_Keil.uvprojx	(nonexistent)
+++ /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/prj/MDK/YC3121_Keil.uvprojx	(working copy)
@@ -0,0 +1,512 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
+
+  <SchemaVersion>2.1</SchemaVersion>
+
+  <Header>### uVision Project, (C) Keil Software</Header>
+
+  <Targets>
+    <Target>
+      <TargetName>YC3121</TargetName>
+      <ToolsetNumber>0x4</ToolsetNumber>
+      <ToolsetName>ARM-ADS</ToolsetName>
+      <pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
+      <uAC6>0</uAC6>
+      <TargetOption>
+        <TargetCommonOption>
+          <Device>ARMCM0</Device>
+          <Vendor>ARM</Vendor>
+          <PackID>ARM.CMSIS.5.5.1</PackID>
+          <PackURL>http://www.keil.com/pack/</PackURL>
+          <Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M0") CLOCK(12000000) ESEL ELITTLE</Cpu>
+          <FlashUtilSpec></FlashUtilSpec>
+          <StartupFile></StartupFile>
+          <FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</FlashDriverDll>
+          <DeviceId>0</DeviceId>
+          <RegisterFile>$$Device:ARMCM0$Device\ARM\ARMCM0\Include\ARMCM0.h</RegisterFile>
+          <MemoryEnv></MemoryEnv>
+          <Cmp></Cmp>
+          <Asm></Asm>
+          <Linker></Linker>
+          <OHString></OHString>
+          <InfinionOptionDll></InfinionOptionDll>
+          <SLE66CMisc></SLE66CMisc>
+          <SLE66AMisc></SLE66AMisc>
+          <SLE66LinkerMisc></SLE66LinkerMisc>
+          <SFDFile>$$Device:ARMCM0$Device\ARM\SVD\ARMCM0.svd</SFDFile>
+          <bCustSvd>0</bCustSvd>
+          <UseEnv>0</UseEnv>
+          <BinPath></BinPath>
+          <IncludePath></IncludePath>
+          <LibPath></LibPath>
+          <RegisterFilePath></RegisterFilePath>
+          <DBRegisterFilePath></DBRegisterFilePath>
+          <TargetStatus>
+            <Error>0</Error>
+            <ExitCodeStop>0</ExitCodeStop>
+            <ButtonStop>0</ButtonStop>
+            <NotGenerated>0</NotGenerated>
+            <InvalidFlash>1</InvalidFlash>
+          </TargetStatus>
+          <OutputDirectory>.\Objects\</OutputDirectory>
+          <OutputName>YC3121_Keil</OutputName>
+          <CreateExecutable>1</CreateExecutable>
+          <CreateLib>0</CreateLib>
+          <CreateHexFile>1</CreateHexFile>
+          <DebugInformation>1</DebugInformation>
+          <BrowseInformation>1</BrowseInformation>
+          <ListingPath>.\Listings\</ListingPath>
+          <HexFormatSelection>1</HexFormatSelection>
+          <Merge32K>0</Merge32K>
+          <CreateBatchFile>1</CreateBatchFile>
+          <BeforeCompile>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopU1X>0</nStopU1X>
+            <nStopU2X>0</nStopU2X>
+          </BeforeCompile>
+          <BeforeMake>
+            <RunUserProg1>0</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name></UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
+          </BeforeMake>
+          <AfterMake>
+            <RunUserProg1>1</RunUserProg1>
+            <RunUserProg2>0</RunUserProg2>
+            <UserProg1Name>fromelf.exe --text -a -c --output=@L_asm.txt "!L"</UserProg1Name>
+            <UserProg2Name></UserProg2Name>
+            <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+            <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopA1X>0</nStopA1X>
+            <nStopA2X>0</nStopA2X>
+          </AfterMake>
+          <SelectedForBatchBuild>0</SelectedForBatchBuild>
+          <SVCSIdString></SVCSIdString>
+        </TargetCommonOption>
+        <CommonProperty>
+          <UseCPPCompiler>0</UseCPPCompiler>
+          <RVCTCodeConst>0</RVCTCodeConst>
+          <RVCTZI>0</RVCTZI>
+          <RVCTOtherData>0</RVCTOtherData>
+          <ModuleSelection>0</ModuleSelection>
+          <IncludeInBuild>1</IncludeInBuild>
+          <AlwaysBuild>0</AlwaysBuild>
+          <GenerateAssemblyFile>0</GenerateAssemblyFile>
+          <AssembleAssemblyFile>0</AssembleAssemblyFile>
+          <PublicsOnly>0</PublicsOnly>
+          <StopOnExitCode>3</StopOnExitCode>
+          <CustomArgument></CustomArgument>
+          <IncludeLibraryModules></IncludeLibraryModules>
+          <ComprImg>1</ComprImg>
+        </CommonProperty>
+        <DllOption>
+          <SimDllName>SARMCM3.DLL</SimDllName>
+          <SimDllArguments>  </SimDllArguments>
+          <SimDlgDll>DARMCM1.DLL</SimDlgDll>
+          <SimDlgDllArguments>-pCM0</SimDlgDllArguments>
+          <TargetDllName>SARMCM3.DLL</TargetDllName>
+          <TargetDllArguments> </TargetDllArguments>
+          <TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
+          <TargetDlgDllArguments>-pCM0</TargetDlgDllArguments>
+        </DllOption>
+        <DebugOption>
+          <OPTHX>
+            <HexSelection>1</HexSelection>
+            <HexRangeLowAddress>0</HexRangeLowAddress>
+            <HexRangeHighAddress>0</HexRangeHighAddress>
+            <HexOffset>0</HexOffset>
+            <Oh166RecLen>16</Oh166RecLen>
+          </OPTHX>
+        </DebugOption>
+        <Utilities>
+          <Flash1>
+            <UseTargetDll>1</UseTargetDll>
+            <UseExternalTool>0</UseExternalTool>
+            <RunIndependent>1</RunIndependent>
+            <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+            <Capability>1</Capability>
+            <DriverSelection>4100</DriverSelection>
+          </Flash1>
+          <bUseTDR>1</bUseTDR>
+          <Flash2>BIN\UL2CM3.DLL</Flash2>
+          <Flash3>"" ()</Flash3>
+          <Flash4></Flash4>
+          <pFcarmOut></pFcarmOut>
+          <pFcarmGrp></pFcarmGrp>
+          <pFcArmRoot></pFcArmRoot>
+          <FcArmLst>0</FcArmLst>
+        </Utilities>
+        <TargetArmAds>
+          <ArmAdsMisc>
+            <GenerateListings>0</GenerateListings>
+            <asHll>1</asHll>
+            <asAsm>1</asAsm>
+            <asMacX>1</asMacX>
+            <asSyms>1</asSyms>
+            <asFals>1</asFals>
+            <asDbgD>1</asDbgD>
+            <asForm>1</asForm>
+            <ldLst>0</ldLst>
+            <ldmm>1</ldmm>
+            <ldXref>1</ldXref>
+            <BigEnd>0</BigEnd>
+            <AdsALst>1</AdsALst>
+            <AdsACrf>1</AdsACrf>
+            <AdsANop>0</AdsANop>
+            <AdsANot>0</AdsANot>
+            <AdsLLst>1</AdsLLst>
+            <AdsLmap>1</AdsLmap>
+            <AdsLcgr>1</AdsLcgr>
+            <AdsLsym>1</AdsLsym>
+            <AdsLszi>1</AdsLszi>
+            <AdsLtoi>1</AdsLtoi>
+            <AdsLsun>1</AdsLsun>
+            <AdsLven>1</AdsLven>
+            <AdsLsxf>1</AdsLsxf>
+            <RvctClst>0</RvctClst>
+            <GenPPlst>0</GenPPlst>
+            <AdsCpuType>"Cortex-M0"</AdsCpuType>
+            <RvctDeviceName></RvctDeviceName>
+            <mOS>0</mOS>
+            <uocRom>0</uocRom>
+            <uocRam>0</uocRam>
+            <hadIROM>1</hadIROM>
+            <hadIRAM>1</hadIRAM>
+            <hadXRAM>0</hadXRAM>
+            <uocXRam>0</uocXRam>
+            <RvdsVP>0</RvdsVP>
+            <RvdsMve>0</RvdsMve>
+            <hadIRAM2>0</hadIRAM2>
+            <hadIROM2>0</hadIROM2>
+            <StupSel>8</StupSel>
+            <useUlib>1</useUlib>
+            <EndSel>1</EndSel>
+            <uLtcg>0</uLtcg>
+            <nSecure>0</nSecure>
+            <RoSelD>3</RoSelD>
+            <RwSelD>3</RwSelD>
+            <CodeSel>0</CodeSel>
+            <OptFeed>0</OptFeed>
+            <NoZi1>0</NoZi1>
+            <NoZi2>0</NoZi2>
+            <NoZi3>0</NoZi3>
+            <NoZi4>1</NoZi4>
+            <NoZi5>0</NoZi5>
+            <Ro1Chk>0</Ro1Chk>
+            <Ro2Chk>0</Ro2Chk>
+            <Ro3Chk>0</Ro3Chk>
+            <Ir1Chk>1</Ir1Chk>
+            <Ir2Chk>0</Ir2Chk>
+            <Ra1Chk>0</Ra1Chk>
+            <Ra2Chk>0</Ra2Chk>
+            <Ra3Chk>0</Ra3Chk>
+            <Im1Chk>1</Im1Chk>
+            <Im2Chk>0</Im2Chk>
+            <OnChipMemories>
+              <Ocm1>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm1>
+              <Ocm2>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm2>
+              <Ocm3>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm3>
+              <Ocm4>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm4>
+              <Ocm5>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm5>
+              <Ocm6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </Ocm6>
+              <IRAM>
+                <Type>0</Type>
+                <StartAddress>0x20000000</StartAddress>
+                <Size>0x20000</Size>
+              </IRAM>
+              <IROM>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x40000</Size>
+              </IROM>
+              <XRAM>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </XRAM>
+              <OCR_RVCT1>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT1>
+              <OCR_RVCT2>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT2>
+              <OCR_RVCT3>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT3>
+              <OCR_RVCT4>
+                <Type>1</Type>
+                <StartAddress>0x1000000</StartAddress>
+                <Size>0x80000</Size>
+              </OCR_RVCT4>
+              <OCR_RVCT5>
+                <Type>1</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT5>
+              <OCR_RVCT6>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT6>
+              <OCR_RVCT7>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT7>
+              <OCR_RVCT8>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT8>
+              <OCR_RVCT9>
+                <Type>0</Type>
+                <StartAddress>0x20000</StartAddress>
+                <Size>0x10000</Size>
+              </OCR_RVCT9>
+              <OCR_RVCT10>
+                <Type>0</Type>
+                <StartAddress>0x0</StartAddress>
+                <Size>0x0</Size>
+              </OCR_RVCT10>
+            </OnChipMemories>
+            <RvctStartVector></RvctStartVector>
+          </ArmAdsMisc>
+          <Cads>
+            <interw>1</interw>
+            <Optim>1</Optim>
+            <oTime>0</oTime>
+            <SplitLS>0</SplitLS>
+            <OneElfS>0</OneElfS>
+            <Strict>0</Strict>
+            <EnumInt>0</EnumInt>
+            <PlainCh>0</PlainCh>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <wLevel>1</wLevel>
+            <uThumb>0</uThumb>
+            <uSurpInc>0</uSurpInc>
+            <uC99>1</uC99>
+            <uGnu>0</uGnu>
+            <useXO>0</useXO>
+            <v6Lang>1</v6Lang>
+            <v6LangP>1</v6LangP>
+            <vShortEn>1</vShortEn>
+            <vShortWch>1</vShortWch>
+            <v6Lto>0</v6Lto>
+            <v6WtE>0</v6WtE>
+            <v6Rtti>0</v6Rtti>
+            <VariousControls>
+              <MiscControls></MiscControls>
+              <Define>__USEKEILCOMPILE__</Define>
+              <Undefine></Undefine>
+              <IncludePath>..\..\..\..\..\Librarier\sdk;..\..\..\..\..\Librarier\core;..\..\user</IncludePath>
+            </VariousControls>
+          </Cads>
+          <Aads>
+            <interw>1</interw>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <thumb>0</thumb>
+            <SplitLS>0</SplitLS>
+            <SwStkChk>0</SwStkChk>
+            <NoWarn>0</NoWarn>
+            <uSurpInc>0</uSurpInc>
+            <useXO>0</useXO>
+            <uClangAs>0</uClangAs>
+            <VariousControls>
+              <MiscControls></MiscControls>
+              <Define></Define>
+              <Undefine></Undefine>
+              <IncludePath></IncludePath>
+            </VariousControls>
+          </Aads>
+          <LDads>
+            <umfTarg>0</umfTarg>
+            <Ropi>0</Ropi>
+            <Rwpi>0</Rwpi>
+            <noStLib>0</noStLib>
+            <RepFail>1</RepFail>
+            <useFile>0</useFile>
+            <TextAddressRange>0x00000000</TextAddressRange>
+            <DataAddressRange>0xd0000</DataAddressRange>
+            <pXoBase></pXoBase>
+            <ScatterFile>.\Objects\YC3121_keil.sct</ScatterFile>
+            <IncludeLibs></IncludeLibs>
+            <IncludeLibsPath></IncludeLibsPath>
+            <Misc></Misc>
+            <LinkerInputFile></LinkerInputFile>
+            <DisabledWarnings></DisabledWarnings>
+          </LDads>
+        </TargetArmAds>
+      </TargetOption>
+      <Groups>
+        <Group>
+          <GroupName>core</GroupName>
+          <Files>
+            <File>
+              <FileName>misc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\core\misc.c</FilePath>
+            </File>
+            <File>
+              <FileName>system.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\core\system.c</FilePath>
+            </File>
+            <File>
+              <FileName>bt_code.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\core\bt_code.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>main</GroupName>
+          <Files>
+            <File>
+              <FileName>main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\user\main.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>sdk</GroupName>
+          <Files>
+            <File>
+              <FileName>yc_gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_uart.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_bt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_bt.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_systick.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_systick.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_ipc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_ipc.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_otp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_otp.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_timer.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_timer.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_lpm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_lpm.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_sysctrl.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_sysctrl.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_trng.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_trng.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_adc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_adc.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_power.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_power.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_ssc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_ssc.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_qspi.lib</FileName>
+              <FileType>4</FileType>
+              <FilePath>..\..\..\..\..\Librarier\sdk\yc_qspi.lib</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>startup</GroupName>
+          <Files>
+            <File>
+              <FileName>flash_start.s</FileName>
+              <FileType>2</FileType>
+              <FilePath>..\..\..\..\..\Librarier\startup\flash_start.s</FilePath>
+            </File>
+            <File>
+              <FileName>startup.s</FileName>
+              <FileType>2</FileType>
+              <FilePath>..\..\..\..\..\Librarier\startup\startup.s</FilePath>
+            </File>
+          </Files>
+        </Group>
+      </Groups>
+    </Target>
+  </Targets>
+
+  <RTE>
+    <apis/>
+    <components/>
+    <files/>
+  </RTE>
+
+</Project>
Index: LPM_SLEEP/lpm_demo/user/main.c
===================================================================
--- /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/user/main.c	(nonexistent)
+++ /YC3121_demo/ModuleDemo/LPM_SLEEP/lpm_demo/user/main.c	(working copy)
@@ -0,0 +1,657 @@
+/**
+  ******************************************************************************
+  * @file    3121Demo\ModuleDemo\BlueTooth\BT&BLE\user\main.c
+  * @author  Yichip Application Team
+  * @version V1.0.0
+  * @date    18-Feb-2020
+  * @brief   BT&BLE test program.
+  ******************************************************************************
+  * @attention
+  *
+  * COPYRIGHT 2019 Yichip Microelectronics
+  *
+  * The purpose of this firmware is to provide guidance to customers engaged in
+	* programming work to guide them smoothly to product development,
+	* so as to save their time.
+	*
+	* Therefore, Yichip microelectronics shall not be responsible for any direct,
+	* indirect or consequential damages caused by any content of this gu jiang
+	* and/or contained in this code used by the customer in its products.
+  *
+  ******************************************************************************
+  */
+
+/* Includes ------------------------------------------------------------------*/
+#include "yc3121.h"
+#include "yc_gpio.h"
+#include "yc_uart.h"
+#include "yc_bt.h"
+#include "yc_systick.h"
+#include "yc_qspi.h"
+#include "yc_ipc.h"
+#include "yc_trng.h"
+#include "yc_power.h"
+#include "yc_ssc.h"
+#include "board_config.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+#define IPC_UART UART0
+#define UART_TO_IPC_BAUDRATE	921600
+//#define UART_TO_IPC
+
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+void UART_Configuration(void);
+
+
+
+// byte0： uuid length
+//byte1-16: uuid
+// 49535343-FE78-4AE5-8FA9-9FAFD205E455
+uint8_t ble_service_uuid_lsps[] = {0x10,0x55,0xe4,0x05,0xd2,0xaf,0x9f,0xa9,0x8f,0xe5,0x4a,0x7d,0xfe,0x43,0x53,0x53,0x49};
+
+/*
+byte0: characterisitic
+byte1:characterisitic uuid length
+byte2-17:characterisitic uuid
+byte18:write/read payload length
+byte19-20:write/read payload
+*/
+//49535343-1E4D-4BD9-BA61-23C647249616
+uint8_t ble_Characteristic_uuid_lsps_tx[] = {0x10,0x10,0x16,0x96,0x24,0x47,0xc6,0x23,0x61,0xba,0xd9,0x4b,0x4d,0x1e,0x43,0x53,0x53,0x49,0x01,0x00};
+//49535343-8841-43F4-A8D4-ECBE34729BB3
+uint8_t ble_Characteristic_uuid_lsps_rx[] = {0x0c,0x10,0xb3,0x9b,0x72,0x34,0xbe,0xec,0xd4,0xa8,0xf4,0x43,0x41,0x88,0x43,0x53,0x53,0x49,0x01,0x00};
+//49535343-aca3-481c-91ec-d85e28a60318
+uint8_t ble_Characteristic_uuid_flow_ctrl[] = {0x18,0x10,0x18,0x03,0xa6,0x28,0x5e,0xd8,0xec,0x91,0x1c,0x48,0xa3,0xac,0x43,0x53,0x53,0x49,0x01,0x00};
+
+
+#define IFLASH_NVRAM_ADDR 0x1000000+((512-4)*1024)
+#define NVRAM_LEN 170//Nvram 长度170bytes,每组Nvram长度为34bytes,最多可存储5组配对信息
+
+uint16_t ble_send_handle=0x2a;
+uint8_t bt_cod[3] = {0x24,0x04,0x04};
+uint8_t NvramData[NVRAM_LEN]={0};
+
+
+//write flash
+uint8_t   ReserveNV(uint8_t* nvram);
+extern tick SystickCount;
+#ifdef UART_TO_IPC
+HCI_TypeDef HCI_Tx;
+HCI_TypeDef HCI_Rx;
+uint8_t ipc_tx_buf[256];
+uint8_t ipc_rx_buf[256];
+#endif
+
+void BT_IRQHandler()
+{
+	while(IPC_have_data())
+	{
+		#ifdef UART_TO_IPC
+		if(TRUE==IPC_ReadBtData(&HCI_Rx))
+		{
+			UART_SendBuf(IPC_UART,(uint8_t*)&HCI_Rx,3);
+			UART_SendBuf(IPC_UART,HCI_Rx.p_data,HCI_Rx.DataLen);
+		}
+		#else
+		BT_ParseBTData();
+		#endif
+	}
+	BT_CONFIG &= (~(1<<BT_INIT_FLAG));
+}
+
+void SYSTICK_IRQHandler()
+{
+	SystickCount++;
+	if(SystickCount>=TICK_MAX_VALUE)	SystickCount=0;
+}
+
+
+
+static uint8_t hex_lookup[16] = { '0', '1', '2', '3', '4', '5', '6', '7','8','9', 'a', 'b', 'c', 'd', 'e', 'f' };
+static void array2hex(uint8_t* in, int inlen, uint8_t* out)
+{
+	int i;
+	for (i = 0; i < inlen; ++i)
+	{
+		out[2 * i] = hex_lookup[in[inlen-1-i] >> 4];
+		out[2 * i + 1] = hex_lookup[in[inlen-1-i] & 0x0f];
+	}
+}
+
+void genBleAdvData(uint8_t *ble_name,int ble_name_len,uint8_t *ble_mac,uint8_t *ble_adv_data)
+{
+    int index=0;
+    //property
+    ble_adv_data[index++]=0x02;
+    ble_adv_data[index++]=0x01;
+    ble_adv_data[index++]=0x02;
+    //name
+    ble_adv_data[index++]=(ble_name_len+1);
+    ble_adv_data[index++]=0x09;//name flag
+    for(int i=0;i<ble_name_len;i++)
+    {
+        ble_adv_data[index++]=ble_name[i];
+    }
+    //manufacturer info
+    ble_adv_data[index++]=0x09;
+    ble_adv_data[index++]=0xff;//manufacturer info flag
+    ble_adv_data[index++]=0x00;
+    ble_adv_data[index++]=0x00;
+    for(int i=0;i<6;i++)
+    {
+        ble_adv_data[index++]=ble_mac[5-i];
+    }
+    //fill
+    while(index<31)
+    {
+        ble_adv_data[index++]=0x00;
+    }
+}
+
+
+/**
+  * @brief  Main program
+  * @param  None
+  * @retval None
+  */
+
+void flash_powerdown(void);
+void BT_ConfigerInit(uint32_t bleinitflag);
+void Power_off_test(void);
+
+extern uint8_t bt_lpm_mode;
+uint32_t bpk_buf[32] = {0};
+#define  FLAG_LEN   1
+int main(void)
+{
+	UART_Configuration();
+    MyPrintf("YC3121 Sleep Mode Demo V1.0!\n");
+    SSC_LPMKeyRead(bpk_buf,FLAG_LEN,0);
+    SysTick_Config(CPU_MHZ/100);
+    BT_ConfigerInit(bpk_buf[0]);
+
+    if(bpk_buf[0] == TRUE)             /*为TRUE 蓝牙不初始化唤醒，唤醒后清0*/
+    {
+        bpk_buf[0] = FALSE;
+        SSC_LPMKeyWrite(bpk_buf,FLAG_LEN,0);
+    }
+    MyPrintf("====================================\n");
+    MyPrintf(" Please input the following numbers to configure the sleep mode !\n");
+    MyPrintf(" 1: M0 Sleep and BT Deep Sleep\n");
+    MyPrintf(" 2: M0 Div Freqency and BT Deep sleep!\n");
+    MyPrintf(" 3: M0 Sleep and BT Light Sleep!\n");
+    MyPrintf("====================================\n");
+    uint8_t uartretval;
+	while (1)
+	{
+        if(UART_IsRXFIFONotEmpty(UART0))
+        {
+            uartretval = UART_ReceiveData(UART0);
+            switch (uartretval)
+            {
+            case '1':
+                MyPrintf(" M0 Sleep and BT Deep Sleep....\n");
+                Disable_Trng();
+                GPIO_Unused_Pd();
+                GPIO_Config(GPIOA, GPIO_Pin_1, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_0, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_14, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_15, GPCFG_PD);
+                CM0_Sleep(10,0,1<<1,0,1);
+                break;
+            case '2':
+                MyPrintf(" M0 Div Freqency and BT Deep sleep....\n");
+                SYSCTRL_HCLKConfig(SYSCTRL_HCLK_Div8);
+                Disable_Trng();
+                GPIO_Unused_Pd();
+                GPIO_Config(GPIOA, GPIO_Pin_1, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_0, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_14, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_15, GPCFG_PD);
+                SYSCTRL_AHBPeriphClockCmd(SYSCTRL_AHBPeriph_INTR | SYSCTRL_AHBPeriph_SHA | \
+                            SYSCTRL_AHBPeriph_CRC | SYSCTRL_AHBPeriph_PWM | \
+                            SYSCTRL_AHBPeriph_WDT | SYSCTRL_AHBPeriph_USB | \
+                            SYSCTRL_AHBPeriph_SPI | SYSCTRL_AHBPeriph_DES | \
+                            SYSCTRL_AHBPeriph_RSA | SYSCTRL_AHBPeriph_ASE | \
+                            SYSCTRL_AHBPeriph_7816 | SYSCTRL_AHBPeriph_SM4 | \
+                            SYSCTRL_AHBPeriph_7811 | SYSCTRL_AHBPeriph_ADC7811 | \
+                            SYSCTRL_AHBPeriph_UART | \
+                            SYSCTRL_AHBPeriph_CP, DISABLE);
+                BT_Hibernate();
+                break;
+            case '3':
+                MyPrintf(" M0 Sleep and BT Light Sleep....\n");
+                GPIO_Unused_Pd();
+                GPIO_Config(GPIOA, GPIO_Pin_1, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_0, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_14, GPCFG_PD);
+                GPIO_Config(GPIOA, GPIO_Pin_15, GPCFG_PD);
+                BT_SetLpmMode(0x01);
+                BT_SetLEAdvInterval(0x640);
+                bpk_buf[0] = TRUE;
+                SSC_LPMKeyWrite(bpk_buf,FLAG_LEN,0);
+                CM0_Sleep(0,0,0,0,0);
+                break;
+            default:
+                break;
+            }
+            uartretval = 0;
+        }
+        BT_Progress();
+        /*芯片下电*/
+        Power_off_test();
+	}
+}
+
+/**
+  * @brief  Serial port 0 initialization function.
+  * @param  None
+  * @retval None
+  */
+void UART_Configuration(void)
+{
+	UART_InitTypeDef UART_InitStruct;
+
+	/* Configure serial ports 0 RX and TX for IO. */
+	GPIO_Config(UART0_TX_PORT, UART0_TX_PIN, UART0_TXD);
+	GPIO_Config(UART0_RX_PORT, UART0_RX_PIN, UART0_RXD);
+
+	/* USARTx configured as follow:
+  - BaudRate = 115200 baud
+  - Word Length = 8 Bits
+  - Stop Bit = 1 Stop Bit
+  - Parity = No Parity
+  - Hardware flow control disabled (RTS and CTS signals)
+  - Receive and transmit enabled
+  */
+	#ifdef UART_TO_IPC
+	UART_InitStruct.BaudRate = UART_TO_IPC_BAUDRATE;			//Configure serial port baud rate, the baud rate defaults to 128000.
+	#else
+	UART_InitStruct.BaudRate = UARTBAUD;
+	#endif
+	UART_InitStruct.DataBits = Databits_8b;
+	UART_InitStruct.StopBits = StopBits_1;
+	UART_InitStruct.Parity = Parity_None;
+	UART_InitStruct.FlowCtrl = FlowCtrl_None;
+	UART_InitStruct.Mode = Mode_duplex;
+
+	UART_Init(UART0, &UART_InitStruct);
+}
+
+
+/**
+  * @brief  deal with data from bt core event
+  * @param  None
+  * @retval None
+  */
+
+
+void flash_powerdown(void)
+{
+    ((void(*)())(0x4e9c+1))();// m0 goto sleep
+}
+
+void Power_off_test(void)
+{
+    uint8_t ret;
+
+    if (TRUE == Power_Keyscan())
+    {
+        /* 如果power_key需要做独立按键可进行长短按设计 */
+        delay_ms(1000);
+        if (TRUE == Power_Keyscan())
+        {
+            MyPrintf("poweroff\n");
+            /* 操作Power_off函数之前先进行关闭LCD等外设的操作 */
+            ret = Power_off(); //如果插入外电，则不会关机，返回FALSE
+        }
+    }
+}
+
+void BT_ConfigerInit(uint32_t bleinitflag)
+{
+	uint8_t bt_name[15] = "YC3121bt";
+	uint8_t bt_addr[6] =  {0x00,0x00,0x00,0x33,0x22,0x10};
+	uint8_t chip_id[6]={0};
+    uint8_t ble_adv_data[31]={0x02,0x01,0x02,0x00};
+	uint16_t temp_handle;
+
+	int UARTCMD = 0;
+	uint8_t getbtstatus = 0;
+	int i = 0;
+	#ifdef UART_TO_IPC
+	HCI_Tx.p_data=ipc_tx_buf;
+	HCI_Rx.p_data=ipc_rx_buf;
+	#endif
+    if(bleinitflag != TRUE)
+    {
+        BT_Init();
+        enable_intr(INTR_BT);
+    }
+    else
+    {
+        BT_WakeupInit();
+    }
+
+	read_chipid(chip_id);
+	array2hex(chip_id,3,bt_name+8);
+	bt_name[14]='\0';
+	memcpy(bt_addr,chip_id,3);
+    if(bleinitflag != TRUE)
+    {
+        #ifndef UART_TO_IPC
+        if(BT_SetBleName(bt_name,sizeof(bt_name)-1)==TRUE)
+            MyPrintf("SetBleName_suc ble name:%s\n",bt_name);
+        else
+            MyPrintf("SetBleName_failed\n");
+
+        if(BT_SetBtName(bt_name,sizeof(bt_name)-1) == TRUE)//bt与ble名字地址可以设置成一样
+            MyPrintf("SetbtName_suc\n");
+        else
+            MyPrintf("SetbtName_fail\n");
+
+        if(BT_SetBleAddr(bt_addr) == TRUE)
+            MyPrintf("SetBleAddr_suc\n");
+        else
+            MyPrintf("SetBleAddr_fail\n");
+
+        if(BT_SetBtAddr(bt_addr) == TRUE)
+            MyPrintf("SetBtAddr_suc\n");
+        else
+            MyPrintf("SetBtAddr_fail\n");
+
+        if(BT_SetParingMode(0x03) == TRUE)//设置配对模式为confirmkey
+            MyPrintf("set confirmkey mode success\n");
+        else
+            MyPrintf("set confirmkey mode failed\n");
+
+        if(BT_SetCOD(bt_cod) == TRUE) //设置COD
+            MyPrintf("set COD sucess\n");
+        else
+            MyPrintf("set COD failed\n");
+
+        if(BT_SetLpmMode(0x00) == TRUE) //设置低功耗模式
+            MyPrintf("set lpm mode sucess\n");
+        else
+            MyPrintf("set lpm mode failed\n");
+
+
+        if(BT_DeleteService() == TRUE) //  删除用户自定义服务
+            MyPrintf("delete service sucess\n");
+        else
+            MyPrintf("delete service failed\n");
+
+        temp_handle=BT_AddBleService(ble_service_uuid_lsps,sizeof(ble_service_uuid_lsps));
+        if( temp_handle!= 0)  //增加服务 返回handle无需保存
+            MyPrintf("add service sucess,handle=%04x\n",temp_handle);
+        else
+            MyPrintf("add service failed,return=%04x\n",temp_handle);
+
+        ble_send_handle=BT_AddBleCharacteristic(ble_Characteristic_uuid_lsps_tx,sizeof(ble_Characteristic_uuid_lsps_tx));
+        if( ble_send_handle!= 0)  //增加服务特征  write返回的handle需要保存，发数据使用
+            MyPrintf("add Characteristic tx sucess,handle=%04x\n",ble_send_handle);
+        else
+            MyPrintf("add Characteristic tx failed,return=%04x\n",ble_send_handle);
+
+        temp_handle=BT_AddBleCharacteristic(ble_Characteristic_uuid_lsps_rx,sizeof(ble_Characteristic_uuid_lsps_rx));
+        if( temp_handle!= 0)
+            MyPrintf("add Characteristic rx sucess;handle=%04x\n",temp_handle);
+        else
+            MyPrintf("add Characteristic rx failed,return=%04x\n",temp_handle);
+
+        temp_handle=BT_AddBleCharacteristic(ble_Characteristic_uuid_flow_ctrl,sizeof(ble_Characteristic_uuid_flow_ctrl));
+        if( temp_handle!= 0)
+            MyPrintf("add Characteristic flow_ctrl sucess;handle=%04x\n",temp_handle);
+        else
+            MyPrintf("add Characteristic flow_ctrl failed,return=%04x\n",temp_handle);
+
+        genBleAdvData(bt_name,sizeof(bt_name)-1,bt_addr,ble_adv_data);
+        if(BT_SetLEAdvData(ble_adv_data,sizeof(ble_adv_data)) == TRUE)
+            MyPrintf("BT_SetLEAdvData sucess\n");
+        else
+            MyPrintf("BT_SetLEAdvData failed\n");
+
+        if(BT_SetLEScanData(ble_adv_data,sizeof(ble_adv_data)) == TRUE)
+            MyPrintf("BT_SetLEScanData sucess\n");
+        else
+            MyPrintf("BT_SetLEScanData failed\n");
+
+        if(BT_SetVisibility(0x00,0x00,0x01) == TRUE)
+            MyPrintf("SetVisibility sucess\n");
+        else
+            MyPrintf("SetVisibility failed\n");
+
+        BT_SetLEAdvInterval(0x40);
+
+        MyPrintf("bt version=%x\n",BT_GetVersion());
+
+        qspi_flash_read(IFLASH_NVRAM_ADDR,NvramData,NVRAM_LEN);
+        if(NvramData[34*0] > 0x05||NvramData[34*1] > 0x05||NvramData[34*2] > 0x05||NvramData[34*3] > 0x05||NvramData[34*4] > 0x05)
+        {
+            memset(NvramData,0x00,NVRAM_LEN);
+        }
+        i=0;
+        if(BT_SetNVRAM(NvramData,NVRAM_LEN) == TRUE)
+        {
+            MyPrintf("set nvram success:\n");
+            while(i<NVRAM_LEN)
+                MyPrintf("0x%02X ",NvramData[i++]);
+            MyPrintf("\n");
+        }
+        else
+            MyPrintf("set nvram failed\n");
+        #else
+        MyPrintf("uart baud rate is:%d\n",UART_TO_IPC_BAUDRATE);
+        #endif
+    }
+}
+
+
+void BT_Progress()
+{
+	int eventCmd= BT_GetEventOpcode();
+    if(eventCmd != 0xFFFFFFFF)
+        MyPrintf("eventCmd = 0x%x\n",eventCmd);
+	switch(eventCmd)
+	{
+		case BT_DATA:
+			{
+				uint8_t i = 0;
+				uint8_t btData[MAX_BLUETOOTH_DATA_LEN];
+				int BtDataLen=0;
+				BtDataLen=BT_ReadBTData(btData);
+				if(BtDataLen>0)
+				{
+					MyPrintf("received %d bytes bt data:\n",BtDataLen);
+					for(int i=0;i<BtDataLen;i++)	MyPrintf("%02x ",btData[i]);
+					MyPrintf("\n");
+
+					BT_SendSppData(btData,BtDataLen);
+					MyPrintf("send %d bytes bt data:\n",BtDataLen);
+					for(int i=0;i<BtDataLen;i++)	MyPrintf("%02x ",btData[i]);
+					MyPrintf("\n");
+					#if (MEM_SPP_FLOWCTRL_FLAG_VALUE==0x01)
+					if(BT_SetSppFlowcontrol(1) != TRUE)	MyPrintf("set Flowcontrol failed\n");
+					#endif
+				}
+				else	MyPrintf("read bt data error\r\n");
+			}
+		break;
+
+		case BLE_DATA:
+			{
+				uint8_t bleData[MAX_BLUETOOTH_DATA_LEN]={0};
+				int BleDataLen=0;
+				BleDataLen=BT_ReadBTData(bleData);
+				if(BleDataLen>0)
+				{
+					MyPrintf("received %d bytes ble data[handle:%02x %02x]:\n",BleDataLen-2,bleData[0],bleData[1]);
+					for(int i=0;i<(BleDataLen-2);i++)	MyPrintf("%02x ",bleData[2+i]);
+					MyPrintf("\n");
+
+					//add handle
+					bleData[0]=(ble_send_handle&0xff);
+					bleData[1]=((ble_send_handle>>8)&0xff);
+					BT_SendBleData(bleData,BleDataLen);
+					MyPrintf("send %d bytes ble data[%02x %02x]:\n",BleDataLen-2,bleData[0],bleData[1]);
+					for(int i=0;i<(BleDataLen-2);i++)	MyPrintf("%02x ",bleData[2+i]);
+					MyPrintf("\n");
+				}
+				else	MyPrintf("read ble data error\r\n");
+			}
+		break;
+
+		case BT_CONNECTED:
+			MyPrintf("bt connected\n");
+		break;
+
+		case BLE_CONNECTED:
+			MyPrintf("ble connected\n");
+		break;
+
+		case BT_DISCONNECTED:
+			MyPrintf("bt disconnected\n");
+		break;
+
+		case BLE_DISCONNECTED:
+			MyPrintf("ble disconnected\n");
+		break;
+
+		case NVRAM_DATA:
+			{
+				uint8_t NvramData[MAX_BLUETOOTH_DATA_LEN];
+				int NvramDataLen=0;
+				NvramDataLen=BT_ReadBTData(NvramData);
+				if(NvramDataLen>0)
+				{
+					MyPrintf("receive %dbytes Nvramdata:",NvramDataLen);
+					for(int i=0;i<NvramDataLen;i++)
+					{
+						MyPrintf("%02X ",NvramData[i]);
+					}
+					MyPrintf("\n");
+					ReserveNV(NvramData);//将最新的5个设备信息（NVRAM） 写入flash ,
+				}
+				else
+					MyPrintf("read Nvram data error\r\n");
+			}
+		break;
+
+		case CONFIRM_GKEY:
+			{
+				uint8_t GkeyData[MAX_BLUETOOTH_DATA_LEN];
+				int GkeyDataLen=0;
+				GkeyDataLen=BT_ReadBTData(GkeyData);
+				if(GkeyDataLen>0)
+				{
+					MyPrintf("receive %dbytes CONFIRM_GKEY:",GkeyDataLen);
+					for(int i=0;i<GkeyDataLen;i++)
+					{
+						MyPrintf("%02X ",GkeyData[i]);
+					}
+					MyPrintf("\n");
+				}
+				else	MyPrintf("read CONFIRM_GKEY data error\r\n");
+
+				if(BT_ConfirmGkey(0) == TRUE)//BT_ConfirmGkey参数为0则继续配对，1则取消配对。
+					MyPrintf("set confirmkey  success");
+				else
+					MyPrintf("set confirmkey  failed\n");
+		}
+		break;
+
+		case PASSKEY:
+			MyPrintf("request Passkey");
+		break;
+
+		case PAIRING_COMPLETED:
+			{
+				uint8_t PairingData[MAX_BLUETOOTH_DATA_LEN];
+				int PairingDataLen=0;
+				PairingDataLen=BT_ReadBTData(PairingData);
+				if(PairingDataLen>0)
+				{
+					MyPrintf("receive %dbytes paring data:",PairingDataLen);
+					for(int i=0;i<PairingDataLen;i++)
+					{
+						MyPrintf("%02X ",PairingData[i]);
+					}
+					MyPrintf("\n");
+				}
+				else	MyPrintf("read PAIRING_COMPLETED data error\r\n");
+			}
+		break;
+
+		case PAIRING_STATE:
+			{
+				uint8_t PairingData[MAX_BLUETOOTH_DATA_LEN];
+				int PairingDataLen=0;
+				uint16_t pairing_status=0;
+				PairingDataLen=BT_ReadBTData(PairingData);
+				if(PairingDataLen==2)
+				{
+					pairing_status |=PairingData[0];
+					pairing_status |=(PairingData[1]<<8);
+					switch(pairing_status)
+					{
+						case 0x0001:
+							MyPrintf("BT Pairing Success\r\n");
+						break;
+
+						case 0x0101:
+							MyPrintf("BT Pairing fail\r\n");
+						break;
+
+						case 0x0080:
+							MyPrintf("BLE Pairing Success\r\n");
+						break;
+
+						case 0x0180:
+							MyPrintf("BLE Pairing fail\r\n");
+						break;
+
+						default:
+							MyPrintf("unknown pairing_status[%04x]\r\n",pairing_status);
+						break;
+					}
+				}
+				else	MyPrintf("read PAIRING_STATE data error\r\n");
+			}
+		break;
+
+		case -1:
+			//no event
+		break;
+
+		default:
+		{
+			MyPrintf("unknown event:%02x\r\n",eventCmd);
+			uint8_t unknownData[MAX_BLUETOOTH_DATA_LEN];
+			int unknownDataLen=0;
+			unknownDataLen=BT_ReadBTData(unknownData);
+			if(unknownDataLen>0)
+			{
+				MyPrintf("datalen:%d\r\n",unknownDataLen);
+				for(int i=0;i<unknownDataLen;i++)
+				{
+					MyPrintf("%02X ",unknownData[i]);
+				}
+				MyPrintf("\n");
+			}
+		}
+		break;
+	}
+}
+
+uint8_t   ReserveNV(uint8_t* nvram)
+{
+	MyPrintf("new nvram data,updata to flash\r\n");
+	qspi_flash_sectorerase(IFLASH_NVRAM_ADDR);
+	return qspi_flash_write(IFLASH_NVRAM_ADDR,nvram,NVRAM_LEN);
+}
+
+/************************ (C) COPYRIGHT Yichip Microelectronics *****END OF FILE****/
+
