Index: d.bat
===================================================================
--- /YC1308AC/branch/usb/d.bat	(revision 1478)
+++ /YC1308AC/branch/usb/d.bat	(working copy)
@@ -1,5 +1,6 @@
 call do.bat eep
 e pu
+e 8043 00
 e 8070 00000000000000000000
 e 807a 00000000000000000000
 e 8070 3e6c6d   
Index: format/app_dongle.format
===================================================================
--- /YC1308AC/branch/usb/format/app_dongle.format	(revision 1478)
+++ /YC1308AC/branch/usb/format/app_dongle.format	(working copy)
@@ -5,15 +5,8 @@
 256 mem_dg_rssi_noise_ms_buffer
 256 mem_dg_rssi_noise_kb_buffer
 
-28 mem_hidreportdesc_ep3
-100 mem_confdesc_new
-64 mem_usb_txbuf3
-64 mem_usb_rxbuf_temp
-1 mem_usb_ep3_out_data_len
-1 mem_usb_ep3_in_data_len
-1 mem_usb_ep3_out_data_flag
-64 mem_usb_ep3_in_data
-64 mem_usb_ep3_out_data
+68 mem_usb_rxbuf_new	//at least 68B
+0 mem_usb_rxbuf_new_end
 )
 
 
Index: output/eeprom.dat
===================================================================
--- /YC1308AC/branch/usb/output/eeprom.dat	(revision 1478)
+++ /YC1308AC/branch/usb/output/eeprom.dat	(working copy)
@@ -2,8 +2,8 @@
 02
 aa
 55
-e6
-04
+0e
+05
 c2
 84
 00
@@ -11,7 +11,7 @@
 c0
 41
 80
-2a
+18
 c0
 45
 00
@@ -23,35 +23,35 @@
 c0
 46
 00
-71
+2a
 c0
 57
 00
-31
+44
 c0
 5d
 80
-39
+4c
 c0
 5e
 00
-3b
+4e
 20
 20
 13
 7c
 c0
 47
-00
-18
+01
+1c
 c0
 48
-00
-5c
+01
+2d
 c0
 4a
-80
-86
+81
+3d
 c0
 54
 80
@@ -59,19 +59,19 @@
 c0
 6f
 00
-8d
+70
 c0
 70
 00
-d1
+b4
 c0
 70
 80
-e2
+c5
 c0
 72
-01
-02
+00
+e5
 20
 20
 13
@@ -100,34 +100,34 @@
 60
 00
 00
-20
-40
-6d
-f3
-20
-40
-79
-bc
 70
-0a
-a8
-03
-70
-8c
-00
+89
 00
+05
 20
 00
-27
-10
+00
+02
 70
-8c
-18
+89
+00
 00
+6f
+e0
+c0
+c5
+c0
+84
+11
+68
+70
+8a
+87
+29
 20
 20
-79
-a3
+11
+7d
 20
 20
 12
@@ -172,34 +172,110 @@
 20
 12
 56
-70
+6f
+f0
 89
+a2
+2f
+ef
+fe
+06
+79
+20
+fe
+07
+67
+e0
+c1
+e9
+6f
+f0
+89
+a3
+1f
+e1
+04
+0f
+18
+43
+84
 00
-05
+1f
+f1
+fe
+00
+98
+40
+84
+00
+18
+4f
+a2
+03
+6f
+e0
+c1
+e9
 20
+40
 00
+3f
+1f
+e6
+7e
 00
-02
-70
-89
+9a
+20
+fe
 00
+1f
+e0
+ff
+f7
+1f
+e1
+7f
+ff
+2f
+ef
+fe
+08
+24
+20
+80
+3d
+58
 00
-6f
+00
+00
+67
 e0
-c0
-c5
-c0
-84
-11
-68
-70
-8a
-87
-29
+80
+19
 20
 20
-11
-7d
+12
+91
+2f
+ef
+fe
+07
+24
+60
+80
+00
+d8
+40
+ff
+00
+98
+41
+fe
+00
+20
+60
+00
+00
 20
 40
 36
@@ -235,7 +311,7 @@
 20
 40
 00
-37
+4a
 20
 20
 36
@@ -255,7 +331,7 @@
 20
 40
 00
-40
+53
 20
 20
 36
@@ -267,11 +343,11 @@
 20
 40
 00
-43
+56
 20
 20
 00
-4f
+62
 6f
 e0
 c9
@@ -323,247 +399,55 @@
 6f
 e0
 c9
-07
-20
-7a
-00
-00
-d8
-e0
-00
-0c
-20
-40
-7d
-74
-24
-7a
-00
-00
-70
-49
-07
-00
-d8
-a0
-0c
-1f
-df
-20
-00
-02
-20
-40
-7d
-17
-70
-0c
-1f
-03
-6f
-e1
-8c
-1f
-67
-e1
-c8
-fd
-20
-20
-36
-b2
-79
-3f
-80
-23
-6f
-e0
-8b
-59
-1f
-e1
-7e
-80
-c0
-00
-00
-61
-20
-20
-7a
-34
-6f
-e0
-8b
-59
-1f
-f1
-fe
-00
-1f
-e3
-7e
-00
-1f
-e1
-7e
-03
-c0
-00
-80
-67
-20
-20
-7a
-43
-6f
-e0
-8b
-5a
-c0
-04
-80
-6a
-20
-20
-7a
-5c
-20
-00
-3a
-98
-20
-20
-7b
-d8
-2f
-ef
-fe
-07
-24
-60
-80
-00
-d8
-40
-ff
-00
-98
-41
-fe
-00
-20
-60
-00
-00
-6f
-f0
-89
-a2
-2f
-ef
-fe
-06
-79
-20
-fe
-07
-67
-e0
-c1
-e9
-6f
-f0
-89
-a3
-1f
-e1
-04
-0f
-18
-43
-84
-00
-1f
-f1
-fe
-00
-98
-40
-84
-00
-18
-4f
-a2
-03
-6f
-e0
-c1
-e9
-20
-40
-00
-6c
-1f
-e6
-7e
-00
-9a
-20
-fe
-00
-1f
-e0
-ff
-f7
-1f
-e1
-7f
-ff
-2f
-ef
-fe
-08
-24
-20
-80
-84
-58
-00
-00
-00
-67
-e0
-80
-19
-20
-20
-12
-91
-6f
+07
+20
+7a
+00
+00
+d8
 e0
-8b
-f9
+00
+0c
 20
+40
+7d
+74
+24
 7a
 00
 00
+70
+49
+07
+00
+d8
+a0
+0c
+1f
+df
+20
+00
+02
+20
+40
+7d
+17
+70
+0c
+1f
+03
 6f
-f0
+e1
 8c
-24
 1f
+67
 e1
-7e
-0f
-24
-3a
-7c
-a4
+c8
+fd
 20
 20
-7c
-59
+36
+b2
 20
 40
 22
@@ -607,7 +491,7 @@
 c5
 97
 80
-9a
+7d
 78
 3c
 fc
@@ -663,7 +547,7 @@
 c5
 17
 80
-a5
+88
 78
 23
 fc
@@ -691,7 +575,7 @@
 24
 22
 80
-8c
+6f
 78
 58
 fc
@@ -763,7 +647,7 @@
 24
 21
 00
-8c
+6f
 1f
 e2
 72
@@ -771,7 +655,7 @@
 20
 22
 80
-c3
+a6
 20
 40
 22
@@ -783,11 +667,11 @@
 c2
 00
 00
-c0
+a3
 c5
 13
 80
-c8
+ab
 18
 a2
 22
@@ -835,7 +719,7 @@
 20
 23
 00
-8c
+6f
 20
 20
 22
@@ -903,7 +787,7 @@
 20
 40
 00
-e8
+cb
 20
 20
 22
@@ -963,7 +847,7 @@
 c5
 16
 80
-f6
+d9
 19
 31
 7e
@@ -1003,7 +887,7 @@
 c2
 00
 00
-f8
+db
 19
 31
 7e
@@ -1035,23 +919,23 @@
 20
 20
 00
-f4
+d7
 6f
 e0
 c8
 93
 c0
 55
-01
-07
+00
+ea
 c0
 2a
-81
-11
+80
+f4
 c0
 11
 01
-21
+04
 20
 20
 23
@@ -1062,12 +946,12 @@
 94
 c0
 00
-81
-0b
+80
+ee
 c0
 01
-01
-0e
+00
+f1
 20
 60
 00
@@ -1102,8 +986,8 @@
 5b
 20
 3a
-01
-17
+00
+fa
 6f
 e2
 48
@@ -1126,12 +1010,12 @@
 94
 c0
 00
-81
-1b
+80
+fe
 c0
 01
 01
-1e
+01
 20
 60
 00
@@ -1167,7 +1051,7 @@
 20
 3a
 01
-27
+0a
 6f
 e2
 48
@@ -1191,11 +1075,11 @@
 c0
 00
 81
-2b
+0e
 c0
 01
 01
-32
+15
 20
 60
 00
@@ -1215,7 +1099,7 @@
 c0
 01
 01
-30
+13
 20
 60
 00
@@ -1243,7 +1127,7 @@
 c0
 80
 01
-37
+1a
 20
 60
 00
@@ -1256,8 +1140,164 @@
 20
 23
 fd
+20
+40
+6d
+f3
+20
+40
+79
+bc
+70
+0a
+a8
+03
+70
+8c
+00
+00
+20
+00
+27
+10
+70
+8c
+18
+00
+6f
+f1
+00
+50
+79
+3f
+fe
+0a
+67
+f1
+00
+50
+70
+8c
+11
+00
+70
+8c
+00
+3c
+58
+00
+10
+4b
+67
+f1
+0c
+03
+67
+f1
+0c
+07
+58
+00
+10
+8f
+67
+f1
+0c
+05
+20
+20
+79
+ad
+79
+3f
+80
+23
+6f
+e0
+8b
+59
+1f
+e1
+7e
+80
+c0
+00
+01
+32
+20
+20
+7a
+34
+6f
+e0
+8b
+59
+1f
+f1
+fe
+00
+1f
+e3
+7e
+00
+1f
+e1
+7e
+03
+c0
+00
+81
+38
+20
+20
+7a
+43
+6f
+e0
+8b
+5a
+c0
+04
+81
+3b
+20
+20
+7a
+5c
+20
+00
+3a
+98
+20
+20
+7b
+d8
+6f
+e0
+8b
+f9
+20
+7a
+00
+00
+6f
+f0
+8c
+24
+1f
+e1
+7e
+0f
+24
+3a
+7c
+a4
+20
+20
 7c
-c4
+59
+08
+a4
 aa
 55
 40
@@ -1429,5 +1469,5 @@
 55
 70
 1c
-65
-9d
+5d
+c2
Index: output/memmap.format
===================================================================
--- /YC1308AC/branch/usb/output/memmap.format	(revision 1478)
+++ /YC1308AC/branch/usb/output/memmap.format	(working copy)
@@ -659,15 +659,8 @@
 0x0d4b mem_dg_rssi_noise_dg_buffer
 0x0e4b mem_dg_rssi_noise_ms_buffer
 0x0f4b mem_dg_rssi_noise_kb_buffer
-0x104b mem_hidreportdesc_ep3
-0x1067 mem_confdesc_new
-0x10cb mem_usb_txbuf3
-0x110b mem_usb_rxbuf_temp
-0x114b mem_usb_ep3_out_data_len
-0x114c mem_usb_ep3_in_data_len
-0x114d mem_usb_ep3_out_data_flag
-0x114e mem_usb_ep3_in_data
-0x118e mem_usb_ep3_out_data
+0x104b mem_usb_rxbuf_new//at least 68B
+0x108f mem_usb_rxbuf_new_end
 
 0x02be mem_le_new_param
 0x02be mem_le_new_transmitwindowsize
Index: program/patch.prog
===================================================================
--- /YC1308AC/branch/usb/program/patch.prog	(revision 1478)
+++ /YC1308AC/branch/usb/program/patch.prog	(working copy)
@@ -29,15 +29,16 @@
 	store 1,core_syn_cal_ctrl
 	rtn
 
-p_usb_init:
-	call enable_authrom
-	call usb_init_param
-	jam 0x03,mem_devicedesc+17	//enable iSerialNumber
-	jam 0x00,core_usb_config
-	nop 10000
-	jam 0x00,core_usb_trig
-	branch usb_init+6
-	
+p_set_sync_on:
+	jam 0x5,modem_en
+	nop 2
+	jam 0x0,modem_en					/* if called from tx or rx */
+	fetch 1,mem_fcomp_div
+	bne XTAL_16M,set_sync_on_24m
+p_set_sync_on_16m:
+	jam 0x29,core_syn_afc_cfg1
+	branch set_sync_on_16m
+
 p_tx_on_next:
 	branch set_tx_power_10db
 
@@ -46,12 +47,10 @@
 	//config osc_xtal_ctrim
 	call init_lpm_ctrl
 	nop 100
-	
 	//optimize RX SX pn
 	jam 0x0b,core_rf_ldo_cfg2
 	jam 0x05,core_rf_ldo_cfg3
 	jam 0x90,core_syn_pfd_lkd_cfg
-
 	jam 0x00,core_syn_loopdiv_dsm_cfg
 	jam 0x40,core_rx_ctrl1
 	//Improve auto agc
@@ -59,15 +58,42 @@
 	jam 0x76,core_agc_nb_sat_th
 	branch initialize_radio_cont+1
 
-p_set_sync_on:
-	jam 0x5,modem_en
-	nop 2
-	jam 0x0,modem_en					/* if called from tx or rx */
-	fetch 1,mem_fcomp_div
-	bne XTAL_16M,set_sync_on_24m
-p_set_sync_on_16m:
-	jam 0x29,core_syn_afc_cfg1
-	branch set_sync_on_16m
+
+p_save_rssi:
+	// bit6 is signed bit. 
+	fetch 1,modem_nb_pow 
+	isolate1 6,pdata 
+	setflag true,7,pdata 
+	store 1,mem_modem_rssi 
+	
+	fetch 1,modem_gain 
+	and pdata,0x0f,temp 
+	lshift temp,temp 
+	rshift4 pdata,pdata 
+	iadd temp,temp 
+	mul32 temp,3,rega // (abb_gain + lna_gain*2)*3 
+
+	fetch 1,mem_modem_rssi 
+	call p_byte_sign_extern 
+	sub pdata,0,pdata //-modem_nb_pow 
+	iadd rega,pdata // (abb_gain + lna_gain*2)*3 + (-modem_nb_pow) 
+	increase -9,pdata // (abb_gain + lna_gain*2)*3 + (-modem_nb_pow) - 9 
+	and pdata,0x1ff,pdata 
+	isolate1 8,pdata 
+	nbranch p_save_rssi_store,true 
+	setarg 0 
+p_save_rssi_store:
+	store 1,mem_rssi_hex
+	branch rssi_hex2dec
+
+p_byte_sign_extern:
+	isolate1 7,pdata
+	nrtn true
+	arg 0xff00,temp
+	ior temp,pdata
+	rtn
+
+
 
 
 p_app_init:
@@ -135,78 +161,6 @@
 	fetch 3,mem_usb_kb_multikey
 	store 3,mem_dg_kb_multikey_last_data	
 	branch dongle_usb_tx_multikey_data
-	
-
-/************************keyboard led patch**********/
-p_usb_class_type:
-	set0 mark_isstr,mark
-	fetch 1,mem_usb_setup_bmRequestType
-	and_into 0x80,pdata
-	beq OUT_DEVICE,p_usb_out_device
-	branch usb_class_type+4
-
-p_usb_out_device:
-	fetch 1,mem_usb_setup_bmRequestType
-	rshift4 pdata,pdata
-	rshift pdata,pdata
-	and_into 0x03,pdata
-	beq CLASS_REQ,p_usb_out_class_req
-	branch usb_out_device+4
-
-p_usb_out_class_req:
-	fetch 1,mem_usb_setup_bRequest
-	beq SET_REPORT,p_usb_set_report
-	branch usb_out_class_req+1
-
-p_usb_set_report:
-	nop 15000	//delay 1ms
-	branch usb_set_report
-
-p_byte_sign_extern:
-	isolate1 7,pdata
-	nrtn true
-	arg 0xff00,temp
-	ior temp,pdata
-	rtn
-
-p_save_rssi:
-	// bit6 is signed bit. 
-	fetch 1,modem_nb_pow 
-	isolate1 6,pdata 
-	setflag true,7,pdata 
-	store 1,mem_modem_rssi 
-	
-	fetch 1,modem_gain 
-	and pdata,0x0f,temp 
-	lshift temp,temp 
-	rshift4 pdata,pdata 
-	iadd temp,temp 
-	mul32 temp,3,rega // (abb_gain + lna_gain*2)*3 
-
-	fetch 1,mem_modem_rssi 
-	call p_byte_sign_extern 
-	sub pdata,0,pdata //-modem_nb_pow 
-	iadd rega,pdata // (abb_gain + lna_gain*2)*3 + (-modem_nb_pow) 
-	increase -9,pdata // (abb_gain + lna_gain*2)*3 + (-modem_nb_pow) - 9 
-	and pdata,0x1ff,pdata 
-	isolate1 8,pdata 
-	nbranch p_save_rssi_store,true 
-	setarg 0 
-p_save_rssi_store:
-	store 1,mem_rssi_hex
-	branch rssi_hex2dec
-
-
-
-/************************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
-	branch usb_tx+3
-
 
 
 p_g24_end_of_packet:
@@ -424,3 +378,63 @@
 	branch g24_bind_dvc2_step_success
 
 
+
+
+p_usb_init:
+	call enable_authrom
+	call usb_init_param
+	jam 0x03,mem_devicedesc+17	//enable iSerialNumber
+	jam 0x00,core_usb_config
+	nop 10000
+	jam 0x00,core_usb_trig
+	fetch 2,core_clkoff
+	set0 CLOCK_OFF_USB,pdata
+	store 2,core_clkoff
+	jam 0x0,core_usb_hmode
+	jam 0x3c,core_usb_config
+	setarg mem_usb_rxbuf_new
+	store 2,core_usb_rx_saddr
+	store 2,core_usb_rxptr
+	setarg mem_usb_rxbuf_new_end
+	store 2,core_usb_rx_eaddr
+	branch usb_init+16
+
+
+/************************keyboard led patch**********/
+p_usb_class_type:
+	set0 mark_isstr,mark
+	fetch 1,mem_usb_setup_bmRequestType
+	and_into 0x80,pdata
+	beq OUT_DEVICE,p_usb_out_device
+	branch usb_class_type+4
+
+p_usb_out_device:
+	fetch 1,mem_usb_setup_bmRequestType
+	rshift4 pdata,pdata
+	rshift pdata,pdata
+	and_into 0x03,pdata
+	beq CLASS_REQ,p_usb_out_class_req
+	branch usb_out_device+4
+
+p_usb_out_class_req:
+	fetch 1,mem_usb_setup_bRequest
+	beq SET_REPORT,p_usb_set_report
+	branch usb_out_class_req+1
+
+p_usb_set_report:
+	nop 15000	//delay 1ms
+	branch usb_set_report
+
+
+/************************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
+	branch usb_tx+3
+
+
+
+
