Index: format/app_dongle.format
===================================================================
--- /branch/usb/usb_public/format/app_dongle.format	(revision 190)
+++ /branch/usb/usb_public/format/app_dongle.format	(working copy)
@@ -5,6 +5,8 @@
 256 mem_dg_rssi_noise_ms_buffer
 256 mem_dg_rssi_noise_kb_buffer
 
+68 mem_usb_rxbuf_new	//at least 68B
+0 mem_usb_rxbuf_new_end
 )
 
 
@@ -34,7 +36,7 @@
 //otp address offset
 (
 0x5A DONGLE_KB_BIND_SUCCESS
-0x1fdf DONGLE_KB_BIND_EFUSE_OFFECT
+0x1fdf DONGLE_KB_BIND_EFUSE_OFFECT	//otp addr 0x7df
 )
 
 (
Index: output/eeprom.dat
===================================================================
--- /branch/usb/usb_public/output/eeprom.dat	(revision 190)
+++ /branch/usb/usb_public/output/eeprom.dat	(working copy)
@@ -2,40 +2,48 @@
 02
 aa
 55
-66
+b2
 01
 c2
 84
 00
-09
+0b
 c0
 00
 00
-0b
+0d
 c0
 01
 80
-2e
+41
+c0
+0b
+b9
+ff
 c0
 31
 00
-10
+12
 c0
 4a
 80
-4b
+5e
+c0
+5c
+80
+18
 c0
 6f
 00
-16
+29
 c0
 71
 00
-31
+44
 c0
 74
 00
-3b
+4e
 20
 20
 3a
@@ -94,12 +102,80 @@
 49
 20
 40
+6f
+d3
+20
+40
+71
+a1
+70
+06
+10
+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
+0b
+b3
+67
+f1
+0c
+03
+67
+f1
+0c
+07
+58
+00
+0b
+f7
+67
+f1
+0c
+05
+20
+20
+71
+92
+20
+40
 3d
 3c
 c5
 97
 80
-1c
+2f
 78
 3c
 fc
@@ -143,7 +219,7 @@
 20
 37
 00
-25
+38
 1b
 42
 04
@@ -195,7 +271,7 @@
 24
 22
 80
-2c
+3f
 20
 20
 38
@@ -283,7 +359,7 @@
 c5
 16
 80
-47
+5a
 20
 20
 3e
@@ -299,7 +375,7 @@
 c2
 00
 00
-48
+5b
 20
 20
 3f
@@ -360,8 +436,8 @@
 20
 6c
 a7
-30
-16
+7c
+62
 aa
 55
 40
@@ -370,7 +446,7 @@
 40
 09
 00
-00
+80
 00
 00
 00
@@ -391,7 +467,7 @@
 00
 00
 00
-00
+02
 00
 00
 00
@@ -635,7 +711,7 @@
 aa
 aa
 55
-4a
+cc
 37
-f1
-21
+ac
+00
Index: output/memmap.format
===================================================================
--- /branch/usb/usb_public/output/memmap.format	(revision 190)
+++ /branch/usb/usb_public/output/memmap.format	(working copy)
@@ -327,6 +327,8 @@
 0x08b3 mem_dg_rssi_noise_dg_buffer
 0x09b3 mem_dg_rssi_noise_ms_buffer
 0x0ab3 mem_dg_rssi_noise_kb_buffer
+0x0bb3 mem_usb_rxbuf_new//at least 68B
+0x0bf7 mem_usb_rxbuf_new_end
 
 0x019a mem_le_new_param
 0x019a mem_le_new_transmitwindowsize
Index: output/program.lis
===================================================================
--- /branch/usb/usb_public/output/program.lis	(revision 190)
+++ /branch/usb/usb_public/output/program.lis	(working copy)
@@ -1,122 +1,143 @@
               include "bt_format "
               org 0x0000
-0000 c2840009 bbit1 8 ,pf_patch_ext 
-0001 c000000b beq patch00_0 ,p_soft_reset 
-0002 c001802e beq patch00_3 ,p_connection_incontext 
-0003 c0310010 beq patch0c_2 ,p_app_init 
-0004 c04a804b beq patch12_5 ,p_enable_adc 
-0005 c06f0016 beq patch1b_6 ,p_le_receive_rxon 
-0006 c0710031 beq patch1c_2 ,p_le_crc_fail_tx 
-0007 c074003b beq patch1d_0 ,p_le_transmit 
-0008 20203aba branch assert 
+0000 c284000b bbit1 8 ,pf_patch_ext 
+0001 c000000d beq patch00_0 ,p_soft_reset 
+0002 c0018041 beq patch00_3 ,p_connection_incontext 
+0003 c00bb9ff beq patch02_7 ,set_tx_power_10db 
+0004 c0310012 beq patch0c_2 ,p_app_init 
+0005 c04a805e beq patch12_5 ,p_enable_adc 
+0006 c05c8018 beq patch17_1 ,p_usb_init 
+0007 c06f0029 beq patch1b_6 ,p_le_receive_rxon 
+0008 c0710044 beq patch1c_2 ,p_le_crc_fail_tx 
+0009 c074004e beq patch1d_0 ,p_le_transmit 
+000a 20203aba branch assert 
 
 pf_patch_ext:
-0009 c17f8000 rtneq patch3f_7 
-000a 20203aba branch assert 
+000b c17f8000 rtneq patch3f_7 
+000c 20203aba branch assert 
 
 p_soft_reset:
-000b 2035b802 branch soft_reset + 1 ,wake 
-000c 6fe240cc fetch 4 ,mem_lpm_ctrl3 
-000d 67f2004c store 4 ,core_lpm_reg 
-000e 20403c49 call lpm_write_ctrl3 
-000f 20203802 branch soft_reset + 1 
+000d 2035b802 branch soft_reset + 1 ,wake 
+000e 6fe240cc fetch 4 ,mem_lpm_ctrl3 
+000f 67f2004c store 4 ,core_lpm_reg 
+0010 20403c49 call lpm_write_ctrl3 
+0011 20203802 branch soft_reset + 1 
 
 p_app_init:
-0010 6fe0c095 fetch 1 ,mem_device_option 
-0011 203a4d9b branch app_init ,blank 
+0012 6fe0c095 fetch 1 ,mem_device_option 
+0013 203a4d9b branch app_init ,blank 
 
 p_dongle_init:
-0012 20758000 rtn wake 
-0013 7040cc3a jam hvin_vin_greater_than_4v2 ,mem_lpm_ctrl3 
-0014 20403c41 call lpm_write_sel_vdd 
-0015 20205249 branch dongle_init 
+0014 20758000 rtn wake 
+0015 7040cc3a jam hvin_vin_greater_than_4v2 ,mem_lpm_ctrl3 
+0016 20403c41 call lpm_write_sel_vdd 
+0017 20205249 branch dongle_init 
+
+p_usb_init:
+0018 20406fd3 call enable_authrom 
+0019 204071a1 call usb_init_param 
+001a 70061003 jam 0x03 ,mem_devicedesc + 17 
+001b 708c0000 jam 0x00 ,core_usb_config 
+001c 20002710 nop 10000 
+001d 708c1800 jam 0x00 ,core_usb_trig 
+001e 6ff10050 fetch 2 ,core_clkoff 
+001f 793ffe0a set0 clock_off_usb ,pdata 
+0020 67f10050 store 2 ,core_clkoff 
+0021 708c1100 jam 0x0 ,core_usb_hmode 
+0022 708c003c jam 0x3c ,core_usb_config 
+0023 58000bb3 setarg mem_usb_rxbuf_new 
+0024 67f10c03 store 2 ,core_usb_rx_saddr 
+0025 67f10c07 store 2 ,core_usb_rxptr 
+0026 58000bf7 setarg mem_usb_rxbuf_new_end 
+0027 67f10c05 store 2 ,core_usb_rx_eaddr 
+0028 20207192 branch usb_init + 16 
 
 p_le_receive_rxon:
-0016 20403d3c call le_prep 
-0017 c597801c bmark0 mark_ble_lr ,p_le_receive_nolr 
-0018 783cfc00 pulse dewhiten_code_calc 
-0019 2000001e nop 30 
-001a 20403d3c call le_prep 
-001b 19699600 lshift3 timeup ,timeup 
+0029 20403d3c call le_prep 
+002a c597802f bmark0 mark_ble_lr ,p_le_receive_nolr 
+002b 783cfc00 pulse dewhiten_code_calc 
+002c 2000001e nop 30 
+002d 20403d3c call le_prep 
+002e 19699600 lshift3 timeup ,timeup 
 
 p_le_receive_nolr:
-001c 7856fc00 disable match 
-001d 7826fc00 enable decode_fec0 
-001e 7830fc00 enable is_rx 
-001f 78507c00 disable is_tx 
-0020 19623600 copy timeup ,stop_watch 
-0021 37c18400 correlate null ,timeout 
-0022 20370025 branch p_le_receive_on_attempt ,attempt 
-0023 1b420400 copy clke ,temp 
-0024 604b000f storet 6 ,mem_sync_clke 
+002f 7856fc00 disable match 
+0030 7826fc00 enable decode_fec0 
+0031 7830fc00 enable is_rx 
+0032 78507c00 disable is_tx 
+0033 19623600 copy timeup ,stop_watch 
+0034 37c18400 correlate null ,timeout 
+0035 20370038 branch p_le_receive_on_attempt ,attempt 
+0036 1b420400 copy clke ,temp 
+0037 604b000f storet 6 ,mem_sync_clke 
 
 p_le_receive_on_attempt:
-0025 242c3e75 nbranch le_unsync_end ,sync 
-0026 78287c00 enable swfine 
-0027 db604eab arg param_t_ifs_150us + param_20ms_init + param_sync_time_difference ,stop_watch 
-0028 6fe0c11d fetch 1 ,mem_system_clk 
-0029 9b6f8400 imul32 stop_watch ,temp 
-002a 9840b600 iadd temp ,stop_watch 
-002b 20203de9 branch le_receive_on_attempt + 6 
+0038 242c3e75 nbranch le_unsync_end ,sync 
+0039 78287c00 enable swfine 
+003a db604eab arg param_t_ifs_150us + param_20ms_init + param_sync_time_difference ,stop_watch 
+003b 6fe0c11d fetch 1 ,mem_system_clk 
+003c 9b6f8400 imul32 stop_watch ,temp 
+003d 9840b600 iadd temp ,stop_watch 
+003e 20203de9 branch le_receive_on_attempt + 6 
 
 p_connection_nosniff:
-002c 70000600 jam 0 ,mem_current_context 
-002d 20203822 branch connection_nosniff 
+003f 70000600 jam 0 ,mem_current_context 
+0040 20203822 branch connection_nosniff 
 
 p_connection_incontext:
-002e 20403863 call context_search_insniff 
-002f 2422802c nbranch p_connection_nosniff ,zero 
-0030 2020381d branch connection_incontext + 3 
+0041 20403863 call context_search_insniff 
+0042 2422803f nbranch p_connection_nosniff ,zero 
+0043 2020381d branch connection_incontext + 3 
 
 p_le_crc_fail_tx:
-0031 20406f09 call ccm_ctrl_clr 
-0032 6fe08198 fetch 1 ,mem_le_rx_phy 
-0033 7d3e7e07 nsetflag ble_coded_info ,bit_le_coded_phy_s8 ,pdata 
-0034 67e08198 store 1 ,mem_le_rx_phy 
-0035 7846fc00 disable decode_fec0 
-0036 20403925 call set_sync_on 
-0037 708a3d12 jam 0x12 ,core_syn_top_ctrl 
-0038 68488008 fetcht 1 ,mem_last_freq 
-0039 1840a202 add temp ,2 ,rega 
-003a 2020398e branch rf_tx_write_freq 
+0044 20406f09 call ccm_ctrl_clr 
+0045 6fe08198 fetch 1 ,mem_le_rx_phy 
+0046 7d3e7e07 nsetflag ble_coded_info ,bit_le_coded_phy_s8 ,pdata 
+0047 67e08198 store 1 ,mem_le_rx_phy 
+0048 7846fc00 disable decode_fec0 
+0049 20403925 call set_sync_on 
+004a 708a3d12 jam 0x12 ,core_syn_top_ctrl 
+004b 68488008 fetcht 1 ,mem_last_freq 
+004c 1840a202 add temp ,2 ,rega 
+004d 2020398e branch rf_tx_write_freq 
 
 p_le_transmit:
-003b 20403d3c call le_prep 
-003c 20403d4b call le_tx_setfreq 
-003d 20406451 call rf_debug_tx_on_line 
-003e 79202a00 set1 txgfsk ,radio_ctrl 
-003f 782efc00 enable encode_fec0 
-0040 78307c00 enable is_tx 
-0041 7850fc00 disable is_rx 
-0042 20403dc2 call le_wait_tx 
-0043 785d7c00 disable lr_s2en 
-0044 c517beff bmark1 mark_ble_lr ,le_transmit_lr 
-0045 c5168047 bmark1 mark_ble_2m ,p_le_transmit_2m 
-0046 20203ec8 branch le_transmit + 12 
+004e 20403d3c call le_prep 
+004f 20403d4b call le_tx_setfreq 
+0050 20406451 call rf_debug_tx_on_line 
+0051 79202a00 set1 txgfsk ,radio_ctrl 
+0052 782efc00 enable encode_fec0 
+0053 78307c00 enable is_tx 
+0054 7850fc00 disable is_rx 
+0055 20403dc2 call le_wait_tx 
+0056 785d7c00 disable lr_s2en 
+0057 c517beff bmark1 mark_ble_lr ,le_transmit_lr 
+0058 c516805a bmark1 mark_ble_2m ,p_le_transmit_2m 
+0059 20203ec8 branch le_transmit + 12 
 
 p_le_transmit_2m:
-0047 6f20c11d fetchr loopcnt ,1 ,mem_system_clk 
+005a 6f20c11d fetchr loopcnt ,1 ,mem_system_clk 
 
 p_le_transmit_2m_dealy:
-0048 20000001 nop 1 
-0049 c2000048 loop p_le_transmit_2m_dealy 
-004a 20203f15 branch le_transmit_2m_dealy + 2 
+005b 20000001 nop 1 
+005c c200005b loop p_le_transmit_2m_dealy 
+005d 20203f15 branch le_transmit_2m_dealy + 2 
 
 p_enable_adc:
-004b 6a508a12 fetchr regb ,1 ,core_rf_ldo_cfg6 
-004c 708a123d jam 0x3d ,core_rf_ldo_cfg6 
-004d 708a11aa jam 0xaa ,core_rf_ldo_cfg5 
-004e 708a0a0c jam 0x0c ,core_rf_ldo_en0 
-004f 6ff08a09 fetch 1 ,core_clkpll_cfg6 
-0050 79207e07 set1 7 ,pdata 
-0051 67f08a09 store 1 ,core_clkpll_cfg6 
-0052 708a0b04 jam 0x04 ,core_rf_ldo_en1 
-0053 2000003c nop 60 
-0054 708a1600 jam 0 ,core_syn_en 
-0055 708a1706 jam 6 ,core_rx_en0 
-0056 20406cb4 call read_adc_mode 
-0057 67f08a97 store 1 ,core_gpadc_ctrl 
-0058 20206ca7 branch enable_adc + 15 
+005e 6a508a12 fetchr regb ,1 ,core_rf_ldo_cfg6 
+005f 708a123d jam 0x3d ,core_rf_ldo_cfg6 
+0060 708a11aa jam 0xaa ,core_rf_ldo_cfg5 
+0061 708a0a0c jam 0x0c ,core_rf_ldo_en0 
+0062 6ff08a09 fetch 1 ,core_clkpll_cfg6 
+0063 79207e07 set1 7 ,pdata 
+0064 67f08a09 store 1 ,core_clkpll_cfg6 
+0065 708a0b04 jam 0x04 ,core_rf_ldo_en1 
+0066 2000003c nop 60 
+0067 708a1600 jam 0 ,core_syn_en 
+0068 708a1706 jam 6 ,core_rx_en0 
+0069 20406cb4 call read_adc_mode 
+006a 67f08a97 store 1 ,core_gpadc_ctrl 
+006b 20206ca7 branch enable_adc + 15 
               org 0x3800
 
 start:
Index: program/patch.prog
===================================================================
--- /branch/usb/usb_public/program/patch.prog	(revision 190)
+++ /branch/usb/usb_public/program/patch.prog	(working copy)
@@ -2,8 +2,11 @@
 	bbit1 8,pf_patch_ext
 	beq patch00_0,p_soft_reset
 	beq patch00_3,p_connection_incontext
+	beq patch02_7,set_tx_power_10db
+//	beq patch06_6,p_dongle_usb_dispatch
 	beq patch0c_2,p_app_init
 	beq patch12_5,p_enable_adc
+	beq patch17_1,p_usb_init
 	beq patch1b_6,p_le_receive_rxon
 	beq patch1c_2,p_le_crc_fail_tx
 	beq patch1d_0,p_le_transmit
@@ -29,7 +32,39 @@
 	jam HVIN_VIN_GREATER_THAN_4V2,mem_lpm_ctrl3
 	call lpm_write_sel_vdd
 	branch dongle_init
- 
+
+	//watch dog enable
+//	call wdt_set_enable
+//p_wdt_kick:
+	//about 125ms
+//	setarg 16
+//	branch wdt_init_config
+
+//p_dongle_usb_dispatch:
+//	call p_wdt_kick
+//	branch dongle_usb_dispatch+1
+
+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
+
+
+
 p_le_receive_rxon:
 	call le_prep
 	bmark0 mark_ble_lr,p_le_receive_nolr
