mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-06-18 16:45:33 -04:00
zeroNUP が流れ、1NUPに入れるべく作業中
・TWLに音量変化割り込みを入れまくらない。 ACKとしてのREADを期待せず、変化した分だけ入れる ・歩数計ログをクリア後、1歩目をカウントしたところからログいっぱいで止める &一応リファクタリング 年またぎなど一通りチェックはしたが… ぼちぼちブランチを切る git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@308 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
parent
2afd580bdd
commit
c1f70d8d17
@ -27,6 +27,7 @@ u8 adc_raw_dep;
|
||||
|
||||
u8 vol_polling;
|
||||
|
||||
u8 vol_level_twl;
|
||||
|
||||
|
||||
typedef struct filter_work
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
///////////////////////////////////////
|
||||
extern u8 vol_polling;
|
||||
extern u8 vol_level_twl;
|
||||
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
#define MCU_VER_MAJOR 0x01
|
||||
#define MCU_VER_MINOR 0x15
|
||||
#define MCU_VER_MINOR 0x20
|
||||
|
||||
|
||||
#define _firm_format_v3_
|
||||
|
BIN
trunk/hoge.bin
BIN
trunk/hoge.bin
Binary file not shown.
@ -28,8 +28,9 @@ typedef signed short sx16;
|
||||
|
||||
|
||||
# ifdef _WIN32
|
||||
// VCの赤線をどうにかする
|
||||
|
||||
typedef bool bit;
|
||||
#define bit bool
|
||||
|
||||
void EI(){};
|
||||
void DI(){};
|
||||
@ -83,6 +84,21 @@ unsigned char WDTE;
|
||||
void EI(){;}
|
||||
void DI(){;}
|
||||
|
||||
unsigned char RWAIT;
|
||||
unsigned char RWST;
|
||||
|
||||
unsigned char bcdtob( unsigned char );
|
||||
|
||||
unsigned char HOUR;
|
||||
unsigned char DAY;
|
||||
unsigned char MONTH;
|
||||
unsigned char YEAR;
|
||||
unsigned char MIN;
|
||||
unsigned char SEC;
|
||||
|
||||
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -17,16 +17,39 @@
|
||||
#include "pool.h"
|
||||
|
||||
// ========================================================
|
||||
static void hosu_increment();
|
||||
// 履歴の最終記録時刻
|
||||
// この順番はログ読み出しの順番でもあるのでいじらないでね
|
||||
// 順番にアドレスの若いのから確保されるのを期待してます...
|
||||
typedef struct{
|
||||
u8 hour_bcd;
|
||||
u8 day_bcd;
|
||||
u8 month_bcd;
|
||||
u8 year_bcd;
|
||||
u8 min_bcd;
|
||||
u8 sec_bcd;
|
||||
}st_calender;
|
||||
|
||||
|
||||
|
||||
// ========================================================
|
||||
u16 get_long_hour();
|
||||
static void hosu_increment_if_necessary();
|
||||
static u16 get_long_hour();
|
||||
static u16 calc_hours_spend( u8 );
|
||||
|
||||
|
||||
|
||||
// ========================================================
|
||||
bit pedolog_overflow; // 192時間記録済みフラグ(i2cで読める)
|
||||
extern uni_pool pool; // 歩数ログはこの構造体の中
|
||||
static u8 p_record; // ログの書き込み位置
|
||||
static st_calender cal_log_latest; // 最後に歩数を更新した時刻
|
||||
static u16 last_hour_fny; // fny:from new year
|
||||
static st_calender cal_temp;
|
||||
static u16 now_longhour;
|
||||
|
||||
|
||||
|
||||
|
||||
extern uni_pool pool;
|
||||
bit pedolog_overflow;
|
||||
|
||||
|
||||
// ========================================================
|
||||
@ -35,6 +58,11 @@ bit pedolog_overflow;
|
||||
unsigned long my_sqrt();
|
||||
#endif
|
||||
|
||||
// 今年は閏年?
|
||||
#define is_leapyear( y ) (( y & 0x03 ) == 0 )
|
||||
// 「去年」は閏年?
|
||||
#define is_firstyear( y ) (( y & 0x03 ) == 1 )
|
||||
|
||||
|
||||
|
||||
/*=========================================================
|
||||
@ -82,7 +110,7 @@ void pedometer()
|
||||
|
||||
hist_indx += 1;
|
||||
|
||||
// ヒストリにフィルタを掛けて、今回の値を求める
|
||||
// ヒストリにフィルタ(fir)を掛けて、今回の値を求める //
|
||||
filterd = 0;
|
||||
// for( i = 8; i != 55; i++ ) // 係数が0ばかりのため
|
||||
for( i = 0; i != 46; i++ ) // 係数テーブルをいじりました。パラメータ調整時注意
|
||||
@ -90,7 +118,7 @@ void pedometer()
|
||||
filterd += (signed long)norm_hist[ ( hist_indx + i ) & TAP-1 ] * lpf_coeff[ i ];
|
||||
}
|
||||
|
||||
filterd += (4096)*512;
|
||||
filterd += (4096)*512; // DC分加算...だったと思う
|
||||
acc_norm_temp = (s16)( filterd /1024 & 0xFFFF ); // ←FIL_COEFF_QUANTから正規化
|
||||
/*
|
||||
if( acc_norm[0] < acc_norm_temp )
|
||||
@ -123,11 +151,12 @@ void pedometer()
|
||||
{
|
||||
if( acc_norm[0] - peak_l > 4200 ){
|
||||
// ■一歩増えました
|
||||
hosu_increment();
|
||||
hosu_increment_if_necessary();
|
||||
}
|
||||
}
|
||||
interval_hh = 0;
|
||||
}
|
||||
// なんちゃって閾値の動的変更
|
||||
if( acc_norm[0] > 18000 )
|
||||
{
|
||||
th_L = acc_norm[0] - 10000;
|
||||
@ -154,29 +183,6 @@ void pedometer()
|
||||
{
|
||||
time_l += ( time_l != 255 ) ? 1: 0;
|
||||
}
|
||||
|
||||
#ifdef _DBG_PEDO_AUTO_ENABLE_
|
||||
{
|
||||
static u8 i = 0;
|
||||
|
||||
vreg_ctr[ 0x50 ] = i++;
|
||||
|
||||
vreg_ctr[ 0x51 ] = (u8)( acc_norm[0] / 256 & 0x00FF );
|
||||
vreg_ctr[ 0x52 ] = (u8)( acc_norm[0] & 0x00FF );
|
||||
|
||||
vreg_ctr[ 0x53 ] = (u8)( norm_hist[ hist_indx -1 & TAP-1 ] / 256 & 0xFF );
|
||||
vreg_ctr[ 0x54 ] = (u8)( norm_hist[ hist_indx -1 & TAP-1 ] & 0xFF );
|
||||
|
||||
vreg_ctr[ 0x55 ] = interval_hh;
|
||||
vreg_ctr[ 0x56 ] = time_l;
|
||||
|
||||
vreg_ctr[ 0x57 ] = vreg_ctr[ VREG_C_ACC_HOSU_L ];
|
||||
vreg_ctr[ 0x58 ] = (u8)( peak_l / 256 & 0x00FF );
|
||||
vreg_ctr[ 0x59 ] = (u8)( peak_l & 0x00FF );
|
||||
// vreg_ctr[ 0x5A ] = (u8)( norm_avg[0] / 256 & 0x00FF );
|
||||
// vreg_ctr[ 0x5B ] = (u8)( norm_avg[0] & 0x00FF );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -188,134 +194,83 @@ void pedometer()
|
||||
*2011/01/20
|
||||
仕様変更 ログがいっぱいになったらそこで止める
|
||||
========================================================*/
|
||||
u8 p_record;
|
||||
u8 log_year;
|
||||
|
||||
u8 pedo_log_latest[ 6 ];
|
||||
enum {
|
||||
LEDO_LOG_LATEST_HOUR,
|
||||
LEDO_LOG_LATEST_DAY,
|
||||
LEDO_LOG_LATEST_MONTH,
|
||||
LEDO_LOG_LATEST_YEAR,
|
||||
LEDO_LOG_LATEST_MIN,
|
||||
LEDO_LOG_LATEST_SEC
|
||||
};
|
||||
|
||||
/*
|
||||
u8 last_hour; // 履歴の最新は何時?
|
||||
u8 last_day;
|
||||
u8 last_month;
|
||||
u8 pedo_log_latest[ LEDO_LOG_LATEST_YEAR ];
|
||||
u8 last_min;
|
||||
u8 last_sec;
|
||||
*/
|
||||
|
||||
#define HOSU_NODATA 0xFFFF
|
||||
#define HOSU_MAX 0xFFFE
|
||||
|
||||
static void hosu_increment()
|
||||
static void hosu_increment_if_necessary()
|
||||
{
|
||||
static u16 last_hour_fny; // from new year
|
||||
u8 year_compd; // hour境界補正済み現在年。comp(ensation)
|
||||
|
||||
// 空白の時間を考慮する。1時間以上放置されたなど。
|
||||
u16 now_longhour;
|
||||
u8 now_year;
|
||||
|
||||
u8 temp_year, temp_hour, temp_day, temp_month, temp_min, temp_sec, log_year_temp;
|
||||
|
||||
// 時計を止める必要が有るので↓は一気に行って下さい
|
||||
// 現在時刻取得
|
||||
DI();
|
||||
RWAIT = 1;
|
||||
while( !RWST ){;}
|
||||
log_year_temp = temp_year = bcdtob( YEAR );
|
||||
|
||||
// 履歴読み出し時に使用。BCDのままでよい
|
||||
temp_hour = HOUR;
|
||||
temp_day = DAY;
|
||||
temp_month = MONTH;
|
||||
temp_min = MIN;
|
||||
temp_sec = SEC;
|
||||
cal_temp.hour_bcd = HOUR;
|
||||
cal_temp.day_bcd = DAY;
|
||||
cal_temp.month_bcd = MONTH;
|
||||
cal_temp.year_bcd = YEAR;
|
||||
cal_temp.min_bcd = MIN;
|
||||
cal_temp.sec_bcd = SEC;
|
||||
|
||||
RWAIT = 0;
|
||||
EI();
|
||||
|
||||
year_compd = bcdtob( cal_temp.year_bcd );
|
||||
|
||||
now_longhour = get_long_hour();
|
||||
|
||||
// RWAIT = 0; ↑で行っています
|
||||
// EI(); 〃
|
||||
|
||||
// 元旦零時台で昨日扱いになった場合の帳尻合わせ
|
||||
if( now_longhour == 65535 )
|
||||
{
|
||||
now_longhour = ( ( 365 + (( temp_year & 0x03 ) == 1 ? 1: 0 )) * 24 ) -1; // 閏年を考慮
|
||||
temp_year -= 1;
|
||||
}
|
||||
|
||||
// 書き込みポインタの更新
|
||||
if(( vreg_ctr[ VREG_C_ACC_HOSU_L ] | vreg_ctr[ VREG_C_ACC_HOSU_M ] | vreg_ctr[ VREG_C_ACC_HOSU_H ] ) != 0 )
|
||||
if( ! ( vreg_ctr[ VREG_C_ACC_HOSU_L ] == 0 && // 歩数計on後、最初の一歩までは前回からの経過時間を計算しない
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_M ] == 0 &&
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_H ] == 0 )) //. 全ビットorでゼロ判定するのはデジタル回路屋の方言みたい
|
||||
{
|
||||
// 歩数計が止まっていた時間を考慮して必要なら進める
|
||||
if( pedo_log_latest[ LEDO_LOG_LATEST_YEAR ] == temp_year )
|
||||
{
|
||||
if( now_longhour > last_hour_fny )
|
||||
{
|
||||
fill_hosu_hist_hours( now_longhour - last_hour_fny );
|
||||
}
|
||||
}
|
||||
else if( pedo_log_latest[ LEDO_LOG_LATEST_YEAR ] == ( temp_year -1 ) )
|
||||
{
|
||||
// 年をまたいでいるとき
|
||||
fill_hosu_hist_hours( ( ( 365 + (( temp_year & 0x03 ) == 1 ? 1: 0 )) * 24 ) - last_hour_fny + now_longhour );
|
||||
}
|
||||
else if( pedo_log_latest[ LEDO_LOG_LATEST_YEAR ] < temp_year )
|
||||
{
|
||||
// 数年放置
|
||||
fill_hosu_hist_hours( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// カレンダーが巻き戻るなど
|
||||
// ノーケアでよい
|
||||
}
|
||||
// 歩数計が止まっていた時間を考慮して必要なら進める
|
||||
// 補正計算 元旦零時台で昨日扱いになった場合、大晦日の23時台に上書き
|
||||
if( now_longhour == (u16)-1 ) // マジックナンバーとかではなくて実際に計算結果が-1
|
||||
{
|
||||
now_longhour = ( ( 365 + ( is_firstyear(year_compd) ? 1: 0 )) * 24 ) -1;
|
||||
year_compd -= 1;
|
||||
}
|
||||
fill_hosu_hist_hours( calc_hours_spend( year_compd ) ); // ■書き込みポインタの更新も行う
|
||||
|
||||
// ログあふれで記録停止?
|
||||
if( pedolog_overflow )
|
||||
{
|
||||
return;
|
||||
// おしまい。ログの更新もなし。
|
||||
}
|
||||
}
|
||||
|
||||
// インクリメントして良い
|
||||
pedo_log_latest[ LEDO_LOG_LATEST_HOUR ] = temp_hour;
|
||||
pedo_log_latest[ LEDO_LOG_LATEST_DAY ] = temp_day;
|
||||
pedo_log_latest[ LEDO_LOG_LATEST_MONTH ] = temp_month;
|
||||
pedo_log_latest[ LEDO_LOG_LATEST_YEAR ] = temp_year;
|
||||
pedo_log_latest[ LEDO_LOG_LATEST_MIN ] = temp_min;
|
||||
pedo_log_latest[ LEDO_LOG_LATEST_SEC ] = temp_sec;
|
||||
cal_log_latest = cal_temp; // ■ログ時刻更新
|
||||
last_hour_fny = now_longhour;
|
||||
|
||||
last_hour_fny = now_longhour;
|
||||
log_year = log_year_temp;
|
||||
|
||||
// 累積の更新 //
|
||||
// いろいろ失敗した...
|
||||
if( ++vreg_ctr[ VREG_C_ACC_HOSU_L ] == 0 )
|
||||
{
|
||||
if( ++vreg_ctr[ VREG_C_ACC_HOSU_M ] == 0 )
|
||||
{
|
||||
if( ++vreg_ctr[ VREG_C_ACC_HOSU_H ] == 0 ){
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_L ] = 255; // カンスト orz
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_M ] = 255;
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_H ] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 毎時ログインクリメント
|
||||
if( pool.vreg_c_ext.pedo_log[ p_record ] == HOSU_NODATA )
|
||||
{
|
||||
// 毎時ログ インクリメント
|
||||
if( pool.vreg_c_ext.pedo_log[ p_record ] == HOSU_NODATA ) // その時間帯最初のカウントの時
|
||||
{ // これしないと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;
|
||||
}
|
||||
|
||||
// 累積の更新 //
|
||||
if( ++vreg_ctr[ VREG_C_ACC_HOSU_L ] == 0 ) //. いろいろ失敗した...
|
||||
{
|
||||
if( ++vreg_ctr[ VREG_C_ACC_HOSU_M ] == 0 )
|
||||
{
|
||||
if( ++vreg_ctr[ VREG_C_ACC_HOSU_H ] == 0 ){
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_L ] = 255; //. カンスト orz
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_M ] = 255;
|
||||
vreg_ctr[ VREG_C_ACC_HOSU_H ] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -324,43 +279,34 @@ static void hosu_increment()
|
||||
空白の時間を適切に0にして、
|
||||
今を含む1時間のデータを書く位置にポインタ?を進める
|
||||
======================================================== */
|
||||
void fill_hosu_hist_hours( u16 hours )
|
||||
static void fill_hosu_hist_hours( u16 hours )
|
||||
{
|
||||
// ログ最大容量以上放置された?
|
||||
if( hours > PEDOMETER_LOG_SIZE )
|
||||
{
|
||||
hours = PEDOMETER_LOG_SIZE;
|
||||
}
|
||||
|
||||
if( p_record >= PEDOMETER_LOG_SIZE )
|
||||
{
|
||||
pedolog_overflow = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if( p_record + hours >= PEDOMETER_LOG_SIZE )
|
||||
// ログあふれ?
|
||||
if( (u16)p_record + hours >= PEDOMETER_LOG_SIZE )
|
||||
{
|
||||
pedolog_overflow = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 空白の数時間の設定
|
||||
do
|
||||
while( hours != 0 )
|
||||
{
|
||||
// 新仕様 いっぱいで停止
|
||||
p_record += 1;
|
||||
if( p_record >= PEDOMETER_LOG_SIZE )
|
||||
#if 1 // debug
|
||||
if( p_record >= PEDOMETER_LOG_SIZE )
|
||||
{
|
||||
pedolog_overflow = true;
|
||||
NOP(); // ここに来るようだとバグ
|
||||
// NOP(); // ここに来るようだとバグ
|
||||
break;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
pool.vreg_c_ext.pedo_log[ p_record ] = 0;
|
||||
}
|
||||
hours -= 1;
|
||||
}
|
||||
while( hours != 0 );
|
||||
|
||||
return;
|
||||
}
|
||||
@ -389,16 +335,18 @@ void clear_hosu_hist()
|
||||
|
||||
|
||||
extern u8 iic_burst_state;
|
||||
bit record_read_msb_lsb;
|
||||
|
||||
bit pedolog_read_msb;
|
||||
/* ========================================================
|
||||
歩数計ヒストリ読み出しの後処理(初期化)
|
||||
読み出しポインタのクリア
|
||||
======================================================== */
|
||||
/* マクロにしました
|
||||
void hosu_read_end( )
|
||||
{
|
||||
record_read_msb_lsb = 0;
|
||||
pedolog_read_msb = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
@ -409,20 +357,19 @@ u8 hosu_read( )
|
||||
{
|
||||
u8 rv;
|
||||
static u8 p_record_buffer;
|
||||
static u8 dat_temp[6]; // 一応、アトミック処理に
|
||||
static st_calender cal_buff; // 一応、アトミック処理に
|
||||
|
||||
if( iic_burst_state == 0 )
|
||||
{
|
||||
p_record_buffer = p_record;
|
||||
p_record_buffer = p_record;
|
||||
DI();
|
||||
cal_buff = cal_log_latest;
|
||||
EI();
|
||||
}
|
||||
|
||||
if( iic_burst_state <= 5 )
|
||||
{
|
||||
rv = pedo_log_latest[ iic_burst_state ];
|
||||
if( iic_burst_state == LEDO_LOG_LATEST_YEAR ) // BCDに直さなきゃという失態
|
||||
{
|
||||
rv = btobcd( rv );
|
||||
}
|
||||
rv = *( (u8*)&cal_buff + iic_burst_state ); // あうあう
|
||||
iic_burst_state += 1;
|
||||
return( rv );
|
||||
}
|
||||
@ -431,7 +378,7 @@ u8 hosu_read( )
|
||||
u16 temp;
|
||||
// 16ビットで記録してあるのでばらして送る todo: もっと楽する方法があるんじゃ
|
||||
temp = pool.vreg_c_ext.pedo_log[ p_record_buffer ];
|
||||
if( record_read_msb_lsb == 0 )
|
||||
if( !pedolog_read_msb )
|
||||
{
|
||||
rv = (u8)( temp & 0x00FF );
|
||||
}
|
||||
@ -447,7 +394,7 @@ u8 hosu_read( )
|
||||
p_record_buffer -= 1;
|
||||
}
|
||||
}
|
||||
record_read_msb_lsb ^= 1;
|
||||
pedolog_read_msb ^= 1;
|
||||
return( rv );
|
||||
}
|
||||
|
||||
@ -462,64 +409,62 @@ u8 hosu_read( )
|
||||
======================================================== */
|
||||
const u16 DAYS_FROM_HNY[] = {
|
||||
0,
|
||||
0, 31, 31+28, 59+31, 90+30,
|
||||
120+31, 151+30, 181+31, 212+31, 243+30,
|
||||
273+31, 304+30 };
|
||||
31,
|
||||
31+28, // =59。 …3月0日は1月59日
|
||||
31+28+31,
|
||||
31+28+31+30,
|
||||
31+28+31+30+31,
|
||||
31+28+31+30+31+30,
|
||||
31+28+31+30+31+30+31,
|
||||
31+28+31+30+31+30+31+31,
|
||||
31+28+31+30+31+30+31+31+30,
|
||||
31+28+31+30+31+30+31+31+30+31,
|
||||
31+28+31+30+31+30+31+31+30+31+30
|
||||
};
|
||||
|
||||
u16 get_long_hour()
|
||||
static u16 get_long_hour()
|
||||
{
|
||||
u8 year = bcdtob( cal_temp.year_bcd );
|
||||
u8 month = bcdtob( cal_temp.month_bcd );
|
||||
u8 day = bcdtob( cal_temp.day_bcd );
|
||||
u8 hour = bcdtob( cal_temp.hour_bcd );
|
||||
u8 min_bcd = cal_temp.min_bcd; // 大小比較しかしないのでbcdのままでよい
|
||||
u8 sec_bcd = cal_temp.sec_bcd;
|
||||
u16 long_hour;
|
||||
u8 year_hex;
|
||||
u8 month_hex;
|
||||
u8 day_hex;
|
||||
u8 hour_hex;
|
||||
|
||||
u8 min;
|
||||
u8 sec;
|
||||
|
||||
// RWAIT = 1 を確認してから↓に進んで下さい
|
||||
year_hex = YEAR;
|
||||
month_hex = MONTH;
|
||||
day_hex = DAY;
|
||||
hour_hex = HOUR;
|
||||
min = MIN;
|
||||
sec = SEC;
|
||||
|
||||
RWAIT = 0;
|
||||
EI();
|
||||
|
||||
year_hex = bcdtob( year_hex );
|
||||
month_hex = bcdtob( month_hex );
|
||||
day_hex = bcdtob( day_hex );
|
||||
hour_hex = bcdtob( hour_hex );
|
||||
|
||||
// まず日数の部分
|
||||
long_hour = DAYS_FROM_HNY[ month_hex ];
|
||||
if(( ( year_hex & 0x03 ) == 0 ) && ( ( 3 <= month_hex )))
|
||||
long_hour = DAYS_FROM_HNY[ month -1 ]; // -1はインデックス合わせ
|
||||
if( is_leapyear(year) && ( 3 <= month ))
|
||||
{
|
||||
// 閏年で、閏日より後
|
||||
long_hour += 1;
|
||||
}
|
||||
long_hour += day_hex - 1;
|
||||
long_hour += day - 1;
|
||||
long_hour *= 24; // 日数→時間
|
||||
|
||||
long_hour += hour_hex;
|
||||
long_hour += hour;
|
||||
|
||||
if( ( min > vreg_ctr[ VREG_C_ACC_HOSU_HOUR_BOUNDARY ] )
|
||||
|| ( ( min >= vreg_ctr[ VREG_C_ACC_HOSU_HOUR_BOUNDARY ] )
|
||||
&& ( sec > vreg_ctr[ VREG_C_ACC_HOSU_HOUR_BOUNDARY_SEC ] ))
|
||||
// 時・分境界の前?後?
|
||||
if( ( min_bcd > vreg_ctr[ VREG_C_ACC_HOSU_HOUR_BOUNDARY ] )
|
||||
|| ( ( min_bcd >= vreg_ctr[ VREG_C_ACC_HOSU_HOUR_BOUNDARY ] )
|
||||
&& ( sec_bcd > vreg_ctr[ VREG_C_ACC_HOSU_HOUR_BOUNDARY_SEC ] ))
|
||||
)
|
||||
{
|
||||
return( long_hour );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( long_hour -1 ); // 1時間前に含める 注意:元旦の0時
|
||||
return( long_hour -1 ); // 1時間前に含める 注意:元旦で昨年扱いにするとき。-1 になる
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long my_sqrt(unsigned long x)
|
||||
|
||||
/* ========================================================
|
||||
軽量平方根。
|
||||
必要十分な精度で打ち切る
|
||||
======================================================== */
|
||||
static unsigned long my_sqrt(unsigned long x)
|
||||
{
|
||||
unsigned long s, t;
|
||||
|
||||
@ -540,3 +485,41 @@ unsigned long my_sqrt(unsigned long x)
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
二つの 前回呼ばれた時刻と、現在時刻の差分を求める。返るのはfill_hosu_hist_hours にそのまま渡せる
|
||||
======================================================== */
|
||||
static u16 calc_hours_spend( u8 year )
|
||||
{
|
||||
// 同じ年の内
|
||||
if( cal_log_latest.year_bcd == year )
|
||||
{
|
||||
if( now_longhour > last_hour_fny )
|
||||
{
|
||||
return( now_longhour - last_hour_fny );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( 0 ); // 同じ時間帯(と、巻き戻り。 どうなっても知らない)
|
||||
}
|
||||
}
|
||||
else if( cal_log_latest.year_bcd == ( year -1 ) )
|
||||
{
|
||||
// 年をまたいでいるとき
|
||||
return( ( ( 365 + ( is_firstyear(year) ? 1: 0 )) * 24 ) - last_hour_fny + now_longhour );
|
||||
}
|
||||
else if( cal_log_latest.year_bcd < year )
|
||||
{
|
||||
// 数年放置
|
||||
return( PEDOMETER_LOG_SIZE +1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// カレンダーが巻き戻るなど
|
||||
// ノーケアでよい…が、不定値というわけにもいかない
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,17 @@
|
||||
#define _pedo_
|
||||
|
||||
|
||||
|
||||
|
||||
// =========================================================
|
||||
void hosu_read_end( );
|
||||
extern bit pedolog_read_msb;
|
||||
|
||||
|
||||
|
||||
// =========================================================
|
||||
//void hosu_read_end( ); マクロ化
|
||||
#define hosu_read_end() pedolog_read_msb = 0
|
||||
|
||||
u8 hosu_read( );
|
||||
void fill_hosu_hist_hours( u16 );
|
||||
void clear_hosu_hist();
|
||||
|
@ -81,7 +81,8 @@ void tsk_misc( )
|
||||
PM互換レジスタへの書き込み
|
||||
ポーリングしかしてない。割り込み?
|
||||
======================================================== */
|
||||
if( !PM_IRQ_n ){
|
||||
if( !PM_IRQ_n )
|
||||
{
|
||||
renge_task_immed_add( tski_ntr_pmic_comm );
|
||||
// NOP();
|
||||
}
|
||||
@ -110,24 +111,28 @@ void tsk_misc( )
|
||||
======================================================== */
|
||||
void check_twl_vol_irq()
|
||||
{
|
||||
static u8 vol_level_twl_sent;
|
||||
static u8 mabiki;
|
||||
|
||||
if( !is_TWL )
|
||||
{
|
||||
return;
|
||||
// おしまい
|
||||
}
|
||||
|
||||
if( mabiki != 0 )
|
||||
{
|
||||
mabiki--;
|
||||
}
|
||||
else
|
||||
{
|
||||
mabiki = 6;
|
||||
|
||||
if( is_TWL )
|
||||
{
|
||||
if( vol_level_twl != vol_level_twl_readed )
|
||||
{
|
||||
set_irq( VREG_C_IRQ2, REG_BIT_SLIDE_VOL_ACROSS_TWL_BOUNDARY );
|
||||
}
|
||||
}
|
||||
return;
|
||||
// おしまい
|
||||
}
|
||||
|
||||
mabiki = 9; // 1フレームは開ける
|
||||
if( vol_level_twl != vol_level_twl_sent )
|
||||
{
|
||||
vol_level_twl_sent = vol_level_twl;
|
||||
set_irq( VREG_C_IRQ2, REG_BIT_SLIDE_VOL_ACROSS_TWL_BOUNDARY );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,8 +21,6 @@ extern bit twl_ver_read;
|
||||
extern bit cam_led_update;
|
||||
|
||||
extern bit vol_changed_by_twl;
|
||||
u8 vol_level_twl,vol_level_twl_readed; // SoC が最後に読んだVol値
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
@ -116,10 +114,6 @@ u8 vreg_twl_read( u8 phy_adrs )
|
||||
vreg_twl[ REG_TWL_INT_ADRS_IRQ ]= 0;
|
||||
return( temp );
|
||||
|
||||
case( REG_TWL_INT_ADRS_VOL ):
|
||||
vol_level_twl_readed = vol_level_twl; // TWLとスライダと不整合が起きないように
|
||||
return( vreg_twl[ REG_TWL_INT_ADRS_VOL ] );
|
||||
|
||||
case( REG_TWL_INT_ADRS_VER_INFO ):
|
||||
// set_irq( VREG_C_IRQ2, REG_BIT_TWL_VER_READ ); // 速度的に無理なので
|
||||
twl_ver_read = true;
|
||||
|
@ -2,9 +2,6 @@
|
||||
#define __vreg_twl__
|
||||
/* ========================================================================= */
|
||||
extern u8 vreg_twl[];
|
||||
extern u8 vol_level_twl,vol_level_twl_readed; // SoC が最後に読んだVol値
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -22,9 +22,9 @@ SubClock=None
|
||||
[Mapping]
|
||||
Count=0
|
||||
[Main]
|
||||
Geometry=52, 213, 1200, 858
|
||||
Window=Normal
|
||||
MDI_MAX=ON
|
||||
Geometry=110, 110, 1200, 858
|
||||
Window=Max
|
||||
MDI_MAX=OFF
|
||||
Button=ON
|
||||
Mode=Auto
|
||||
Trace=Uncond ON
|
||||
@ -78,9 +78,9 @@ Symbol Type=OFF
|
||||
Language=C
|
||||
Kanji=SJIS
|
||||
[Source]
|
||||
Geometry=410, 186, 600, 400
|
||||
Window=Max
|
||||
DispStart=30
|
||||
Geometry=212, 6, 902, 1043
|
||||
Window=Normal
|
||||
DispStart=11
|
||||
CaretPos=81,0
|
||||
Mode=Normal
|
||||
DispFile=
|
||||
@ -140,18 +140,18 @@ SaveStart=
|
||||
SaveEnd=
|
||||
Accumulative=ON
|
||||
[Source1]
|
||||
Geometry=25, 25, 600, 400
|
||||
Geometry=32, 50, 771, 1011
|
||||
Window=Normal
|
||||
DispStart=393
|
||||
CaretPos=442,5
|
||||
DispStart=453
|
||||
CaretPos=506,17
|
||||
Mode=Normal
|
||||
DispFile=\\tsclient\C\78k_data\yav-mcu-basara\trunk\vreg_ctr.c
|
||||
DispFile=\\tsclient\C\78k_data\yav-mcu-basara\trunk\pedo_alg_thre_det2.c
|
||||
Accumulative=ON
|
||||
[Assemble]
|
||||
Geometry=0, 0, 0, 0
|
||||
Window=Hide
|
||||
DispStart=847434752
|
||||
CaretPos=0,0
|
||||
Geometry=574, 49, 600, 400
|
||||
Window=Normal
|
||||
DispStart=802
|
||||
CaretPos=802,27
|
||||
Address1=
|
||||
Address2=
|
||||
Address3=
|
||||
@ -259,9 +259,9 @@ Destination=0
|
||||
[I/O Port]
|
||||
Line=0
|
||||
[Stack]
|
||||
Geometry=0, 0, 0, 0
|
||||
Window=Hide
|
||||
Boundary=0
|
||||
Geometry=1141, 319, 400, 300
|
||||
Window=Normal
|
||||
Boundary=13762687
|
||||
Mode=Proper
|
||||
[Sfr]
|
||||
Geometry=0, 0, 0, 0
|
||||
@ -822,9 +822,9 @@ L529=IICWL1
|
||||
L530=IICWH1
|
||||
L531=SVA1
|
||||
[Local Variable]
|
||||
Geometry=0, 0, 0, 0
|
||||
Window=Hide
|
||||
Boundary=0
|
||||
Geometry=1150, 803, 400, 300
|
||||
Window=Normal
|
||||
Boundary=13041851
|
||||
Mode=Proper
|
||||
[Trace View]
|
||||
Geometry=0, 0, 0, 0
|
||||
@ -965,17 +965,20 @@ Detail=OFF
|
||||
Last Name=
|
||||
Count=0
|
||||
[Variable]
|
||||
Geometry=0, 0, 0, 0
|
||||
Window=Hide
|
||||
Boundary=0
|
||||
Line=0
|
||||
Geometry=1110, 10, 440, 300
|
||||
Window=Normal
|
||||
Boundary=13762700
|
||||
0=+cal_log_latest,.,N,A,-,1
|
||||
1=.last_hour_fny,D,N,A,+,1
|
||||
2=.now_longhour,D,N,A,+,1
|
||||
Line=3
|
||||
[Quick Watch]
|
||||
0=
|
||||
1=
|
||||
2=
|
||||
3=
|
||||
4=
|
||||
5=
|
||||
0=cal_buff,P,A,1
|
||||
1=rv,P,A,1
|
||||
2=iic_burst_state,P,A,1
|
||||
3=now_longhour,P,A,1
|
||||
4=last_hour_fny,P,A,1
|
||||
5=cal_log_latest,P,A,1
|
||||
6=
|
||||
7=
|
||||
8=
|
||||
@ -990,11 +993,19 @@ Line=0
|
||||
Geometry=0, 0, 0, 0
|
||||
Window=Hide
|
||||
Width=150 30 200 100
|
||||
Name0=Swb00001
|
||||
Address0=vreg_ctr.c#_vreg_ctr_read+0x74
|
||||
Name0=Swb00003
|
||||
Address0=pedo_alg_thre_det2.c#_get_long_hour+0x7b
|
||||
Window0=ASM
|
||||
Status0=ON
|
||||
Count=1
|
||||
Name1=Swb00001
|
||||
Address1=pedo_alg_thre_det2.c#_hosu_increment_if_necessary+0x55
|
||||
Window1=ASM
|
||||
Status1=ON
|
||||
Name2=Swb00002
|
||||
Address2=pedo_alg_thre_det2.c#_calc_hours_spend+0x28
|
||||
Window2=ASM
|
||||
Status2=ON
|
||||
Count=3
|
||||
[Reset]
|
||||
Debugger=ON
|
||||
Symbol=OFF
|
||||
|
Loading…
Reference in New Issue
Block a user