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;