Index: do.bat
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/do.bat	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/do.bat	(working copy)
@@ -12,6 +12,7 @@
 for /f %%f in ('dir /b /o program_patch\ble_spec_code\*.prog') do @set progs_patch=!progs_patch! program_patch\ble_spec_code\%%f
 for /f %%f in ('dir /b /o program_patch\bt_spec_code\*.prog') do @set progs_patch=!progs_patch! program_patch\bt_spec_code\%%f
 for /f %%f in ('dir /b /o program_patch\debug_spec_code\*.prog') do @set progs_patch=!progs_patch! program_patch\debug_spec_code\%%f
+for /f %%f in ('dir /b /o program_patch\fcc_spec_code\*.prog') do @set progs_patch=!progs_patch! program_patch\fcc_spec_code\%%f
 type program_patch\main_patch.prog %progs_patch% > program\patch.prog
 
 for %%f in (program\ble_protocol_stack\*.prog) do @set progs=!progs! %%f
Index: format/app.format
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/format/app.format	(revision 1295)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/format/app.format	(working copy)
@@ -319,7 +319,7 @@
 6 power_starting_cb_offset
 8 power_standby_cb_offset
 10 ui_butten_up_cb_offset
-)
+)
 
 //auth rom address
 (
Index: format/app_mouse.format
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/format/app_mouse.format	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/format/app_mouse.format	(working copy)
@@ -762,3 +762,63 @@
 )
 
 
+
+memalloc mouse_fcc(
+0 mem_fcc_mode_start
+0 mem_fcc_param_new	
+1 mem_fcc_ch_new
+1 mem_fcc_mod_new
+1 mem_fcc_txrx_new
+1 mem_fcc_btble_new
+1 mem_fcc_data_new
+1 mem_fcc_data_length_new
+1 mem_fcc_hop_new
+
+0 mem_fcc_param
+1 mem_fcc_ch
+1 mem_fcc_mod
+1 mem_fcc_txrx
+1 mem_fcc_btble
+1 mem_fcc_data
+1 mem_fcc_data_length
+1 mem_fcc_hop
+
+1 mem_fcc_ch_switch
+1 mem_fcc_ch_switch_inc_en
+1 mem_fcc_ch_switch_dec_en
+1 mem_fcc_mode_switch
+1 mem_fcc_lkey_press
+1 mem_fcc_rkey_press
+1 mem_fcc_mkey_press
+
+1 mem_fcc_scan_mode_mkey_press
+1022 mem_pn9
+0 mem_fcc_mode_end
+)
+
+
+(
+1 FCC_STEP1_SCAN_MODE
+2 FCC_STEP2_MOD_TX_2408
+3 FCC_STEP3_MOD_TX_2440
+4 FCC_STEP4_MOD_TX_2474
+5 FCC_STEP5_MOD_RX_2408
+6 FCC_STEP6_MOD_RX_2440
+7 FCC_STEP7_MOD_RX_2474
+8 FCC_STEP8_NON_MOD_TX_2408
+9 FCC_STEP9_NON_MOD_TX_2440
+10 FCC_STEP10_NON_MOD_TX_2474
+11 FCC_STEP11_NON_MOD_RX_2408
+12 FCC_STEP12_NON_MOD_RX_2440
+13 FCC_STEP13_NON_MOD_RX_2474
+14 FCC_STEP14_NON_MOD_TX_2408
+15 FCC_STEP15_NON_MOD_TX_2440
+16 FCC_STEP16_NON_MOD_TX_2474
+17 FCC_STEP17_NON_MOD_RX_2408
+18 FCC_STEP18_NON_MOD_RX_2440
+19 FCC_STEP19_NON_MOD_RX_2474
+20 FCC_STEP_MAX
+)
+
+
+
Index: format/regs.format
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/format/regs.format	(revision 1295)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/format/regs.format	(working copy)
@@ -159,6 +159,7 @@
 	0x828a core_docd_pdata
 
 	0x8900 modem_en
+	0x890d core_tx_test_mode
 	0x8938 mod_value_scale1
 	0x8960 core_rf_rx_agc_ctrl
 	0x8961 core_rf_rx_gain_fix
Index: output/eeprom.dat
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/output/eeprom.dat	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/output/eeprom.dat	(working copy)
@@ -6261,6 +6261,18 @@
 ff
 aa
 55
+06
+00
+a8
+40
+16
+a2
+c8
+12
+23
+51
+aa
+55
 01
 00
 65
@@ -6434,13 +6446,10 @@
 aa
 aa
 55
-04
-21
-db
-54
-ff
-ff
-ff
+f7
+24
+39
+d8
 ff
 ff
 ff
@@ -8179,14 +8188,5 @@
 ff
 ff
 ff
-ff
-ff
-ff
-ff
-ff
-ff
-ff
-ff
-ff
-c2
-85
+15
+57
Index: output/flash.dat
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/output/flash.dat	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/output/flash.dat	(working copy)
@@ -6261,6 +6261,18 @@
 ff
 aa
 55
+06
+00
+a8
+40
+16
+a2
+c8
+12
+23
+51
+aa
+55
 01
 00
 65
@@ -6434,13 +6446,10 @@
 aa
 aa
 55
-04
-21
-db
-54
-ff
-ff
-ff
+f7
+24
+39
+d8
 ff
 ff
 ff
@@ -8179,14 +8188,5 @@
 ff
 ff
 ff
-ff
-ff
-ff
-ff
-ff
-ff
-ff
-ff
-ff
-c2
-85
+15
+57
Index: output/memmap.format
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/output/memmap.format	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/output/memmap.format	(working copy)
@@ -565,6 +565,33 @@
 0x09fa mem_data_current
 0x09fc mem_data_sum
 0x09ff mem_data_value
+0x0a01 mem_fcc_mode_start
+0x0a01 mem_fcc_param_new
+0x0a01 mem_fcc_ch_new
+0x0a02 mem_fcc_mod_new
+0x0a03 mem_fcc_txrx_new
+0x0a04 mem_fcc_btble_new
+0x0a05 mem_fcc_data_new
+0x0a06 mem_fcc_data_length_new
+0x0a07 mem_fcc_hop_new
+0x0a08 mem_fcc_param
+0x0a08 mem_fcc_ch
+0x0a09 mem_fcc_mod
+0x0a0a mem_fcc_txrx
+0x0a0b mem_fcc_btble
+0x0a0c mem_fcc_data
+0x0a0d mem_fcc_data_length
+0x0a0e mem_fcc_hop
+0x0a0f mem_fcc_ch_switch
+0x0a10 mem_fcc_ch_switch_inc_en
+0x0a11 mem_fcc_ch_switch_dec_en
+0x0a12 mem_fcc_mode_switch
+0x0a13 mem_fcc_lkey_press
+0x0a14 mem_fcc_rkey_press
+0x0a15 mem_fcc_mkey_press
+0x0a16 mem_fcc_scan_mode_mkey_press
+0x0a17 mem_pn9
+0x0e15 mem_fcc_mode_end
 0x09f6 mem_tst_pktcnt_sync
 0x09f8 mem_tst_pktcnt_hec
 0x09fa mem_tst_pktcnt_crc
Index: program/patch.prog
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/program/patch.prog	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/program/patch.prog	(working copy)
@@ -2,6 +2,7 @@
 //define CLASSIC
 //define G24_OTA
 //define PW_CTRL
+//define FCC
 define FIRE_KEY
 //define UARTA_DEBUG
 
@@ -3180,3 +3181,369 @@
 
 
 
+
+ifdef FCC
+
+p_fcc_mode_start:
+	setarg mem_fcc_mode_end
+	arg mem_fcc_mode_start,contw
+	isub contw,loopcnt
+	call clear_mem
+	call p_pn9
+	call p_fcc_step1_scan_mode
+	jam 0x19,mem_fcc_data_length_new
+	branch p_test_tx_new_param
+
+p_pn9:
+	arg 1022,loopcnt
+ 	arg mem_pn9,contw
+  	setarg 0x1ff
+	force 0,regb
+p_pn9_loop:    
+	rshift3 pdata,rega
+	rshift rega,rega
+	ixor rega,rega
+	isolate1 0,rega
+	setflag true,9,pdata
+	rshift temp,temp
+	isolate1 0,pdata
+	setflag true,7,temp
+	rshift pdata,pdata
+	increase 1,regb
+	compare 0,regb,0x7
+	nbranch p_pn9_loop,true
+	istoret 1,contw
+	loop p_pn9_loop
+	rtn
+
+    
+
+p_test_tx_new_param:
+	fetch 7,mem_fcc_param_new
+	store 7,mem_fcc_param
+p_test_tx_or_rx:
+	fetch 1,mem_fcc_txrx
+	beq 0x01,p_test_tx_start
+	beq 0x02,p_test_rx_start
+p_test_tx_start:
+p_test_ble_tx_on:
+	call set_sync_on
+	fetcht 1,mem_fcc_ch
+	call set_freq_tx
+	call le_enable
+	set1 TXGFSK,radio_ctrl
+	enable encode_fec0
+	enable is_tx
+	disable is_rx
+	call le_wait_tx
+	fetch 1,mem_fcc_data
+	store 1,core_tx_test_mode
+	beq 0,p_test_tx_data
+p_test_tx_carrier_loop:
+	fetchr loopcnt,1,mem_fcc_data_length
+	arg mem_pn9,contr
+p_pnloop_carrier:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_carrier
+	call p_key_wheel_process
+	fetch 7,mem_fcc_param
+	fetcht 7,mem_fcc_param_new
+	isub temp,null
+	branch p_test_tx_carrier_loop,zero
+	branch p_test_tx_new_param
+
+p_test_tx_data:
+	fetch 1,mem_fcc_hop
+	beq 1,p_tx_data_hopping
+p_tx_data:
+	arg 53,loopcnt
+	arg mem_pn9,contr
+p_pnloop_stable:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_stable
+p_stable_stop:
+	call p_key_wheel_process
+	fetch 7,mem_fcc_param
+	fetcht 7,mem_fcc_param_new
+	isub temp,null
+	branch p_tx_data,zero
+	call shutdown_radio
+	branch p_test_tx_new_param
+
+
+p_tx_data_hopping:
+	disable swfine
+	arg 26,stop_watch	//26 * 0.3125 = 8.125ms
+p_tx_data_hopping2:
+	arg 55,loopcnt
+	arg mem_pn9,contr
+p_pnloop_stable2:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_stable2
+	nbranch p_tx_data_hopping2,timeout
+	call shutdown_radio
+	arg 15,queue
+	setarg 800	//500ms
+	call timer_init
+p_500ms_cycle:
+	arg 15,queue
+	call timer_check
+	branch p_hopping_change_ch,blank
+	call p_key_wheel_process
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP1_SCAN_MODE,p_500ms_cycle
+	branch p_test_tx_new_param
+
+p_hopping_change_ch:
+	call p_hopping_ch_update
+	branch p_test_tx_new_param
+
+p_hopping_ch_update:
+	fetch 1,mem_fcc_scan_mode_mkey_press
+	nbranch p_fcc_set_channel_2408,blank
+	fetch 1,mem_fcc_ch_new
+	pincrease 2
+	store 1,mem_fcc_ch_new
+	rtnne 74
+	branch p_fcc_set_channel_2408
+
+
+p_test_rx_start:
+	call p_test_ble_rx_on
+p_test_rx_loop:
+	call p_key_wheel_process
+	fetch 7,mem_fcc_param
+	fetcht 7,mem_fcc_param_new
+	isub temp,null
+	branch p_test_rx_loop,zero
+	branch p_test_tx_new_param
+
+p_test_ble_rx_on:
+	call shutdown_radio	//close tx
+	fetcht 1,mem_fcc_ch
+	branch le_rf_rx_enable
+
+p_key_wheel_process:
+	call p_key_process
+	branch p_wheel_process
+
+p_key_process:
+	disable user
+	call mouse_key
+	nrtn user
+	fetch 1,mem_mouse_key
+ 	beq MOUSE_L_BUTTON,p_fcc_mode_exit
+	beq MOUSE_R_BUTTON,p_fcc_mode_switch
+	beq MOUSE_M_BUTTON,p_fcc_mkey_channel_switch
+	jam 0,mem_fcc_lkey_press
+	jam 0,mem_fcc_rkey_press
+	jam 0,mem_fcc_mkey_press	
+	rtn
+
+
+p_fcc_mode_exit:
+	fetch 1,mem_fcc_lkey_press
+	nrtn blank
+	jam 1,mem_fcc_lkey_press
+	jam 1,core_reset
+	branch assert
+
+p_fcc_mode_switch:
+	fetch 1,mem_fcc_rkey_press
+	nrtn blank
+	jam 1,mem_fcc_rkey_press
+	call p_fcc_mode_cnt
+	branch p_fcc_mode_choose
+
+p_fcc_mode_cnt:
+	fetch 1,mem_fcc_mode_switch
+	pincrease 1
+	store 1,mem_fcc_mode_switch
+	rtnne FCC_STEP_MAX
+	jam FCC_STEP1_SCAN_MODE,mem_fcc_mode_switch
+	rtn
+
+p_fcc_mode_choose:
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP1_SCAN_MODE,p_fcc_step1_scan_mode
+	jam 0,mem_fcc_scan_mode_mkey_press
+	beq FCC_STEP2_MOD_TX_2408,p_fcc_step2_mod_tx_2408
+	beq FCC_STEP3_MOD_TX_2440,p_fcc_step3_mod_tx_2440
+	beq FCC_STEP4_MOD_TX_2474,p_fcc_step4_mod_tx_2474
+	beq FCC_STEP5_MOD_RX_2408,p_fcc_step5_mod_rx_2408
+	beq FCC_STEP6_MOD_RX_2440,p_fcc_step6_mod_rx_2440
+	beq FCC_STEP7_MOD_RX_2474,p_fcc_step7_mod_rx_2474
+	beq FCC_STEP8_NON_MOD_TX_2408,p_fcc_non_mod_tx_2408
+	beq FCC_STEP9_NON_MOD_TX_2440,p_fcc_non_mod_tx_2440
+	beq FCC_STEP10_NON_MOD_TX_2474,p_fcc_non_mod_tx_2474
+	beq FCC_STEP11_NON_MOD_RX_2408,p_fcc_non_mod_rx_2408
+	beq FCC_STEP12_NON_MOD_RX_2440,p_fcc_non_mod_rx_2440
+	beq FCC_STEP13_NON_MOD_RX_2474,p_fcc_non_mod_rx_2474
+	beq FCC_STEP14_NON_MOD_TX_2408,p_fcc_non_mod_tx_2408
+	beq FCC_STEP15_NON_MOD_TX_2440,p_fcc_non_mod_tx_2440
+	beq FCC_STEP16_NON_MOD_TX_2474,p_fcc_non_mod_tx_2474
+	beq FCC_STEP17_NON_MOD_RX_2408,p_fcc_non_mod_rx_2408
+	beq FCC_STEP18_NON_MOD_RX_2440,p_fcc_non_mod_rx_2440
+	beq FCC_STEP19_NON_MOD_RX_2474,p_fcc_non_mod_rx_2474
+	rtn
+
+p_fcc_step1_scan_mode:
+	jam FCC_STEP1_SCAN_MODE,mem_fcc_mode_switch
+	jam 0,mem_fcc_scan_mode_mkey_press
+	jam 6,mem_fcc_ch_new
+	jam 0,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	jam 0x01,mem_fcc_btble_new
+	jam 0x01,mem_fcc_hop_new
+	rtn
+
+p_fcc_step2_mod_tx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x00,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	jam 0x00,mem_fcc_hop_new
+	rtn
+p_fcc_step3_mod_tx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x00,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_step4_mod_tx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x00,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_step5_mod_rx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_step6_mod_rx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_step7_mod_rx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_tx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_tx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_tx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_rx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_rx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_rx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+
+	
+p_fcc_mkey_channel_switch:
+	fetch 1,mem_fcc_mkey_press
+	nrtn blank
+	jam 1,mem_fcc_mkey_press
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP1_SCAN_MODE,p_fcc_mkey_scan_mode_ch_switch
+	beq FCC_STEP2_MOD_TX_2408,p_fcc_mkey_mod_tx_channel_switch
+	beq FCC_STEP3_MOD_TX_2440,p_fcc_mkey_mod_tx_channel_switch
+	beq FCC_STEP4_MOD_TX_2474,p_fcc_mkey_mod_tx_channel_switch
+	rtn
+p_fcc_mkey_mod_tx_channel_switch:
+	fetch 1,mem_fcc_ch_new
+	beq 6,p_fcc_set_channel_2440
+	beq 38,p_fcc_set_channel_2474
+	beq 72,p_fcc_set_channel_2408
+p_fcc_set_channel_2408:
+	jam 6,mem_fcc_ch_new
+	rtn
+p_fcc_set_channel_2440:
+	jam 38,mem_fcc_ch_new
+	rtn
+p_fcc_set_channel_2474:
+	jam 72,mem_fcc_ch_new
+	rtn	
+
+p_fcc_mkey_scan_mode_ch_switch:
+	jam 6,mem_fcc_ch_new
+	jam 1,mem_fcc_scan_mode_mkey_press
+	rtn
+
+
+p_wheel_process:
+	call mouse_wheel_check
+	fetch 1,mem_mouse_z_data
+	rtn blank
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP2_MOD_TX_2408,p_fcc_wheel_mod_tx_channel_switch
+	beq FCC_STEP3_MOD_TX_2440,p_fcc_wheel_mod_tx_channel_switch
+	beq FCC_STEP4_MOD_TX_2474,p_fcc_wheel_mod_tx_channel_switch
+	rtn
+
+p_fcc_wheel_mod_tx_channel_switch:
+	fetch 1,mem_mouse_z_data
+	jam 0,mem_mouse_z_data
+	beq 0x01,p_fcc_wheel_mod_tx_channel_inc	//forward
+	beq 0xff,p_fcc_wheel_mod_tx_channel_dec	//back
+	rtn
+p_fcc_wheel_mod_tx_channel_inc:
+	fetch 1,mem_fcc_ch_new
+	pincrease 1
+	store 1,mem_fcc_ch_new
+	rtnne 73
+	jam 6,mem_fcc_ch_new
+	rtn
+p_fcc_wheel_mod_tx_channel_dec:
+	fetch 1,mem_fcc_ch_new
+	pincrease -1
+	store 1,mem_fcc_ch_new
+	rtnne 5
+	jam 72,mem_fcc_ch_new
+	rtn
+	
+	
+endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: program_patch/fcc_spec_code/patch_fcc.prog
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/program_patch/fcc_spec_code/patch_fcc.prog	(nonexistent)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/program_patch/fcc_spec_code/patch_fcc.prog	(working copy)
@@ -0,0 +1,366 @@
+
+ifdef FCC
+
+p_fcc_mode_start:
+	setarg mem_fcc_mode_end
+	arg mem_fcc_mode_start,contw
+	isub contw,loopcnt
+	call clear_mem
+	call p_pn9
+	call p_fcc_step1_scan_mode
+	jam 0x19,mem_fcc_data_length_new
+	branch p_test_tx_new_param
+
+p_pn9:
+	arg 1022,loopcnt
+ 	arg mem_pn9,contw
+  	setarg 0x1ff
+	force 0,regb
+p_pn9_loop:    
+	rshift3 pdata,rega
+	rshift rega,rega
+	ixor rega,rega
+	isolate1 0,rega
+	setflag true,9,pdata
+	rshift temp,temp
+	isolate1 0,pdata
+	setflag true,7,temp
+	rshift pdata,pdata
+	increase 1,regb
+	compare 0,regb,0x7
+	nbranch p_pn9_loop,true
+	istoret 1,contw
+	loop p_pn9_loop
+	rtn
+
+    
+
+p_test_tx_new_param:
+	fetch 7,mem_fcc_param_new
+	store 7,mem_fcc_param
+p_test_tx_or_rx:
+	fetch 1,mem_fcc_txrx
+	beq 0x01,p_test_tx_start
+	beq 0x02,p_test_rx_start
+p_test_tx_start:
+p_test_ble_tx_on:
+	call set_sync_on
+	fetcht 1,mem_fcc_ch
+	call set_freq_tx
+	call le_enable
+	set1 TXGFSK,radio_ctrl
+	enable encode_fec0
+	enable is_tx
+	disable is_rx
+	call le_wait_tx
+	fetch 1,mem_fcc_data
+	store 1,core_tx_test_mode
+	beq 0,p_test_tx_data
+p_test_tx_carrier_loop:
+	fetchr loopcnt,1,mem_fcc_data_length
+	arg mem_pn9,contr
+p_pnloop_carrier:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_carrier
+	call p_key_wheel_process
+	fetch 7,mem_fcc_param
+	fetcht 7,mem_fcc_param_new
+	isub temp,null
+	branch p_test_tx_carrier_loop,zero
+	branch p_test_tx_new_param
+
+p_test_tx_data:
+	fetch 1,mem_fcc_hop
+	beq 1,p_tx_data_hopping
+p_tx_data:
+	arg 53,loopcnt
+	arg mem_pn9,contr
+p_pnloop_stable:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_stable
+p_stable_stop:
+	call p_key_wheel_process
+	fetch 7,mem_fcc_param
+	fetcht 7,mem_fcc_param_new
+	isub temp,null
+	branch p_tx_data,zero
+	call shutdown_radio
+	branch p_test_tx_new_param
+
+
+p_tx_data_hopping:
+	disable swfine
+	arg 26,stop_watch	//26 * 0.3125 = 8.125ms
+p_tx_data_hopping2:
+	arg 55,loopcnt
+	arg mem_pn9,contr
+p_pnloop_stable2:
+	ifetch 1,contr
+	inject mod,8
+	loop p_pnloop_stable2
+	nbranch p_tx_data_hopping2,timeout
+	call shutdown_radio
+	arg 15,queue
+	setarg 800	//500ms
+	call timer_init
+p_500ms_cycle:
+	arg 15,queue
+	call timer_check
+	branch p_hopping_change_ch,blank
+	call p_key_wheel_process
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP1_SCAN_MODE,p_500ms_cycle
+	branch p_test_tx_new_param
+
+p_hopping_change_ch:
+	call p_hopping_ch_update
+	branch p_test_tx_new_param
+
+p_hopping_ch_update:
+	fetch 1,mem_fcc_scan_mode_mkey_press
+	nbranch p_fcc_set_channel_2408,blank
+	fetch 1,mem_fcc_ch_new
+	pincrease 2
+	store 1,mem_fcc_ch_new
+	rtnne 74
+	branch p_fcc_set_channel_2408
+
+
+p_test_rx_start:
+	call p_test_ble_rx_on
+p_test_rx_loop:
+	call p_key_wheel_process
+	fetch 7,mem_fcc_param
+	fetcht 7,mem_fcc_param_new
+	isub temp,null
+	branch p_test_rx_loop,zero
+	branch p_test_tx_new_param
+
+p_test_ble_rx_on:
+	call shutdown_radio	//close tx
+	fetcht 1,mem_fcc_ch
+	branch le_rf_rx_enable
+
+p_key_wheel_process:
+	call p_key_process
+	branch p_wheel_process
+
+p_key_process:
+	disable user
+	call mouse_key
+	nrtn user
+	fetch 1,mem_mouse_key
+ 	beq MOUSE_L_BUTTON,p_fcc_mode_exit
+	beq MOUSE_R_BUTTON,p_fcc_mode_switch
+	beq MOUSE_M_BUTTON,p_fcc_mkey_channel_switch
+	jam 0,mem_fcc_lkey_press
+	jam 0,mem_fcc_rkey_press
+	jam 0,mem_fcc_mkey_press	
+	rtn
+
+
+p_fcc_mode_exit:
+	fetch 1,mem_fcc_lkey_press
+	nrtn blank
+	jam 1,mem_fcc_lkey_press
+	jam 1,core_reset
+	branch assert
+
+p_fcc_mode_switch:
+	fetch 1,mem_fcc_rkey_press
+	nrtn blank
+	jam 1,mem_fcc_rkey_press
+	call p_fcc_mode_cnt
+	branch p_fcc_mode_choose
+
+p_fcc_mode_cnt:
+	fetch 1,mem_fcc_mode_switch
+	pincrease 1
+	store 1,mem_fcc_mode_switch
+	rtnne FCC_STEP_MAX
+	jam FCC_STEP1_SCAN_MODE,mem_fcc_mode_switch
+	rtn
+
+p_fcc_mode_choose:
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP1_SCAN_MODE,p_fcc_step1_scan_mode
+	jam 0,mem_fcc_scan_mode_mkey_press
+	beq FCC_STEP2_MOD_TX_2408,p_fcc_step2_mod_tx_2408
+	beq FCC_STEP3_MOD_TX_2440,p_fcc_step3_mod_tx_2440
+	beq FCC_STEP4_MOD_TX_2474,p_fcc_step4_mod_tx_2474
+	beq FCC_STEP5_MOD_RX_2408,p_fcc_step5_mod_rx_2408
+	beq FCC_STEP6_MOD_RX_2440,p_fcc_step6_mod_rx_2440
+	beq FCC_STEP7_MOD_RX_2474,p_fcc_step7_mod_rx_2474
+	beq FCC_STEP8_NON_MOD_TX_2408,p_fcc_non_mod_tx_2408
+	beq FCC_STEP9_NON_MOD_TX_2440,p_fcc_non_mod_tx_2440
+	beq FCC_STEP10_NON_MOD_TX_2474,p_fcc_non_mod_tx_2474
+	beq FCC_STEP11_NON_MOD_RX_2408,p_fcc_non_mod_rx_2408
+	beq FCC_STEP12_NON_MOD_RX_2440,p_fcc_non_mod_rx_2440
+	beq FCC_STEP13_NON_MOD_RX_2474,p_fcc_non_mod_rx_2474
+	beq FCC_STEP14_NON_MOD_TX_2408,p_fcc_non_mod_tx_2408
+	beq FCC_STEP15_NON_MOD_TX_2440,p_fcc_non_mod_tx_2440
+	beq FCC_STEP16_NON_MOD_TX_2474,p_fcc_non_mod_tx_2474
+	beq FCC_STEP17_NON_MOD_RX_2408,p_fcc_non_mod_rx_2408
+	beq FCC_STEP18_NON_MOD_RX_2440,p_fcc_non_mod_rx_2440
+	beq FCC_STEP19_NON_MOD_RX_2474,p_fcc_non_mod_rx_2474
+	rtn
+
+p_fcc_step1_scan_mode:
+	jam FCC_STEP1_SCAN_MODE,mem_fcc_mode_switch
+	jam 0,mem_fcc_scan_mode_mkey_press
+	jam 6,mem_fcc_ch_new
+	jam 0,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	jam 0x01,mem_fcc_btble_new
+	jam 0x01,mem_fcc_hop_new
+	rtn
+
+p_fcc_step2_mod_tx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x00,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	jam 0x00,mem_fcc_hop_new
+	rtn
+p_fcc_step3_mod_tx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x00,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_step4_mod_tx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x00,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_step5_mod_rx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_step6_mod_rx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_step7_mod_rx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_tx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_tx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_tx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x01,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_rx_2408:
+	jam 6,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_rx_2440:
+	jam 38,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+p_fcc_non_mod_rx_2474:
+	jam 72,mem_fcc_ch_new
+	jam 0x22,mem_fcc_data_new
+	jam 0x02,mem_fcc_txrx_new
+	rtn
+
+	
+p_fcc_mkey_channel_switch:
+	fetch 1,mem_fcc_mkey_press
+	nrtn blank
+	jam 1,mem_fcc_mkey_press
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP1_SCAN_MODE,p_fcc_mkey_scan_mode_ch_switch
+	beq FCC_STEP2_MOD_TX_2408,p_fcc_mkey_mod_tx_channel_switch
+	beq FCC_STEP3_MOD_TX_2440,p_fcc_mkey_mod_tx_channel_switch
+	beq FCC_STEP4_MOD_TX_2474,p_fcc_mkey_mod_tx_channel_switch
+	rtn
+p_fcc_mkey_mod_tx_channel_switch:
+	fetch 1,mem_fcc_ch_new
+	beq 6,p_fcc_set_channel_2440
+	beq 38,p_fcc_set_channel_2474
+	beq 72,p_fcc_set_channel_2408
+p_fcc_set_channel_2408:
+	jam 6,mem_fcc_ch_new
+	rtn
+p_fcc_set_channel_2440:
+	jam 38,mem_fcc_ch_new
+	rtn
+p_fcc_set_channel_2474:
+	jam 72,mem_fcc_ch_new
+	rtn	
+
+p_fcc_mkey_scan_mode_ch_switch:
+	jam 6,mem_fcc_ch_new
+	jam 1,mem_fcc_scan_mode_mkey_press
+	rtn
+
+
+p_wheel_process:
+	call mouse_wheel_check
+	fetch 1,mem_mouse_z_data
+	rtn blank
+	fetch 1,mem_fcc_mode_switch
+	beq FCC_STEP2_MOD_TX_2408,p_fcc_wheel_mod_tx_channel_switch
+	beq FCC_STEP3_MOD_TX_2440,p_fcc_wheel_mod_tx_channel_switch
+	beq FCC_STEP4_MOD_TX_2474,p_fcc_wheel_mod_tx_channel_switch
+	rtn
+
+p_fcc_wheel_mod_tx_channel_switch:
+	fetch 1,mem_mouse_z_data
+	jam 0,mem_mouse_z_data
+	beq 0x01,p_fcc_wheel_mod_tx_channel_inc	//forward
+	beq 0xff,p_fcc_wheel_mod_tx_channel_dec	//back
+	rtn
+p_fcc_wheel_mod_tx_channel_inc:
+	fetch 1,mem_fcc_ch_new
+	pincrease 1
+	store 1,mem_fcc_ch_new
+	rtnne 73
+	jam 6,mem_fcc_ch_new
+	rtn
+p_fcc_wheel_mod_tx_channel_dec:
+	fetch 1,mem_fcc_ch_new
+	pincrease -1
+	store 1,mem_fcc_ch_new
+	rtnne 5
+	jam 72,mem_fcc_ch_new
+	rtn
+	
+	
+endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: program_patch/main_patch.prog
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/program_patch/main_patch.prog	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/program_patch/main_patch.prog	(working copy)
@@ -2,6 +2,7 @@
 //define CLASSIC
 //define G24_OTA
 //define PW_CTRL
+//define FCC
 define FIRE_KEY
 //define UARTA_DEBUG
 
Index: /YC1308AC/branch/mouse_project/mouse_pubulic/sched/ble.dat	(added)
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/sched/ble.dat	(revision 0)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/sched/ble.dat	(revision 0)
Index: sched/classic.dat
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/sched/classic.dat	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/sched/classic.dat	(working copy)
@@ -1,5 +1,4 @@
 mem_app_connection_options:06
-mem_lap:16 a2 c8 12 23 51
 mem_local_name_length:
 'BT3.0 Mouse
 mem_sniff_param_interval:
Index: sched/g24.dat
===================================================================
--- /YC1308AC/branch/mouse_project/mouse_pubulic/sched/g24.dat	(revision 1300)
+++ /YC1308AC/branch/mouse_project/mouse_pubulic/sched/g24.dat	(working copy)
@@ -1,4 +1,5 @@
 #24g init
+mem_lap:16 a2 c8 12 23 51
 mem_24g_tx_phy:02#0x01:1M/0x02:2M/0x04:S2/0x84:S8
 mem_24g_rx_phy:02#0x01:1M/0x02:2M/0x04:S2/0x84:S8
 mem_24g_data_type:01        #mouse 1,kb 2
