Index: format/app.format
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/format/app.format	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/format/app.format	(working copy)
@@ -65,10 +65,19 @@
 
 
 //adc
+0 mem_reference_inter1p8v_2v_adc_io_data
+0 mem_inter1v_adc_ft_data
 2 mem_3v_adc_io_data
+0 mem_reference_inter1p8v_2p6v_adc_vdcdc_data
+0 mem_inter1p2v_adc_ft_data
 2 mem_2v_adc_hvin_data
+0 mem_reference_inter1p8v_1v_adc_io_data
+0 mem_io1v_adc_ft_data
 2 mem_1v_adc_io_data
+0 mem_reference_inter1p8v_4p6v_adc_vdcdc_data
+0 mem_io2v_adc_ft_data
 2 mem_3v_adc_hvin_data
+0 mem_adc_ratio
 2 mem_reference_voltage
 1 mem_adc_config_flag
 1 mem_adc_channel
@@ -209,6 +218,8 @@
 7 OTP_OFFSET_XRAM_BISTFIX	//2 byte
 9 OTP_OFFSET_PATCH_BISTFIX	//2 byte
 
+0xfc0 OTP_OFFSET_ADC_PARAM_L_C0
+
 0xfd0 OTP_OFFSET_ADC_PARAM_L
 0xff0 OTP_OFFSET_UCODE_KEY_L
 0x1000 OTP_OFFSET_H
@@ -368,4 +379,8 @@
 0x0d ADC_CH_GPIO22
 0x0e ADC_CH_GPIO13
 )
-
+//mem_adc_reference_mode
+(
+1 SADC_REFERENCE_INTER3V
+2 SADC_REFERENCE_INTER1P8V_DIV2
+)
Index: format/app_shutter_dy.format
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/format/app_shutter_dy.format	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/format/app_shutter_dy.format	(working copy)
@@ -202,6 +202,24 @@
 1 mem_shutter_photo_time
 1 mem_shutter_photo_click_count
 1 mem_shutter_photo_double_time
+
+//adc
+//adc struct
+0 mem_shutter_vdd_calculate_set
+2 mem_shutter_vdd_full_vol
+2 mem_shutter_vdd_empty_vol
+2 mem_shutter_vdd_low_vol
+2 mem_shutter_vdd_now_vol
+
+1 mem_shutter_start_adc_flag
+1 mem_shutter_adc_read_timer
+1 mem_shutter_enable_low_voltage_flag
+1 mem_shutter_adc_last_low_voltage_flag
+
+1 mem_shutter_battery_level_percentage
+1 mem_shutter_adc_read_time_init
+1 mem_shutter_low_volatge_led_time
+1 mem_shutter_low_voltage_led_status
 0 mem_shutter_dy_end
 )
 
Index: format/bt.format
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/format/bt.format	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/format/bt.format	(working copy)
@@ -209,8 +209,17 @@
 1 mem_system_clk
 
 ifdef DEBUG_RF_INIT
-18 mem_rf_init_data
+5 mem_rf_init_data
 endif
+
+0 mem_adc_reference3v_ft_data
+2 mem_adc_reference3v_gpio1v_ft_data
+2 mem_adc_reference3v_gpio2v_ft_data
+2 mem_adc_reference3v_vdcdc3p6v_ft_data
+2 mem_adc_reference3v_vdcdc4p6v_ft_data
+2 mem_adc_reference3v_inter1v_ft_data
+2 mem_adc_reference3v_inter1v_now_data
+1 mem_adc_reference_mode
 1 mem_otp_charge_pump_x
 1 mem_otp_dpll_ibais_x
 
Index: output/otp.dat
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/output/otp.dat	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/output/otp.dat	(working copy)
@@ -11,92 +11,100 @@
 00
 aa
 55
-7a
-0f
+d6
+11
 c2
 84
 00
-16
+18
 c0
 00
 00
-4f
+51
 c0
 01
 01
-1d
+1f
 c0
 08
 81
-26
+28
 c0
 0a
 03
-1d
+0a
 c0
 0a
 81
-b3
+b5
 c0
 0c
 01
-c1
+c3
 c0
 0c
 81
-80
+82
 c0
 0d
 01
-38
+3a
 c0
 12
 83
-3f
+2c
 c0
 13
 80
-7a
+7c
 c0
 51
 80
-c2
+c4
 c0
 52
 80
-fa
+fc
 c0
 53
 00
-85
+87
 c0
 53
 80
-98
+9a
 c0
 55
 00
-ea
+ec
 c0
 58
 81
-d3
+d5
 c0
 62
 00
-1d
+1f
 c0
 62
 81
-c8
+ca
 c0
 6d
 02
-ee
+f3
+c0
+6d
+84
+1c
 c0
 6e
-02
-fe
+04
+59
+c0
+6e
+84
+3a
 20
 20
 23
@@ -104,23 +112,23 @@
 c0
 12
 00
-53
+55
 c0
 12
 80
-d3
+d5
 c0
 13
 00
-d8
+da
 c0
 1c
 83
-39
+26
 c0
 26
 83
-3d
+2a
 c1
 7f
 80
@@ -164,7 +172,7 @@
 20
 20
 80
-47
+49
 6f
 f0
 80
@@ -284,11 +292,11 @@
 20
 20
 80
-23
+25
 c5
 11
 00
-47
+49
 79
 20
 00
@@ -296,7 +304,7 @@
 20
 20
 00
-24
+26
 6f
 f1
 00
@@ -320,11 +328,11 @@
 24
 20
 80
-23
+25
 c2
 00
 00
-20
+22
 20
 20
 6b
@@ -352,7 +360,7 @@
 c5
 97
 80
-59
+5b
 78
 3c
 fc
@@ -396,7 +404,7 @@
 20
 37
 00
-62
+64
 1b
 42
 04
@@ -444,7 +452,7 @@
 20
 40
 00
-70
+72
 6f
 e0
 81
@@ -564,19 +572,19 @@
 c0
 03
 00
-8e
+90
 c0
 03
 80
-92
+94
 c0
 04
 00
-96
+98
 c0
 04
 80
-97
+99
 20
 20
 65
@@ -636,7 +644,7 @@
 20
 40
 00
-9e
+a0
 20
 74
 00
@@ -684,7 +692,7 @@
 20
 22
 80
-aa
+ac
 18
 e0
 8e
@@ -692,7 +700,7 @@
 20
 20
 00
-9f
+a1
 67
 e1
 4a
@@ -740,11 +748,11 @@
 20
 22
 80
-b7
+b9
 20
 20
 00
-b6
+b8
 70
 4e
 c0
@@ -796,7 +804,7 @@
 24
 3a
 00
-cc
+ce
 70
 4c
 00
@@ -808,7 +816,7 @@
 20
 40
 00
-cf
+d1
 20
 40
 65
@@ -840,7 +848,7 @@
 20
 20
 00
-c4
+c6
 df
 e0
 00
@@ -968,7 +976,7 @@
 c0
 00
 80
-f0
+f2
 20
 20
 66
@@ -984,7 +992,7 @@
 c0
 03
 00
-f4
+f6
 20
 60
 00
@@ -992,7 +1000,7 @@
 20
 20
 00
-f5
+f7
 70
 4e
 aa
@@ -1068,7 +1076,7 @@
 24
 3a
 01
-09
+0b
 20
 20
 65
@@ -1092,11 +1100,11 @@
 c0
 03
 01
-12
+14
 c0
 03
 81
-16
+18
 da
 60
 4a
@@ -1112,11 +1120,11 @@
 20
 40
 01
-1a
+1c
 20
 40
 03
-a8
+95
 da
 60
 4f
@@ -1128,11 +1136,11 @@
 20
 40
 01
-1a
+1c
 20
 40
 03
-cb
+b8
 da
 60
 4f
@@ -1188,7 +1196,7 @@
 20
 20
 01
-1d
+1f
 70
 8a
 0f
@@ -1308,7 +1316,7 @@
 20
 40
 01
-88
+8a
 6f
 e0
 c4
@@ -1320,7 +1328,7 @@
 24
 55
 81
-34
+36
 37
 d9
 82
@@ -1336,7 +1344,7 @@
 c0
 08
 01
-75
+77
 6f
 e0
 c4
@@ -1380,7 +1388,7 @@
 20
 40
 01
-67
+69
 70
 80
 43
@@ -1404,15 +1412,15 @@
 20
 40
 02
-c0
+c5
 20
 40
 02
-eb
+f0
 20
 40
 01
-61
+63
 70
 41
 48
@@ -1424,7 +1432,7 @@
 20
 20
 02
-ed
+f2
 20
 75
 80
@@ -1456,7 +1464,7 @@
 c0
 0c
 01
-6d
+6f
 6f
 e0
 c4
@@ -1548,7 +1556,7 @@
 20
 20
 01
-53
+55
 6f
 e0
 c1
@@ -1556,7 +1564,7 @@
 c0
 05
 01
-83
+85
 20
 20
 22
@@ -1584,7 +1592,7 @@
 20
 35
 81
-af
+b1
 6f
 e2
 02
@@ -1752,7 +1760,7 @@
 20
 20
 01
-99
+9b
 20
 40
 68
@@ -1891,10 +1899,14 @@
 00
 20
 40
-01
+03
 cb
 20
 40
+01
+cd
+20
+40
 64
 59
 58
@@ -1912,7 +1924,7 @@
 58
 00
 02
-4f
+54
 67
 e1
 43
@@ -1920,7 +1932,7 @@
 58
 00
 02
-2c
+31
 67
 e1
 43
@@ -1928,7 +1940,7 @@
 58
 00
 02
-41
+46
 67
 e1
 43
@@ -1944,7 +1956,7 @@
 58
 00
 01
-f4
+f7
 67
 e1
 43
@@ -1960,7 +1972,7 @@
 58
 00
 02
-09
+0c
 67
 e1
 43
@@ -2024,7 +2036,7 @@
 20
 40
 01
-f9
+fc
 20
 40
 70
@@ -2068,7 +2080,7 @@
 20
 22
 82
-04
+07
 1f
 e2
 04
@@ -2076,15 +2088,15 @@
 20
 40
 02
-07
+0a
 1a
 20
 a2
 01
 c2
 00
+02
 01
-fe
 20
 60
 00
@@ -2099,12 +2111,20 @@
 dd
 20
 40
+03
+e0
+20
+40
+03
+cd
+20
+40
 02
-24
+29
 20
 40
 02
-16
+1b
 20
 40
 67
@@ -2116,7 +2136,7 @@
 20
 40
 02
-0f
+14
 20
 20
 64
@@ -2128,7 +2148,7 @@
 da
 40
 02
-12
+17
 20
 20
 42
@@ -2156,7 +2176,7 @@
 da
 40
 02
-19
+1e
 20
 20
 42
@@ -2172,19 +2192,19 @@
 c0
 00
 82
-1e
+23
 c0
 01
 02
-20
+25
 20
 20
 02
-29
+2e
 20
 40
 02
-29
+2e
 20
 20
 67
@@ -2192,7 +2212,7 @@
 20
 40
 02
-29
+2e
 70
 4f
 e6
@@ -2212,7 +2232,7 @@
 da
 40
 02
-27
+2c
 20
 20
 42
@@ -2244,19 +2264,19 @@
 c0
 20
 02
-38
+3d
 c0
 18
 82
-36
+3b
 c0
 0a
 82
-33
+38
 c0
 0a
 02
-32
+37
 20
 20
 64
@@ -2308,7 +2328,7 @@
 24
 3a
 02
-4c
+51
 6f
 e4
 4f
@@ -2328,7 +2348,7 @@
 c0
 12
 02
-44
+49
 20
 60
 00
@@ -2352,7 +2372,7 @@
 24
 3a
 02
-4c
+51
 6f
 e4
 4f
@@ -2380,7 +2400,7 @@
 20
 40
 02
-5a
+5f
 d8
 e0
 00
@@ -2416,11 +2436,11 @@
 20
 40
 02
-74
+79
 20
 20
 03
-68
+55
 6f
 e1
 44
@@ -2428,7 +2448,7 @@
 c2
 84
 82
-5f
+64
 d8
 a0
 45
@@ -2476,7 +2496,7 @@
 24
 21
 02
-6b
+70
 6f
 e0
 c9
@@ -2588,7 +2608,7 @@
 20
 40
 02
-91
+96
 6f
 e1
 06
@@ -2636,7 +2656,7 @@
 c2
 00
 02
-7d
+82
 20
 60
 00
@@ -2680,7 +2700,7 @@
 20
 20
 02
-9b
+a0
 1a
 60
 8c
@@ -2692,7 +2712,7 @@
 20
 20
 02
-9e
+a3
 20
 40
 65
@@ -2708,7 +2728,7 @@
 20
 40
 02
-b8
+bd
 18
 e2
 7e
@@ -2716,19 +2736,19 @@
 c0
 03
 02
-a8
+ad
 c0
 03
 82
-aa
+af
 c0
 04
 02
-ac
+b1
 c0
 04
 82
-b3
+b8
 20
 20
 65
@@ -2752,7 +2772,7 @@
 20
 40
 02
-ae
+b3
 20
 20
 63
@@ -2880,7 +2900,7 @@
 20
 40
 02
-dd
+e2
 2a
 2f
 fe
@@ -2912,7 +2932,7 @@
 20
 40
 02
-dd
+e2
 d8
 a0
 8a
@@ -2940,7 +2960,7 @@
 20
 21
 02
-d2
+d7
 20
 20
 21
@@ -3044,7 +3064,7 @@
 20
 40
 03
-16
+03
 70
 8a
 08
@@ -3077,102 +3097,6 @@
 60
 00
 00
-20
-40
-03
-0c
-6f
-f0
-8a
-09
-79
-3f
-fe
-07
-67
-f0
-8a
-09
-70
-8a
-07
-77
-70
-8a
-08
-c1
-70
-8a
-0b
-01
-20
-40
-6f
-90
-6f
-e0
-c4
-09
-67
-f0
-80
-cd
-20
-00
-0b
-b8
-20
-40
-03
-16
-70
-80
-cd
-00
-20
-20
-6f
-a1
-6f
-f0
-80
-cc
-79
-20
-7e
-01
-67
-f0
-80
-cc
-6a
-40
-c4
-19
-6f
-e0
-c4
-33
-67
-e0
-c4
-19
-df
-20
-00
-08
-20
-40
-6f
-67
-62
-40
-c4
-19
-20
-60
-00
-00
 70
 80
 cc
@@ -3184,7 +3108,7 @@
 c3
 02
 83
-17
+04
 68
 59
 01
@@ -3220,7 +3144,7 @@
 c0
 08
 03
-36
+23
 58
 00
 57
@@ -3264,7 +3188,7 @@
 c0
 08
 03
-33
+20
 58
 00
 2b
@@ -3300,7 +3224,7 @@
 20
 20
 03
-2f
+1c
 58
 00
 83
@@ -3312,7 +3236,7 @@
 20
 20
 03
-24
+11
 6f
 e0
 c3
@@ -3360,7 +3284,7 @@
 20
 40
 03
-50
+3d
 6f
 e0
 c0
@@ -3472,7 +3396,7 @@
 20
 22
 83
-63
+50
 e7
 e0
 80
@@ -3492,7 +3416,7 @@
 c2
 00
 03
-5d
+4a
 1a
 42
 04
@@ -3540,7 +3464,7 @@
 24
 21
 03
-7a
+67
 1a
 20
 a2
@@ -3552,7 +3476,7 @@
 24
 3a
 03
-6e
+5b
 da
 20
 00
@@ -3560,7 +3484,7 @@
 20
 40
 03
-7f
+6c
 1c
 42
 7e
@@ -3616,11 +3540,11 @@
 20
 40
 03
-86
+73
 20
 20
 03
-80
+6d
 da
 60
 4f
@@ -3628,7 +3552,7 @@
 da
 40
 03
-89
+76
 20
 20
 42
@@ -3640,11 +3564,11 @@
 c0
 00
 83
-8d
+7a
 c0
 01
 03
-b0
+9d
 20
 60
 00
@@ -3656,7 +3580,7 @@
 24
 3a
 03
-9c
+89
 70
 49
 e5
@@ -3684,7 +3608,7 @@
 20
 42
 83
-a8
+95
 da
 60
 4f
@@ -3692,7 +3616,7 @@
 20
 40
 03
-d3
+c0
 ef
 e1
 00
@@ -3712,7 +3636,7 @@
 20
 40
 03
-db
+c8
 6f
 e0
 cf
@@ -3732,7 +3656,7 @@
 20
 42
 83
-a8
+95
 da
 60
 4f
@@ -3740,7 +3664,7 @@
 20
 40
 03
-d3
+c0
 ef
 e1
 00
@@ -3776,7 +3700,7 @@
 20
 40
 03
-d3
+c0
 58
 00
 06
@@ -3796,7 +3720,7 @@
 24
 3a
 03
-bf
+ac
 70
 49
 e5
@@ -3822,159 +3746,839 @@
 7c
 5a
 20
-42
-83
-cb
-da
+42
+83
+b8
+da
+60
+4f
+d0
+20
+40
+03
+c0
+ef
+e1
+00
+3f
+1f
+e0
+ff
+f6
+e7
+e1
+00
+11
+20
+20
+63
+71
+20
+40
+03
+c8
+6f
+e0
+cf
+db
+1f
+e0
+fe
+01
+67
+e0
+cf
+db
+1f
+e6
+7c
+3c
+20
+42
+83
+b8
+da
+60
+4f
+d0
+20
+40
+03
+c0
+ef
+e1
+00
+3f
+1f
+e0
+ff
+f6
+e7
+e1
+00
+11
+20
+20
+63
+71
+70
+4f
+db
+00
+da
+60
+4f
+d2
+20
+40
+63
+71
+da
+60
+4f
+d0
+20
+40
+03
+c0
+58
+00
+0a
+00
+e7
+e1
+00
+11
+20
+60
+00
+00
+d8
+40
+4c
+02
+ef
+e0
+80
+13
+1f
+e0
+ff
+ff
+1f
+ef
+fe
+0d
+98
+40
+fe
+00
+1f
+e0
+fe
+06
+1f
+e2
+22
+00
+20
+60
+00
+00
+70
+49
+e5
+01
+70
+4f
+d9
+02
+20
+60
+00
+00
+70
+4f
+ef
+01
+20
+60
+00
+00
+6f
+e0
+cf
+ef
+20
+7a
+00
+00
+6f
+e0
+cf
+f1
+20
+7a
+00
+00
+da
+60
+4f
+f5
+da
+40
+03
+d4
+20
+20
+42
+e0
+70
+4f
+f5
+05
+6f
+e0
+cf
+f6
+79
+40
+7e
+00
+67
+e0
+cf
+f6
+c0
+00
+c3
+23
+20
+20
+43
+25
+6f
+e0
+cf
+f0
+1f
+e0
+fe
+01
+67
+e0
+cf
+f0
+68
+48
+cf
+f4
+98
+46
+7c
+00
+20
+60
+00
+00
+6f
+e0
+cf
+ef
+20
+7a
+00
+00
+20
+40
+03
+da
+24
+61
+00
+00
+70
+4f
+f0
+00
+70
+44
+07
+01
+20
+40
+6f
+f3
+20
+40
+6f
+eb
+20
+40
+04
+59
+20
+40
+04
+3a
+67
+e1
+4f
+ed
+da
+20
+4f
+e7
+20
+40
+03
+f2
+6f
+e0
+c4
+0c
+c2
+80
+84
+12
+c3
+00
+04
+16
+70
+4f
+f2
+01
+20
+20
+04
+14
+ef
+e4
+00
+11
+67
+e4
+06
+70
+20
+40
+6f
+f3
+20
+40
+6f
+eb
+6f
+e1
+06
+76
+68
+49
+06
+72
+98
+46
+7c
+00
+24
+41
+6f
+ef
+68
+49
+06
+74
+98
+46
+7c
+00
+24
+41
+6f
+e7
+6f
+e1
+06
+76
+68
+49
+06
+70
+98
+46
+7c
+00
+20
+21
+04
+0e
+68
+49
+06
+72
+98
+46
+7e
+00
+24
+21
+04
+10
+20
+3a
+04
+10
+1f
+ef
+a2
+64
+6f
+e1
+06
+70
+68
+49
+06
+72
+98
+46
+04
+00
+1a
+22
+7e
+00
+98
+46
+fc
+00
+20
+40
+7d
+5f
+67
+e0
+cf
+f3
+20
+60
+00
+00
+70
+4f
+f3
+64
+20
+60
+00
+00
+70
+4f
+f3
+00
+20
+60
+00
+00
+20
+40
+43
+25
+20
+20
+43
+27
+70
+4f
+f1
+01
+20
+60
+00
+00
+70
+4f
+f1
+00
+6f
+e0
+cf
+f2
+20
+7a
+00
+00
+20
+40
+43
+25
+70
+4f
+f2
+00
+20
+60
+00
+00
+6f
+e4
+01
+fd
+20
+3a
+6f
+79
+67
+e4
+43
+fd
+20
+40
+6b
+3a
+20
+40
+6a
+ad
+df
+e0
+0f
+c0
+9a
+40
+a4
+00
+df
+20
+00
+0a
+da
+20
+01
+fd
+20
+40
+6b
+74
+20
+40
+6b
+37
+6f
+e4
+01
+fd
+20
+7a
+00
+00
+67
+e4
+41
+4e
+ef
+e1
+00
+06
+e7
+e1
+00
+05
+20
+60
+00
+00
+6f
+f0
+80
+cc
+79
+20
+7e
+01
+67
+f0
+80
+cc
+6a
+40
+c4
+19
+6f
+e0
+c4
+33
+67
+e0
+c4
+19
+df
+20
+00
+08
+20
+40
+6f
+67
+62
+40
+c4
+19
+6f
+f0
+8a
+0a
+79
+3f
+fe
+04
+67
+f0
+8a
+0a
+20
+60
+00
+00
+6f
+e0
+c4
+07
+c0
+00
+84
+3e
+c0
+01
+04
+45
+20
+60
+00
+00
+58
+00
+03
+e8
+67
+e1
+44
+05
+68
+49
+41
+52
+6f
+e1
+41
+54
+da
+60
+0e
+10
+20
+40
+6f
+c0
+20
+20
+04
+4b
+58
+00
+03
+e8
+67
+e1
+44
+05
+68
+49
+41
+4e
+6f
+e1
+41
+50
+da
+60
+03
+e8
+20
+40
+6f
+c0
+68
+49
+41
+56
+98
+4f
+fe
+00
+68
+49
+41
+58
+98
+46
+fc
+00
+20
+20
+7d
+5f
+20
+40
+04
+2d
+6f
+f0
+8a
+09
+79
+3f
+fe
+07
+67
+f0
+8a
+09
+70
+8a
+07
+77
+70
+8a
+08
+c1
+70
+8a
+0d
+61
+70
+8a
+0b
+00
+20
 60
-4f
-d0
-20
-40
-03
-d3
-ef
-e1
 00
-3f
-1f
-e0
-ff
-f6
-e7
-e1
 00
-11
 20
-20
-63
-71
+40
+04
+50
 20
 40
-03
-db
+6f
+90
 6f
 e0
-cf
-db
-1f
-e0
-fe
-01
+c4
+09
 67
-e0
-cf
-db
-1f
-e6
-7c
-3c
+f0
+80
+cd
 20
-42
-83
-cb
-da
+40
+6f
+97
+70
+8a
+0d
 60
-4f
-d0
+70
+80
+cd
+00
 20
 40
-03
-d3
-ef
-e1
-00
-3f
-1f
+04
+50
+6f
 e0
-ff
-f6
-e7
-e1
-00
-11
-20
-20
-63
-71
+c4
+09
+67
+f0
+80
+cd
 70
-4f
-db
+8a
+0b
+50
+70
+8a
+0e
+c0
+df
 00
-da
-60
-4f
-d2
+00
+0b
+6d
+e1
+44
+0a
+70
+80
+cc
+03
 20
 40
-63
-71
-da
+04
+72
+68
+59
+01
+64
 60
-4f
-d0
+49
+41
+58
 20
 40
-03
-d3
-58
+6f
+9c
+df
 00
-0a
 00
-e7
+0b
+65
 e1
-00
-11
-20
+44
+0a
+70
+8a
+0d
 60
-00
-00
-d8
-40
-4c
-02
-ef
-e0
+70
 80
-13
-1f
-e0
-ff
-ff
-1f
-ef
-fe
-0d
-98
-40
-fe
+cd
 00
-1f
-e0
-fe
-06
-1f
-e2
-22
+70
+80
+cc
 00
 20
 60
 00
 00
-70
-49
-e5
-01
-70
-4f
-d9
+6f
+f0
+81
+29
+c3
 02
+84
+72
 20
 60
 00
 00
-e2
-29
+6d
+c1
 aa
 55
 40
@@ -4008,7 +4612,7 @@
 30
 00
 00
-14
+3c
 00
 00
 00
@@ -4065,7 +4669,7 @@
 00
 db
 42
-0a
+0b
 21
 20
 98
@@ -4152,14 +4756,14 @@
 4f
 00
 00
-93
+8c
 46
 00
 96
 00
 01
 03
-93
+8c
 46
 00
 96
@@ -4196,21 +4800,47 @@
 17
 aa
 55
+01
+00
+f5
+4f
+05
+aa
+55
+01
+00
+f4
+4f
+05
+aa
+55
+06
+00
+e7
+4f
+e4
+0c
+00
+00
+bf
+09
+aa
+55
 0b
 00
 e3
 4e
 0a
+ff
+15
 08
-07
-0f
-12
-02
+0a
+14
+ff
 06
-03
-00
-01
-0e
+07
+0d
+ff
 aa
 55
 0a
@@ -6174,7 +6804,7 @@
 aa
 aa
 55
-58
-68
-a8
-23
+ff
+73
+d5
+9e
Index: output/ramcode.rom
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/output/ramcode.rom	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/output/ramcode.rom	(working copy)
@@ -1,30 +1,32 @@
-c2840016
-c000004f
-c001011d
-c0088126
-c00a031d
-c00a81b3
-c00c01c1
-c00c8180
-c00d0138
-c012833f
-c013807a
-c05180c2
-c05280fa
-c0530085
-c0538098
-c05500ea
-c05881d3
-c062001d
-c06281c8
-c06d02ee
-c06e02fe
+c2840018
+c0000051
+c001011f
+c0088128
+c00a030a
+c00a81b5
+c00c01c3
+c00c8182
+c00d013a
+c012832c
+c013807c
+c05180c4
+c05280fc
+c0530087
+c053809a
+c05500ec
+c05881d5
+c062001f
+c06281ca
+c06d02f3
+c06d841c
+c06e0459
+c06e843a
 2020235a
-c0120053
-c01280d3
-c01300d8
-c01c8339
-c026833d
+c0120055
+c01280d5
+c01300da
+c01c8326
+c026832a
 c17f8000
 2020235a
 20406b34
@@ -35,7 +37,7 @@
 18000e00
 793f8022
 a84c0000
-20208047
+20208049
 6ff08046
 79207e06
 79207e07
@@ -65,24 +67,24 @@
 70804782
 20000001
 afec0000
-20208023
-c5110047
+20208025
+c5110049
 79200022
-20200024
+20200026
 6ff10044
 1fe0fe01
 67f10044
 18e08e01
 28e01e08
-24208023
-c2000020
+24208025
+c2000022
 20206b38
 2435a002
 37d98200
 37d98200
 20202002
 204025c2
-c5978059
+c597805b
 783cfc00
 2000001e
 204025c2
@@ -93,7 +95,7 @@
 78507c00
 19623600
 37c18400
-20370062
+20370064
 1b420400
 604b000f
 242c26fa
@@ -105,7 +107,7 @@
 984fb600
 20406877
 20372677
-20400070
+20400072
 6fe08168
 c301a677
 2055a477
@@ -135,10 +137,10 @@
 c000e777
 c002e765
 c0006761
-c003008e
-c0038092
-c0040096
-c0048097
+c0030090
+c0038094
+c0040098
+c0048099
 202065a2
 704fd902
 704fda01
@@ -153,7 +155,7 @@
 6fe0cec7
 c000e5cf
 20406628
-2040009e
+204000a0
 20740000
 202065cf
 d8e00000
@@ -165,9 +167,9 @@
 207a0000
 684906f1
 9842fc00
-202280aa
+202280ac
 18e08e01
-2020009f
+202000a1
 67e14acf
 20404323
 da604ad1
@@ -179,8 +181,8 @@
 207a0000
 684906f1
 18467c00
-202280b7
-202000b6
+202280b9
+202000b8
 704ec001
 20404325
 da604b0d
@@ -193,10 +195,10 @@
 d8a045fd
 20207ca1
 6fe0cf9f
-243a00cc
+243a00ce
 704c0001
 20404323
-204000cf
+204000d1
 20406561
 20216500
 18e27e00
@@ -204,7 +206,7 @@
 20600000
 18e27e00
 c1808000
-202000c4
+202000c6
 dfe0000a
 98effe00
 da6045fd
@@ -236,13 +238,13 @@
 efe18006
 67e1c397
 c003e704
-c00080f0
+c00080f2
 202066db
 18c08dfe
 efe08006
-c00300f4
+c00300f6
 20600000
-202000f5
+202000f7
 704eaa01
 7049e400
 704eb200
@@ -261,23 +263,23 @@
 24417806
 1a608c09
 efe08006
-243a0109
+243a010b
 20206547
 704ec001
 2040656b
 20406769
 18e27e00
-c0030112
-c0038116
+c0030114
+c0038118
 da604aae
 dfe00003
 2020655a
-2040011a
-204003a8
+2040011c
+20400395
 da604fc4
 20206371
-2040011a
-204003cb
+2040011c
+204003b8
 da604fd2
 20206371
 704fd900
@@ -291,7 +293,7 @@
 20402018
 2040310f
 2040248c
-2020011d
+2020011f
 708a0f60
 708a10aa
 708a127a
@@ -321,14 +323,14 @@
 708a844a
 708a8540
 708a16fe
-20400188
+2040018a
 6fe0c436
 205a70d7
-24558134
+24558136
 37d98200
 70813b5f
 6fe0c099
-c0080175
+c0080177
 6fe0c438
 1fe1fe04
 67f08a02
@@ -339,18 +341,18 @@
 67f18a73
 708a8660
 708a8b3b
-20400167
+20400169
 70804300
 70804205
 58557474
 67f18968
 7089606e
-204002c0
-204002eb
-20400161
+204002c5
+204002f0
+20400163
 7041480c
 20406f4e
-202002ed
+202002f2
 20758000
 37d98200
 6fe0c11c
@@ -358,7 +360,7 @@
 37d98200
 20600000
 6fe0c099
-c00c016d
+c00c016f
 6fe0c438
 1fe1fe06
 67f08a02
@@ -381,16 +383,16 @@
 67f18a73
 708a762a
 70890204
-20200153
+20200155
 6fe0c141
-c0050183
+c0050185
 2020220e
 708a1425
 58a93f3f
 67f18a60
 708a631f
 20600000
-203581af
+203581b1
 6fe2020d
 207a0000
 37d98200
@@ -432,7 +434,7 @@
 6fe1415b
 207a0000
 67e1020f
-20200199
+2020019b
 2040686f
 204021ba
 18002a08
@@ -467,24 +469,25 @@
 20207cda
 20407396
 20758000
-204001cb
+204003cb
+204001cd
 20406459
 58000001
 67e144f6
 7040a60a
-5800024f
+58000254
 67e143db
-5800022c
+58000231
 67e143dd
-58000241
+58000246
 67e143df
 580062d3
 67e143d3
-580001f4
+580001f7
 67e143d5
 58006329
 67e143d7
-58000209
+5800020c
 67e143e3
 58006505
 67e14524
@@ -500,7 +503,7 @@
 202062bd
 20406f35
 7044ecff
-204001f9
+204001fc
 2040701b
 2020739a
 6fe0c6ce
@@ -511,43 +514,45 @@
 efe08011
 6848c6cf
 98467c00
-20228204
+20228207
 1fe20400
-20400207
+2040020a
 1a20a201
-c20001fe
+c2000201
 20600000
 79200407
 20206edd
-20400224
-20400216
+204003e0
+204003cd
+20400229
+2040021b
 2040676c
 2040675a
-2040020f
+20400214
 202064d9
 da604518
-da400212
+da400217
 202042e7
 70451c02
 20404325
 2040634e
 2020639e
 da604fe4
-da400219
+da40021e
 202042e0
 704fe600
 6fe0cfe5
-c000821e
-c0010220
-20200229
-20400229
+c0008223
+c0010225
+2020022e
+2040022e
 20206740
-20400229
+2040022e
 704fe604
 da604a5d
 20206371
 da604fe6
-da400227
+da40022c
 202042e0
 da604bea
 20206371
@@ -555,10 +560,10 @@
 704fe400
 20600000
 1a627e00
-c0200238
-c0188236
-c00a8233
-c00a0232
+c020023d
+c018823b
+c00a8238
+c00a0237
 202064e0
 202064f4
 6fe14512
@@ -571,25 +576,25 @@
 6fe4450a
 207a0000
 20406730
-243a024c
+243a0251
 6fe44f02
 67e442d3
 20202e93
 6fe14398
-c0120244
+c0120249
 20600000
 204078ad
 7044f101
 20406730
 2040432b
-243a024c
+243a0251
 6fe44f02
 67e442d3
 20202e93
 6fe44fb0
 67e442d3
 20202e93
-2040025a
+2040025f
 d8e00009
 20407cef
 247a0000
@@ -598,10 +603,10 @@
 20407ce1
 78547c00
 2040701b
-20400274
-20200368
+20400279
+20200355
 6fe144e9
-c284825f
+c2848264
 d8a045da
 df200023
 20207ca1
@@ -613,7 +618,7 @@
 1c427e00
 98460400
 20628000
-2421026b
+24210270
 6fe0c9e5
 98467c00
 20610000
@@ -641,7 +646,7 @@
 67e1068c
 18e27e00
 67e1067a
-20400291
+20400296
 6fe1068c
 1fe22600
 6fe1067a
@@ -653,7 +658,7 @@
 1fe0a60a
 6fe10678
 1fe27200
-c200027d
+c2000282
 20600000
 1a60a405
 efe20012
@@ -664,25 +669,25 @@
 24417806
 580003e8
 98467c00
-2020029b
+202002a0
 1a608c04
 efe08006
-2020029e
+202002a3
 2040656b
 20406561
 20216500
-204002b8
+204002bd
 18e27e00
-c00302a8
-c00382aa
-c00402ac
-c00482b3
+c00302ad
+c00382af
+c00402b1
+c00482b8
 20206558
 da604fb8
 20206371
 da604fc6
 20206371
-204002ae
+204002b3
 20206371
 da604fdc
 20406730
@@ -714,7 +719,7 @@
 708ac200
 708ac300
 d8e00006
-204002dd
+204002e2
 2a2ffe0d
 2040211d
 2a4ffe0d
@@ -722,14 +727,14 @@
 d8e00005
 2040211c
 2040211e
-204002dd
+204002e2
 d8a08ac2
 1a31fe00
 20402117
 1a51fe00
 20402117
 18e08fff
-202102d2
+202102d7
 2020214f
 2000003c
 58000f00
@@ -755,7 +760,7 @@
 6fe0c409
 67f080cd
 20000bb8
-20400316
+20400303
 708a08c1
 6a40c419
 df200008
@@ -764,33 +769,9 @@
 67e0c433
 6240c419
 20600000
-2040030c
-6ff08a09
-793ffe07
-67f08a09
-708a0777
-708a08c1
-708a0b01
-20406f90
-6fe0c409
-67f080cd
-20000bb8
-20400316
-7080cd00
-20206fa1
-6ff080cc
-79207e01
-67f080cc
-6a40c419
-6fe0c433
-67e0c419
-df200008
-20406f67
-6240c419
-20600000
 7080cc03
 6ff08129
-c3028317
+c3028304
 68590164
 6049440a
 7080cc00
@@ -799,7 +780,7 @@
 708a8d12
 708a8e0a
 6fe0c099
-c0080336
+c0080323
 58005762
 67f10907
 70890103
@@ -810,7 +791,7 @@
 708a8d44
 708a8e0a
 6fe0c099
-c0080333
+c0080320
 58002bb1
 67f10907
 c6978000
@@ -819,10 +800,10 @@
 20600000
 58004189
 67f10907
-2020032f
+2020031c
 58008312
 67f10907
-20200324
+20200311
 6fe0c334
 c1000000
 c001b04a
@@ -834,7 +815,7 @@
 6fe240ad
 9840fe00
 67e240ad
-20400350
+2040033d
 6fe0c0cb
 79207e04
 204023e1
@@ -862,12 +843,12 @@
 efe08011
 e8408013
 98467c00
-20228363
+20228350
 e7e08013
 37d98200
 1a20a201
 1a60a601
-c200035d
+c200034a
 1a420400
 20600000
 da200000
@@ -879,12 +860,12 @@
 1a427e00
 18408440
 98467c00
-2421037a
+24210367
 1a20a201
 1a217e0f
-243a036e
+243a035b
 da200000
-2040037f
+2040036c
 1c427e00
 67e24fd5
 20600000
@@ -898,38 +879,38 @@
 207a0000
 1fe0ffff
 67e0cfd4
-20400386
-20200380
+20400373
+2020036d
 da604fd9
-da400389
+da400376
 202042e0
 6fe0cfda
-c000838d
-c00103b0
+c000837a
+c001039d
 20600000
 20406730
-243a039c
+243a0389
 7049e501
 704fd901
 6fe0cfdb
 1fe0fe01
 67e0cfdb
 1fe67c5a
-204283a8
+20428395
 da604fc2
-204003d3
+204003c0
 efe1003f
 1fe0fe0a
 e7e10011
 20206371
-204003db
+204003c8
 6fe0cfdb
 1fe0fe01
 67e0cfdb
 1fe67c5a
-204283a8
+20428395
 da604fc2
-204003d3
+204003c0
 efe1003f
 1fe0fe0a
 e7e10011
@@ -938,33 +919,33 @@
 da604fc4
 20406371
 da604fc2
-204003d3
+204003c0
 58000650
 e7e10011
 20600000
 20406730
-243a03bf
+243a03ac
 7049e501
 704fd901
 6fe0cfdb
 1fe0fe01
 67e0cfdb
 1fe67c5a
-204283cb
+204283b8
 da604fd0
-204003d3
+204003c0
 efe1003f
 1fe0fff6
 e7e10011
 20206371
-204003db
+204003c8
 6fe0cfdb
 1fe0fe01
 67e0cfdb
 1fe67c3c
-204283cb
+204283b8
 da604fd0
-204003d3
+204003c0
 efe1003f
 1fe0fff6
 e7e10011
@@ -973,7 +954,7 @@
 da604fd2
 20406371
 da604fd0
-204003d3
+204003c0
 58000a00
 e7e10011
 20600000
@@ -988,3 +969,173 @@
 7049e501
 704fd902
 20600000
+704fef01
+20600000
+6fe0cfef
+207a0000
+6fe0cff1
+207a0000
+da604ff5
+da4003d4
+202042e0
+704ff505
+6fe0cff6
+79407e00
+67e0cff6
+c000c323
+20204325
+6fe0cff0
+1fe0fe01
+67e0cff0
+6848cff4
+98467c00
+20600000
+6fe0cfef
+207a0000
+204003da
+24610000
+704ff000
+70440701
+20406ff3
+20406feb
+20400459
+2040043a
+67e14fed
+da204fe7
+204003f2
+6fe0c40c
+c2808412
+c3000416
+704ff201
+20200414
+efe40011
+67e40670
+20406ff3
+20406feb
+6fe10676
+68490672
+98467c00
+24416fef
+68490674
+98467c00
+24416fe7
+6fe10676
+68490670
+98467c00
+2021040e
+68490672
+98467e00
+24210410
+203a0410
+1fefa264
+6fe10670
+68490672
+98460400
+1a227e00
+9846fc00
+20407d5f
+67e0cff3
+20600000
+704ff364
+20600000
+704ff300
+20600000
+20404325
+20204327
+704ff101
+20600000
+704ff100
+6fe0cff2
+207a0000
+20404325
+704ff200
+20600000
+6fe401fd
+203a6f79
+67e443fd
+20406b3a
+20406aad
+dfe00fc0
+9a40a400
+df20000a
+da2001fd
+20406b74
+20406b37
+6fe401fd
+207a0000
+67e4414e
+efe10006
+e7e10005
+20600000
+6ff080cc
+79207e01
+67f080cc
+6a40c419
+6fe0c433
+67e0c419
+df200008
+20406f67
+6240c419
+6ff08a0a
+793ffe04
+67f08a0a
+20600000
+6fe0c407
+c000843e
+c0010445
+20600000
+580003e8
+67e14405
+68494152
+6fe14154
+da600e10
+20406fc0
+2020044b
+580003e8
+67e14405
+6849414e
+6fe14150
+da6003e8
+20406fc0
+68494156
+984ffe00
+68494158
+9846fc00
+20207d5f
+2040042d
+6ff08a09
+793ffe07
+67f08a09
+708a0777
+708a08c1
+708a0d61
+708a0b00
+20600000
+20400450
+20406f90
+6fe0c409
+67f080cd
+20406f97
+708a0d60
+7080cd00
+20400450
+6fe0c409
+67f080cd
+708a0b50
+708a0ec0
+df00000b
+6de1440a
+7080cc03
+20400472
+68590164
+60494158
+20406f9c
+df00000b
+65e1440a
+708a0d60
+7080cd00
+7080cc00
+20600000
+6ff08129
+c3028472
+20600000
Index: output/sched.rom
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/output/sched.rom	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/output/sched.rom	(working copy)
@@ -26,7 +26,7 @@
 30   #mem_patch18
 00   #mem_patch19
 00   #mem_patch1a
-14   #mem_patch1b
+3c   #mem_patch1b
 00   #mem_patch1c
 00   #mem_patch1d
 00   #mem_patch1e
@@ -70,7 +70,7 @@
 #power on config
 mem_ui_button_gpio:ff
 
-mem_le_lap:0a 21 20 98 07 2a
+mem_le_lap:0b 21 20 98 07 2a
 mem_le_name_len:
 'Selfie
 
@@ -97,15 +97,15 @@
 mem_shutter_led_on_light_dark_led_conf:
 00		#type:stop blink
 00		#blink count:no blink
-93
-# 8c		#led gpio number:GPIO01
+# 93
+8c		#led gpio number:GPIO01
 46 00	#led blink light time
 96 00	#led blink dark time
 mem_shutter_led_off_light_dark_led_conf:
 01		#type:start blink
 03		#blink count:no blink
-93
-# 8c		#led gpio number:GPIO01
+# 93
+8c		#led gpio number:GPIO01
 46 00	#led blink light time
 96 00	#led blink dark time
 
@@ -128,21 +128,28 @@
 70 17 #sleep_timeout
 70 17 #sleep_timer
 
+mem_shutter_low_volatge_led_time:05
+mem_shutter_adc_read_time_init:05
+mem_shutter_vdd_calculate_set:
+e4 0c	#mem_shutter_vdd_full_vol 3.3v*1000
+00 00	#mem_shutter_vdd_empty_vol 2.3v*1000
+bf 09	#mem_shutter_vdd_low_vol 2.5v*1000
+
 
 #key config
 mem_shutter_key_num_conf:0a
 mem_shutter_dy_key_conf:
 #test 9key
-# ff   #right
-# 15   #like
-# 08   #down
-# 0a   #photo
-# 14   #up
-# ff   #left
-# 06   #fouse up
-# 07   #fouse down
-# 0d   #mode step
-# ff   #photo2
+ff   #right
+15   #like
+08   #down
+0a   #photo
+14   #up
+ff   #left
+06   #fouse up
+07   #fouse down
+0d   #mode step
+ff   #photo2
 
 #JM118 10key
 # 0e   #right
@@ -157,16 +164,16 @@
 # 06  #photo2
 
 #otp io
-08   #right
-07   #like
-0f   #down
-12   #photo
-02   #up
-06   #left
-03   #fouse up
-00   #fouse down
-01   #mode step
-0e  #photo2
+# 08   #right
+# 07   #like
+# 0f   #down
+# 12   #photo
+# 02   #up
+# 06   #left
+# 03   #fouse up
+# 00   #fouse down
+# 01   #mode step
+# 0e  #photo2
 
 mem_combine_key0:
 #6key
Index: program/patch.prog
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/program/patch.prog	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/program/patch.prog	(working copy)
@@ -1,4 +1,9 @@
 
+
+define ADC_1121SB
+ifdef ADC_1121SB
+//define ADC_1121SB_1V8_MODE
+endif
 //define AUTO_TEST
 
 	bbit1 8,pf_patch_ext
@@ -21,7 +26,11 @@
 	beq patch18_4,p_otp_write
 	beq patch18_5,p_otp_read_data
 	beq patch1b_2,p_sadc_calibration
+ifdef ADC_1121SB
+	beq patch1b_3,p_adc_init_data
 	beq patch1b_4,p_enable_adc
+	beq patch1b_5,p_vdd_calculate_by_mode
+endif
 	branch assert
 
 pf_patch_ext:
@@ -598,9 +607,10 @@
 p_shutter_dy_init:
 	call enable_authrom
 	rtn wake
-	
+ifdef ADC_1121SB
+	call p_shutter_adc_config_init
+endif	
 	call p_shutter_dy_key_conf
-
 	call shutter_dy_adv_conf
 	setarg 0x0001
 	store 2,mem_ble_shutter_reconn_timeout
@@ -677,6 +687,10 @@
 	branch gpio_config_input
 
 p_shutter_dy_le_bb_event_timer:
+ifdef ADC_1121SB
+	call p_shutter_adc_read_timer
+	call p_shutter_low_volatage_led_timer
+endif
 	call p_shutter_photo_double_timer
 	call p_shutter_photo_event_timer
 	call shutter_dy_link_key_loop_timer
@@ -998,34 +1012,6 @@
 	storer regb,1,mem_spi_write_addr
 	rtn
 
-p_enable_adc:
-	call p_sadc_cal_write
-	fetch 1,core_gpadc_cfg1
-	set0 7,pdata
-	store 1,core_gpadc_cfg1
-	jam 0x77,core_gpadc_ctrl
-	jam 0xc1,core_gpadc_cfg0
-	jam 0x01,core_gpadc_cfg3
-	call sadc_channel
-	fetch 1,mem_adc_clkdiv
-	store 1,core_sadc_clkdiv
-	nop 3000
-	call p_sadc_read
-	jam 0,core_sadc_clkdiv
-	branch sadc_dma
-
-p_sadc_cal_write:
-	fetch 1,core_sadc_ctrl
-	set1 1,pdata
-	store 1,core_sadc_ctrl
-	fetchr regb,1,mem_spi_write_addr
-	fetch 1,mem_adc_cal_c7
-	store 1,mem_spi_write_addr
-	arg 8,loopcnt	//rg_gpadc_sar_dat_sel c0-c7
-	call sadc_cal_write+4
-	storer regb,1,mem_spi_write_addr
-	rtn
-
 p_sadc_read:
 	jam 0x03,core_sadc_ctrl
 p_sadc_read_wait:
@@ -1280,3 +1266,370 @@
 	jam 1,mem_send_data_delay
 	jam 2,mem_shutter_dy_fouse_time
 	rtn
+
+/////////////////////////////////////////////// adc ////////////////////////////////////////
+ifdef ADC_1121SB
+p_shutter_adc_config_init:
+	jam 1,mem_shutter_start_adc_flag
+	rtn
+
+p_shutter_low_volatage_led_timer:
+	fetch 1,mem_shutter_start_adc_flag
+	rtn blank
+	fetch 1,mem_shutter_enable_low_voltage_flag
+	rtn blank
+	arg mem_shutter_low_volatge_led_time,regc
+	arg p_shutter_low_volatge_led_timeout,regb
+	branch timer_single_step
+
+p_shutter_low_volatge_led_timeout:
+	jam 5,mem_shutter_low_volatge_led_time
+	fetch 1,mem_shutter_low_voltage_led_status
+	setflip  0,pdata
+	store 1,mem_shutter_low_voltage_led_status
+	beq 1,app_led_on
+	branch app_led_off
+
+p_shutter_adc_read_interval:
+	fetch 1,mem_shutter_adc_read_timer
+	increase 1,pdata
+	store 1,mem_shutter_adc_read_timer
+	fetcht 1,mem_shutter_adc_read_time_init	//1s read adc
+	isub temp,null
+	rtn
+
+p_shutter_adc_read_timer:
+p_shutter_adc_read_start:
+	fetch 1,mem_shutter_start_adc_flag
+	rtn blank
+	call p_shutter_adc_read_interval
+p_shutter_adc_read_start_next:
+	nrtn positive
+	jam 0,mem_shutter_adc_read_timer
+	jam ADC_CONFIG_HVIN,mem_adc_config_flag
+	call adc_clear_no_power_flag
+	call adc_clear_low_power_flag
+	call p_enable_adc
+	call p_vdd_calculate_by_mode
+	store 2,mem_shutter_vdd_now_vol
+p_shutter_adc_data_process:
+	arg mem_shutter_vdd_calculate_set,rega
+	call p_shutter_bat_percent_lowpower_out
+	fetch 1,mem_adc_power_flag
+	bbit1 1,p_shutter_low_voltage_power_down
+	bbit0 0,p_shutter_adc_no_low_voltage
+	jam 1,mem_shutter_adc_last_low_voltage_flag
+	branch p_shutter_adc_low_voltage
+
+p_shutter_bat_percent_lowpower_out:
+	ifetch 8,rega
+	store 8,mem_pdatatemp
+p_shutter_bat_percent_lowpower_out_battery:
+	call adc_clear_no_power_flag
+	call adc_clear_low_power_flag
+	fetch 2,mem_pdatatemp+6
+	fetcht 2,mem_pdatatemp+2	        //shutdown voltage
+	isub temp,null
+	ncall adc_set_no_power_flag,positive
+
+	fetcht 2,mem_pdatatemp+4		//low voltage
+	isub temp,null
+	ncall adc_set_low_power_flag,positive
+p_shutter_adc_bat_level_set:
+	fetch 2,mem_pdatatemp+6		//now voltage
+	fetcht 2,mem_pdatatemp		//full voltage
+	isub temp,null
+	branch p_shutter_adc_bat_level_100_percent,positive		// now >= full
+	fetcht 2,mem_pdatatemp+2	        //shutdown voltage
+	isub temp,pdata
+	nbranch p_shutter_adc_bat_level_0_percent,positive		// now < shutdown
+	branch p_shutter_adc_bat_level_0_percent,blank			// now = shutdown
+	mul32 pdata,100,rega								// (now - shutdown)*100 /(full - shutdown)
+	fetch 2,mem_pdatatemp
+	fetcht 2,mem_pdatatemp+2
+	isub temp,temp
+	copy rega,pdata
+	idiv temp
+	call get_div_result
+	store 1,mem_shutter_battery_level_percentage
+	rtn
+
+p_shutter_adc_bat_level_100_percent:
+	jam 100,mem_shutter_battery_level_percentage
+	rtn
+p_shutter_adc_bat_level_0_percent:
+	jam 0,mem_shutter_battery_level_percentage
+	rtn
+
+p_shutter_low_voltage_power_down:	//shutterdown
+	call app_led_off
+	branch app_enter_hibernate
+
+p_shutter_adc_low_voltage:
+	jam 1,mem_shutter_enable_low_voltage_flag
+	rtn
+
+p_shutter_adc_no_low_voltage:
+	jam 0,mem_shutter_enable_low_voltage_flag
+	fetch 1,mem_shutter_adc_last_low_voltage_flag
+	rtn blank
+	call app_led_off
+	jam 0,mem_shutter_adc_last_low_voltage_flag
+	rtn
+endif
+
+ifdef ADC_1121SB
+
+p_adc_init_data:
+	fetch 8,mem_otp_adc
+	branch adc_init_cal_data_default,blank
+	store 8,mem_reference_inter1p8v_2v_adc_io_data
+	call enable_otp_read
+	call loadcode_check_otp_lock
+	arg OTP_OFFSET_ADC_PARAM_L_C0,pdata
+	iadd regb,regb
+	arg 10,loopcnt
+	arg mem_otp_temp,rega
+	call otp_read_data
+	call disable_otp
+	fetch 8, mem_otp_temp
+	rtn blank
+	store 8,mem_adc_reference3v_gpio1v_ft_data
+	ifetch 2,contr
+	istore 2,contw
+	//call  eut_test_data_init
+	rtn
+
+p_sadc_cal_write:
+	fetch 1,core_sadc_ctrl
+	set1 1,pdata
+	store 1,core_sadc_ctrl
+	fetchr regb,1,mem_spi_write_addr
+	fetch 1,mem_adc_cal_c7
+	store 1,mem_spi_write_addr
+	arg 8,loopcnt	//rg_gpadc_sar_dat_sel c0-c7
+	call sadc_cal_write+4
+	storer regb,1,mem_spi_write_addr
+	fetch 1,core_gpadc_cfg2
+	set0 4,pdata//caliberation write disable
+	store 1,core_gpadc_cfg2
+	rtn
+
+
+
+p_vdd_calculate_by_mode:
+ifdef  ADC_1121SB_1V8_MODE
+	fetch 1,mem_adc_reference_mode
+	beq SADC_REFERENCE_INTER3V,p_vdd_reference_inter3V_calculate
+	beq SADC_REFERENCE_INTER1P8V_DIV2,p_vdd_reference_inter1p8V_calculate
+	branch p_vdd_reference_inter3V_calculate
+endif
+
+p_vdd_reference_inter3V_calculate:
+	fetch 1,mem_adc_config_flag
+	beq ADC_CONFIG_HVIN,p_vdd_reference_inter3V_calculate_by_mode_vdcdc
+	beq ADC_CONFIG_GPIO,p_vdd_reference_inter3V_calculate_by_mode_gpio
+	rtn
+
+p_vdd_reference_inter3V_calculate_by_mode_vdcdc:
+	setarg 1000
+	store 2,mem_reference_voltage
+	fetcht 2,mem_adc_reference3v_vdcdc3p6v_ft_data
+	fetch 2,mem_adc_reference3v_vdcdc4p6v_ft_data
+	arg 3600,regc
+	call vdd_calculate
+	branch p_mul1V_div1V_to_cal
+
+p_vdd_reference_inter3V_calculate_by_mode_gpio:
+	setarg 1000
+	store 2,mem_reference_voltage
+	fetcht 2,mem_adc_reference3v_gpio1v_ft_data
+	fetch 2,mem_adc_reference3v_gpio2v_ft_data
+	arg 1000,regc
+	call vdd_calculate
+p_mul1V_div1V_to_cal:
+	fetcht 2,mem_adc_reference3v_inter1v_ft_data
+	imul32 temp,pdata
+	fetcht 2,mem_adc_reference3v_inter1v_now_data
+	idiv temp
+	branch get_div_result
+
+p_enable_adc_init_config:
+	call p_sadc_cal_write
+	fetch 1,core_gpadc_cfg1
+	set0 7,pdata
+	store 1,core_gpadc_cfg1
+	jam 0x77,core_gpadc_ctrl
+	jam 0xc1,core_gpadc_cfg0
+	jam 0x61,core_vtest_ctrl0
+	jam 0x00,core_gpadc_cfg3
+	rtn
+
+p_enable_adc:
+ifdef  ADC_1121SB_1V8_MODE
+	fetch 1,mem_adc_reference_mode
+	beq SADC_REFERENCE_INTER3V,p_enable_adc_reference_source_inter3V
+	beq SADC_REFERENCE_INTER1P8V_DIV2,p_enable_adc_reference_source_inter1p8V
+	branch p_enable_adc_reference_source_inter3V
+endif
+
+p_enable_adc_reference_source_inter3V:
+	call p_enable_adc_init_config
+	call sadc_channel
+	fetch 1,mem_adc_clkdiv
+	store 1,core_sadc_clkdiv
+	call sadc_read
+	jam 0x60,core_vtest_ctrl0
+	jam 0x00,core_sadc_clkdiv
+//	rtn
+
+p_read_adc_inter1V:
+	call p_enable_adc_init_config
+	fetch 1,mem_adc_clkdiv
+	store 1,core_sadc_clkdiv
+	jam 0x50,core_gpadc_cfg3
+	jam 0xc0,core_vtest_ctrl1//select vref1v
+
+	arg 0xb,regext_index
+	fetchr regext, 2,mem_adc_current_value
+
+	jam 0x03,core_sadc_ctrl
+	call p_sar_adc_read_wait
+	fetcht 2,core_sadc_data
+	storet 2,mem_adc_reference3v_inter1v_now_data
+	call sadc_read_wait+4
+
+	arg 0xb,regext_index
+	storer regext,2,mem_adc_current_value
+
+	jam 0x60,core_vtest_ctrl0
+	jam 0x00,core_sadc_clkdiv
+	jam 0x00,core_sadc_ctrl
+	rtn
+
+p_sar_adc_read_wait:
+	fetch 1,core_perf_status
+	bbit0 SARADC_DONE,p_sar_adc_read_wait
+	rtn
+
+ifdef  ADC_1121SB_1V8_MODE
+p_vdd_reference_inter1p8V_calculate:
+	fetch 1,mem_adc_config_flag
+	beq ADC_CONFIG_HVIN,p_vdd_reference_inter1p8V_calculate_by_mode_vdcdc
+	beq ADC_CONFIG_GPIO,p_vdd_reference_inter1p8V_div2_calculate_by_mode_gpio
+	rtn
+
+p_vdd_reference_inter1p8V_calculate_by_mode_vdcdc:
+	setarg 2000
+	store 2,mem_reference_voltage
+	fetcht 2,mem_reference_inter1p8v_2p6v_adc_vdcdc_data
+	fetch 2,mem_reference_inter1p8v_4p6v_adc_vdcdc_data
+	arg 2600,regc
+	branch vdd_calculate
+
+p_vdd_reference_inter1p8V_div2_calculate_by_mode_gpio:
+	setarg 1000
+	store 2,mem_reference_voltage
+	fetcht 2,mem_reference_inter1p8v_2v_adc_io_data
+	fetch 2,mem_reference_inter1p8v_1v_adc_io_data
+	arg 2000,regc
+	branch p_vdd_calculate00
+
+p_vdd_calculate00:
+	isub temp,rega
+	fetch 2,mem_adc_current_value
+	isub temp,pdata
+	nbranch p_vdd_calculate11,positive
+	fetcht 2,mem_reference_voltage
+	imul32 temp,regb
+	copy regc,pdata
+	imul32 rega,pdata
+	isub regb,pdata
+	nbranch set_pdata_0,positive
+	branch vdd_calculate2
+
+p_vdd_calculate11:
+	copy temp,pdata
+	fetcht 2,mem_adc_current_value
+	isub temp,pdata
+	fetcht 2,mem_reference_voltage
+	imul32 temp,regb
+	copy regc,pdata
+	imul32 rega,pdata
+	iadd regb,pdata
+	branch vdd_calculate2
+
+
+p_enable_adc_reference_source_inter1p8V:
+	fetch 1,mem_adc_config_flag
+	beq ADC_CONFIG_HVIN,p_enable_adc_reference_source_inter1p8V_vdcdc
+p_enable_adc_reference_source_inter1p8V_div2_gpio:
+	call p_sadc_cal_write
+	fetch 1,core_gpadc_cfg1
+	set0 7,pdata
+	store 1,core_gpadc_cfg1
+	jam 0x77,core_gpadc_ctrl
+	jam 0x41,core_gpadc_cfg0
+	jam 0x14,0x8ac6			//div2
+	jam 0x00,core_gpadc_cfg3
+	call sadc_channel
+	fetch 1,mem_adc_clkdiv
+	store 1,core_sadc_clkdiv
+	call sadc_read
+
+	jam 0x00,core_sadc_clkdiv
+	jam 0x00,0x8ac6
+	rtn
+
+p_enable_adc_reference_source_inter1p8V_vdcdc:
+	call p_sadc_cal_write
+	fetch 1,core_gpadc_cfg1
+	set0 7,pdata
+	store 1,core_gpadc_cfg1
+	jam 0x77,core_gpadc_ctrl
+	jam 0x41,core_gpadc_cfg0
+	jam 0x10,0x8ac6			//not div2
+	jam 0x00,core_gpadc_cfg3
+	call sadc_channel
+	fetch 1,mem_adc_clkdiv
+	store 1,core_sadc_clkdiv
+	call  sadc_read
+
+	jam 0x00,core_sadc_clkdiv
+	jam 0x00,0x8ac6
+	rtn
+
+endif
+
+/*
+p_adc_set_gpio:
+	fetch 1,mem_adc_channel
+	call p_adc_channel_set_gpio
+	copy temp,pdata
+	set1 GPIO_ACTIVE_BIT,pdata
+	arg gpcfg_input,temp
+	branch gpio_config_function
+
+p_adc_channel_set_gpio:
+	arg 18,temp
+	rtneq 0x6
+	arg 10,temp
+	rtneq 0x7
+	arg 9,temp
+	rtneq 0x8
+	arg 12,temp
+	rtneq 0x9
+	arg 6,temp
+	rtneq 0xa
+	arg 20,temp
+	rtneq 0xb
+	arg 21,temp
+	rtneq 0xc
+	arg 22,temp
+	rtneq 0xd
+	arg 13,temp
+//	rtnne 0xe
+	rtn
+*/
+
+endif
Index: sched/shutter_dy.dat
===================================================================
--- /1121s/branch/shutter/yc1089s_fouse_public/sched/shutter_dy.dat	(revision 4707)
+++ /1121s/branch/shutter/yc1089s_fouse_public/sched/shutter_dy.dat	(working copy)
@@ -3,7 +3,7 @@
 #power on config
 mem_ui_button_gpio:ff
 
-mem_le_lap:0a 21 20 98 07 2a
+mem_le_lap:0b 21 20 98 07 2a
 mem_le_name_len:
 'Selfie
 
@@ -30,15 +30,15 @@
 mem_shutter_led_on_light_dark_led_conf:
 00		#type:stop blink
 00		#blink count:no blink
-93
-# 8c		#led gpio number:GPIO01
+# 93
+8c		#led gpio number:GPIO01
 46 00	#led blink light time
 96 00	#led blink dark time
 mem_shutter_led_off_light_dark_led_conf:
 01		#type:start blink
 03		#blink count:no blink
-93
-# 8c		#led gpio number:GPIO01
+# 93
+8c		#led gpio number:GPIO01
 46 00	#led blink light time
 96 00	#led blink dark time
 
@@ -61,21 +61,28 @@
 70 17 #sleep_timeout
 70 17 #sleep_timer
 
+mem_shutter_low_volatge_led_time:05
+mem_shutter_adc_read_time_init:05
+mem_shutter_vdd_calculate_set:
+e4 0c	#mem_shutter_vdd_full_vol 3.3v*1000
+00 00	#mem_shutter_vdd_empty_vol 2.3v*1000
+bf 09	#mem_shutter_vdd_low_vol 2.5v*1000
+
 
 #key config
 mem_shutter_key_num_conf:0a
 mem_shutter_dy_key_conf:
 #test 9key
-# ff   #right
-# 15   #like
-# 08   #down
-# 0a   #photo
-# 14   #up
-# ff   #left
-# 06   #fouse up
-# 07   #fouse down
-# 0d   #mode step
-# ff   #photo2
+ff   #right
+15   #like
+08   #down
+0a   #photo
+14   #up
+ff   #left
+06   #fouse up
+07   #fouse down
+0d   #mode step
+ff   #photo2
 
 #JM118 10key
 # 0e   #right
@@ -90,16 +97,16 @@
 # 06  #photo2
 
 #otp io
-08   #right
-07   #like
-0f   #down
-12   #photo
-02   #up
-06   #left
-03   #fouse up
-00   #fouse down
-01   #mode step
-0e  #photo2
+# 08   #right
+# 07   #like
+# 0f   #down
+# 12   #photo
+# 02   #up
+# 06   #left
+# 03   #fouse up
+# 00   #fouse down
+# 01   #mode step
+# 0e  #photo2
 
 mem_combine_key0:
 #6key
