Index: program/patch.prog
===================================================================
--- /branch/mouse_project/LeXiang/1066_Project/PBSwitch_2.4G&BLE_3ch_D1027E8_GAN/program/patch.prog	(revision 4262)
+++ /branch/mouse_project/LeXiang/1066_Project/PBSwitch_2.4G&BLE_3ch_D1027E8_GAN/program/patch.prog	(working copy)
@@ -279,10 +279,9 @@
 ifdef HIGH_REPORT
 	setarg G24_4MS_INTERVAL_PARAM
 else
-	setarg 58000
+	setarg 58500
 endif
-p_g24_enter_sleep:
-	branch g24_lpm_long_sleep2
+	branch lpm_dispatch_sleep
 	
 p_g24_transmit_customer_data:
 	call p_g24_transmit_by_interrupt_enable
@@ -1280,20 +1279,18 @@
 p_mouse_store_flash_device_info:
 	call p_flash_release_deep_power_down
 	call p_flash_erase_sector
+	call p_flash_write_enable
 	call p_mouse_information_flash_parameters
 	call p_spid_write_flash
 	call p_wait_flash_done
 	call p_mouse_store_flash_dpi
 p_mouse_store_random_addr_increase_count:
 	call p_spid_init_flash
+	call p_flash_write_enable
 	arg 2,temp
 	arg mem_random_addr_increase_count,rega
 	arg MOUSE_RANDOM_ADDR_COUNT_EEPROM_OFFSET,regb
-p_mouse_store_flash_comm:
-	fetch 3,mem_flash_base
-	iadd regb,pdata
-	call p_spid_write_flash
-	call p_wait_flash_done
+	call p_mouse_store_flash_comm
 	call p_flash_deep_power_down
 p_mouse_spi_init:
 	jam 0x76,mem_spi_init_clk
@@ -1301,24 +1298,40 @@
 
 p_mouse_store_flash_dpi:
 	call p_spid_init_flash
+	call p_flash_write_enable
 	arg 1,temp
 	arg mem_mouse_dpi,rega
 	arg MOUSE_DPI_EEPROM_OFFECT,regb
-	branch p_mouse_store_flash_comm
+p_mouse_store_flash_comm:
+	fetch 3,mem_flash_base
+	iadd regb,pdata
+	call p_spid_write_flash
+	branch p_wait_flash_done
 
 p_flash_erase_sector:
 	fetch 3,mem_flash_base
 	store 3,mem_spi_write_addr
-	call flash_erase_sector+2
+	call p_flash_write_enable
+	call flash_erase_sector+3
 p_wait_flash_done:
-	setarg 100000	
-	call sleep
-	call spid_unlock_flash
+	call p_flash_read_status
+	bbit1 FLASH_STATUS_WIP,p_wait_flash_done
+	rtn
+
+p_flash_read_status:
 	setarg mem_spid_rbuf
 	hstore 2,core_spid_rxaddr
 	setarg FLASH_READ_SATUS
-	call spid_read_reg
-	bbit1 FLASH_STATUS_WIP,p_wait_flash_done
+	force 1,temp
+	store 1,mem_spid_tbuf
+	setarg mem_spid_tbuf
+	hstore 2,core_spid_txaddr
+	branch spid_read_regs+2
+
+p_flash_write_enable:
+	call spid_unlock_flash
+	call p_flash_read_status
+	bbit0 FLASH_STATUS_WEL,p_flash_write_enable+1
 	rtn
 
 p_spid_write_flash:
@@ -1364,7 +1377,6 @@
 p_spid_write_flash_cmd:
 	call p_spid_init_flash
 	call delay_nop100
-	call spid_unlock_flash
 	arg mem_write_flash_head_temp,rega
 	fetcht 1,mem_temp
 	call spid_write_flash_common
@@ -1787,6 +1799,7 @@
 	increase 3,pdata
 	store 1,mem_mouse_multi_led_blink_count
 	call p_mouse_dpi_multi_led_blink
+	call p_mouse_store_flash_device_info
 	branch mouse_seting_dpi
 p_mouse_dpi_up:
 	call p_gpio_set_input_pu
@@ -2294,7 +2307,7 @@
 	fetch 1,mem_config_sensor_type
 	beq P3212,p_mouse_seting_3212_dpi
 	beq P3065_XY,p_mouse_seting_3065XY_dpi
-	beq P_MX8650,p_mouse_seting_3065XY_dpi
+	beq MX8650,p_mouse_seting_3065XY_dpi
 //	beq KA8,p_mouse_seting_ka8_dpi
 p_mouse_seting_3205_dpi:
 	fetch 1,mem_mouse_dpi
@@ -3374,16 +3387,28 @@
 //	beq TX_POWER_3DB,p_set_tx_power_3db	
 	beq TX_POWER_5DB,p_set_tx_power_5db
 //	beq TX_POWER_f3DB,p_set_tx_power_f3db	
-	beq TX_POWER_f5DB,p_set_tx_power_f5db
+	beq TX_POWER_f5DB,p_set_tx_power_0db
 	beq TX_POWER_PAIR,p_set_tx_power_pair
 //	branch p_set_tx_power_0db
+	
+p_set_tx_power_5db:
+//	call p_rx_high_sens
+
+//	jam 0xba,0x894b
+	jam 0xd0,0x8955
+	jam 0xe0,0x8956
+//	jam 0x88,0x8957
+	jam 0x3c,0x8958
+//	jam 0x10,0x8959
+	branch set_tx_power_5db
+
 p_set_tx_power_0db:
-	call p_rx_low_sens
+//	call p_rx_low_sens
 //	jam 0xba,0x894b
 	jam 0xd0,0x8955
 	jam 0xe0,0x8956
 //	jam 0x88,0x8957
-	jam 0x6c,0x8958
+	jam 0x3c,0x8958
 //	jam 0x10,0x8959
 	branch set_tx_power_0db	
 
@@ -3396,21 +3421,6 @@
 //	jam 0x3c,0x8958
 //	jam 0x10,0x8959
 //	branch set_tx_power_3db
-	
-p_set_tx_power_5db:
-//	call p_rx_high_sens
-	jam 0xfb,0x894c 
-	jam 0xef,0x894d
-	jam 0xec,0x894e 
-	jam 0x5e,0x894f
-
-//	jam 0xba,0x894b
-	jam 0xd0,0x8955
-	jam 0xe0,0x8956
-//	jam 0x88,0x8957
-	jam 0x3c,0x8958
-//	jam 0x10,0x8959
-	branch set_tx_power_5db
 
 //p_set_tx_power_f3db:
 //	call p_rx_low_sens
@@ -3423,21 +3433,21 @@
 //	branch set_tx_power_f3db
 	
 p_set_tx_power_f5db:
-	call p_rx_low_sens
+//	call p_rx_low_sens
 //	jam 0xba,0x894b
 	jam 0xd0,0x8955
-	jam 0xc0,0x8956
+	jam 0xe0,0x8956
 //	jam 0x88,0x8957
-	jam 0x6c,0x8958
+	jam 0x3c,0x8958
 //	jam 0x10,0x8959
 	branch set_tx_power_f5db
 
-p_rx_low_sens:
-	jam 0x5b,0x894c
-	jam 0x96,0x894d
-	jam 0x2c,0x894e 
-	jam 0x46,0x894f
-	rtn
+//p_rx_low_sens:
+//	jam 0x5b,0x894c
+//	jam 0x96,0x894d
+//	jam 0x2c,0x894e 
+//	jam 0x46,0x894f
+//	rtn
 
 //p_rx_high_sens:
 //	jam 0xfb,0x894c 
@@ -3654,20 +3664,6 @@
 	nop 10
 	rtn
 
-test_gpio1_init:
-	arg TEST_GPIO1,temp
-	call gpio_config_output
-test_gpio1_low:
-	arg TEST_GPIO1,temp
-	call gpio_out_active
-	nop 10
-	rtn
-test_gpio1_high:
-	arg TEST_GPIO1,temp
-	call gpio_out_inactive
-	nop 10
-	rtn	
-
 test_h_l:
 	call test_gpio_high
 	branch test_gpio_low
Index: sched/mouse.dat
===================================================================
--- /branch/mouse_project/LeXiang/1066_Project/PBSwitch_2.4G&BLE_3ch_D1027E8_GAN/sched/mouse.dat	(revision 4262)
+++ /branch/mouse_project/LeXiang/1066_Project/PBSwitch_2.4G&BLE_3ch_D1027E8_GAN/sched/mouse.dat	(working copy)
@@ -462,7 +462,7 @@
 #24g init
 mem_24g_mode:01#tx
 mem_24g_data_type:01        #mouse 1,kb 2
-mem_24g_max_retry:04#max tx retry
+mem_24g_max_retry:06#max tx retry
 mem_24g_no_ack:00#with ack
 mem_24g_rx_window:c0 12     #400us
 mem_24g_interval:19			#0x19 24g report 125hz;0x0c,24g report 250hz
