mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-06-18 16:45:33 -04:00

TSボードに書き込むと動作はしますが実機との差分で以下の不具合があります。 (ベースが10.10であり、E3実機専用版と言うことで) ・加速度センサが使用できません ・音量Volが上下反転しています git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@162 013db118-44a6-b54f-8bf7-843cb86687b1
104 lines
2.6 KiB
C
104 lines
2.6 KiB
C
/* ========================================================
|
|
MCU CTR BSR
|
|
2008,2009 nintendo
|
|
開発技術部 藤田
|
|
======================================================== */
|
|
|
|
|
|
// ========================================================
|
|
#include "incs_loader.h"
|
|
|
|
#include "WDT.h"
|
|
#include "rtc.h"
|
|
#include "pm.h"
|
|
#include "accero.h"
|
|
#include "led.h"
|
|
#include "adc.h"
|
|
|
|
|
|
// ========================================================
|
|
static void read_dipsw( );
|
|
|
|
|
|
// ========================================================
|
|
system_status_ system_status;
|
|
bit update;
|
|
|
|
|
|
u16 pool[256]; // アップデート時のワークエリア 兼 歩数計データ
|
|
/* ========================================================
|
|
本当のエントリ関数は loader.c にあります
|
|
======================================================== */
|
|
void main_loop( void )
|
|
{
|
|
|
|
// 電池投入時、ファームアップデート後のみ
|
|
RTC_init( ); // 内部でリブートか判定しています
|
|
|
|
renge_init( );
|
|
|
|
iic_mcu_start( );
|
|
EI( );
|
|
|
|
PM_init();
|
|
|
|
if( system_status.reboot )
|
|
{
|
|
#ifdef _PMIC_TWL_
|
|
if( RESET1_n )
|
|
#else
|
|
if( PM_chk_LDSW() != 0 )
|
|
#endif
|
|
{
|
|
system_status.pwr_state = ON_TRIG;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// リブート時は実行されない
|
|
system_status.pwr_state = OFF_TRIG;
|
|
}
|
|
|
|
#ifdef _PARRADIUM_
|
|
system_status.pwr_state = OFF;
|
|
#endif
|
|
vreg_ctr_init( );
|
|
vreg_twl_init( );
|
|
|
|
read_dipsw( ); // 特定スイッチで何かするか?
|
|
|
|
clear_hosu_hist(); // 履歴クリア
|
|
|
|
renge_task_interval_run_force = 1;
|
|
|
|
RTCIMK = 0; /* 割り込み(アラーム&インターバル)許可 */
|
|
|
|
// メインループ //
|
|
while( 1 )
|
|
{ // システムtick、または割り込みで廻ります。
|
|
WDT_Restart( );
|
|
renge_task_interval_run( ); // 内部で、システムtickまたは強制起動します
|
|
while( renge_task_interval_run_force != 0 )
|
|
{
|
|
renge_task_interval_run( );
|
|
}
|
|
WDT_Restart( );
|
|
while( renge_task_immed_run( ) != ERR_SUCCESS ); // ここのループが廻る度に実行されます
|
|
HALT( );
|
|
}
|
|
}
|
|
|
|
|
|
/* ========================================================
|
|
======================================================== */
|
|
static void read_dipsw( )
|
|
{
|
|
// ソフトディップスイッチ読み込み
|
|
// PU4 |= 0x03; // dip sw 0,1
|
|
system_status.dipsw0 = ( DIPSW_0 == 0 ) ? 0 : 1;
|
|
system_status.dipsw1 = ( DIPSW_1 == 0 ) ? 0 : 1;
|
|
// PU4 &= ~0x03;
|
|
}
|
|
|
|
|