mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-10-31 13:51:10 -04:00
・歩数計部分の加速度onと歩数計onビットが間違えていた件
→互換製のため仕様書を変更(accero.c) ・TypeTではWDT時にFCRAM RESET をかけてしまうのを回避できない 暴走してしまうのでリセットをかける(loader.c) ・バッテリパラメータ整理(白箱向け削除)(pm.c) ・MCUリブート時にLEDがフェードインしてたのを修正(led.c) ・リブート判定をミスっていたところを修正(main.c) ・リブートフラグを消すのを忘れていた。(task_sys.c) git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@118 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
parent
5d608354b9
commit
033a70af66
@ -45,8 +45,8 @@
|
|||||||
#define ACC_BITS_ALL_AXIS_ON 7
|
#define ACC_BITS_ALL_AXIS_ON 7
|
||||||
|
|
||||||
|
|
||||||
#define VREG_BITMASK_ACC_CONF_ACQ ( 1 << 1 )
|
#define VREG_BITMASK_ACC_CONF_ACQ ( 1 << 0 )
|
||||||
#define VREG_BITMASK_ACC_CONF_HOSU ( 1 << 0 )
|
#define VREG_BITMASK_ACC_CONF_HOSU ( 1 << 1 )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,33 @@ enum BATT_VENDER {
|
|||||||
|
|
||||||
|
|
||||||
static const u8 BT_PARAM[][64] = {
|
static const u8 BT_PARAM[][64] = {
|
||||||
{ // ID = 0 Panasonic
|
// ID = 0 GND 白箱
|
||||||
|
/// パラメータ無し
|
||||||
|
{ // ID = 1 120 ohm
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
},
|
||||||
|
{ // ID = 2 360 hom
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
},
|
||||||
|
{ // ID = 3 750 ohm
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
},
|
||||||
|
{ // ID = 4 1.3kohm
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
},
|
||||||
|
{ // ID = 5 2.7kohm パナ
|
||||||
0xAD, 0x30, 0xAE, 0x70, 0xB0, 0x00, 0xB3, 0x00,
|
0xAD, 0x30, 0xAE, 0x70, 0xB0, 0x00, 0xB3, 0x00,
|
||||||
0xB4, 0x70, 0xB5, 0xA0, 0xB7, 0x80, 0xBA, 0x00,
|
0xB4, 0x70, 0xB5, 0xA0, 0xB7, 0x80, 0xBA, 0x00,
|
||||||
|
|
||||||
@ -27,43 +53,13 @@ static const u8 BT_PARAM[][64] = {
|
|||||||
0x0C, 0xF0, 0x08, 0xC0, 0x08, 0xB0, 0x07, 0xF0,
|
0x0C, 0xF0, 0x08, 0xC0, 0x08, 0xB0, 0x07, 0xF0,
|
||||||
0x0B, 0x00, 0x05, 0xD0, 0x02, 0x00, 0x09, 0x00
|
0x0B, 0x00, 0x05, 0xD0, 0x02, 0x00, 0x09, 0x00
|
||||||
},
|
},
|
||||||
{
|
{ // ID = 6 8.2kohm
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
},
|
},
|
||||||
{
|
{ // ID = 7 マクセル
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
||||||
},
|
|
||||||
{ // ID = 7 Maxell
|
|
||||||
0xAD, 0x30, 0xAE, 0x70, 0xB0, 0x00, 0xB3, 0x00,
|
0xAD, 0x30, 0xAE, 0x70, 0xB0, 0x00, 0xB3, 0x00,
|
||||||
0xB4, 0x70, 0xB5, 0xA0, 0xB7, 0x80, 0xBA, 0x00,
|
0xB4, 0x70, 0xB5, 0xA0, 0xB7, 0x80, 0xBA, 0x00,
|
||||||
|
|
||||||
|
|||||||
@ -73,6 +73,12 @@ void LED_init( )
|
|||||||
TS0 = 0b0000000011101111; // “®<E2809C>ìŠJŽn
|
TS0 = 0b0000000011101111; // “®<E2809C>ìŠJŽn
|
||||||
|
|
||||||
TDR00 = LED_BRIGHT_MAX - 1; // 10bit, ŽüŠú
|
TDR00 = LED_BRIGHT_MAX - 1; // 10bit, ŽüŠú
|
||||||
|
|
||||||
|
if( system_status.reboot )
|
||||||
|
{
|
||||||
|
vreg_ctr[VREG_C_LED_POW] = LED_POW_ILM_AUTO;
|
||||||
|
LED_duty_pow_H = LED_BRIGHT_MAX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -72,14 +72,19 @@ void main( )
|
|||||||
WDT_Restart( );
|
WDT_Restart( );
|
||||||
if( RTCEN )
|
if( RTCEN )
|
||||||
{
|
{
|
||||||
system_status.reboot = 1;
|
system_status.reboot = 1;
|
||||||
}
|
}
|
||||||
else if( ( RESF & 0x10 ) != 0) // WDRF,WDTでリセット
|
else if( ( RESF & 0x10 ) != 0) // WDRF,WDTでリセット
|
||||||
{
|
{
|
||||||
system_status.reboot = 1;
|
system_status.reboot = 1;
|
||||||
vreg_ctr[ VREG_C_MCU_STATUS ] |= REG_BIT_STATUS_WDT_RESET;
|
#ifdef _PMIC_TWL_
|
||||||
set_irq( VREG_C_IRQ0, REG_BIT_IRQ_WDT_RESET );
|
// 暴走してしまうので再起動させる
|
||||||
hdwinit2( );
|
PM_reset_ast();
|
||||||
|
#else
|
||||||
|
vreg_ctr[ VREG_C_MCU_STATUS ] |= REG_BIT_STATUS_WDT_RESET;
|
||||||
|
set_irq( VREG_C_IRQ0, REG_BIT_IRQ_WDT_RESET );
|
||||||
|
#endif
|
||||||
|
hdwinit2( );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -44,16 +44,12 @@ void main_loop( void )
|
|||||||
|
|
||||||
if( system_status.reboot )
|
if( system_status.reboot )
|
||||||
{
|
{
|
||||||
// システムの電源が入りっぱなしだったら、
|
#ifdef _PMIC_TWL_
|
||||||
// マイコンだけが再起動したのだ
|
|
||||||
// todo
|
|
||||||
#ifdef _MCU_BSR_
|
|
||||||
if( RESET1_n )
|
if( RESET1_n )
|
||||||
#else
|
#else
|
||||||
if( PM_chk_LDSW() != 0 )
|
if( PM_chk_LDSW() != 0 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
vreg_ctr[VREG_C_LED_POW] = LED_POW_ILM_AUTO;
|
|
||||||
system_status.pwr_state = ON_TRIG;
|
system_status.pwr_state = ON_TRIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,11 @@
|
|||||||
#include "renge.h"
|
#include "renge.h"
|
||||||
|
|
||||||
#include "batt_params.h"
|
#include "batt_params.h"
|
||||||
|
|
||||||
|
#include <fsl.h>
|
||||||
|
#include "fsl_user.h"
|
||||||
|
extern u16 pool[];
|
||||||
|
|
||||||
// ========================================================
|
// ========================================================
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +87,7 @@ void PM_init( )
|
|||||||
|
|
||||||
// 電池メーカーの識別
|
// 電池メーカーの識別
|
||||||
BT_DET_P = 1;
|
BT_DET_P = 1;
|
||||||
temp = ( u8 ) ( get_adc( ADC_SEL_BATT_DET ) >> 5 );
|
temp = ( u8 ) ( ( get_adc( ADC_SEL_BATT_DET ) >> 5 ) -1 ); // 識別値0の白箱の分、インデックス合わせ
|
||||||
BT_DET_P = 0;
|
BT_DET_P = 0;
|
||||||
|
|
||||||
iic_mcu_set_wo_dma( );
|
iic_mcu_set_wo_dma( );
|
||||||
@ -921,3 +926,5 @@ task_status_immed tski_PM_BL_set()
|
|||||||
|
|
||||||
return( ERR_SUCCESS );
|
return( ERR_SUCCESS );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ extern task_status_immed acc_read();
|
|||||||
extern task_status_immed acc_write();
|
extern task_status_immed acc_write();
|
||||||
extern task_status_immed tski_mcu_info_read();
|
extern task_status_immed tski_mcu_info_read();
|
||||||
//extern task_status_immed acc_hosu_set();
|
//extern task_status_immed acc_hosu_set();
|
||||||
|
extern task_status_immed tski_mcu_reset();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -161,7 +161,11 @@ err firm_update( )
|
|||||||
|
|
||||||
!= FSL_OK )
|
!= FSL_OK )
|
||||||
{
|
{
|
||||||
FSL_Close( );
|
// 書き込み後のチェックエラー
|
||||||
|
// リブートののち、リストア
|
||||||
|
FSL_ForceReset(); // リセット
|
||||||
|
// FSL_SwapBootCluster( );
|
||||||
|
// FSL_Close( );
|
||||||
return ( ERR_ERR );
|
return ( ERR_ERR );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,8 +204,11 @@ err firm_update( )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FSL_Close( );
|
// データエラー
|
||||||
firm_restore( );
|
// リブートののち、リストア
|
||||||
|
FSL_ForceReset(); // リセット
|
||||||
|
// FSL_SwapBootCluster( );
|
||||||
|
// FSL_Close( );
|
||||||
// 戻ってこない //
|
// 戻ってこない //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,6 +239,7 @@ err firm_restore( )
|
|||||||
|
|
||||||
// リブート
|
// リブート
|
||||||
// スワップは不要です!
|
// スワップは不要です!
|
||||||
|
// FSL_SwapBootCluster();
|
||||||
FSL_ForceReset( );
|
FSL_ForceReset( );
|
||||||
return ( ERR_SUCCESS );
|
return ( ERR_SUCCESS );
|
||||||
}
|
}
|
||||||
@ -263,6 +271,10 @@ static void FSL_Open( void )
|
|||||||
while( DST1 ){;}
|
while( DST1 ){;}
|
||||||
DEN1 = 0;
|
DEN1 = 0;
|
||||||
|
|
||||||
|
MK0 = 0xFFFF;
|
||||||
|
MK1 = 0xFFFF;
|
||||||
|
MK2 = 0xFFFF;
|
||||||
|
|
||||||
FSL_FLMD0_HIGH; // フラッシュ書き替え許可
|
FSL_FLMD0_HIGH; // フラッシュ書き替え許可
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +360,10 @@ static err firm_duplicate( __far u8 * p_rom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1ブロック書き込み完了。内部電圧チェックを行う
|
// 1ブロック書き込み完了。内部電圧チェックを行う
|
||||||
while( FSL_IVerify( target_block ) != FSL_OK ){;}
|
while( FSL_IVerify( target_block ) != FSL_OK ){
|
||||||
|
// todo
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return( ERR_SUCCESS );
|
return( ERR_SUCCESS );
|
||||||
|
|
||||||
@ -372,3 +387,16 @@ static err my_FSL_Init()
|
|||||||
return( ERR_SUCCESS );
|
return( ERR_SUCCESS );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
task_status_immed tski_mcu_reset()
|
||||||
|
{
|
||||||
|
// 普通に再起動
|
||||||
|
my_FSL_Init();
|
||||||
|
FSL_Close( );
|
||||||
|
// FSL_SwapBootCluster();
|
||||||
|
FSL_ForceReset(); // リセット
|
||||||
|
|
||||||
|
// 保険? //
|
||||||
|
WDTE = 0xAA; // WDTで再起動(テスト向け)
|
||||||
|
return( ERR_SUCCESS ); // no reach
|
||||||
|
}
|
||||||
|
|||||||
@ -142,6 +142,7 @@ void tsk_sys( )
|
|||||||
MK2L = ~INT_MSK2_WIFI_TX_KE3;
|
MK2L = ~INT_MSK2_WIFI_TX_KE3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
system_status.reboot = 0;
|
||||||
system_status.pwr_state = ON;
|
system_status.pwr_state = ON;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -277,26 +277,19 @@ void vreg_ctr_write( u8 adrs, u8 data )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ( VREG_C_COMMAND3 ):
|
case ( VREG_C_COMMAND3 ):
|
||||||
|
vreg_ctr[adrs] = data;
|
||||||
switch ( data )
|
switch ( data )
|
||||||
{
|
{
|
||||||
case ( 'r' ): // マイコン再起動
|
case ( 'r' ):
|
||||||
|
// 割り込みルーチンからFSLライブラリを呼ぶのは禁止のため
|
||||||
|
// renge_task_immed_add( tski_mcu_reset );
|
||||||
|
// break;
|
||||||
|
|
||||||
|
case ( 'w' ):
|
||||||
|
// WDTで再起動(テスト向け)
|
||||||
WDTE = 0xAA;
|
WDTE = 0xAA;
|
||||||
|
|
||||||
DI( );
|
|
||||||
RTCE = 0;
|
|
||||||
while( DST1 ){;}
|
|
||||||
DEN1 = 0;
|
|
||||||
FSL_FLMD0_HIGH; // フラッシュ書き替え許可
|
|
||||||
FSL_Init( pool ); // ライブラリ初期化。割り込み中断考慮せず
|
|
||||||
FSL_ModeCheck( ); // ライトプロテクトチェック。失敗することを考慮せず
|
|
||||||
FSL_ForceReset(); // リセット
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
vreg_ctr[adrs] = data;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user