mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-10-31 13:51:10 -04:00
音量muteにならないことがあったようなので遊びを増やした
i2c_m無限ループの可能性があった i2c_m排他フラグの管理で割り込み禁止忘れ volatileなレジスタをif~elseで評価していたのを修正 電池残量ICのためのウエイトを削除(不要なようでした) 一部の無駄なマクロを展開 長押しoffの時間の計算を間違えていた(誤差の蓄積が無視できなくなった) フラグチェック→レジスタへの反映 をアトミックに TWLソフトで一瞬画面が暗くなる(スリープ?)が改善するか? vol32のビットのミラーを正式追加 twlの電源フラグを間違えていた ×充電中 → ○アダプタ有り git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@177 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
parent
477cbf231d
commit
2ec0a7b270
16
trunk/adc.c
16
trunk/adc.c
@ -50,14 +50,14 @@ extern void nop8();
|
||||
// max -15db
|
||||
const u8 slider_to_codec[64] =
|
||||
{
|
||||
127, 127, 127, 126, 125, 124, 123, 122,
|
||||
121, 120, 119, 118, 117, 116, 115, 114,
|
||||
113, 112, 111, 110, 109, 108, 107, 106,
|
||||
105, 104, 103, 102, 101, 100, 99, 98,
|
||||
97, 96, 95, 94, 93, 92, 91, 90,
|
||||
89, 88, 87, 86, 85, 84, 83, 82,
|
||||
81, 80, 79, 78, 77, 76, 75, 74,
|
||||
73, 72, 71, 70, 69, 68, 67, 66
|
||||
127, 127, 127, 127, 127, 126, 125, 123,
|
||||
122, 121, 120, 119, 118, 117, 116, 115,
|
||||
114, 113, 112, 110, 109, 108, 107, 106,
|
||||
105, 104, 103, 102, 101, 100, 99, 97,
|
||||
96, 95, 94, 93, 92, 91, 90, 89,
|
||||
88, 87, 86, 85, 84, 83, 82, 81,
|
||||
80, 79, 78, 77, 76, 75, 74, 73,
|
||||
71, 70, 69, 68, 67, 66, 66, 66
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@ -83,13 +83,24 @@ void nop8()
|
||||
|
||||
static err iic_mcu_is_ready()
|
||||
{
|
||||
iic_mcu_start( );
|
||||
u16 tot = 0;
|
||||
|
||||
while( iic_mcu_busy )
|
||||
iic_mcu_start( );
|
||||
while( 1 )
|
||||
{
|
||||
NOP( );
|
||||
DI();
|
||||
if( !iic_mcu_busy )
|
||||
{
|
||||
iic_mcu_busy = 1;
|
||||
break;
|
||||
}
|
||||
EI();
|
||||
if( ++tot == 0 )
|
||||
{
|
||||
return( ERR_ERR );
|
||||
}
|
||||
}
|
||||
iic_mcu_busy = 1;
|
||||
EI();
|
||||
return( ERR_SUCCESS );
|
||||
}
|
||||
|
||||
@ -256,7 +267,7 @@ err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat )
|
||||
if( iic_mcu_call_slave( SLA ) != 0 )
|
||||
{
|
||||
iic_mcu_busy = 0;
|
||||
return ( ERR_NAK );
|
||||
return ( ERR_NOSLAVE );
|
||||
}
|
||||
iic_mcu_send_a_byte( adrs );
|
||||
iic_mcu_send_a_byte( dat );
|
||||
@ -299,8 +310,7 @@ err iic_mcu_write( u8 slave, u8 adrs, u8 len, void * src )
|
||||
if( iic_mcu_call_slave( slave ) != 0 )
|
||||
{
|
||||
iic_mcu_busy = 0;
|
||||
EI( );
|
||||
return ( ERR_NAK );
|
||||
return ( ERR_NOSLAVE );
|
||||
}
|
||||
|
||||
IICIF10 = 0;
|
||||
|
||||
@ -103,7 +103,7 @@ __interrupt void int_iic_twl( )
|
||||
{
|
||||
u8 my_iics;
|
||||
|
||||
wait_next; // 1バイト受信完了を待つ
|
||||
wait_next; // 1バイト受信完了を待つ
|
||||
|
||||
my_iics = IICS;
|
||||
IICAIF = 0;
|
||||
@ -111,7 +111,7 @@ __interrupt void int_iic_twl( )
|
||||
if( my_iics & 0x02 ) // ( STD && !SPD )
|
||||
{
|
||||
// スタートコンディションがきた
|
||||
if( !TRC ) // 送信方向フラグ 0:マイコンが受信
|
||||
if( ( my_iics & 0x08 ) == 0 ) // ( TRC ) 送信方向フラグ 0:マイコンが受信
|
||||
{
|
||||
// ①’マイコンが応答できず、TWLがリトライしたときとか
|
||||
// ここに来るのはスレーブ呼び出しの時 //
|
||||
@ -127,7 +127,7 @@ __interrupt void int_iic_twl( )
|
||||
state = DATA_READED;
|
||||
}
|
||||
}
|
||||
else if( ( my_iics & 0x03 ) == 0 ) // !STD && !SPD )
|
||||
else if( ( my_iics & 0x03 ) == 0 ) // ( !STD && !SPD )
|
||||
{
|
||||
// 何らか受信
|
||||
rcvd = IICA;
|
||||
|
||||
@ -55,7 +55,6 @@ void main_loop( void )
|
||||
BT_DET_P = 1; // チャージに時間が掛かるので、先に上げておく
|
||||
BT_TEMP_P = 1;
|
||||
iic_mcu_start( );
|
||||
wait_ms( 100 );
|
||||
BT_init( ); // 実機やバッテリの判定、電池残量ICの設定
|
||||
system_status.pwr_state = ON_TRIG;
|
||||
}
|
||||
|
||||
14
trunk/pm.c
14
trunk/pm.c
@ -81,8 +81,6 @@ err PM_LCD_on( )
|
||||
// BSR //
|
||||
void PM_LCD_off()
|
||||
{
|
||||
u8 temp;
|
||||
|
||||
SND_DEPOP_SND_MUTE;
|
||||
|
||||
// BLついてたら消す
|
||||
@ -658,8 +656,16 @@ void tsk_batt( )
|
||||
|
||||
// 充電 //
|
||||
// →割り込み。miscの中でよろしくやってくれている。
|
||||
set_bit( !BT_CHG_n, vreg_ctr[VREG_C_STATUS], REG_BIT_BATT_CHARGE );
|
||||
LED_CHARGE = !BT_CHG_n ? 1 : 0;
|
||||
if( !BT_CHG_n )
|
||||
{
|
||||
set_bit( 1, vreg_ctr[VREG_C_STATUS], REG_BIT_BATT_CHARGE );
|
||||
LED_CHARGE = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_bit( 0, vreg_ctr[VREG_C_STATUS], REG_BIT_BATT_CHARGE );
|
||||
LED_CHARGE = 0;
|
||||
}
|
||||
|
||||
// 電池残量 //
|
||||
if( system_status.pwr_state == ON )
|
||||
|
||||
@ -11,10 +11,10 @@ extern bit SW_pow_mask;
|
||||
|
||||
#ifdef _FORCE_OFF_1SEC_
|
||||
#define HOLD_THREASHOLD (u8)( 800 / INTERVAL_TSK_SW )
|
||||
#define FORCEOFF_THREASHOLD (u8)( 1000 / INTERVAL_TSK_SW / 6 )
|
||||
#define FORCEOFF_THREASHOLD (u8)( 1200 / INTERVAL_TSK_SW /10 )
|
||||
#else
|
||||
#define HOLD_THREASHOLD (u8)( 2000 / INTERVAL_TSK_SW )
|
||||
#define FORCEOFF_THREASHOLD (u8)( 4000 / INTERVAL_TSK_SW / 6 )
|
||||
#define FORCEOFF_THREASHOLD (u8)( 4000 / INTERVAL_TSK_SW /10 )
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -38,7 +38,9 @@ void tsk_status( )
|
||||
}
|
||||
|
||||
// 蓋開けチェック
|
||||
DI();
|
||||
set_bit( SHELL_OPEN, vreg_ctr[VREG_C_STATUS], REG_BIT_ST_SHELL_OPEN );
|
||||
EI();
|
||||
|
||||
// ステータスレジスタ関係 → 割り込み //
|
||||
// pm.c で、その場で行います。
|
||||
|
||||
@ -76,7 +76,6 @@ void tsk_sys( )
|
||||
BT_DET_P = 1; // チャージに時間が掛かるので、先に上げておく
|
||||
BT_TEMP_P = 1;
|
||||
iic_mcu_start( );
|
||||
wait_ms( 100 );
|
||||
BT_init( ); // 実機やバッテリの判定、電池残量ICの設定
|
||||
|
||||
if( system_status.poweron_reason == EXT_POWER )
|
||||
@ -299,7 +298,6 @@ void tsk_sys( )
|
||||
{
|
||||
if( !bt_status_old ){
|
||||
iic_mcu_start( );
|
||||
wait_ms( 100 );
|
||||
BT_init( ); // 実機やバッテリの判定、電池残量ICの設定
|
||||
}
|
||||
bt_status_old = 1;
|
||||
|
||||
@ -357,7 +357,9 @@ u8 vreg_ctr_read( u8 adrs )
|
||||
}
|
||||
else if( adrs == VREG_C_MCU_STATUS )
|
||||
{
|
||||
return( vreg_ctr[ VREG_C_MCU_STATUS ] | ( ( vreg_twl[ REG_TWL_INT_ADRS_MODE ] & 0x03 ) << 6 ) );
|
||||
return( vreg_ctr[ VREG_C_MCU_STATUS ] |
|
||||
( ( vreg_twl[ REG_TWL_INT_ADRS_MODE ] & 0x03 ) << 6 ) | // sys_mode
|
||||
( ( vreg_twl[ REG_TWL_INT_ADRS_MODE ] & 0x80 ) >> 2 )); // vol32
|
||||
}
|
||||
else if( adrs == VREG_C_ACC_HOSU_HIST )
|
||||
{
|
||||
|
||||
@ -51,7 +51,7 @@ void vreg_twl_write( u8 adrs, u8 data )
|
||||
}
|
||||
|
||||
case ( REG_TWL_INT_ADRS_MODE ):
|
||||
vreg_twl[ REG_TWL_INT_ADRS_MODE ] = ( data & 0x83 );
|
||||
vreg_twl[ REG_TWL_INT_ADRS_MODE ] = ( data & 0x83 ); // [8]vol32 [1:0]nand
|
||||
break;
|
||||
|
||||
case ( REG_TWL_INT_ADRS_CAM ):
|
||||
@ -117,8 +117,7 @@ u8 vreg_twl_read( u8 phy_adrs )
|
||||
}else{
|
||||
vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x00;
|
||||
}
|
||||
|
||||
return( vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] | ( !BT_CHG_n ? 0x80: 0x00 ) ); // アダプタbit
|
||||
return( vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] | ( !PM_EXTDC_n ? 0x80: 0x00 ) ); // アダプタbit(アダプタ有無)
|
||||
|
||||
case( REG_TWL_INT_ADRS_IRQ ):
|
||||
temp = vreg_twl[ REG_TWL_INT_ADRS_IRQ ];
|
||||
|
||||
@ -6,12 +6,17 @@ magic.c(10) : CC78K0R warning W0871: Data aligned after 'MGC_LOAD'in 'MGC_LOAD s
|
||||
Compilation complete, 0 error(s) and 3 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 -qvjl2wt -sainter_asm -zpb -w2 -no sw.c
|
||||
sw.c(100) : CC78K0R warning W0760: Double and long double are treated as IEEE 754 single format
|
||||
sw.c(164) : CC78K0R warning W0851: Data aligned in '@@DATA section'
|
||||
sw.c(164) : CC78K0R warning W0851: Data aligned in '@@INIT section'
|
||||
Compilation complete, 0 error(s) and 3 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\sw.asm
|
||||
"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 -qvjl2wt -sainter_asm -zpb -w2 -no renge\renge.c
|
||||
renge\renge.c(131) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(168) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(169) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(187) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(219) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(219) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(333) : CC78K0R warning W0714: Too many register variables
|
||||
renge\renge.c(43) : CC78K0R warning W0851: Data aligned in '@@DATA section'
|
||||
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\renge.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 -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 led.rel rtc.rel vreg_ctr.rel vreg_twl.rel adc.rel renge.rel accero.rel self_flash.rel sw.rel task_debug.rel task_misc.rel task_sys.rel pedo_alg_thre_det2.rel ini_VECT.rel task_status.rel
|
||||
Link complete, 0 error(s) and 0 warning(s) found.
|
||||
@ -23,4 +28,4 @@ intel-HEX to bsr bin converter
|
||||
file converted!
|
||||
|
||||
|
||||
Build Total error(s) : 0 Total warning(s) : 6
|
||||
Build Total error(s) : 0 Total warning(s) : 11
|
||||
|
||||
Loading…
Reference in New Issue
Block a user