From 2ec0a7b270830ec833f280e9b3f009188500623e Mon Sep 17 00:00:00 2001 From: N2232 Date: Wed, 26 May 2010 09:12:31 +0000 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E9=87=8Fmute=E3=81=AB=E3=81=AA?= =?UTF-8?q?=E3=82=89=E3=81=AA=E3=81=84=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=82=88=E3=81=86=E3=81=AA=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E9=81=8A=E3=81=B3=E3=82=92=E5=A2=97=E3=82=84=E3=81=97=E3=81=9F?= =?UTF-8?q?=20i2c=5Fm=E7=84=A1=E9=99=90=E3=83=AB=E3=83=BC=E3=83=97?= =?UTF-8?q?=E3=81=AE=E5=8F=AF=E8=83=BD=E6=80=A7=E3=81=8C=E3=81=82=E3=81=A3?= =?UTF-8?q?=E3=81=9F=20i2c=5Fm=E6=8E=92=E4=BB=96=E3=83=95=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E7=AE=A1=E7=90=86=E3=81=A7=E5=89=B2=E3=82=8A?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E7=A6=81=E6=AD=A2=E5=BF=98=E3=82=8C=20volati?= =?UTF-8?q?le=E3=81=AA=E3=83=AC=E3=82=B8=E3=82=B9=E3=82=BF=E3=82=92if?= =?UTF-8?q?=EF=BD=9Eelse=E3=81=A7=E8=A9=95=E4=BE=A1=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?=E9=9B=BB=E6=B1=A0=E6=AE=8B=E9=87=8FIC=E3=81=AE=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AE=E3=82=A6=E3=82=A8=E3=82=A4=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4(=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=A7=E3=81=97=E3=81=9F)=20=E4=B8=80=E9=83=A8?= =?UTF-8?q?=E3=81=AE=E7=84=A1=E9=A7=84=E3=81=AA=E3=83=9E=E3=82=AF=E3=83=AD?= =?UTF-8?q?=E3=82=92=E5=B1=95=E9=96=8B=20=E9=95=B7=E6=8A=BC=E3=81=97off?= =?UTF-8?q?=E3=81=AE=E6=99=82=E9=96=93=E3=81=AE=E8=A8=88=E7=AE=97=E3=82=92?= =?UTF-8?q?=E9=96=93=E9=81=95=E3=81=88=E3=81=A6=E3=81=84=E3=81=9F=EF=BC=88?= =?UTF-8?q?=E8=AA=A4=E5=B7=AE=E3=81=AE=E8=93=84=E7=A9=8D=E3=81=8C=E7=84=A1?= =?UTF-8?q?=E8=A6=96=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9F=EF=BC=89=20=E3=83=95=E3=83=A9=E3=82=B0=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E2=86=92=E3=83=AC=E3=82=B8=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=81=B8=E3=81=AE=E5=8F=8D=E6=98=A0=20=E3=82=92?= =?UTF-8?q?=E3=82=A2=E3=83=88=E3=83=9F=E3=83=83=E3=82=AF=E3=81=AB=20?= =?UTF-8?q?=E3=80=80TWL=E3=82=BD=E3=83=95=E3=83=88=E3=81=A7=E4=B8=80?= =?UTF-8?q?=E7=9E=AC=E7=94=BB=E9=9D=A2=E3=81=8C=E6=9A=97=E3=81=8F=E3=81=AA?= =?UTF-8?q?=E3=82=8B=EF=BC=88=E3=82=B9=E3=83=AA=E3=83=BC=E3=83=97=EF=BC=9F?= =?UTF-8?q?=EF=BC=89=E3=81=8C=E6=94=B9=E5=96=84=E3=81=99=E3=82=8B=E3=81=8B?= =?UTF-8?q?=EF=BC=9F=20vol32=E3=81=AE=E3=83=93=E3=83=83=E3=83=88=E3=81=AE?= =?UTF-8?q?=E3=83=9F=E3=83=A9=E3=83=BC=E3=82=92=E6=AD=A3=E5=BC=8F=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=20twl=E3=81=AE=E9=9B=BB=E6=BA=90=E3=83=95=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=82=92=E9=96=93=E9=81=95=E3=81=88=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=80=80=C3=97=E5=85=85=E9=9B=BB=E4=B8=AD=E3=80=80?= =?UTF-8?q?=E2=86=92=E3=80=80=E2=97=8B=E3=82=A2=E3=83=80=E3=83=97=E3=82=BF?= =?UTF-8?q?=E6=9C=89=E3=82=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- trunk/adc.c | 16 ++++++++-------- trunk/i2c_mcu.c | 24 +++++++++++++++++------- trunk/i2c_twl.c | 6 +++--- trunk/main.c | 1 - trunk/pm.c | 14 ++++++++++---- trunk/sw.h | 4 ++-- trunk/task_status.c | 2 ++ trunk/task_sys.c | 2 -- trunk/vreg_ctr.c | 4 +++- trunk/vreg_twl.c | 5 ++--- trunk/yav_mcu_bsr.plg | 19 ++++++++++++------- 11 files changed, 59 insertions(+), 38 deletions(-) diff --git a/trunk/adc.c b/trunk/adc.c index 39db695..c373f68 100644 --- a/trunk/adc.c +++ b/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 diff --git a/trunk/i2c_mcu.c b/trunk/i2c_mcu.c index 0737763..71fb41a 100644 --- a/trunk/i2c_mcu.c +++ b/trunk/i2c_mcu.c @@ -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; diff --git a/trunk/i2c_twl.c b/trunk/i2c_twl.c index 62120db..637c272 100644 --- a/trunk/i2c_twl.c +++ b/trunk/i2c_twl.c @@ -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; diff --git a/trunk/main.c b/trunk/main.c index 116888e..92201ff 100644 --- a/trunk/main.c +++ b/trunk/main.c @@ -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; } diff --git a/trunk/pm.c b/trunk/pm.c index e5119c3..a2da155 100644 --- a/trunk/pm.c +++ b/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 ) diff --git a/trunk/sw.h b/trunk/sw.h index 1ad7d4c..656e326 100644 --- a/trunk/sw.h +++ b/trunk/sw.h @@ -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 diff --git a/trunk/task_status.c b/trunk/task_status.c index a502dc4..a17da2a 100644 --- a/trunk/task_status.c +++ b/trunk/task_status.c @@ -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 で、その場で行います。 diff --git a/trunk/task_sys.c b/trunk/task_sys.c index a232bd2..4d9067d 100644 --- a/trunk/task_sys.c +++ b/trunk/task_sys.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; diff --git a/trunk/vreg_ctr.c b/trunk/vreg_ctr.c index 9b97c83..5adc08f 100644 --- a/trunk/vreg_ctr.c +++ b/trunk/vreg_ctr.c @@ -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 ) { diff --git a/trunk/vreg_twl.c b/trunk/vreg_twl.c index f0dc490..87542cd 100644 --- a/trunk/vreg_twl.c +++ b/trunk/vreg_twl.c @@ -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 ]; diff --git a/trunk/yav_mcu_bsr.plg b/trunk/yav_mcu_bsr.plg index 2112441..5ac57bf 100644 --- a/trunk/yav_mcu_bsr.plg +++ b/trunk/yav_mcu_bsr.plg @@ -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