Index: do.bat
===================================================================
--- /YC1308AC/branch/usb/do.bat	(revision 1458)
+++ /YC1308AC/branch/usb/do.bat	(working copy)
@@ -71,8 +71,8 @@
 ::echo exist c51 code
 ::geneep
 
-cd ..\output
-perl create_exen.pl 1 1024 64
+::cd ..\output
+::perl create_exen.pl 1 1024 64
 cd ..
 
 if "%device_option%" equ "mouse" (
Index: format/app_dongle.format
===================================================================
--- /YC1308AC/branch/usb/format/app_dongle.format	(revision 1458)
+++ /YC1308AC/branch/usb/format/app_dongle.format	(working copy)
@@ -34,46 +34,10 @@
 1 mem_dg_usb_tx_interval
 30 mem_dg_usb_device_name
 
-1 mem_g24_ota_config_type     //rr
-2 mem_g24_ota_storage_size   //byte
-2 mem_g24_ota_config_addr
-2 mem_g24_ota_config_remain_space
-
-1 mem_g24_ota_mode
-1 mem_g24_ota_sm
-
-1 mem_g24_ota_opcode
-1 mem_g24_ota_rtn_state
-1 mem_g24_ota_target
-1 mem_g24_ota_rx_len
-2 mem_g24_ota_rx_alllen
-2 mem_g24_ota_rx_alllen_p
-2 mem_g24_ota_rx_sum
-1 mem_g24_ota_rx_data_count
-1 mem_g24_ota_reset_timer
-1 mem_g24_ota_version_timer
-1 mem_g24_ota_txbuf_len
-31 mem_g24_ota_txbuf
-
-1 mem_g24_reportrate_count
-1 mem_g24_reportrate_count2
-1 mem_g24_reportrate_count3
-6 mem_g24_reportrate_lasttime
-6 mem_g24_reportrate_lasttime2
-6 mem_g24_reportrate_lasttime3
-
-4 mem_g24_reportrate_detatime
-4 mem_g24_reportrate_detatime3
-
-1 mem_g24_reportrate_check_count
-3 mem_24g_tsniff
-7 mem_g24_tx_last
-1 mem_g24_reportrate_add
-1 mem_g24_reportrate_continue
-0 mem_dongle_end
+1 mem_24g_device1_bind_disable
+1 mem_24g_device2_bind_disable
 
-1 mem_24g_mouse_bind_enable
-1 mem_24g_keyboard_bind_enable
+0 mem_dongle_end
 )
 
 
Index: format/regs.format
===================================================================
--- /YC1308AC/branch/usb/format/regs.format	(revision 1458)
+++ /YC1308AC/branch/usb/format/regs.format	(working copy)
@@ -159,6 +159,7 @@
 	0x828a core_docd_pdata
 
 	0x8900 modem_en
+	0x8921 core_rx_ctrl1
 	0x8938 mod_value_scale1
 	0x8960 core_rf_rx_agc_ctrl
 	0x8961 core_rf_rx_gain_fix
Index: output/eeprom.dat
===================================================================
--- /YC1308AC/branch/usb/output/eeprom.dat	(revision 1460)
+++ /YC1308AC/branch/usb/output/eeprom.dat	(working copy)
@@ -2,8 +2,8 @@
 02
 aa
 55
-32
-05
+e6
+04
 c2
 84
 00
@@ -11,31 +11,31 @@
 c0
 41
 80
-30
+2a
 c0
 45
 00
-21
+1f
 c0
 45
 80
-22
+20
 c0
 46
 00
-7f
+71
 c0
 57
 00
-37
+31
 c0
 5d
 80
-47
+39
 c0
 5e
 00
-49
+3b
 20
 20
 13
@@ -43,43 +43,35 @@
 c0
 47
 00
-1a
-c0
-47
-fa
-26
-c0
-48
-fa
-7e
+18
 c0
 48
 00
-6a
+5c
 c0
 4a
 80
-94
+86
 c0
 54
 80
-14
+12
 c0
 6f
 00
-9d
+8d
 c0
 70
 00
-e4
+d1
 c0
 70
 80
-f5
+e2
 c0
 72
 01
-15
+02
 20
 20
 13
@@ -169,22 +161,6 @@
 21
 40
 70
-48
-65
-02
-70
-48
-64
-02
-58
-00
-bb
-80
-67
-e1
-48
-38
-70
 89
 68
 76
@@ -224,58 +200,26 @@
 20
 11
 7d
-d8
-40
-69
-78
 20
 40
-23
-20
-58
-00
 36
-4e
-67
-e1
-48
-89
+20
 58
 00
-00
-9a
+69
+78
 67
 e1
 48
-8d
-58
-00
-37
-12
-67
-e1
+38
+70
 48
-8f
-58
-00
-36
-f5
-67
-e1
+65
+02
+70
 48
-8b
-58
-00
-36
-5b
-67
-e1
-0b
-45
-20
-40
-79
-9d
+64
+02
 20
 40
 62
@@ -291,7 +235,7 @@
 20
 40
 00
-45
+37
 20
 20
 36
@@ -311,7 +255,7 @@
 20
 40
 00
-4e
+40
 20
 20
 36
@@ -323,11 +267,11 @@
 20
 40
 00
-51
+43
 20
 20
 00
-5d
+4f
 6f
 e0
 c9
@@ -443,7 +387,7 @@
 c0
 00
 00
-6f
+61
 20
 20
 7a
@@ -467,7 +411,7 @@
 c0
 00
 80
-75
+67
 20
 20
 7a
@@ -479,7 +423,7 @@
 c0
 04
 80
-78
+6a
 20
 20
 7a
@@ -559,7 +503,7 @@
 20
 40
 00
-7a
+6c
 1f
 e6
 7e
@@ -583,7 +527,7 @@
 24
 20
 80
-92
+84
 58
 00
 00
@@ -622,14 +566,6 @@
 59
 20
 40
-37
-01
-20
-60
-00
-00
-20
-40
 22
 3f
 6f
@@ -664,18 +600,6 @@
 40
 16
 c8
-6f
-f0
-89
-60
-79
-20
-7e
-03
-67
-f0
-89
-60
 20
 40
 21
@@ -683,7 +607,7 @@
 c5
 97
 80
-ad
+9a
 78
 3c
 fc
@@ -738,8 +662,8 @@
 af
 c5
 17
-a1
-f6
+80
+a5
 78
 23
 fc
@@ -767,7 +691,7 @@
 24
 22
 80
-9c
+8c
 78
 58
 fc
@@ -839,7 +763,7 @@
 24
 21
 00
-9c
+8c
 1f
 e2
 72
@@ -847,7 +771,7 @@
 20
 22
 80
-d6
+c3
 20
 40
 22
@@ -859,11 +783,11 @@
 c2
 00
 00
-d3
+c0
 c5
 13
 80
-db
+c8
 18
 a2
 22
@@ -911,7 +835,7 @@
 20
 23
 00
-9c
+8c
 20
 20
 22
@@ -979,7 +903,7 @@
 20
 40
 00
-fb
+e8
 20
 20
 22
@@ -1038,8 +962,8 @@
 73
 c5
 16
-81
-09
+80
+f6
 19
 31
 7e
@@ -1078,8 +1002,8 @@
 02
 c2
 00
-01
-0b
+00
+f8
 19
 31
 7e
@@ -1110,8 +1034,8 @@
 28
 20
 20
-01
-07
+00
+f4
 6f
 e0
 c8
@@ -1119,15 +1043,15 @@
 c0
 55
 01
-1a
+07
 c0
 2a
 81
-24
+11
 c0
 11
 01
-34
+21
 20
 20
 23
@@ -1139,11 +1063,11 @@
 c0
 00
 81
-1e
+0b
 c0
 01
 01
-21
+0e
 20
 60
 00
@@ -1151,7 +1075,7 @@
 6f
 e0
 c9
-92
+32
 24
 7a
 00
@@ -1163,7 +1087,7 @@
 6f
 e0
 c9
-93
+33
 24
 7a
 00
@@ -1179,7 +1103,7 @@
 20
 3a
 01
-2a
+17
 6f
 e2
 48
@@ -1203,11 +1127,11 @@
 c0
 00
 81
-2e
+1b
 c0
 01
 01
-31
+1e
 20
 60
 00
@@ -1215,7 +1139,7 @@
 6f
 e0
 c9
-92
+32
 24
 7a
 00
@@ -1227,7 +1151,7 @@
 6f
 e0
 c9
-93
+33
 24
 7a
 00
@@ -1243,7 +1167,7 @@
 20
 3a
 01
-3a
+27
 6f
 e2
 48
@@ -1267,11 +1191,11 @@
 c0
 00
 81
-3e
+2b
 c0
 01
 01
-45
+32
 20
 60
 00
@@ -1279,7 +1203,7 @@
 6f
 e0
 c9
-92
+32
 24
 7a
 00
@@ -1291,14 +1215,14 @@
 c0
 01
 01
-43
+30
 20
 60
 00
 00
 70
 49
-92
+32
 01
 20
 20
@@ -1307,7 +1231,7 @@
 6f
 e0
 c9
-93
+33
 24
 7a
 00
@@ -1319,21 +1243,21 @@
 c0
 80
 01
-4a
+37
 20
 60
 00
 00
 70
 49
-93
+33
 01
 20
 20
 23
 fd
-e5
-a4
+7c
+c4
 aa
 55
 40
@@ -1389,8 +1313,8 @@
 00
 00
 00
-c0
-23
+40
+21
 00
 00
 02
@@ -1498,145 +1422,12 @@
 00
 ee
 41
-00
-aa
-55
-78
-00
-4b
-10
-1b
-06
-00
-ff
-09
-01
-a1
-01
-85
-af
-95
-1f
-75
-08
-26
-ff
-00
-15
-00
-09
-01
-81
-02
-09
-01
-91
-02
-c0
-5b
-09
-02
-5b
-00
-03
-01
-00
-a0
-32
-09
-04
-00
-00
-01
-03
-01
-01
-00
-09
-21
-00
-02
-00
-01
-22
-1a
-00
-07
-05
-81
-03
-40
-00
-02
-09
-04
-01
-00
-01
-03
-01
-02
-00
-09
-21
-00
-02
-00
-01
-22
-a3
-00
-07
-05
-82
-03
-40
-00
-02
-09
-04
-02
-00
-02
-03
-00
-00
-00
-09
-21
-00
-02
-00
-01
-22
-1b
-00
-07
-05
-83
-03
-40
-00
-02
-07
-05
-03
-03
-40
-00
-02
-aa
-55
-01
-00
-85
-49
-20
+80
 55
 aa
 aa
 55
-ec
-2d
-2b
-42
+70
+1c
+65
+9d
Index: output/memmap.format
===================================================================
--- /YC1308AC/branch/usb/output/memmap.format	(revision 1458)
+++ /YC1308AC/branch/usb/output/memmap.format	(working copy)
@@ -1912,40 +1912,9 @@
 0x490a mem_dg_usb_vid_pid
 0x4913 mem_dg_usb_tx_interval
 0x4914 mem_dg_usb_device_name
-0x4932 mem_g24_ota_config_type//rr
-0x4933 mem_g24_ota_storage_size//byte
-0x4935 mem_g24_ota_config_addr
-0x4937 mem_g24_ota_config_remain_space
-0x4939 mem_g24_ota_mode
-0x493a mem_g24_ota_sm
-0x493b mem_g24_ota_opcode
-0x493c mem_g24_ota_rtn_state
-0x493d mem_g24_ota_target
-0x493e mem_g24_ota_rx_len
-0x493f mem_g24_ota_rx_alllen
-0x4941 mem_g24_ota_rx_alllen_p
-0x4943 mem_g24_ota_rx_sum
-0x4945 mem_g24_ota_rx_data_count
-0x4946 mem_g24_ota_reset_timer
-0x4947 mem_g24_ota_version_timer
-0x4948 mem_g24_ota_txbuf_len
-0x4949 mem_g24_ota_txbuf
-0x4968 mem_g24_reportrate_count
-0x4969 mem_g24_reportrate_count2
-0x496a mem_g24_reportrate_count3
-0x496b mem_g24_reportrate_lasttime
-0x4971 mem_g24_reportrate_lasttime2
-0x4977 mem_g24_reportrate_lasttime3
-0x497d mem_g24_reportrate_detatime
-0x4981 mem_g24_reportrate_detatime3
-0x4985 mem_g24_reportrate_check_count
-0x4986 mem_24g_tsniff
-0x4989 mem_g24_tx_last
-0x4990 mem_g24_reportrate_add
-0x4991 mem_g24_reportrate_continue
-0x4992 mem_dongle_end
-0x4992 mem_24g_mouse_bind_enable
-0x4993 mem_24g_keyboard_bind_enable
+0x4932 mem_24g_device1_bind_disable
+0x4933 mem_24g_device2_bind_disable
+0x4934 mem_dongle_end
 0x487e mem_rssi_hex_received
 0x487f mem_24g_pair_sm
 0x4880 mem_24g_pair_no_ack
Index: program/app_dongle.prog
===================================================================
--- /YC1308AC/branch/usb/program/app_dongle.prog	(revision 1458)
+++ /YC1308AC/branch/usb/program/app_dongle.prog	(working copy)
@@ -43,7 +43,6 @@
 	store 2,mem_rssi_noise_device2_buffer_ptr
 	call g24_enable_1M
 	call g24_receive_init
-dongle_default_no_eeprom_next:
 	call g24_pair_param_init
 	call g24_chmap_param_init
 	//usb init
Index: program/patch.prog
===================================================================
--- /YC1308AC/branch/usb/program/patch.prog	(revision 1460)
+++ /YC1308AC/branch/usb/program/patch.prog	(working copy)
@@ -1,6 +1,4 @@
 //define KEYBOARD
-//define OTA_CODE
-//define REPORTRATE_CODE
 
 	bbit1 8,pf_patch_ext
 	beq patch10_3,p_set_sync_on
@@ -13,14 +11,7 @@
 	branch loop
 
 pf_patch_ext:
-ifdef OTA_CODE
-	beq patch31_7,p_usb_rx
-	beq patch32_1,p_usb0_request_get_descriptor
-else
 	beq patch31_6,p_usb_init
-	beq patch31_7,usb_rx+1
-	beq patch32_1,usb0_request_get_descriptor+1
-endif 
 	beq patch32_0,p_usb_class_type
 	beq patch32_5,p_usb_tx
 	beq patch35_1,p_le_enable
@@ -49,7 +40,8 @@
 	
 p_tx_on_next:
 	branch set_tx_power_10db
-/********************rx fail patch************************/
+
+
 p_initialize_radio_cont:
 	//config osc_xtal_ctrim
 	call init_lpm_ctrl
@@ -61,15 +53,10 @@
 	jam 0x90,core_syn_pfd_lkd_cfg
 
 	jam 0x00,core_syn_loopdiv_dsm_cfg
-	jam 0x40,0x8921
-	jam 2,mem_24g_tx_phy
-	jam 2,mem_24g_rx_phy
-	setarg 0xbb80
-	store 2,mem_24g_rx_window
+	jam 0x40,core_rx_ctrl1
 	//Improve auto agc
 	jam 0x76,core_agc_wb_sat_th
 	jam 0x76,core_agc_nb_sat_th
-
 	branch initialize_radio_cont+1
 
 p_set_sync_on:
@@ -84,55 +71,14 @@
 
 
 p_app_init:
-/********************dongle rx window patch************************/
-	arg 0x6978,temp
-	call g24_rx_window_store
-
-
-ifdef OTA_CODE
-	call p_g24_check_ota_data
-	call p_g24_load_ota_config,user
-	
-	fetch 2,core_lpm_ctrl
-	call lpm_write_config
-
-	fetch 9,mem_dg_usb_vid_pid
-	store 9,mem_usb_vid_pid
-
-	
-	setarg p_dongle_timer
-	store 2,mem_cb_event_timer
-	setarg p_dongle_usb_config
-	store 2,mem_cb_usb_config
-	
-	arg mem_usb_ep3_in_data,contw
-	call clear_mem_512
-	arg mem_usb_ep3_out_data,contw
-	call clear_mem_512
-	
-	setarg p_dongle_dispatch
-	store 2,mem_cb_24g_receive_process
-
-else
-	setarg dongle_dispatch
-	store 2,mem_cb_24g_receive_process
-	
-endif	
-	setarg p_dongle_g24_mouse
-	store 2,mem_cb_24g_data_device1
-	setarg dongle_g24_kb
-	store 2,mem_cb_24g_data_device2
-	setarg dongle_ackpayload_prep
-	store 2,mem_cb_24g_ackpayload
-
-	setarg dongle_usb_config
-	store 2,mem_cb_usb_config
-
+	call dongle_init
+	setarg 0x6978
+	store 2,mem_24g_rx_window
+	jam 2,mem_24g_tx_phy
+	jam 2,mem_24g_rx_phy
 ifdef KEYBOARD
 	jam DONGLE_KB_BIND_SUCCESS,mem_dg_kb_bind_flag
 endif
-	call usb_init
-	
 	//watch dog enable
 	call wdt_set_enable
 p_wdt_kick:
@@ -140,532 +86,17 @@
 	setarg 125
 	branch wdt_init_config
 
-ifdef OTA_CODE
-
-/********************add wdt************************/
-
-p_dongle_usb_rx_epc3:
-	jam 0,mem_usb_ep3_out_data_flag
-	fetch 1,mem_usb_ep3_out_data_len
-//	sub pdata,3,null
-	rtn blank
-	fetch 1,mem_usb_ep3_out_data
-	rtnne COMMAND_CURRENT_OTA
-//	ifetch 1,contr
-	branch p_dongle_usb_cmd_ota
-
-p_dongle_usb_dispatch:
-	call p_wdt_kick
-	call usb_isr
-	fetch 1,mem_usb_ep3_out_data_flag
-	nbranch p_dongle_usb_rx_epc3,blank
-	fetch 1,mem_usb0_get_set_report
-	rtn blank
-	jam 0,mem_usb0_get_set_report
-	fetch 2,mem_usb_setup_bValue_temp
-	arg PC_SET_REPORT,temp
-	isub temp,null
-	nrtn zero
-	//get usb host command
-	fetch 1,mem_usb0_set_report_data
-	rtnne PC_REPORT_ID
-	fetch 1,mem_usb0_set_report_data+1
-	beq COMMAND_MODE,dongle_dispose_cmd_mode
-	beq COMMAND_BIND,dongle_dispose_cmd_bind
-	beq COMMAND_CURRENT_PROJECT,dongle_dispose_cmd_current_project
-	beq COMMAND_CURRENT_MODE,dongle_dispose_cmd_current_mode
-	beq COMMAND_CURRENT_FW_VERSION,dongle_dispose_cmd_current_fw_version
-//	beq COMMAND_CURRENT_OTA,p_dongle_usb_cmd_ota
-	branch dongle_usb0_data_ready_report_set0
-
-p_dongle_usb_cmd_ota:
-	ifetch 1,contr
-	store 1,mem_g24_ota_opcode
-	beq G24_OTA_CMD_VERSION,p_dongle_usb_cmd_ota_version
-	beq G24_OTA_CMD_INFO,p_dongle_usb_cmd_ota_info
-	beq G24_OTA_CMD_CONFIG,p_dongle_usb_cmd_ota_config
-	beq G24_OTA_CMD_SET_CONFIG_END,p_dongle_usb_cmd_ota_set_config_end
-	beq G24_OTA_CMD_DATA,p_dongle_usb_cmd_ota_data
-	beq G24_OTA_CMD_RESET,p_dongle_usb_cmd_ota_reset
-	beq G24_OTA_CMD_SYNC,p_dongle_usb_cmd_sync
-	rtn
-
-p_dongle_usb_cmd_ota_version:
-	ifetch 1,contr
-	rtnne 3
-	ifetch 1,contr
-	beq G24_OTA_TARGET_DONGLE,p_g24_dongle_ota_version_no_mouse
-	rtnne G24_OTA_TARGET_DONGLE_MOUSE
-	jam 90,mem_g24_ota_version_timer
-	branch p_start_g24_ota
-
-p_dongle_usb_cmd_ota_info:
-	jam G24_OTA_DONGLE_SM_INFO_RX_USB,mem_g24_ota_sm
-	ifetch 1,contr
-	rtnne 1
-	ifetch 1,contr
-	store 1,mem_g24_ota_target	
-	beq G24_OTA_TARGET_DONGLE,p_dongle_usb_cmd_ota_info_dongle
-	beq G24_OTA_TARGET_MOUSE,p_dongle_usb_cmd_ota_info_mouse
-	rtn
-
-p_dongle_usb_cmd_ota_info_dongle:
-	jam G24_OTA_DONGLE_SM_VERSION_TX_USB,mem_g24_ota_sm
-	jam COMMAND_CURRENT_OTA,mem_usb_ep3_in_data
-	jam G24_OTA_CMD_INFO,mem_usb_ep3_in_data+1
-	jam 22,mem_usb_ep3_in_data+2
-	jam G24_OTA_STATUS_SUCCESS,mem_usb_ep3_in_data+3
-	jam G24_OTA_TARGET_DONGLE,mem_usb_ep3_in_data+4
-	fetch 2,core_chipid
-	store 4,mem_usb_ep3_in_data+5
-	setarg 1
-	istore 6,contw
-	setarg 0
-	istore 2,contw
-	istore 2,contw
-	fetch 1,mem_g24_ota_config_type
-	istore 1,contw
-	setarg 0
-	istore 1,contw
-	fetcht 2,mem_g24_ota_config_addr
-	istoret 2,contw
-	fetch 2,mem_g24_ota_storage_size
-	lshift8 pdata,pdata
-	rshift  pdata,pdata 
-	isub temp,pdata
-	nbranch  p_dongle_usb_cmd_ota_info_dongle_empty,positive
-p_dongle_usb_cmd_ota_info_dongle_common:	
-	istore 2,contw	
-	store 2,mem_g24_ota_config_remain_space
-	branch p_g24_dongle_ota_tx_usb_common	
-	
-p_dongle_usb_cmd_ota_info_dongle_empty:
-	setarg 0
-	branch p_dongle_usb_cmd_ota_info_dongle_common
-	
-p_dongle_usb_cmd_ota_info_mouse:
-	jam G24_OTA_DONGLE_SM_INFO_RX_USB,mem_g24_ota_sm
-	branch p_dongle_usb_cmd_ota_common
-	
-p_dongle_usb_cmd_ota_common:
-	fetch 2,mem_usb_ep3_out_data
-	store 2,mem_g24_ota_txbuf
-	fetch 1,mem_usb_ep3_out_data+2
-	sub pdata,29,null
-	nbranch assert,positive
-	copy pdata,loopcnt
-	increase 2,pdata
-	store 1,mem_g24_ota_txbuf_len
-	arg mem_usb_ep3_out_data+3,contr
-	arg mem_g24_ota_txbuf+2,contw
-	branch memcpy
-	
-p_dongle_usb_cmd_ota_config:
-	jam G24_OTA_DONGLE_SM_CONFIG_RX_USB,mem_g24_ota_sm
-	ifetch 1,contr
-	rtnne 7
-	ifetch 1,contr
-	store 1,mem_g24_ota_target	
-	beq G24_OTA_TARGET_DONGLE,p_dongle_usb_cmd_ota_config_dongle
-	beq G24_OTA_TARGET_MOUSE,p_dongle_usb_cmd_ota_config_mouse
-	rtn
-
-p_dongle_usb_cmd_ota_config_dongle:
-	jam G24_OTA_DONGLE_SM_CONFIG_TX_USB,mem_g24_ota_sm
-	ifetch 2,contr
-	ifetcht 2,contr
-	storet 2,mem_g24_ota_rx_alllen_p
-	fetch 2,mem_g24_ota_config_remain_space
-	isub temp,null
-	nbranch p_dongle_usb_cmd_ota_fail2,positive
-	branch p_dongle_usb_cmd_ota_ok2
-	
-	
-p_dongle_usb_cmd_ota_config_mouse:
-	branch p_dongle_usb_cmd_ota_common
-	
-
-p_dongle_usb_cmd_ota_set_config_end:
-	jam G24_OTA_DONGLE_SM_SET_CONFIG_RX_USB,mem_g24_ota_sm
-	ifetch 1,contr
-	rtnne 5
-	ifetch 1,contr
-	store 1,mem_g24_ota_target
-	beq G24_OTA_TARGET_DONGLE,p_dongle_usb_cmd_ota_set_config_dongle
-	beq G24_OTA_TARGET_MOUSE,p_dongle_usb_cmd_ota_set_config_mouse
-	rtn
-
-p_dongle_usb_cmd_ota_set_config_dongle:
-	jam G24_OTA_DONGLE_SM_SET_CONFIG_TX_USB,mem_g24_ota_sm
-	ifetch 2,contr
-	ifetcht 2,contr
-	fetchr rega, 2,mem_g24_ota_rx_alllen
-	isub rega,null
-	nbranch p_dongle_usb_cmd_ota_fail2,zero	
-	fetch 2,mem_g24_ota_rx_sum
-	isub temp,null
-	nbranch p_dongle_usb_cmd_ota_fail2,zero
-
-	call p_g24_check_ota_data_all
-	nbranch p_dongle_usb_cmd_ota_fail2,user
-	
-p_dongle_usb_cmd_ota_ok2:
-	jam G24_OTA_STATUS_SUCCESS,mem_g24_ota_rtn_state	
-p_g24_dongle_ota_tx_usb_common_len2:	
-	jam COMMAND_CURRENT_OTA,mem_usb_ep3_in_data
-	fetch 1,mem_g24_ota_opcode
-	store 1,mem_usb_ep3_in_data+1
-	jam 2,mem_usb_ep3_in_data+2
-	fetch 1,mem_g24_ota_rtn_state
-	store 1,mem_usb_ep3_in_data+3
-	fetch 1,mem_g24_ota_target
-	store 1,mem_usb_ep3_in_data+4
-	branch p_g24_dongle_ota_tx_usb_common	
-
-
-p_g24_check_ota_data_all:
-	call p_g24_check_ota_data
-	nrtn user	
-	fetch 2,mem_g24_ota_rx_sum
-	isub alarm,null
-	nbranch disable_user,zero	
-	fetcht 2,mem_temp_block6
-	fetch 2,mem_g24_ota_rx_alllen
-	increase -5,pdata
-	isub temp,null
-	nbranch disable_user,zero
-	branch enable_user
-	
-	
-p_g24_check_ota_data:
-	fetch 2,mem_g24_ota_config_addr
-	byteswap pdata,pdata
-	store 2,mem_addr_mi
-	arg 3,temp
-	arg mem_temp_block5,rega
-	call iicd_read_eep	
-
-	fetch 1,mem_temp_block5
-	bne  G24_OTA_DATA_HEADER,disable_user
-	ifetcht 2,contr
-//	fetch 2,mem_g24_ota_rx_alllen
-//	increase -5,pdata
-//	isub temp,null
-//	nbranch disable_user,zero
-	storet 2,mem_pdatatemp //len
-	storet 2,mem_temp_block6 //len
-
-	fetch 1,mem_temp_block5
-	arg 0xffff,rege //crc
-	arg 0,temp
-	arg mem_temp_block5,contr
-	arg 3,loopcnt
-	call p_g24_dongle_data_sum
-	copy temp,alarm
-	
-	fetch 2,mem_g24_ota_config_addr
-	add pdata,3,regf
-	call p_g24_check_ota_data_loop
-
-	byteswap regf,pdata
-	store 2,mem_addr_mi
-	arg 2,temp
-	arg mem_temp_block5,rega
-	call iicd_read_eep	
-	fetch 2,mem_temp_block5
-	isub rege, null
-	nbranch disable_user,zero
-	fetch 1,mem_temp_block5
-	iadd alarm,alarm
-	ifetch 1,contr
-	iadd alarm,alarm
-	setarg 0xffff
-	iand alarm,alarm
-	branch enable_user
-
-	
-p_g24_check_ota_data_loop:
-	fetch 2,mem_pdatatemp
-	rtn blank
-	copy pdata,temp
-	sub pdata,16,null
-	branch p_g24_check_ota_data_loopend,positive
-	increase -16,pdata
-	arg 0x10,temp //len
-p_g24_check_ota_data_loop2:
-	store 2,mem_pdatatemp
-	copy temp,regext
-	copy regf,pdata
-	byteswap pdata,pdata
-	store 2,mem_addr_mi
-	arg mem_temp_block5,rega
-	call iicd_read_eep
-	copy regf,pdata
-	iadd regext,regf
-	copy regext,loopcnt
-	copy rege,pdata
-	arg mem_temp_block5,contr
-	icrc contr
-	copy pdata,rege
-	copy regext,loopcnt
-	arg mem_temp_block5,contr
-	copy alarm,temp
-	call p_g24_dongle_data_sum
-	copy temp,alarm
-	branch p_g24_check_ota_data_loop
-
-p_g24_check_ota_data_loopend:
-	setarg 0
-	branch p_g24_check_ota_data_loop2
-	
-	
-p_dongle_usb_cmd_ota_fail2:
-	jam G24_OTA_STATUS_FAIL,mem_g24_ota_rtn_state
-	branch p_g24_dongle_ota_tx_usb_common_len2
-	
-	
-p_dongle_usb_cmd_ota_set_config_mouse:
-	branch p_dongle_usb_cmd_ota_common
-	
-p_dongle_usb_cmd_ota_data:
-	jam G24_OTA_DONGLE_SM_DATA_RX_USB,mem_g24_ota_sm
-	ifetchr regb,1,contr //len
-	ifetch 1,contr
-	store 1,mem_g24_ota_target
-	beq G24_OTA_TARGET_DONGLE,p_dongle_usb_cmd_ota_data_dongle
-	beq G24_OTA_TARGET_MOUSE,p_dongle_usb_cmd_ota_data_mouse
-	rtn
-
-p_dongle_usb_cmd_ota_data_dongle:
-	ifetch 1,contr
-	copy contr,rega
-	call p_dongle_usb_cmd_ota_data_check_count
-	nbranch p_dongle_usb_cmd_ota_data_dongle_fail,user
-
-	sub regb,2,null
-	branch p_dongle_usb_cmd_ota_data_dongle_fail,positive
-	increase -2,regb
-	storer regb,2,mem_hold_contw
-	storer rega,2,mem_hold_contr
-	call iicd_eeprom_write_enable
-	call 	p_dongle_usb_cmd_ota_write_data
-	call iicd_eeprom_write_disable
-	fetchr regb,2,mem_hold_contw
-	fetchr rega,2,mem_hold_contr
-	fetch 2,mem_g24_ota_rx_alllen
-	iadd regb,pdata
-	store 2,mem_g24_ota_rx_alllen
-	copy regb,loopcnt
-	arg 0,temp
-	copy rega,contr
-	call p_g24_dongle_data_sum	
-	fetch 2,mem_g24_ota_rx_sum
-	iadd temp,pdata
-	store 2,mem_g24_ota_rx_sum
-	
-	jam G24_OTA_DONGLE_SM_DATA_TX_USB,mem_g24_ota_sm
-	jam COMMAND_CURRENT_OTA,mem_usb_ep3_in_data
-	jam G24_OTA_CMD_DATA,mem_usb_ep3_in_data+1
-	jam 3,mem_usb_ep3_in_data+2
-	jam G24_OTA_STATUS_SUCCESS,mem_usb_ep3_in_data+3
-	fetch 1,mem_g24_ota_target
-	store 1,mem_usb_ep3_in_data+4
-	fetch 1,mem_g24_ota_rx_data_count
-	store  1,mem_usb_ep3_in_data+5
-	branch  p_g24_dongle_ota_tx_usb_common	
-
-p_dongle_usb_cmd_ota_write_data:
-//	fetch 1,mem_g24_ota_config_type
-	fetch 2,mem_g24_ota_config_addr
-	rtn blank
-	fetcht 2,mem_g24_ota_rx_alllen
-	iadd temp,pdata
-	copy regb,temp
-	branch iicd_write_ota_data 
-	
-	
-p_dongle_usb_cmd_ota_data_dongle_fail:
-	jam G24_OTA_DONGLE_SM_DATA_TX_USB,mem_g24_ota_sm
-	jam COMMAND_CURRENT_OTA,mem_usb_ep3_in_data
-	jam G24_OTA_CMD_DATA,mem_usb_ep3_in_data+1
-	jam 3,mem_usb_ep3_in_data+2
-	jam G24_OTA_STATUS_FAIL,mem_usb_ep3_in_data+3
-	fetch 1,mem_g24_ota_target
-	store 1,mem_usb_ep3_in_data+4
-	fetch 1,mem_g24_ota_rx_data_count
-	store  1,mem_usb_ep3_in_data+5
-	branch  p_g24_dongle_ota_tx_usb_common		
-
-p_dongle_usb_cmd_ota_data_check_count:
-	fetcht 1,mem_g24_ota_rx_data_count
-	store 1,mem_g24_ota_rx_data_count
-	beq 0,p_dongle_usb_cmd_ota_data_check_count_0
-	isub temp,pdata
-	beq  1,enable_user	
-	branch disable_user
-	
-p_dongle_usb_cmd_ota_data_check_count_0:	
-	sub temp,0xff,null
-	branch enable_user,zero
-	branch disable_user
-	
-	
-p_dongle_usb_cmd_ota_data_mouse:
-	branch p_dongle_usb_cmd_ota_common
-	
-	
-p_dongle_usb_cmd_ota_reset:
-	jam G24_OTA_DONGLE_SM_RESET_RX_USB ,mem_g24_ota_sm
-	ifetch 1,contr
-	rtnne 1
-	ifetch 1,contr
-	beq G24_OTA_TARGET_DONGLE,p_dongle_usb_cmd_reset_dongle
-	beq G24_OTA_TARGET_MOUSE,p_dongle_usb_cmd_ota_reset_mouse
-	beq G24_OTA_TARGET_DONGLE_MOUSE,p_dongle_usb_cmd_reset_dongle_mouse
-	rtn
-
-p_dongle_usb_cmd_reset_dongle:
-	branch soft_reset_chip
-	
-p_dongle_usb_cmd_ota_reset_mouse:
-p_dongle_usb_cmd_reset_dongle_mouse:
-	jam 20,mem_g24_ota_reset_timer
-	branch p_dongle_usb_cmd_ota_common
-
-	
-p_dongle_usb_cmd_sync:
-	ifetch 1,contr
-	rtnne 1
-	ifetch 1,contr
-	rtnne 0x5a
-	jam COMMAND_CURRENT_OTA,mem_usb_ep3_in_data
-	jam G24_OTA_CMD_SYNC,mem_usb_ep3_in_data+1
-	jam 1,mem_usb_ep3_in_data+2
-	jam 0xa5,mem_usb_ep3_in_data+3
-	branch  p_g24_dongle_ota_tx_usb_common			
-
-
 
-
-
-	
-
-p_g24_work_mode_start:
-	fetch 1,mem_24g_work_mode
-	rtnne DONGLE_WORK
-	call g24_work_init
-	call g24_ch_process
-//	branch g24_receive_packet_start
-
-//p_g24_receive_packet_start:
-call p_g24_receive_transmit_ack
-	nbranch g24_rx_interrupt_clear,user3
-p_g24_receive_packet_parse:
-	call g24_receive_packet_parse_pid_crc
-	nbranch g24_rx_interrupt_clear,user
-	fetch 1,mem_24g_rxdata_length
-	branch g24_rx_interrupt_clear,blank
-	increase 2,pdata
-	iforce loopcnt
-	arg mem_24g_rxbuf,contr
-	arg mem_24g_rxdata_temp,contw
-	call memcpy
-	jam 0,mem_24g_mode_switch
-	fetch 1,mem_24g_pair_mode
-	call g24_enable_nodata_timer,blank
-	fetch 1,mem_24g_rxdata_temp+2
-	beq DATATYPE_DEVICE1,g24_data_device1	//mouse
-	beq DATATYPE_DEVICE2,g24_data_device2	//keyboard
-	beq DATATYPE_ATTEMP,g24_data_attemp	//reconn packet
-	beq DATATYPE_OTA,p_g24_data_ota
-	branch g24_rx_interrupt_clear
-
-
-	
-	
-	
-
-
-
-
-	
-	
-	
-
-
-
-
-	
-	
-	
-
-
-	
-p_g24_receive_transmit_ack:
-	call g24_rx_interrupt_clear
-	call g24_receive_packet
-	nrtn user3
-//g24_transmit_ack:
-//data type
-	
-	fetch 1,mem_24g_rxbuf
-	store 1,mem_24g_data_type
-//read len pid crc
-	call g24_read_len_pid_crc
-//read ack
-	fetch 1,mem_24g_rxbuf+1
-	isolate1 bit_ack_24g,pdata
-	branch g24tx_no_ack,true
-//g24tx_with_ack:
-
-	branch g24tx_no_ack
-
-p_g24_ackpayload_prep:
-	jam 0,mem_24g_datalen
-	branch p_dongle_ackpayload_prep
-//	fetch 1,mem_24g_ackpayload_enable
-//	rtn blank
-//	fetch 2,mem_cb_24g_ackpayload
-//	branch callback_func
-else
-/********************add wdt************************/
 p_dongle_usb_dispatch:
 	call p_wdt_kick
 	branch dongle_usb_dispatch+1
-endif 
-
 
 
-
-	
 /************************keyboard blank patch**********/
 p_dongle_work_mode_auto:
 	fetch 1,mem_24g_work_mode
 	rtnne DONGLE_WORK
-ifdef REPORTRATE_CODE
-	call p_g24_check_reportrate2
-	call p_g24_check_reportrate3
-//	fetch 1,mem_usb_tx_enable
-//	isolate1 2,pdata
-//	ncall p_g24_check_reportrate3,true
-	fetch 1,mem_usb_tx_enable
-	isolate1 2,pdata
-ifdef OTA_CODE
-	ncall p_g24_work_mode_start,true
-else
-	ncall g24_work_mode_start,true	
-endif
-	fetch 1,mem_24g_abort_packet
-	ncall p_g24_check_reportrate_stopadd,blank
-else
-ifdef OTA_CODE
-	call p_g24_work_mode_start
-else
-	call g24_work_mode_start	
-endif
-
-endif
-
+	call g24_work_mode_start
 	call p_dongle_g24_blank_data_process
 	branch dongle_work_mode_auto+5
 
@@ -766,397 +197,7 @@
 	branch rssi_hex2dec
 
 
-ifdef OTA_CODE
-
-
-/************************usb mac wakeup patch**********/
-p_usb_tx:
-	fetch 1,mem_usb_tx_enable
-	rtn blank
-	fetch 1,core_usb_txbusy
-	and_into 0x0f,pdata
-	nbranch usb_inwake_state_tx_dispose,blank
-	fetch 1,mem_usb_device_enumeration_endflag
-	branch usb_tx_fifo_release,blank
-	fetch 1,mem_usb_state
-	beq USB_SLEEP,usb_windows_wakeup
-	bne USB_CONNECTED,usb_tx_fifo_release
-	fetch 1,mem_usb_clear_remote_wakeup
-	nbranch usb_tx_fifo_release,blank
-	call usb_tx_data_ep1
-	call usb_tx_data_ep2
-	branch p_usb_tx_data_ep3
-
-p_usb_tx_data_ep3:
-	fetch 1,core_usb_txbusy
-	rtnbit1 3
-	fetch 1,mem_usb_tx_enable
-	rtnbit0 3
-	fetch 1,mem_usb_tx_enable
-	set0 3,pdata
-	store 1,mem_usb_tx_enable
-	fetchr loopcnt, 1,mem_usb_ep3_in_data_len
-//	jam 0,mem_usb_ep3_in_data_len
-	arg 32,loopcnt
-	arg mem_usb_ep3_in_data,contr
-p_usb_tx_ep3:
-	arg 3,queue
-	arg mem_usb_txbuf3,rega
-	storer rega,2,core_usb_tx_saddr3
-	branch usb_tx_buf
-
-
-p_usb_tx_enable_ep3:
-	fetch 1,mem_usb_tx_enable
-	set1 3,pdata
-	store 1,mem_usb_tx_enable
-	rtn
-
-
-p_usb_rx:
-	fetch 1,mem_usb_status
-	rtnbit0 USB_STATUS_RXREADY
-	arg mem_usb_rxbuf_temp,contw
-	call usb_rx_data
-	fetchr loopcnt,2,mem_usb_read_len
-	storer loopcnt,1,mem_usb_ep3_out_data_len
-	arg mem_usb_rxbuf_temp,contr	
-	copy temp,pdata
-	beq 0,p_usb0_rx
-	beq 3,p_usb_rx_ep3
-	branch usb_data_rx
-
-p_usb0_rx:
-	arg mem_usb_setup,contw
-	call memcpy
-	branch usb0_rx
-
-
-p_usb_rx_ep3:
-	arg mem_usb_ep3_out_data,contw
-	call memcpy
-	jam 1,mem_usb_ep3_out_data_flag
-	rtn
-
-
-	
-
-
-p_dongle_usb_config:
-	fetch 1,mem_dg_kb_bind_flag
-	bne DONGLE_KB_BIND_SUCCESS,p_dongle_usb_config_param
-	jam DONGLE_KB_BIND_SUCCESS,mem_dg_kb_bind_flag
-	fetch 4,USB_DEVICEDATA_ADDR+9
-	set1 29,pdata
-	store 4,mem_devicedesc+9
-p_dongle_usb_config_param:
-	call dongle_usb_device_name
-	call p_usb_tx_interval_config
-	call dongle_usb_vid_pid_config
-	branch p_dongle_usb_hid_icon_config
-
-p_usb_tx_interval_config:
-	fetch 1,mem_usb_tx_interval
-	rtn blank
-	store 1,mem_confdesc_new+34
-	store 1,mem_confdesc_new+59
-	rtn
-
-p_dongle_usb_hid_icon_config:
-	fetch 1,mem_dg_kb_bind_flag
-	beq DONGLE_KB_BIND_SUCCESS,p_dongle_usb_kb_hidreportdesc
-	setarg USB_KBDATA_VENDOR_DEFINE_ADDR
-	store 2,mem_hidreportdesc_kb
-	jam 0x1a,mem_confdesc_new+26//hid_descriptor--keyboard length
-	rtn
-p_dongle_usb_kb_hidreportdesc:
-	setarg USB_KBDATA_ADDR
-	store 2,mem_hidreportdesc_kb
-	jam 0x3f,mem_confdesc_new+26//hid_descriptor--keyboard length	
-	rtn
-
-
-p_usb0_request_get_descriptor:
-	fetch 1,mem_usb_setup_bValueH
-	beq DSC_CONFIG,p_dsc_config_info
-	beq DSC_HID,p_dsc_hid_info
-	beq DSC_HID_REPORT,p_dsc_hid_report_info
-	branch usb0_request_get_descriptor+2
-
-p_dsc_config_info:
-	setarg mem_confdesc_new
-	fetcht 1,mem_confdesc_new
-	branch dsc_info_set_data_len
-
-p_dsc_hid_info:
-	jam 0,mem_usb_get_protocol_flag
-	fetch 1,mem_usb_setup_wIndex
-	beq 0,p_dsc_hid_info_interface0
-	beq 1,p_dsc_hid_info_interface1
-	beq 2,p_dsc_hid_info_interface2
-	branch usb0_force_stall
-//class_descriptor hid_descriptor--keyboard 
-p_dsc_hid_info_interface0:
-	fetchr regb,1,mem_confdesc_new+19
-	arg mem_confdesc_new+19,rega
-	branch usb0_respond
-//class_descriptor hid_descriptor--mouse 
-p_dsc_hid_info_interface1:
-	fetchr regb,1,mem_confdesc_new+44
-	arg mem_confdesc_new+44,rega
-	branch usb0_respond
-//class_descriptor hid_descriptor--user
-p_dsc_hid_info_interface2:
-	fetchr regb,1,mem_confdesc_new+69
-	arg mem_confdesc_new+69,rega
-	branch usb0_respond
-
-
-p_dsc_hid_report_info:
-	fetch 2,mem_usb_setup_wIndex
-	beq 0,dsc_hid_report_info_0
-	beq 1,dsc_hid_report_info_1
-	beq 2,p_dsc_hid_report_info_2
-	branch usb0_force_stall
-p_dsc_hid_report_info_2:
-	jam 1,mem_usb_device_enumeration_endflag
-	jam USB_GOT_REPORT_REQ,mem_usb_state	
-	arg mem_hidreportdesc_ep3,rega
-	branch usb0_respond_length
-
-
-//----------------------------------------------------------------------
-
-
-p_dongle_g24_rx_mouse_ota:
-	rtn
-	
-p_dongle_dispatch:
-	fetch 1,mem_24g_pair_mode
-	beq 0x00,p_dongle_auto_bind
-	beq 0x01,dongle_pc_bind
-	beq 0x0f,dongle_all_powerful
-	rtn
-
-p_dongle_auto_bind:
-	call g24_mode_switch_init
-p_dongle_auto_bind_loop:
-	call g24_mode_switch
-	call dongle_work_mode_auto
-	call g24_bind_mode_auto
-	call g24_search_mode_auto
-	call dongle_usb_dispatch
-	call ui_timer_check
-	branch p_dongle_auto_bind_loop
-
-
-p_start_g24_ota:
-	call p_g24_ota_mode_enable
-//	fetch 1,mem_g24_ota_sm
-	
-//	jam OTA_ACKPAYLOAD,mem_24g_ackpayload_enable
-	jam G24_OTA_DONGLE_SM_VERSION_RX_USB,mem_g24_ota_sm
-	rtn
-
-
-p_dongle_ackpayload_prep:
-	fetch 1,mem_g24_ota_mode
-	nbranch p_g24_ota_ackpayload_prep,blank 
-	fetch 1,mem_24g_ackpayload_enable
-	beq BIND_ACKPAYLOAD,g24_bind_ackpayload_prep
-	beq KB_LED_ACKPAYLOAD,dongle_g24_kb_led_ackpayload_prep
-	rtn
-
-p_g24_ota_ackpayload_prep:
-	fetch 1,mem_g24_ota_sm
-	beq G24_OTA_DONGLE_SM_VERSION_RX_USB,p_g24_ota_ackpayload_verison
-	beq G24_OTA_DONGLE_SM_INFO_RX_USB,p_g24_ota_ackpayload_info
-	beq G24_OTA_DONGLE_SM_CONFIG_RX_USB,p_g24_ota_ackpayload_info
-	beq G24_OTA_DONGLE_SM_SET_CONFIG_RX_USB,p_g24_ota_ackpayload_info
-	beq G24_OTA_DONGLE_SM_DATA_RX_USB,p_g24_ota_ackpayload_info
-	beq G24_OTA_DONGLE_SM_RESET_RX_USB,p_g24_ota_ackpayload_reset
-	rtn
-
-p_g24_ota_ackpayload_reset:
-	jam 3,mem_24g_datalen
-	jam OTA_ACKPAYLOAD,mem_24g_txbuf	
-	jam G24_OTA_CMD_RESET,mem_24g_txbuf+1
-	jam G24_OTA_TARGET_MOUSE,mem_24g_txbuf+2
-	rtn	
-	
-p_g24_ota_ackpayload_verison:
-	jam 3,mem_24g_datalen
-	jam OTA_ACKPAYLOAD,mem_24g_txbuf	
-	jam G24_OTA_CMD_VERSION,mem_24g_txbuf+1
-	jam G24_OTA_TARGET_MOUSE,mem_24g_txbuf+2
-	rtn
-
-p_g24_ota_ackpayload_info:
-//	jam G24_OTA_DONGLE_SM_INFO_TX_MOUSE,mem_g24_ota_sm
-	fetchr loopcnt, 1,mem_g24_ota_txbuf_len
-	storer loopcnt, 1,mem_24g_datalen
-	arg mem_g24_ota_txbuf,contr
-	arg mem_24g_txbuf,contw
-	branch memcpy
-	
-
-p_g24_ota_mode_enable:
-	jam 1,mem_g24_ota_mode
-//	jam CLEAR_INIT,mem_24g_mode_init
-p_ota_init:
-	setarg 0
-	store 2,mem_g24_ota_rx_alllen
-	store 2,mem_g24_ota_rx_sum
-	store 1,mem_g24_ota_rx_data_count
-	store 1,mem_g24_ota_sm
-	rtn
-	
-p_g24_data_ota:
-	
-	fetch 1,mem_24g_rxdata_temp+3
-	store 1,mem_g24_ota_opcode
-	ifetcht 1,contr
-	sub temp,G24_OTA_STATUS_SUCCESS,null
-	nbranch p_g24_data_ota_fail,zero
-	ifetcht 1,contr
-	sub temp,G24_OTA_TARGET_MOUSE,null
-	nbranch assert,zero
-	beq G24_OTA_CMD_VERSION,p_g24_dongle_ota_process_version
-	beq G24_OTA_CMD_INFO,p_g24_dongle_ota_process_info
-	beq G24_OTA_CMD_CONFIG,p_g24_dongle_ota_process_config
-	beq G24_OTA_CMD_SET_CONFIG_END,p_g24_dongle_ota_process_set_config_end
-	beq G24_OTA_CMD_DATA,p_g24_dongle_ota_process_data
-	beq G24_OTA_CMD_RESET,p_g24_dongle_ota_process_reset
-	beq G24_OTA_CMD_PING,p_g24_dongle_ota_process_ping
-	branch assert
-
-p_g24_data_ota_fail:
-	//call ice_break
-	branch p_dongle_usb_cmd_reset_dongle
-
-p_g24_dongle_ota_process_reset:
-	branch p_g24_dongle_ota_process_reset
-	
-p_g24_dongle_ota_process_ping:
-	rtn
-	
-
-p_g24_dongle_ota_process_version:
-	jam 0,mem_g24_ota_version_timer
-	ifetch  2,contr
-	store 2,mem_temp
-	branch p_g24_dongle_ota_version
-	
-p_g24_dongle_ota_version_no_mouse:
-	setarg 0
-	store 2,mem_temp
-p_g24_dongle_ota_version:	
-	jam G24_OTA_DONGLE_SM_VERSION_TX_USB,mem_g24_ota_sm
-	jam COMMAND_CURRENT_OTA,mem_usb_ep3_in_data
-	jam G24_OTA_CMD_VERSION,mem_usb_ep3_in_data+1
-	jam 7,mem_usb_ep3_in_data+2
-	jam G24_OTA_STATUS_SUCCESS,mem_usb_ep3_in_data+3
-	jam G24_OTA_TARGET_DONGLE,mem_usb_ep3_in_data+4
-	setarg 1
-	store  2,mem_usb_ep3_in_data+5
-	setarg G24_OTA_TARGET_MOUSE
-	istore 1,contw
-	fetch 2,mem_temp
-	istore  2,contw
-	
-p_g24_dongle_ota_tx_usb_common:
-	fetch 1,mem_usb_ep3_in_data+2
-	increase 3,pdata
-	store 1,mem_usb_ep3_in_data_len
-	branch p_usb_tx_enable_ep3	
-	
-p_g24_dongle_ota_process_info:
-	jam G24_OTA_DONGLE_SM_INFO_TX_USB,mem_g24_ota_sm
-p_g24_dongle_ota_process_common:
-//call ice_break	
-	fetch 2,mem_24g_rxdata_temp+2
-	store 2,mem_usb_ep3_in_data
-	
-	fetch 1,mem_24g_rxdata_length	
-	sub pdata,2,null
-	rtn positive
-	increase -2,pdata
-	istore 1,contw
-	copy pdata,loopcnt
-	arg mem_usb_ep3_in_data+3,contw
-	arg mem_24g_rxdata_temp+4,contr
-	call memcpy
-	branch p_g24_dongle_ota_tx_usb_common
-	
-	
-p_g24_dongle_ota_process_config:
-	jam G24_OTA_DONGLE_SM_CONFIG_TX_USB,mem_g24_ota_sm	
-	branch p_g24_dongle_ota_process_common
-	
-p_g24_dongle_ota_process_set_config_end:
-	jam G24_OTA_DONGLE_SM_SET_CONFIG_TX_USB,mem_g24_ota_sm	
-	branch p_g24_dongle_ota_process_common
-
-p_g24_dongle_ota_process_data:
-	jam G24_OTA_DONGLE_SM_DATA_TX_USB,mem_g24_ota_sm	
-	branch p_g24_dongle_ota_process_common
-	
-
-p_g24_dongle_data_sum:
-	ifetch 1,contr
-	iadd temp,temp
-	loop p_g24_dongle_data_sum
-	rtn
-	
-
-
-//input loopcnt :len ; contr :data ptr 
-//ouput pdata :crc
-p_g24_dongle_ota_crc:
-	setarg 0xffff
-	icrc contr
-	rtn
-
-
-p_g24_load_ota_config:	
-	arg iicd_read_eep,regc
-	fetch 2,mem_g24_ota_config_addr
-	increase 3,pdata
-	byteswap pdata,pdata
-	store 2,mem_addr_mi
-	branch load_storage_loop
-
-
-
-
-
-
 
-
-
-
-
-
-	
-
-p_dongle_timer:
-	call p_dongle_reset_timer
-//	branch p_dongle_version_timer
-p_dongle_version_timer:
-	arg mem_g24_ota_version_timer,regc
-	arg p_dongle_version_timeout,regb
-	branch timer_single_step	
-	
-p_dongle_reset_timer:
-	arg mem_g24_ota_reset_timer,regc
-	arg p_dongle_usb_cmd_reset_dongle,regb
-	branch timer_single_step	
-
-p_dongle_version_timeout:
-//	jam p_start_g24_ota
-	//nop 1
-	branch p_g24_dongle_ota_version_no_mouse
-else
 /************************usb mac wakeup patch**********/
 p_usb_tx:
 	fetch 1,mem_usb_tx_enable
@@ -1165,212 +206,12 @@
 	and_into 0x0f,pdata
 	nbranch usb_inwake_state_tx_dispose,blank
 	branch usb_tx+3
-endif
 
 
 
-p_dongle_g24_mouse:
-ifdef OTA_CODE
-	fetch 1,mem_g24_ota_mode
-	nbranch  p_dongle_g24_rx_mouse_ota,blank
-endif
-	call dongle_g24_mouse
-
-ifndef REPORTRATE_CODE	
-	rtn
-else
-	fetch 7,mem_24g_rxdata_temp+3
-	store 7,mem_g24_tx_last
-	call p_g24_check_reportrate_count1
-	call p_g24_check_reportrate_count2
-	branch p_g24_check_reportrate_count3
-	
-p_g24_check_reportrate_count1:	
-	fetch 1,mem_g24_reportrate_count
-	increase 1,pdata
-	store 1,mem_g24_reportrate_count
-//	rtnne 1
-	copy clkn,pdata
-	store 6,mem_g24_reportrate_lasttime	
-	branch p_g24_check_reportrate_continue0
-	
-p_g24_check_reportrate_count2:	
-	fetch 1,mem_g24_reportrate_count2
-	increase 1,pdata
-	store 1,mem_g24_reportrate_count2
-	rtnne 1
-	copy clkn,pdata
-	store 6,mem_g24_reportrate_lasttime2	
-	rtn
-	
-p_g24_check_reportrate_count3:	
-	fetch 1,mem_g24_reportrate_count3
-	increase 1,pdata
-	store 1,mem_g24_reportrate_count3
-	rtn
-		
-p_g24_check_reportrate_auto:
-	fetch 1,mem_g24_reportrate_count2
-	rtnne 125
-	jam 0,mem_g24_reportrate_count2
-	
-	fetcht 6,mem_g24_reportrate_lasttime2
-	copy clkn,pdata
-	call clk_diff_rt
-	copy pdata,temp
-	setarg 8400000 //700ms 
-	isub temp,null
-	branch p_g24_check_reportrate_250,positive
-	fetch 3,mem_24g_tsniff
-	nrtn blank
-p_g24_check_reportrate_125:
-	setarg 0x17700
-	branch p_g24_check_reportrate_common
-
-
-p_g24_check_reportrate_250:
-	setarg 0xbb80
-p_g24_check_reportrate_common:
-	store 3,mem_24g_tsniff
-	call p_g24_check_reportrate_reset
-	branch p_g24_check_reportrate_reset3
-	
-p_g24_check_reportrate3:
-	fetch 3,mem_24g_tsniff
-	rtn blank
-	fetcht 1,mem_g24_reportrate_check_count
-//increase 1,temp
-	imul32 temp,regext
-//	rshift pdata,pdata
-	iadd regext ,regext
-	fetcht 6,mem_g24_reportrate_lasttime3
-	sub temp,0,null
-	rtn zero
-	copy clkn,pdata
-	call clk_diff_rt
-	fetcht 4,mem_g24_reportrate_detatime3
-	iadd temp,pdata
-	isub regext,temp
-	nrtn positive
-	setarg  1200000 //100ms
-	isub temp,null
-	nbranch p_g24_check_reportrate_reset3,positive
-	storet 4,mem_g24_reportrate_detatime3
-
-//	setarg 0
-//	store 6,mem_g24_reportrate_lasttime
-	copy clkn,pdata
-	store 6,mem_g24_reportrate_lasttime3	
-	fetch 1,mem_g24_reportrate_check_count
-	fetcht 1,mem_g24_reportrate_add
-	iadd temp,pdata
-	fetcht 1,mem_g24_reportrate_count3
-	jam 0,mem_g24_reportrate_count3
-	isub temp,pdata
-	branch p_g24_check_reportrate_add3, zero
-	nbranch p_g24_check_reportrate_reset3, positive
-//	beq  1,p_g24_check_reportrate_continue0
-	sub pdata,4,null
-	nbranch p_g24_check_reportrate_reset3, positive
-	increase -1,pdata
-	store 1,mem_g24_reportrate_add
- 	fetch 1,mem_g24_reportrate_continue
- 	sub pdata,5,null
- 	nbranch p_g24_check_reportrate_reset3,positive
-	branch p_g24_check_reportrate_addpacket
-	
-p_g24_check_reportrate2:
-	fetch 3,mem_24g_tsniff
-	branch p_g24_check_reportrate_auto, blank
-	arg 0xbb80,temp
-	isub temp,null
-	ncall p_g24_check_reportrate_auto, zero
-	rtn
-	
-/*	
-p_g24_check_reportrate:
-	fetch 3,mem_24g_tsniff
-	rtn blank
-	fetcht 1,mem_g24_reportrate_continue
-	increase 2,temp
-	imul32 temp,regext
-	fetcht 6,mem_g24_reportrate_lasttime
-	sub temp,0,null
-	rtn zero
-	copy clkn,pdata
-	call clk_diff_rt
-	fetcht 4,mem_g24_reportrate_detatime
-	iadd temp,pdata
-	isub regext,temp
-	nrtn positive
-	setarg  600000 //50ms
-	isub temp,null
-	nbranch p_g24_check_reportrate_reset,positive
-	storet 4,mem_g24_reportrate_detatime
-
-	fetch 1,mem_g24_reportrate_continue
-//	iadd temp,pdata
-	fetcht 1,mem_g24_reportrate_count
-//	jam 0,mem_g24_reportrate_count
-	isub temp,pdata
-	fetch 1,mem_g24_reportrate_continue
-	sub pdata,5,null
- 	nbranch p_g24_check_reportrate_reset,positive
- 	increase 1,pdata
- 	store 1,mem_g24_reportrate_continue
-	call p_g24_check_reportrate_addpacket
-	branch p_g24_check_reportrate_count3
-*/
-
-p_g24_check_reportrate_continue0:
-	jam 0,mem_g24_reportrate_continue
-	branch p_g24_check_reportrate_reset
-
-p_g24_check_reportrate_deta0:
-	setarg 0
-	store 4,mem_g24_reportrate_detatime
-	rtn
-	
-	
-p_g24_check_reportrate_reset:
-//	copy clkn,pdata
-//	store 6,mem_g24_reportrate_lasttime	
-	jam 0,mem_g24_reportrate_count
-	branch p_g24_check_reportrate_deta0
-
-
-p_g24_check_reportrate_deta3:
-	setarg 0
-	store 4,mem_g24_reportrate_detatime3
-	//rtn
-p_g24_check_reportrate_add3:
-	jam 0,mem_g24_reportrate_add
-	rtn
-
-p_g24_check_reportrate_stopadd:
-	jam 0xff,mem_g24_reportrate_continue
-	rtn
-
-	
-p_g24_check_reportrate_reset3:
-	copy clkn,pdata
-	store 6,mem_g24_reportrate_lasttime3	
-	jam 0,mem_g24_reportrate_count3
-	branch p_g24_check_reportrate_deta3
-	
-
-p_g24_check_reportrate_addpacket:	
-	setarg MS_REPORT_ID
-	store 1,mem_usb_mouse_data
-	fetch 7,mem_g24_tx_last
-	istore 7,contw
-	branch dongle_usb_tx_ms_data
-
-endif
 p_g24_end_of_packet:
 	call g24_end_of_packet
 p_g24_receive_packet:
-	//bpatchx patch3b_6,mem_patch3b
 	fetch 1,mem_24g_rx_phy
 	call le_enable_phy_by_pdata
 	fetch 4,mem_24g_addr
@@ -1379,9 +220,6 @@
 	call set_sync_on
 	fetcht 1,mem_24g_ch
 	call le_rf_rx_enable
-	fetch 1,core_rf_rx_agc_ctrl
-	set1 3,pdata
-	store 1,core_rf_rx_agc_ctrl
 p_g24_receive_rxon:
 	call g24_prep
 	bmark0 mark_ble_lr,p_g24_receive_nolr
@@ -1399,11 +237,10 @@
 	correlate null,timeout
 	nbranch g24_sync_timeout,sync
 	call rf_debug_rx_sync_line
-	bmark1 mark_ble_lr,g24_receive_skip_fec1
-//		disable decode_fec0	
-//		enable decode_fec1	//lr do not use fec1
-
-//g24_receive_skip_fec1:
+	bmark1 mark_ble_lr,p_g24_receive_skip_fec1
+//	disable decode_fec0	
+//	enable decode_fec1	//lr do not use fec1
+p_g24_receive_skip_fec1:
 	enable enable_white
 	enable enable_crc
 	call g24_receive_byte
@@ -1411,7 +248,6 @@
 	fetcht 1,mem_24g_syncword_crc8
 	isub temp,null
 	nbranch p_g24_end_of_packet,zero
-//	bpatchx patch3b_7,mem_patch3b
 	disable user7
 	isolate1 mark_ble_lr,mark
 	call g24_lr_receive_pdu_len,true
@@ -1452,6 +288,7 @@
 	call save_rssi_dec,true
 	branch p_g24_end_of_packet,crc_failed
 	branch g24_receive_skip_rssi+8
+
 p_g24_receive_skip_rssi_next:
 	fetch 1,mem_24g_tx_phy
 	call le_enable_phy_by_pdata
@@ -1470,8 +307,8 @@
 	call g24_transmit_prep
 	call p_g24_transmit+6
 	branch g24_receive_skip_rssi+12
+
 p_g24_transmit:
-//	bpatchx patch3c_1,mem_patch3c
 	fetch 1,mem_24g_tx_phy
 	call le_enable_phy_by_pdata
 	fetch 4,mem_24g_addr
@@ -1492,7 +329,6 @@
 	inject mod,40
 p_g24_transmit_packet:
 	bmark1 mark_ble_lr,g24_transmit_nolr
-//	enable encode_fec0
 //	disable encode_fec0	
 //	enable encode_fec1	////lr use encode_fec3
 	branch g24_transmit_nolr
@@ -1503,7 +339,6 @@
 p_g24_transmit_2M_dealy:
 	nop 2
 	loop p_g24_transmit_2M_dealy
-//	nop 36	//2M Ç°¶Ë·¢ËÍ±È1M¿ì3us×óÓÒ
 	rshift16 access,pdata
 	rshift8 pdata,pdata
 	rshift4 pdata,temp
@@ -1527,11 +362,11 @@
 	beq DATATYPE_DEVICE2,p_g24_bind_first_step_device2
 	rtn
 p_g24_bind_first_step_device1:
-	fetch 1,mem_24g_mouse_bind_enable
+	fetch 1,mem_24g_device1_bind_disable
 	nrtn blank
 	branch g24_bind_first_step_device1
 p_g24_bind_first_step_device2:
-	fetch 1,mem_24g_keyboard_bind_enable
+	fetch 1,mem_24g_device2_bind_disable
 	nrtn blank
 	branch g24_bind_first_step_device2
 	
@@ -1548,11 +383,11 @@
 	beq DATATYPE_DEVICE2,p_g24_bind_second_step_device2
 	rtn
 p_g24_bind_second_step_device1:
-	fetch 1,mem_24g_mouse_bind_enable
+	fetch 1,mem_24g_device1_bind_disable
 	nrtn blank
 	branch g24_bind_second_step_device1
 p_g24_bind_second_step_device2:
-	fetch 1,mem_24g_keyboard_bind_enable
+	fetch 1,mem_24g_device2_bind_disable
 	nrtn blank
 	branch g24_bind_second_step_device2
 
@@ -1569,23 +404,23 @@
 	beq DATATYPE_DEVICE2,p_g24_bind_third_step_device2
 	rtn
 p_g24_bind_third_step_device1:
-	fetch 1,mem_24g_mouse_bind_enable
+	fetch 1,mem_24g_device1_bind_disable
 	nrtn blank
 	fetch 1,mem_24g_device1_bind_step
 	beq 2,p_g24_bind_dvc1_step_success
 	rtn
 p_g24_bind_dvc1_step_success:
-	jam 1,mem_24g_mouse_bind_enable	
+	jam 1,mem_24g_device1_bind_disable	
 	branch g24_bind_dvc1_step_success
 	
 p_g24_bind_third_step_device2:
-	fetch 1,mem_24g_keyboard_bind_enable
+	fetch 1,mem_24g_device2_bind_disable
 	nrtn blank
 	fetch 1,mem_24g_device2_bind_step
 	bne 0,p_g24_bind_dvc2_step_success
 	rtn
 p_g24_bind_dvc2_step_success:
-	jam 1,mem_24g_keyboard_bind_enable
+	jam 1,mem_24g_device2_bind_disable
 	branch g24_bind_dvc2_step_success
 
 
Index: sched/dongle.dat
===================================================================
--- /YC1308AC/branch/usb/sched/dongle.dat	(revision 1458)
+++ /YC1308AC/branch/usb/sched/dongle.dat	(working copy)
@@ -60,148 +60,6 @@
 mem_dig_aon_vsel:00
 #hw agc
 mem_gain_fix:ff
-mem_gain_second_agc_en:00
+mem_gain_second_agc_en:80
 
 
-
-mem_hidreportdesc_ep3:
-1b			#tal length
-06 00 ff	# USAGE_PAGE (Vendor Defined Page 1)
-09 01		# USAGE (Vendor Usage 1)
-a1 01		# COLLECTION (Application)
-85 af		# Report ID
-95 1f		# REPORT_COUNT ()
-75 08		# REPORT_SIZE (8)
-26 ff 00	# LOGICAL_MAXIMUM (255)
-15 00		# LOGICAL_MINIMUM (0)
-09 01		# USAGE (Vendor Usage 1)
-81 02		# INPUT (DataVarAbs)
-09 01		# USAGE (Vendor Usage 1)
-91 02		# OUTPUT (DataVarAbs)
-c0			# END Application Collection
-
-
-mem_confdesc_new:
-5b	# total length
-
-# From "USB Device Class Definition for Human Interface Devices (HID)".
-# Section 7.1:
-# "When a Get_Descriptor(Configuration) request is issued,
-# it returns the Configuration confdesc, all Interface descriptors,
-# all Endpoint descriptors, and the HID confdesc for each interface."
-# configuration_descriptor hid_configuration_descriptor
-
- 09		#Size of this descriptor in bytes.
- 02		#Configuration (assigned by USB).
- 5b 00 	#Total length of data returned for this configuration
- 03		#Number of interfaces supported by this configuration  
- 01		#bConfigurationValue
- 00		#iConfiguration
- a0		#bmAttributes
- 32		#MaxPower (in 2mA units) 
- 
- #interface_descriptor hid_interface_descriptor--keyboard
- 
- 09		# bLength
- 04		# bDescriptorType
- 00		#  bInterfaceNumber
- 00		#  bAlternateSetting
- 01		#  bNumEndpoints
- 03		#  bInterfaceClass (3 = HID)
- 01		#  bInterfaceSubClass
- 01		#  bInterfaceProcotol ; 1=keyboard
- 00		#  iInterface
- 
- #class_descriptor hid_descriptor--keyboard
- 
- 09		#  bLength
- 21		#   bDescriptorType
- 00 02	#  bcdHID
- 00		#  bCountryCode
- 01		#   bNumDescriptors
- 22		# bDescriptorType
- 1a 00 	#  wItemLength (tot. len. of report confdesc)
-
- #IN endpoint (mandatory for HID)--keyboard 
- 
- 07		#bLength
- 05		#bDescriptorType
- 81		#bEndpointAddress
- 03		#bmAttributes
- 40 00	#MaxPacketSize (LITTLE ENDIAN)
- 02		#bInterval 
- 
- #interface_descriptor hid_interface_descriptor--mouse
- 
- 09		#bLength 
- 04		#bDescriptorType   
- 01		#bInterfaceNumber  
- 00		#bAlternateSetting
- 01		#bNumEndpoints  
- 03		#bInterfaceClass (3 = HID)   
- 01		#bInterfaceSubClass  
- 02		#bInterfaceProcotol ; 2=mouse  
- 00		#iInterface 
- 
- #class_descriptor hid_descriptor--mouse 
- 
- 09		#bLength   
- 21		#bDescriptorType  
- 00 02	#bcdHID 
- 00		#bCountryCode  
- 01		#bNumDescriptors  
- 22		#bDescriptorType
-a3 00	#wItemLength (tot. len. of report confdesc)
- 
- #endpoint_descriptor hid_endpoint_in_descriptor--mouse
- 
- 07		#bLength  
- 05		#bDescriptorType  
- 82		#bEndpointAddress  
- 03		# bmAttributes  
- 40 00	#MaxPacketSize (LITTLE  ENDIAN)  
- 02		#bInterval
-
-
-#interface_descriptor hid_interface_descriptor
-
-09		#bLength 
-04		#bDescriptorType   
-02		#bInterfaceNumber  
-00		#bAlternateSetting
-02		#bNumEndpoints
-03		#bInterfaceClass (3 = HID)   
-00		#bInterfaceSubClass  
-00		#bInterfaceProcotol
-00		#iInterface 
- 
-#class_descriptor hid_descriptor 
-
-09		#bLength   
-21		#bDescriptorType  
-00 02	#bcdHID 
-00		#bCountryCode  
-01		#bNumDescriptors  
-22		#bDescriptorType
-1b 00	#wItemLength (tot. len. of report confdesc)
- 
-#endpoint_descriptor hid_endpoint_in_descriptor
-
-07		#bLength  
-05		#bDescriptorType  
-83		#bEndpointAddress  
-03		# bmAttributes  
-40 00	#MaxPacketSize (LITTLE ENDIAN) 
-02		#bInterval
-
-#endpoint_descriptor hid_endpoint_out_descriptor
-
-07		#bLength  
-05		#bDescriptorType  
-03		#bEndpointAddress  
-03		# bmAttributes  
-40 00	#MaxPacketSize (LITTLE ENDIAN) 
-02		#bInterval
-
-mem_g24_reportrate_check_count:20
-
