From 02950b03663cc25e5ba9159a8cbedc7dbae6efb0 Mon Sep 17 00:00:00 2001 From: n2232 Date: Thu, 20 Jan 2011 01:28:40 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B3=A3=E3=81=8F=E6=B3=A3=E3=81=8F=E6=89=8B?= =?UTF-8?q?=E5=8B=95=E3=81=A7=E3=80=81SDK0.14=E7=B3=BB=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=83=9E=E3=83=BC=E3=82=B8=20=E3=83=BB=E9=9B=BB=E6=BA=90LED?= =?UTF-8?q?=E3=81=8C=E9=9D=92=E3=81=A7=E3=81=AA=E3=81=84=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AB=E9=9B=BB=E6=BA=90=E6=96=AD=E3=82=92=E8=A1=8C=E3=81=86?= =?UTF-8?q?=E3=81=A8=E3=80=81=E6=AC=A1=E5=9B=9E=E3=81=AE=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E6=99=82=E3=81=AB=E5=95=8F=E7=AD=94=E7=84=A1=E7=94=A8=E3=81=A7?= =?UTF-8?q?=E5=BC=B7=E5=88=B6=E9=9B=BB=E6=BA=90=E6=96=AD=E3=81=8C=E7=99=BA?= =?UTF-8?q?=E7=94=9F=E3=81=99=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20=E3=83=BB=E3=83=A2=E3=83=BC=E3=83=89=E9=81=B7=E7=A7=BB?= =?UTF-8?q?=E4=B8=AD=E3=81=AB=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88=E3=81=AA?= =?UTF-8?q?=E3=81=A9=E3=81=A7TWL=E5=81=B4=E3=81=AEMCU=E3=83=AC=E3=82=B8?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=81=8C=E4=B8=8D=E6=95=B4=E5=90=88=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=AE=E3=82=92=E5=BC=B7=E5=88=B6=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=82=A2=20=E3=83=BB=E3=82=A2=E3=83=89=E3=83=AC?= =?UTF-8?q?=E3=82=B9=200x7F=20=E3=81=AE=E6=9C=AC=E4=BD=93=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=AE=E8=AA=AD=E3=81=BF=E5=87=BA=E3=81=97=E3=82=92?= =?UTF-8?q?=E3=80=818=E6=96=87=E5=AD=97=E4=BB=A5=E4=B8=8B=E3=81=A7?= =?UTF-8?q?=E6=89=93=E3=81=A1=E5=88=87=E3=82=8B=E3=81=A8I2C=E3=82=92?= =?UTF-8?q?=E3=81=8C=E3=82=81=E3=81=A6=E3=81=97=E3=81=BE=E3=81=84=E3=80=81?= =?UTF-8?q?=E7=B6=9A=E3=81=8F=E6=95=B0=E6=96=87=E5=AD=97=E5=88=86=E3=81=AE?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E3=81=AB=E5=AF=BE=E3=81=97=E3=81=A6=E6=9C=9F?= =?UTF-8?q?=E5=BE=85=E3=81=97=E3=81=AA=E3=81=84=E5=80=A4=E3=82=92=E8=BF=94?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3(task=5Fmisc)=20?= =?UTF-8?q?=E3=83=BB=E8=A9=A6=E9=81=8A=E5=8F=B0=E5=AF=BE=E5=BF=9C=20?= =?UTF-8?q?=E3=83=BBLED=5FNOTIF=5FDATA=E3=82=92=E6=9B=B8=E3=81=8F=E3=81=A8?= =?UTF-8?q?=E6=99=82=E8=A8=88=E3=81=8C=E7=8B=82=E3=81=86=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@303 013db118-44a6-b54f-8bf7-843cb86687b1 --- trunk/config.h | 2 +- trunk/i2c_twl.c | 2 +- trunk/led.c | 4 ---- trunk/pm.c | 11 ++++++----- trunk/sw.c | 17 +++++++---------- trunk/sw.h | 6 +++++- trunk/task_misc.c | 28 +++++++++++++++++----------- trunk/task_sys.c | 15 ++++++++++++++- trunk/user_define.h | 1 + trunk/vreg_ctr.c | 1 + trunk/vreg_twl.c | 5 ++++- 11 files changed, 57 insertions(+), 35 deletions(-) diff --git a/trunk/config.h b/trunk/config.h index 3e7afab..a150b01 100644 --- a/trunk/config.h +++ b/trunk/config.h @@ -15,7 +15,7 @@ #define MCU_VER_MAJOR 0x01 -#define MCU_VER_MINOR 13 +#define MCU_VER_MINOR 0x15 #define _firm_format_v3_ diff --git a/trunk/i2c_twl.c b/trunk/i2c_twl.c index 468299d..1a2fa17 100644 --- a/trunk/i2c_twl.c +++ b/trunk/i2c_twl.c @@ -150,7 +150,7 @@ __interrupt void int_iic_twl( ) { // BW // データ書き込まれ - SVA = 0x5A; + SVA = 0x5A; // ダミー LREL = 1; // スタートコンディション待ちへ(連続書き込み未対応のため) vreg_twl_write( vreg_adrs, rcvd ); SVA = IIC_T_SLAVEADDRESS; diff --git a/trunk/led.c b/trunk/led.c index e7bdcc2..7672ec7 100644 --- a/trunk/led.c +++ b/trunk/led.c @@ -558,12 +558,10 @@ void tsk_led_notify( ) // 次のフレームに進める? if( time_to_next_frame == 0 ) { - DBG_LED_on; time_to_next_frame = info_LED.info_LED.term; if( frame >= NOTIFY_LED_TERM -1 ) { - DBG_LED2_on; vreg_ctr[ VREG_C_LED_NOTIFY_FLAG ] |= REG_BIT_IN_LOOP; if( info_LED.info_LED.last_loop != 255 ) // 255:無限ループ { @@ -591,8 +589,6 @@ void tsk_led_notify( ) LED_dim_status_info_B.delta = (( LED_dim_status_info_B.to - LED_dim_status_info_B.now ) ) / info_LED.info_LED.fade_time; } - DBG_LED_off; - DBG_LED2_off; time_to_next_frame -= 1; } } diff --git a/trunk/pm.c b/trunk/pm.c index 2002ae8..3211b9d 100644 --- a/trunk/pm.c +++ b/trunk/pm.c @@ -66,7 +66,8 @@ const u8 BT_MANUF_BORDER[] = { PM_EXTDCは割り込みメインにするかも ======================================================== */ -#define INTERVAL_TSK_BATT 100 +#define INTERVAL_TSK_BATT 60 +// ↑100だと充電エラー時にうまく点滅しないので bit temp_zone_charge_disable; // 温度で充電停止する時にヒステリシスを付けるため void tsk_batt( ) @@ -578,13 +579,13 @@ void BT_get_left(){ vreg_ctr[ VREG_C_BT_REMAIN_FINE ] = temp_fuel[1]; } // 電池電圧 -/* - if( iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL, 2, temp_v ) == ERR_SUCCESS ) +//* + if( iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL, 2, temp_fuel ) == ERR_SUCCESS ) { - vreg_ctr[ VREG_C_BT_VOLTAGE ] = temp_v[0]; + vreg_ctr[ VREG_C_BT_VOLTAGE ] = temp_fuel[0]; } else -*/ +//*/ { vreg_ctr[ VREG_C_BT_VOLTAGE ] = 200; } diff --git a/trunk/sw.c b/trunk/sw.c index 066cc03..1edc228 100644 --- a/trunk/sw.c +++ b/trunk/sw.c @@ -82,7 +82,6 @@ void tsk_sw( ) if( system_status.pwr_state == ON_TRIG ) { SW_pow_count = 0; // カウントクリア - off_timeout_timer = 0; } if( --task_interval != 0 ) @@ -109,15 +108,13 @@ void tsk_sw( ) else if( SW_pow_count == ( HOLD_THREASHOLD ) ) { set_irq( VREG_C_IRQ0, REG_BIT_SW_POW_HOLD ); - off_timeout_timer = vreg_ctr[ VREG_C_OFF_DELAY ] * 16; + if( off_timeout_timer == 0 ) + { + off_timeout_timer = vreg_ctr[ VREG_C_OFF_DELAY ] * 16; + } } -/* - else if( SW_pow_count > ( HOLD_THREASHOLD + vreg_ctr[ VREG_C_OFF_DELAY ] )) // およそ 100/SYSTEM_TICK - { - system_status.force_off = 1; - } -*/ - if( off_timeout_timer != 0 ) + + if( off_timeout_timer != 0 ) // 長押し割り込み後、タイムアウトで強制オフ。 { off_timeout_timer -= 1; if( off_timeout_timer == 1 ) @@ -141,7 +138,7 @@ void tsk_sw( ) default: SW_HOME_n = 1; // 放されてる状態 } - if( !( system_status.taikendai || system_status.taikendai_nbd )) +// if( !( system_status.taikendai || system_status.taikendai_nbd )) { chk_clicked( SW_HOME_n, SW_home_count, REG_BIT_SW_HOME_CLICK ); chk_clicked( !SW_HOME_n, SW_home_count_rel, REG_BIT_SW_HOME_RELEASE ); diff --git a/trunk/sw.h b/trunk/sw.h index 01f47bf..88aaea1 100644 --- a/trunk/sw.h +++ b/trunk/sw.h @@ -10,7 +10,11 @@ extern bit SW_pow_mask; #define CLICK_THRESHOLD 2 #define HOLD_THREASHOLD (u16)( 3000 /INTERVAL_TSK_SW ) -#define TIME_PWSW_CLICK (u8)( 160 /INTERVAL_TSK_SW ) +#define TIME_PWSW_CLICK (u8)( 220 /INTERVAL_TSK_SW ) #define FORCEOFF_THREASHOLD (u8)( 12000 /INTERVAL_TSK_SW /16 ) + +extern u16 off_timeout_timer; +#define clear_pow_off_countdown(){ off_timeout_timer = 0; system_status.force_off = false; } + #endif diff --git a/trunk/task_misc.c b/trunk/task_misc.c index 98cf4e3..21d3d92 100644 --- a/trunk/task_misc.c +++ b/trunk/task_misc.c @@ -207,7 +207,9 @@ task_status_immed tski_do_command0( ) { FCRAM_RST_ast; // twlはntrモードで動作してる } - vreg_twl[ REG_TWL_INT_ADRS_MODE ] = 0x03; + // TWLモードからDSモードへの切り替え中にリセットすると + // IRQが読まれない場合があるのでTWLレジスタを初期化する + vreg_twl_init(); } if( temp_command & REG_BIT_FCRAM_RESET_REQ ) { @@ -264,16 +266,15 @@ extern bit bt_chg_ready; ======================================================== */ task_status_immed tski_mcu_info_read() { - static u8 infos[10]; + static u8 infos[10]; // staticにしたんだし、電源投入時にでもキャッシュしとけばいいのに - if( SPD ) // stop + if( SPD ) // stop { goto end; } if( STD ) // restart { - SPIE = 1; WDT_Restart( ); } @@ -281,10 +282,8 @@ task_status_immed tski_mcu_info_read() { return( ERR_CONTINUE ); } - else - { - IICAIF = 0; - } + + IICAIF = 0; WDT_Restart( ); if( iic_burst_state > 8 ) @@ -293,7 +292,7 @@ task_status_immed tski_mcu_info_read() } else if( iic_burst_state == 0 ) { - if( !system_status.captureBox ) + if( !system_status.captureBox ) { IICA = (u8)system_status.model; } @@ -314,13 +313,20 @@ task_status_immed tski_mcu_info_read() { IICA = infos[ iic_burst_state -1 ]; } - iic_burst_state++; + + if( !ACKD ) // 途中で打ち切り + { + goto end; + } + + iic_burst_state++; return( ERR_CONTINUE ); end: - LREL = 1; SPIE = 0; + IICAIF = 0; IICAMK = 0; + LREL = 1; iic_burst_state = 0; return( ERR_FINISED ); } diff --git a/trunk/task_sys.c b/trunk/task_sys.c index 3a2f4e9..16b931c 100644 --- a/trunk/task_sys.c +++ b/trunk/task_sys.c @@ -294,7 +294,8 @@ void tsk_sys( ) { return; } - system_status.force_off = false; + + clear_pow_off_countdown(); vreg_ctr[ VREG_C_ACC_CONFIG ] = 0x00; tski_acc_hosu_set(); @@ -391,6 +392,7 @@ void tsk_sys( ) } else { + // アダプタなし if( chg_led_override != 0 ) // これがゼロになるまで待つ { return; @@ -431,8 +433,19 @@ void tsk_sys( ) system_status.pwr_state = ON_CHECK; } RTCIMK = 0; + if( system_status.taikendai ) + { + system_status.pwr_state = OFF_TRIG; + } + } return; + +#if 0 + default: + NOP( ); // あり得ないステート +#endif + } } diff --git a/trunk/user_define.h b/trunk/user_define.h index f8564be..d6c37a7 100644 --- a/trunk/user_define.h +++ b/trunk/user_define.h @@ -4,6 +4,7 @@ #define IIC_T_SLAVEADDRESS 0x4A #define IIC_C_SLAVEADDRESS 0x4A +#define IIC_C_SLAVEADDRESS_DMY 0x4C #define IIC_SLA_DCP 0x50 diff --git a/trunk/vreg_ctr.c b/trunk/vreg_ctr.c index bd59cfa..9121791 100644 --- a/trunk/vreg_ctr.c +++ b/trunk/vreg_ctr.c @@ -207,6 +207,7 @@ void vreg_ctr_write( u8 adrs, u8 data ) info_led_pattern_updated = true; } } + break; /// 非同期で動いているためここでは書かない。 // 予約するだけでstopで書く diff --git a/trunk/vreg_twl.c b/trunk/vreg_twl.c index 98cc67b..cfc15e3 100644 --- a/trunk/vreg_twl.c +++ b/trunk/vreg_twl.c @@ -59,7 +59,10 @@ void vreg_twl_write( u8 adrs, u8 data ) case ( REG_TWL_INT_ADRS_CAM ): vreg_twl[ REG_TWL_INT_ADRS_CAM ] = ( data & 0x03 ); - cam_led_update = true; + if( ( data & 0x03 ) == TWL_CAMLED_BLINK ) + { + cam_led_update = true; // こうでないと一発消灯時に不具合があるため + } tsk_led_cam(); break;