・nbd体験台対応(電池残量が常に100%)
・i2c_mcuの割り込み処理修正。
 だから、中で関数呼んじゃだめなんだってば!
・スリープ中、カメラLEDを勝手に消す(TWLにあわせる)
・task_sys
 スリープに入るかチェックがあまりよくなかった
 電源切れてるところから入れるあたり、処理がよくなかった。
  きれいにしようと思ったが大改造になりそうだからやめた


git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@284 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
n2232 2010-12-03 07:47:05 +00:00
parent 30756b489d
commit c0e58f917a
15 changed files with 228 additions and 186 deletions

View File

@ -111,8 +111,8 @@ task_status_immed tski_cbk_accero( )
iic_mcu_read( IIC_SLA_ACCEL, ( ACC_REG_X | 0x80 ), 6, temp );
}
}
if(( system_status.pwr_state != OFF )
&&( system_status.pwr_state != BT_CHARGE )
if(( system_status.pwr_state != ON_CHECK )
&&( system_status.pwr_state != OFF )
#ifndef _DBG_PEDO_AUTO_ENABLE_
&&( ( vreg_ctr[VREG_C_ACC_CONFIG] & VREG_BITMASK_ACC_CONF_HOSU ) != 0 )
#endif

View File

@ -218,6 +218,7 @@ task_status_immed tski_vol_update()
// レジスタの更新 //
vreg_ctr[ VREG_C_SND_VOL ] = sent_index;
// スケーリング
#if 1
// if( sent_index == 1 )
if( sent_index == 0 )
{
@ -231,6 +232,16 @@ task_status_immed tski_vol_update()
{
vreg_twl[ REG_TWL_INT_ADRS_VOL ] = sent_index/2 ;
}
#else
if( sent_index == 1 )
{
vreg_twl[ REG_TWL_INT_ADRS_VOL ] = 1;
}
else
{
vreg_twl[ REG_TWL_INT_ADRS_VOL ] = sent_index/2 ;
}
#endif
// 8段階のレベル化。 割り込みを入れるのに必要
{

View File

@ -5,13 +5,13 @@
enum pwr_state_
{
OFF_TRIG = 0,
OFF,
ON_CHECK,
ON_TRIG,
ON,
// SLEEP_TRIG,
SLEEP,
// WAKE,
BT_CHARGE,
OFF,
};
enum poweron_reason_
@ -42,6 +42,7 @@ typedef struct _system_status_
unsigned char force_off:1;
unsigned char captureBox:1; // キャプチャ箱 SDKには実機と返す
unsigned char taikendai:1;
unsigned char taikendai_nbd:1;
enum model_ model;
}system_status_;

View File

@ -11,9 +11,11 @@
//#define _PMIC_TEST_
//#define _ENABLE_WDT_TEST_
//#define _FORCE_TAIKENDAI_
//#define _FORCE_TAIKENDAI_NBD_
#define MCU_VER_MAJOR 0x01
#define MCU_VER_MINOR 0x0F
#define MCU_VER_MINOR 0x10
#define _firm_format_v3_

View File

@ -94,6 +94,7 @@ static err iic_mcu_wait_free()
if( !iic_mcu_busy )
{
iic_mcu_busy = true;
EI();
break;
}
EI();
@ -105,7 +106,6 @@ static err iic_mcu_wait_free()
return( ERR_ERR );
}
}
EI();
return( ERR_SUCCESS );
}
@ -374,32 +374,33 @@ err iic_mcu_write( u8 slave, u8 adrs, u8 len, void * src )
======================================================== */
__interrupt void int_dma1( )
{
u16 i = 0;
EI();
DMAMK1 = 1;
DEN1 = 0;
while( ( SSR02L & TSF0 ) != 0 )
{
u16 i = 0;
if( ++i == 0 ) // タイムアウト?
{
break;
}
}
// iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪いので展開
// iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪い(汎用レジスタ待避が発生する)ので展開
{
ST0 = 0x0004;
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
SO0 = 0x0000 | TAUS_MASK; // SCL
nop8();
// nop8(); すら呼んじゃだめ
NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP();
SO0 = 0x0400 | TAUS_MASK; // SCL
nop8();
NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP();
SO0 = 0x0404 | TAUS_MASK;
}
IICMK10 = 1;
iic_mcu_busy = false;
}
@ -425,18 +426,19 @@ __interrupt void int_iic10( )
// 最後のバイト送信完了
IICMK10 = 1;
// iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪いので展開
// iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪い(汎用レジスタ待避が発生する)ので展開
{
ST0 = 0x0004;
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
SO0 = 0x0000 | TAUS_MASK; // SCL
nop8();
NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP();
SO0 = 0x0400 | TAUS_MASK; // SCL
nop8();
NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP();
SO0 = 0x0404 | TAUS_MASK;
}
iic_mcu_wo_dma = false;
iic_mcu_busy = false;
}

View File

@ -40,28 +40,48 @@ void NOP(){};
#define __far
typedef struct
typedef struct hoge
{
unsigned 7 :1;
unsigned 6 :1;
unsigned 5 :1;
unsigned 4 :1;
unsigned 3 :1;
unsigned 2 :1;
unsigned 1 :1;
unsigned 0 :1;
unsigned _7 :1;
unsigned _6 :1;
unsigned _5 :1;
unsigned _4 :1;
unsigned _3 :1;
unsigned _2 :1;
unsigned _1 :1;
unsigned _0 :1;
}mcu_reg;
mcu_reg P20;
mcu_reg P7;
mcu_reg P4;
mcu_reg P0;
mcu_reg PM0;
mcu_reg PM1;
mcu_reg P1;
mcu_reg P2;
mcu_reg PM2;
mcu_reg PM3;
mcu_reg P3;
mcu_reg P4;
mcu_reg P5;
mcu_reg PM5;
mcu_reg PU5;
mcu_reg P7;
mcu_reg PM7;
mcu_reg P14;
mcu_reg PM14;
mcu_reg PU20;
mcu_reg PM20;
mcu_reg P20;
unsigned char PMK23;
unsigned char RTCIMK;
unsigned char WDTE;
unsigned char PM2;
unsigned char PU7;
unsigned char WDTE;
void EI(){;}
void DI(){;}
# endif

View File

@ -220,7 +220,7 @@ void LED_stop( )
enum pwr_state_{
OFF_TRIG = 0,
OFF,
ON_CHECK,
ON_TRIG,
ON,
SLEEP
@ -623,6 +623,7 @@ void tsk_led_cam( )
static u8 task_interval;
u8 LED_CAM_mirror;
DI(); // レジスタへの書き込みで強制起動がかかることがあるため
if( !cam_led_update )
{
if( task_interval != 0 )
@ -632,7 +633,15 @@ void tsk_led_cam( )
}
}
cam_led_update = false; // TWL のブリンク設定(一発だけ点灯)のため
EI();
if( system_status.pwr_state == SLEEP ) // sleep中、強制消灯
{
LED_CAM_mirror = 0;
state_led_cam = 0;
}
else
{
// ブリンクのように待たせたいとき以外は毎週起動する
// (レジスタの変更にすぐに反応する)
switch ( vreg_ctr[VREG_C_LED_CAM] )
@ -717,6 +726,7 @@ void tsk_led_cam( )
break;
}
}
} // if( system_status.pwr_state == sleep ) ... else ...
// 輝度更新 //
if( system_status.info_fullcolor )

View File

@ -150,6 +150,19 @@ void main( )
system_status.taikendai = 0;
}
#ifndef _FORCE_TAIKENDAI_NBD_
if( !DIPSW_1 )
#else
if(1)
#endif
{
system_status.taikendai_nbd = 1;
}
else
{
system_status.taikendai_nbd = 0;
}
// Ê<E28099>í‰^“]
main_loop( );
}

View File

@ -40,7 +40,7 @@ unsigned long my_sqrt();
========================================================*/
void pedometer()
{
static s16 th_H = 15000; // 閾値。暫定。動的変更とかしたい…ので変数
static s16 th_H = 15000; // 閾値。動的変更します
static s16 th_L = 11000;
static u16 acc_norm[3]; // 加速度の大きさのヒストリ。数字が大きい方が古い
static u16 acc_norm_temp;

View File

@ -165,8 +165,8 @@ void tsk_batt( )
// 割り込みはmiscが引き受ける
// 電池残量 //
if(( system_status.pwr_state != OFF )&&
( system_status.pwr_state != BT_CHARGE ))
if(( system_status.pwr_state != ON_CHECK )&&
( system_status.pwr_state != OFF ))
{
BT_get_left();
}
@ -566,6 +566,7 @@ void BT_get_left(){
else if( system_status.model == MODEL_SHIROBAKO )
{
// 白箱 //
// “drŽc—Ê
if( iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_SOC, 2, temp_fuel ) != ERR_SUCCESS )
{
// エミュレーション機能がおかしい
@ -576,8 +577,18 @@ void BT_get_left(){
vreg_ctr[ VREG_C_BT_REMAIN ] = temp_fuel[0];
vreg_ctr[ VREG_C_BT_REMAIN_FINE ] = temp_fuel[1];
}
// “dr“dˆ³
/*
if( iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL, 2, temp_v ) == ERR_SUCCESS )
{
vreg_ctr[ VREG_C_BT_VOLTAGE ] = temp_v[0];
}
else
*/
{
vreg_ctr[ VREG_C_BT_VOLTAGE ] = 200;
}
}
else
{
// 実機 //
@ -672,6 +683,10 @@ void BT_get_left(){
}
}
}
if( system_status.taikendai_nbd )
{
vreg_ctr[ VREG_C_BT_REMAIN ] = 100;
}
}

View File

@ -95,8 +95,8 @@ void tsk_sw( )
{
case ( ON ):
case ( SLEEP ):
case ( BT_CHARGE ):
case ( OFF ):
case ( ON_CHECK ):
// 電源スイッチの監視 //
if( SW_pow_count == (u8)( 320/ INTERVAL_TSK_SW ) )
{

View File

@ -95,7 +95,7 @@ task_interval tsk_hina( )
{
switch ( system_status.pwr_state )
{
case OFF:
case ON_CHECK:
case ON_TRIG:
case ON:
case SLEEP:

View File

@ -50,7 +50,7 @@ void tsk_sys( )
switch ( system_status.pwr_state )
{
case OFF: //-------------------------------------------------------
case ON_CHECK: //-------------------------------------------------------
// スイッチ操作などで割り込みが発生し、スリープが解除されるとここに来ます。
if( system_status.poweron_reason == NONE )
@ -67,7 +67,7 @@ void tsk_sys( )
if( timeout > 100 )
{
system_status.pwr_state = OFF_TRIG; // スイッチはノイズだった。寝る。
system_status.pwr_state = OFF; // スイッチはノイズだった。寝る。
renge_task_interval_run_force = true;
return;
}
@ -230,30 +230,23 @@ void tsk_sys( )
chk_emergencyExit();
// SLP監視
if( PIF0 ){ // slp割り込み
if( going_to_sleep ) // 絶対に SLP_REQ の前に予告が来る
{
timeout_sleep += 1;
if( timeout_sleep == 0 || // オーバーフローを期待。sleepするって言ったけど一瞬で起きて気がつかなかった
( PIF0 && !SLP_REQ )) // slp割り込みが入った気がしたが、もう起きてしまった
{
PIF0 = 0;
if( !SLP_REQ ){ // 一瞬で起きた
send_getup_to_soc();
}
else
{
if( PIF0 && SLP_REQ ){
PIF0 = 0;
PM_VDD_ecoMode();
system_status.pwr_state = SLEEP;
renge_task_interval_run_force = true;
}
}
// 絶対に SLP_REQ の前に予告が来るので、sleepに入るときはピンでのチェック不用
if( going_to_sleep )
{
timeout_sleep += 1;
if( timeout_sleep == 0 ) // sleepするって言ったけど一瞬で起きて気がつかなかった
{
send_getup_to_soc();
}
}
// 強制offカウント
force_off_check();
@ -288,10 +281,10 @@ void tsk_sys( )
}
break;
case OFF_TRIG: //---------------------------------------
default:
default: //---------------------------------------
system_status.pwr_state = OFF_TRIG;
// no break //
case OFF_TRIG: //---------------------------------------
// LED消灯を待つ
vreg_ctr[ VREG_C_LED_POW ] = LED_POW_ILM_OFF;
vreg_ctr[ VREG_C_LED_WIFI ] = WIFI_LED_OFF;
@ -362,14 +355,14 @@ void tsk_sys( )
timeout = 0;
system_status.pwr_state = BT_CHARGE;
system_status.pwr_state = OFF;
SW_pow_mask = true;
SW_pow_count = 0;
// no break //
case BT_CHARGE:
case OFF:
if( !PM_EXTDC_n )
{
// アダプタが刺さってるときはこのブロックを繰り返す。
@ -381,7 +374,7 @@ void tsk_sys( )
{
// 電源投入
system_status.poweron_reason = PWSW;
system_status.pwr_state = OFF;
system_status.pwr_state = ON_CHECK;
}
if( system_status.model != MODEL_JIKKI )
{
@ -393,20 +386,16 @@ void tsk_sys( )
// 電源投入
wait_ms(46);
system_status.poweron_reason = PWSW;
system_status.pwr_state = OFF;
system_status.pwr_state = ON_CHECK;
}
}
else
{
// / static bit chg_ena_orig;
if( chg_led_override != 0 ) // これがゼロになるまで待つ
{
return;
};
// / chg_ena_orig = BT_CHG_Ena_n;
// 省電力へ移行
system_status.poweron_reason = NONE;
@ -424,43 +413,26 @@ void tsk_sys( )
CKC = 0b00001001;
OSMC = 0x00;
// / BT_CHG_ENABLE(); // リークを減らすため
STOP( );
// 起きる //
// 起きる条件は
// ・KeyReturn割り込み電源ボたん
// ・RTCアラーム
// ・KeyReturn割り込み電源ボタン
// ・アダプタ挿抜
// / BT_CHG_Ena_n = chg_ena_orig;
if( PM_EXTDC_n )
{
// 一度起こしてしまう。ペリフェラルの初期化など流用のため。
// 電源ボタンのタイムアウトで返ってくる
SW_pow_mask = false;
}
OSMC = 0x01;
CKC = 0b00001000;
RTCIMK = 0;
system_status.pwr_state = OFF;
if( system_status.taikendai )
if( PM_EXTDC_n )
{
system_status.pwr_state = OFF_TRIG;
// 電源ボタンで起きたとき
SW_pow_mask = false;
system_status.poweron_reason = NONE;
system_status.pwr_state = ON_CHECK;
}
RTCIMK = 0;
}
return;
#if 0
default:
NOP( ); // あり得ないステート
#endif
}
}

View File

@ -128,7 +128,6 @@ void vreg_ctr_write( u8 adrs, u8 data )
case ( VREG_C_COMMAND0 ):
if( data != 0 )
{
// SVA1 = 0x5A; // 通信受け付けない todo
renge_task_immed_add( tski_do_command0 );
}
vreg_ctr[ VREG_C_COMMAND0 ] |= data;

View File

@ -59,10 +59,7 @@ void vreg_twl_write( u8 adrs, u8 data )
case ( REG_TWL_INT_ADRS_CAM ):
vreg_twl[ REG_TWL_INT_ADRS_CAM ] = ( data & 0x03 );
if( ( data & 0x03 ) == TWL_CAMLED_BLINK )
{
cam_led_update = true;
}
tsk_led_cam();
break;