歩数計仕様変更:24*7時間で呈し

拡張情報レジスタ(0x7F)のリードを8バイト以下で中断すると、その次の通信の先頭8-nバイトくらいが不正なのを修正
同レジスタの更新方法を変更、その影響でタスクの修正(削除)
エージングはOK。歩数計はまだ十分な検証が済んでない


git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@304 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
n2232 2011-01-21 01:39:21 +00:00
parent 02950b0366
commit c8ed4d66e3
7 changed files with 74 additions and 122 deletions

View File

@ -148,14 +148,7 @@ __interrupt void int_iic_ctr( )
reg_adrs = IICA;
adrs_access_from = reg_adrs;
tx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
if( reg_adrs != VREG_CX_INFO ) // 特殊なバーストリードを行うため、割り込み駆動から外す
{
state = IIC_TX_OR_RX;
}
else
{
state = IIC_IDLE;
}
state = IIC_TX_OR_RX;
WREL = 1;
break;

View File

@ -183,6 +183,8 @@ void pedometer()
 
  
 
*2011/01/20
 
========================================================*/
u8 p_record;
u8 last_hour = 0x23; // 履歴の最新は何時?
@ -199,9 +201,14 @@ u8 log_year;
static void hosu_increment()
{
static u16 last_hour_fny;
static u16 last_hour_fny; // from new year
// 累積の更新 //
if( p_record >= PEDOMETER_LOG_SIZE )
{
return;
}
// 累積の更新 //
// いろいろ失敗した...
if( ++vreg_ctr[ VREG_C_ACC_HOSU_L ] == 0 )
{
@ -241,11 +248,12 @@ static void hosu_increment()
// 元旦零時台で昨日扱いになった場合の帳尻合わせ
if( now_longhour == 65535 )
{
now_longhour = ( ( 365 + (( now_year & 0x03 ) == 1 ? 1: 0 )) * 24 ) -1;
now_longhour = ( ( 365 + (( now_year & 0x03 ) == 1 ? 1: 0 )) * 24 ) -1; // 閏年を考慮
now_year -= 1;
}
// 歩数計が止まっていた時間を考慮して必要なら進める //
// 書き込みポインタの更新
// 歩数計が止まっていた時間を考慮して必要なら進める
if( last_year == now_year )
{
if( now_longhour > last_hour_fny )
@ -272,17 +280,13 @@ static void hosu_increment()
last_hour_fny = now_longhour;
// 実際にインクリメント
if( pool.vreg_c_ext.pedo_log[ p_record ] == HOSU_NODATA ) //※ 読みにくい…
{
u16* p_pedo_data = &pool.vreg_c_ext.pedo_log[ p_record ];
if( *p_pedo_data == HOSU_NODATA )
{
*p_pedo_data = 1;
}
else if( *p_pedo_data != HOSU_MAX )
{
*p_pedo_data += 1;
}
pool.vreg_c_ext.pedo_log[ p_record ] = 1;
}
else if( pool.vreg_c_ext.pedo_log[ p_record ] != HOSU_MAX )
{
pool.vreg_c_ext.pedo_log[ p_record ] += 1;
}
}
}
@ -355,45 +359,39 @@ void hosu_read_end( )
======================================================== */
u8 hosu_read( )
{
u8 dat;
u16 temp;
u8 rv;
static u8 p_record_buffer;
static u8 dat_temp[6]; // 一応、アトミック処理に
switch( iic_burst_state ){
case( 0 ):
if( iic_burst_state == 0 )
{
p_record_buffer = p_record;
iic_burst_state += 1;
return( last_hour );
dat_temp[0] = last_hour;
dat_temp[1] = last_day;
dat_temp[2] = last_month;
dat_temp[3] = btobcd( log_year );
dat_temp[4] = now_min;
dat_temp[5] = now_sec;
}
case( 1 ):
if( iic_burst_state <= 5 )
{
rv = dat_temp[ iic_burst_state ];
iic_burst_state += 1;
return( last_day );
case( 2 ):
iic_burst_state += 1;
return( last_month );
case( 3 ):
iic_burst_state += 1;
return( btobcd( log_year ) );
case( 4 ):
iic_burst_state += 1;
return( now_min ); // reserved dummy
case( 5 ):
iic_burst_state += 1;
return( now_sec ); // reserved. dummy
default:
return( rv );
}
else
{
u16 temp;
// 16ビットで記録してあるのでばらして送る todo: もっと楽する方法があるんじゃ
temp = pool.vreg_c_ext.pedo_log[ p_record_buffer ];
if( record_read_msb_lsb == 0 )
{
dat = (u8)( temp & 0x00FF );
rv = (u8)( temp & 0x00FF );
}
else
{
dat = (u8)(( temp >> 8 ) & 0x00FF );
rv = (u8)(( temp >> 8 ) & 0x00FF );
if( p_record_buffer == 0 )
{
p_record_buffer = PEDOMETER_LOG_SIZE-1;
@ -404,8 +402,9 @@ u8 hosu_read( )
}
}
record_read_msb_lsb ^= 1;
return( dat );
return( rv );
}
}

View File

@ -33,6 +33,10 @@ bit ntr_pm_bt_low_old;
bit BT_CHG_STAT_Change;
u8 pmic_version;
u8 mgic_version[2];
// ========================================================
static void BT_model_detect();
static void BT_mgic_quick_start();
@ -974,11 +978,16 @@ err PM_sys_pow_on( )
return ( ERR_ERR ); // reset1はほっといて良い
}
// 電源周りIC情報
pmic_version = iic_mcu_read_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VER );
iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VERSION, 2, mgic_version );
// リセット解除など。システム起動!
PM_reset_neg();
FCRAM_RST_neg;
RESET2_neg;
codec_reg_init(); // CODEC 不定レジスタ初期化
codec_reg_init(); // CODEC 不定レジスタ初期化(reset2の後でないといけないので)
reg_shadow = 0; //  〃 こんなところで...
return ( ERR_SUCCESS );

View File

@ -131,6 +131,8 @@ extern u8 raw_adc_temperature;
extern BT_VENDER battery_manufacturer;
extern bit bt_force_update;
extern u8 pmic_version;
extern u8 mgic_version[];
//=========================================================

View File

@ -4,14 +4,13 @@
#include "renge_defs.h"
// *************************************
#define TASK_IMMED_RUN_LIST_MAX 16
#define TASK_IMMED_RUN_LIST_MAX 10
extern task_status_immed tski_do_command0( );
extern task_status_immed tski_ntr_pmic_comm();
extern task_status_immed tski_acc_read();
extern task_status_immed tski_acc_write();
extern task_status_immed tski_mcu_info_read();
//extern task_status_immed tski_acc_hosu_set(); // accero.h
extern task_status_immed tski_mcu_reset();
extern task_status_immed tski_vol_update();

View File

@ -231,7 +231,6 @@ task_status_immed tski_do_command0( )
return ( ERR_CONTINUE );
}
*/
// SVA1 = IIC_C_SLAVEADDRESS; todo
return ( ERR_FINISED );
}
@ -264,71 +263,29 @@ extern bit bt_chg_ready;
8) ( !temp_zone_charge_disable | ( bt_chg_ready << 1 ) )
9)
======================================================== */
task_status_immed tski_mcu_info_read()
u8 extinfo_read()
{
static u8 infos[10]; // staticにしたんだし、電源投入時にでもキャッシュしとけばいいのに
u8 infos[10];
if( SPD ) // stop
{
goto end;
}
if( STD ) // restart
{
WDT_Restart( );
}
if( IICAIF == 0 ) // I2Cのステートが進むのを待つ
{
return( ERR_CONTINUE );
}
IICAIF = 0;
WDT_Restart( );
if( iic_burst_state > 8 )
{
goto end;
}
else if( iic_burst_state == 0 )
{
if( !system_status.captureBox )
{
IICA = (u8)system_status.model;
}
else
{
IICA = MODEL_CAPTURE_BOX;
}
// これで勝手に転送が始まるから今のうちにデータの準備をしておく
infos[0] = iic_mcu_read_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VER );
infos[1] = battery_manufacturer;
iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VERSION, 2, &infos[2] );
infos[4] = (u8)( _dbg_rcomp & 0xFF );
infos[5] = raw_adc_temperature;
infos[6] = ( !temp_zone_charge_disable | ( bt_chg_ready << 1 ) );
infos[7] = system_status.info_fullcolor;
}
else
{
IICA = infos[ iic_burst_state -1 ];
return( 0xAA );
}
if( !ACKD ) // 途中で打ち切り
{
goto end;
}
// static でとるほどのものでないので毎回スタックからとってくる
// switchとかにするとromが困る... なんだかなぁ。
infos[0] = system_status.captureBox? MODEL_CAPTURE_BOX: (u8)system_status.model;
infos[1] = pmic_version;
infos[2] = battery_manufacturer;
infos[3] = mgic_version[0];
infos[4] = mgic_version[1];
infos[5] = (u8)( _dbg_rcomp & 0xFF );
infos[6] = raw_adc_temperature;
infos[7] = ( !temp_zone_charge_disable | ( bt_chg_ready << 1 ) );
infos[8] = system_status.info_fullcolor;
iic_burst_state++;
return( ERR_CONTINUE );
end:
SPIE = 0;
IICAIF = 0;
IICAMK = 0;
LREL = 1;
iic_burst_state = 0;
return( ERR_FINISED );
return( infos[ iic_burst_state -1 ] );
}
#ifdef i2c_timeout_test
@ -343,3 +300,4 @@ void i2c_mcu_error_monitor()
LED_CAM = 1;
}
#endif

View File

@ -15,9 +15,7 @@ CTR MCU I2C
#include "fsl_user.h"
extern u8 mcu_info_read(); // task_misc.c
extern u8 extinfo_read(); // task_misc.c
extern u8 iic_burst_state; // 特殊バーストアクセスする時のカウンタ
extern bit info_led_pattern_updated; // お知らせLEDのパターンを先頭に戻す
@ -38,7 +36,6 @@ bit irq_readed; // AAA
// ********************************************************
extern task_status_immed tski_firm_update();
extern task_status_immed tski_mcu_info_read();
extern task_status_immed tski_mcu_reset();
@ -438,12 +435,7 @@ u8 vreg_ctr_read( u8 adrs )
}
else if( adrs == VREG_CX_INFO )
{
// I2C_mを使うので、ここからでは割り込みが使えなくて困る
// なのでタスク登録する。
// 強制的にI2C_2割り込みをマスクする
renge_task_immed_add( tski_mcu_info_read );
IICAMK = 1;
return( 0x4A );
return( extinfo_read() );
}
#if 0