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

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@421 013db118-44a6-b54f-8bf7-843cb86687b1
80 lines
2.0 KiB
C
80 lines
2.0 KiB
C
#ifndef _WIN32
|
|
|
|
#pragma SFR
|
|
#pragma NOP
|
|
#pragma HALT
|
|
#pragma STOP
|
|
|
|
#endif
|
|
|
|
#include "incs_loader.h"
|
|
#include "renge\renge.h"
|
|
#include "hal.h"
|
|
|
|
#include "pm.h"
|
|
|
|
#include "accero.h"
|
|
#include "adc.h"
|
|
#include "i2c_mcu.h"
|
|
#include "led.h"
|
|
|
|
|
|
/* ========================================================
|
|
ステータスレジスタ反映・割り込み
|
|
======================================================== */
|
|
void tsk_status( )
|
|
{
|
|
static u8 state_old; // ステータス変化検出→割り込み の為
|
|
u8 diff;
|
|
|
|
// 蓋開けチェック
|
|
set_bit( SHELL_OPEN, vreg_ctr[VREG_C_STATUS], REG_BIT_ST_SHELL_OPEN );
|
|
|
|
// ステータスレジスタ関係 → 割り込み //
|
|
// pm.c で、その場で行います。
|
|
// REG_BIT_LCD_ON/OFF
|
|
// REG_BIT_BL_ON/OFF
|
|
// REG_BIT_BT_DC_CONNECT/DISC
|
|
|
|
diff = (u8)( vreg_ctr[VREG_C_STATUS] ^ state_old );
|
|
if( diff != 0 )
|
|
{
|
|
state_old = vreg_ctr[VREG_C_STATUS];
|
|
|
|
if( system_status.pwr_state == ON )
|
|
{
|
|
if( diff & REG_BIT_BATT_CHARGE )
|
|
{
|
|
// 充電状態反映
|
|
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_BATT_CHARGE ) // set_irqを別々に呼ぶ方がコンパクト
|
|
{
|
|
set_irq( VREG_C_IRQ1, REG_BIT_BT_CHG_START );
|
|
}
|
|
else
|
|
{
|
|
set_irq( VREG_C_IRQ1, REG_BIT_BT_CHG_STOP );
|
|
}
|
|
}
|
|
}
|
|
|
|
if(( system_status.pwr_state == ON ) ||
|
|
( system_status.pwr_state == SLEEP )
|
|
)
|
|
{
|
|
if( diff & REG_BIT_ST_SHELL_OPEN )
|
|
{
|
|
// 蓋の開け閉め
|
|
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_ST_SHELL_OPEN )
|
|
{
|
|
set_irq( VREG_C_IRQ0, REG_BIT_SHELL_OPEN );
|
|
}
|
|
else
|
|
{
|
|
set_irq( VREG_C_IRQ0, REG_BIT_SHELL_CLOSE );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|