/* ======================================================== 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" #include "pool.h" // ======================================================== system_status_ system_status; uni_pool pool; bit force_off; #ifdef i2c_timeout_test bit i2c_mcu_time_out_error; // I2Cが何らかで詰まった。結露など含む。 extern void i2c_mcu_error_monitor(); #endif /* ======================================================== 本当のエントリ関数は loader.c にあります ======================================================== */ void main_loop( void ) { #ifdef i2c_timeout_test i2c_mcu_time_out_error = false; #endif // HALデバッグリセット vreg_ctr[ VREG_C_HAL_OVW_CONT0 ] = 0; vreg_ctr[ VREG_C_HAL_OVW_CONT1 ] = 0; vreg_ctr[ VREG_C_HAL_OVW_TEMPERATURE ] = 0xFF; vreg_ctr[ VREG_C_HAL_OVW_BT_FUEL ] = 0xFF; vreg_ctr[ VREG_C_HAL_OVW_BT_VOLTAGE ] = 0xFF; hal_update(); // 電池投入時、ファームアップデート後のみ RTC_init( ); // 内部でリブートか判定しています renge_init( ); iic_mcu_start( ); EI( ); BT_chk(); system_status.pwr_state = OFF_TRIG; if( system_status.reboot ) { // リブート時は電源onに上書き if( PM_chk_LDSW() != 0 ) { system_status.pwr_state = ON_TRIG; } vreg_ctr[VREG_C_BT_REMAIN] = 100; } vreg_ctr_init( ); clear_hosu_hist(); // 履歴クリア renge_task_interval_run_force = true; RTCIMK = 0; /* 割り込み(アラーム&インターバル)許可 */ // メインループ // while( 1 ) { // システムtick、または割り込みで廻ります。 renge_task_interval_run( ); // 内部で、システムtickまたは強制起動します renge_task_immed_run(); #ifdef i2c_timeout_test if( i2c_mcu_time_out_error ) { i2c_mcu_error_monitor(); } #endif HALT( ); } }