Vol、SVR2にヒステリシスを付けた。

SVR2を一時的に64段階に(値が飛び飛びで0-0xFC)
BL_OFFコマンド時はウェイトを入れない(PWMが入る前にBL-ONしてシャットダウンの回避を修正)
互換性検証 100208リリース

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@95 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
fujita_ryohei 2010-02-08 05:12:32 +00:00
parent d88fef1e83
commit bc2d7dd805
10 changed files with 132 additions and 140 deletions

View File

@ -11,6 +11,10 @@
bit adc_updated;
u8 adc_raw_vol;
u8 adc_raw_dep;
#define INTERVAL_TSK_ADC 16
/* ========================================================
@ -64,49 +68,49 @@ void tsk_adc( )
if( system_status.pwr_state == ON )
{
// Tune ///////////////////////////////////////
#if 0
tune
// tune
if( abs( old_tune - vreg_ctr[VREG_TUNE] ) >= 4 )
{
old_tune = vreg_ctr[VREG_TUNE];
vreg_ctr[VREG_C_IRQ0] |= REG_BIT_VR_TUNE_CHANGE;
if( ( vreg_ctr[VREG_C_IRQ_MASK0] & REG_BIT_VR_TUNE_CHANGE ) == 0 )
// 似非ヒステリシスを付けて64段
static u8 old_value;
u8 temp;
if( abs( adc_raw_dep - old_value ) >= 2 )
{
IRQ0_ast;
}
}
vreg_ctr[ VREG_C_TUNE ] = ( adc_raw_dep & 0xFC );
old_value = adc_raw_dep;
#if 0
;
;
set_irq( VREG_C_IRQ0, REG_BIT_VR_TUNE_CHANGE );
#endif
vreg_ctr[ VREG_C_DBG1 ] = vreg_ctr[ VREG_C_TUNE ];
}
vreg_ctr[ VREG_C_DBG2 ] = adc_raw_dep; // dbg
}
// Volume /////////////////////////////////////
{
// 似非ヒステリシスを付けて64段
static u8 vol_old;
static u8 class_old;
static u8 hysterisis_vol;
u16 class;
u8 temp;
// // ヒステリシスを付けておく。上に抜けた場合に閾値を少し下げることにする
// hysterisis_vol = ( vol_old <= vreg_ctr[VREG_C_SND_VOL] )? 2: 0;
// vol_old = vreg_ctr[VREG_C_SND_VOL];
if( abs( adc_raw_vol - vol_old ) >= 2 )
{
temp = slider_to_codec[ adc_raw_vol / 4 ];
/*
class = ( vreg_ctr[VREG_C_SND_VOL] + hysterisis_vol ) / ( 256 / 8 ); // 32段の割り込み
if( class != class_old )
{
class_old = class;
set_irq( VREG_C_IRQ0, REG_BIT_VR_SNDVOL_CHANGE );
}
*/
// デバイスに伝える
if( sndvol_codec != vreg_ctr[VREG_C_SND_VOL] )
{
sndvol_codec = vreg_ctr[VREG_C_SND_VOL];
// DCPにも伝えておく
iic_mcu_write_a_byte( IIC_SLA_DCP, 0,
slider_to_codec[ sndvol_codec/4 ] );
// codecに伝える
iic_mcu_write_a_byte( IIC_SLA_CODEC, CODEC_REG_VOL,
slider_to_codec[ sndvol_codec/4 ] );
if( vreg_ctr[ VREG_C_SND_VOL ] != temp )
{
vol_old = adc_raw_vol;
// レジスタ更新
vreg_ctr[ VREG_C_SND_VOL ] = temp;
vreg_twl[ REG_TWL_INT_ADRS_VOL ] = adc_raw_vol / ( 256 / 32 ); // ←adc値でよい
// codecに伝える
iic_mcu_write_a_byte( IIC_SLA_CODEC, CODEC_REG_VOL, temp );
iic_mcu_write_a_byte( IIC_SLA_DCP, 0, temp ); // todo
set_irq( VREG_C_IRQ0, REG_BIT_VR_SNDVOL_CHANGE );
}
}
}
@ -212,18 +216,17 @@ case ( ADC_SEL_AMB_BRIT ):
case ( ADC_SEL_TUNE ):
hist_tune[index] = ADCRH;
#ifdef _MODEL_WM0_
vreg_ctr[ VREG_C_TUNE ] = 255 - getmean3( hist_tune );
adc_raw_dep = 255 - getmean3( hist_tune );
#else
vreg_ctr[ VREG_C_TUNE ] = getmean3( hist_tune );
adc_raw_dep = getmean3( hist_tune );
#endif
break;
case ( ADC_SEL_VOL ):
hist_snd_vol[index] = ADCRH;
vreg_ctr[VREG_C_SND_VOL] = getmean3( hist_snd_vol );
// TWL用レジスタの更新
vreg_twl[ REG_TWL_INT_ADRS_VOL ] = vreg_ctr[VREG_C_SND_VOL] / ( 256 / 32 ); // 8段の割り込み
// 割り込みはHorizonを通してコマンドを発行されるのを待てばよい
adc_raw_vol = getmean3( hist_snd_vol );
// TWL用レジスタ(32段)の更新。アトミックな処理として扱わないと不都合が。
/// 割り込みはHorizonを通してコマンドを発行されるのを待てばよい
break;
case ( ADC_SEL_BATT_TEMP ):
@ -240,7 +243,7 @@ case ( ADC_SEL_AMB_BRIT ):
// もっとまともな書き方がありそうだ
// if( ADS == ADC_SEL_BATT_DET ){b
// if( ADS == ADC_SEL_BATT_DET ){
if( ADS != ADC_SEL_BATT_TEMP )
{ // 電池判別は電源投入の一回のみ
ADS += 1; // 次のチャンネル

View File

@ -6,7 +6,7 @@
#define MCU_VER_MAJOR 0x00
#define MCU_VER_MINOR 0x0D
#define MCU_VER_MINOR 0x0E
#define _OVERCLOCK_
@ -17,8 +17,8 @@
//#define _PARRADIUM_
//#define _MODEL_TEG2_
//#define _MODEL_WM0_
#define _MODEL_TS0_
#define _MODEL_WM0_
//#define _MODEL_TS0_
//#define _MODEL_CTR_
//#define _SW_HOME_ENABLE_

View File

@ -357,17 +357,18 @@ SoC
vreg_ctr[ VREG_C_IRQ3 ] |= ( intset & ~vreg_ctr[ VREG_C_IRQ_MASK3 ] );
IRQ0_neg;
tot = 0;
while( !IRQ0 && ( ++tot != 0 ) ){;}
while( !IRQ0 && ( ++tot != 0 ) ){;} // 割り込みを入れ直す
IRQ0_ast;
}
}
// Write
wait_ms( 10 );
iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_BL, blset );
if( blset != 0x00 ){
// wait_ms( 10 );
if( blset != 0 ) // BLを付ける場合はウェイトを挟まないとPWMが来ておらず
/// シャットダウンすることがある
{
wait_ms( 10 );
}
iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_BL, blset );
return( ERR_SUCCESS ); // ここでは異常チェック不要
}
@ -507,7 +508,7 @@ err PM_sys_pow_on( )
wait_ms( 100 );
{ // CODEC 不定レジスタ初期化
u8 codec_reg_init[3] = { 0,0,0 };
iic_mcu_write( IIC_SLA_CODEC, CODEC_REG_PM, 3, codec_reg_init );
iic_mcu_write( IIC_SLA_CODEC, CODEC_REG_PM, 3, codec_reg_init );
}
*/
#else
@ -546,7 +547,7 @@ err PM_sys_pow_on( )
/*
{ // CODEC 不定レジスタ初期化
u8 codec_reg_init[3] = { 0,0,0 };
iic_mcu_write( IIC_SLA_CODEC, CODEC_REG_PM, 3, codec_reg_init );
iic_mcu_write( IIC_SLA_CODEC, CODEC_REG_PM, 3, codec_reg_init );
}
*/
#endif
@ -780,6 +781,16 @@ task_status_immed ntr_pmic_comm( )
}
}
// テストコード ↓ //
// バックライト設定
/// 今のところさらに細かくは分けないけど…
if( ( reg_shadow & ( REG_BIT_TWL_REQ_BL_U | REG_BIT_TWL_REQ_BL_U ) ) == 0 )
{
// vreg_ctr[ VREG_C_COMMAND2 ] = ( REG_BIT_CMD_BL_U_OFF | REG_BIT_CMD_BL_U_OFF );
// renge_task_immed_add( tski_PM_BL_set );
}
// offリクエスト //////////////////////////////////////
if( ( reg_shadow & REG_BIT_TWL_REQ_OFF_REQ ) != 0 )
{
@ -799,8 +810,11 @@ task_status_immed ntr_pmic_comm( )
// バックライトをマスクして書き戻す
EI( );
reg_shadow &= ~( REG_BIT_TWL_REQ_OFF_REQ | REG_BIT_TWL_REQ_RST_REQ );
iic_mcu_write_a_byte( IIC_SLA_CODEC, CODEC_REG_PM, reg_shadow );
if( ( reg_shadow & ( REG_BIT_TWL_REQ_OFF_REQ | REG_BIT_TWL_REQ_RST_REQ )) != 0 )
{
reg_shadow &= ~( REG_BIT_TWL_REQ_OFF_REQ | REG_BIT_TWL_REQ_RST_REQ );
iic_mcu_write_a_byte( IIC_SLA_CODEC, CODEC_REG_PM, reg_shadow );
}
return ( ERR_FINISED );
}

View File

@ -51,7 +51,7 @@ void tsk_debug2( )
*/
str[3] = vreg_ctr[ VREG_C_DBG1 ];
str[2] = vreg_ctr[ VREG_C_DBG2 ];
str[1] = vreg_ctr[ VREG_C_DBG3 ];
str[1] = vreg_ctr[ VREG_C_IRQ2 ];
// str[1] = MIN;
str[0] = SEC;

View File

@ -36,7 +36,7 @@
// VREG_C_IRQ0
//#define REG_BIT_VR_SNDVOL_CHANGE ( 1 << 7 )
#define REG_BIT_VR_SNDVOL_CHANGE ( 1 << 7 )
#define REG_BIT_SHELL_OPEN ( 1 << 6 )
#define REG_BIT_SHELL_CLOSE ( 1 << 5 )
#define REG_BIT_SW_WIFI_CLICK ( 1 << 4 )

View File

@ -1,26 +1,8 @@
C:\WINDOWS\system32\cmd.exe /c touch magic.c
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -quvjl3wt -sainter_asm -zp -no pm.c
pm.c(167) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(178) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(182) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(233) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(270) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(349) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(357) : CC78K0R warning W0401: Conversion may lose significant digits
pm.c(839) : CC78K0R warning W0401: Conversion may lose significant digits
Compilation complete, 0 error(s) and 8 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\pm.asm
Assembly complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -quvjl3wt -sainter_asm -zp -no magic.c
Compilation complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\magic.asm
Assembly complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -quvjl3wt -sainter_asm -zp -no task_misc.c
task_misc.c(48) : CC78K0R warning W0401: Conversion may lose significant digits
task_misc.c(34) : CC78K0R warning W0401: Conversion may lose significant digits
Compilation complete, 0 error(s) and 2 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\task_misc.asm
Assembly complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\lk78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -obsr.lmf "..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r\s0rm.rel" -go85h,0FC00h,1024 -gi0FFFFFFFFFFFFFFFFFFFFh -pbsr_k0r.map -nkd -kp -gb7EFBFFh -b"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib" -bcl0rdm.lib -bcl0rm.lib -bcl0rmf.lib -i"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r" -dbsr_mcu.dr -s -w0 loader.rel pm.rel i2c_ctr.rel main.rel magic.rel WDT.rel i2c_mcu.rel i2c_twl.rel ini_VECT.rel led.rel rtc.rel vreg_ctr.rel vreg_twl.rel adc.rel renge.rel accero.rel self_flash.rel reboot.rel sw.rel task_debug.rel task_misc.rel task_sys.rel
Link complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\oc78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -o.\bsr.hex -nu -ki bsr.lmf
@ -31,4 +13,4 @@ intel-HEX to bsr bin converter
file converted!
Build Total error(s) : 0 Total warning(s) : 10
Build Total error(s) : 0 Total warning(s) : 0

View File

@ -23,7 +23,7 @@ SubClock=None
Count=0
[Main]
Geometry=65, 39, 1467, 1110
Window=Max
Window=Normal
MDI_MAX=OFF
Button=ON
Mode=Auto
@ -80,8 +80,8 @@ Kanji=SJIS
[Source]
Geometry=155, 80, 1012, 920
Window=Normal
DispStart=68
CaretPos=69,0
DispStart=46
CaretPos=95,0
Mode=Normal
DispFile=
Address1=
@ -142,8 +142,8 @@ Accumulative=ON
[Assemble]
Geometry=605, 2, 600, 400
Window=Normal
DispStart=1262
CaretPos=1262,27
DispStart=685
CaretPos=685,27
Address1=
Address2=
Address3=
@ -858,43 +858,34 @@ Count=0
Geometry=1232, 6, 354, 910
Window=Normal
Boundary=13762700
0=.iic_mcu_busy,P,N,A,+,1
1=.tx_buf,P,N,A,+,1
2=.new_task,P,N,A,+,1
3=.if2h,P,S,A,+,1
4=+pool,P,N,A,-,1
5=.new_task,P,N,A,+,1
6=.vreg_ctr,P,N,A,+,1
7=.cmd_BL,P,N,A,+,1
8=.P7,B,S,A,+,1
9=.p5,B,S,A,+,1
Line=10
0=.adc_raw_vol,P,N,A,+,1
1=.vol_old,P,N,A,+,1
2=.vol,P,N,A,+,1
3=.direction,P,N,A,+,1
4=.temp,P,N,A,+,1
Line=5
[Quick Watch]
0=vreg_twl,P,A,1
1=pm0,P,A,1
2=data,P,A,1
3=P5.3,P,A,1
4=p4.3,P,A,1
5=pu0,P,A,1
6=p5,B,A,1
7=P7,B,A,1
8=cmd_BL,P,A,1
9=vreg_ctr,P,A,1
10=pool,P,A,1
11=if2,P,A,1
12=if2h,P,A,1
13=new_task,P,A,1
14=tx_buf,P,A,1
15=iic_mcu_busy,P,A,1
0=pu0,P,A,1
1=p5,B,A,1
2=P7,B,A,1
3=cmd_BL,P,A,1
4=vreg_ctr,P,A,1
5=pool,P,A,1
6=if2,P,A,1
7=if2h,P,A,1
8=new_task,P,A,1
9=tx_buf,P,A,1
10=iic_mcu_busy,P,A,1
11=adc_raw_vol,P,A,1
12=direction,P,A,1
13=vol,P,A,1
14=temp,P,A,1
15=vol_old,P,A,1
[Software Break]
Geometry=1204, 674, 500, 428
Window=Normal
Width=150 30 200 100
Name0=Swb00001
Address0=vreg_twl.c#_vreg_twl_read+0x6e
Window0=ASM
Status0=ON
Count=1
Count=0
[Reset]
Debugger=ON
Symbol=OFF

View File

@ -743,11 +743,6 @@ Include27=reboot.h
Include28=sw.h
Include29=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h
Include30=batt_params.h
[ToolSet]
ToolSetName=(•ĎŤX)78K0R Software Package V1.10
Tool1=CC78K0R|W2.10
Tool2=RA78K0R|W1.31
Tool3=ID78K0R-QB|V3.60
[Options.LK78K0R 0]
Version=100
O0=bsr_k0r.lmf
@ -1040,3 +1035,8 @@ DefaultMode2=1
DefaultMode3=1
DefaultMode4=1
DefaultMode5=1
[ToolSet]
ToolSetName=(•ĎŤX)78K0R Software Package V1.10
Tool1=CC78K0R|W2.10
Tool2=RA78K0R|W1.31
Tool3=ID78K0R-QB|V3.60

View File

@ -1,14 +1,16 @@
[ProjectManager]
FrameMax=0
FrameX=64
FrameY=122
FrameX=26
FrameY=50
FrameCX=1299
FrameCY=1044
OpenFile1=renge\renge.h,0,502,637,1746,1394,29,16,29,0
OpenFile2=ProjectWindow
OpenFile2=pm.c,0,154,154,1133,791,0,792,0,0
OpenFile3=adc.c,0,132,132,1111,769,34,98,34,0
OpenFile4=ProjectWindow
PrjPos=0,2,754,3,253
OpenFile3=config.h,0,22,22,1001,659,21,21,29,0
OpenFile4=OutputWindow
OpenFile5=config.h,0,284,54,1263,691,29,9,29,0
OpenFile6=OutputWindow
OutputPos=0,421,829,388,1497
ActivePRJ=yav_mcu_bsr.prj
[ProjectWindow]

View File

@ -1,7 +1,7 @@
[SdbInfo]
Ver=5
[loader.c]
T=4b67cfc9
T=4b68f956
1=incs_loader.h
2=fsl.h
3=fsl_user.h
@ -11,7 +11,7 @@ T=4b67cfc9
7=rtc.h
8=reboot.h
[pm.c]
T=4b667a4d
T=4b6ba554
1=incs.h
2=adc.h
3=led.h
@ -19,11 +19,11 @@ T=4b667a4d
5=renge\renge.h
6=batt_params.h
[i2c_ctr.c]
T=4b60e64a
T=4b690471
1=incs.h
2=accero.h
[main.c]
T=4b677175
T=4b68d913
1=incs_loader.h
2=WDT.h
3=rtc.h
@ -32,7 +32,7 @@ T=4b677175
6=led.h
7=adc.h
[magic.c]
T=4b67eda0
T=4b6bde17
1=config.h
[WDT.c]
T=4afd21ca
@ -42,7 +42,7 @@ T=4b0bae4b
1=incs.h
2=i2c_mcu.h
[i2c_twl.c]
T=4b60e5e8
T=4b6a657d
1=incs.h
2=i2c_twl_defs.h
[ini_VECT.c]
@ -53,10 +53,10 @@ T=4b4438bb
1=incs.h
2=led.h
[rtc.c]
T=4b4438a1
T=4b6a6fa4
1=incs.h
[vreg_ctr.c]
T=4b66ac04
T=4b6b8339
1=incs.h
2=vreg_ctr.h
3=rtc.h
@ -66,14 +66,14 @@ T=4b66ac04
7=..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h
8=fsl_user.h
[vreg_twl.c]
T=4b667aab
T=4b6907de
1=incs.h
2=jhl_defs.h
3=vreg_twl.h
4=vreg_ctr.h
5=renge\renge_task_intval.h
[adc.c]
T=4b66954e
T=4b6bd936
1=incs.h
2=adc.h
3=pm.h
@ -88,7 +88,7 @@ T=4b5d73b9
6=user_define.h
7=bsr_system.h
[accero.c]
T=4b66b29e
T=4b6a666a
1=incs.h
2=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h
[self_flash.c]
@ -110,13 +110,13 @@ T=4b4d6c9b
6=pm.h
7=rtc.h
[task_debug.c]
T=4b663267
T=4b6bc508
1=incs.h
2=renge\renge.h
3=pm.h
4=accero.h
[task_misc.c]
T=4b663267
T=4b6a6fb1
1=incs.h
2=renge\renge.h
3=pm.h
@ -146,9 +146,9 @@ T=4b25f1a9
T=4b023fdb
1=config.h
[user_define.h]
T=4b66880a
T=4b690aa2
[config.h]
T=4b67f2af
T=4b6bde15
[bsr_system.h]
T=4b3064de
[renge\renge.h]
@ -161,7 +161,7 @@ T=4b32f836
T=4b42ee65
1=renge\renge_defs.h
[vreg_ctr.h]
T=4b667aa5
T=4b6bc3cc
1=config.h
[loader.h]
T=4afd21ca
@ -177,9 +177,9 @@ T=4afd21cb
[i2c_ctr.h]
T=4afd21cb
[pm.h]
T=4b42e71f
T=4b68df75
[rtc.h]
T=4b161be1
T=4b6a6fa4
[adc.h]
T=4b25ee1e
1=jhl_defs.h
@ -197,7 +197,7 @@ T=4b25e780
8=rtc.h
9=accero.h
[vreg_twl.h]
T=4afd21cb
T=4b690471
[accero.h]
T=4b66ac04
1=jhl_defs.h