ctr_mcu/snake_branches/2.2F_CLOSER_DP1_Prewrite/task_status.c
N2925 635e1ad13e snake_tags/2.2F_CLOSER_DP1 を snake_branches/2.2F_CLOSER_DP1_Prewrite へ移動
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@569 013db118-44a6-b54f-8bf7-843cb86687b1
2013-09-11 06:46:58 +00:00

90 lines
2.1 KiB
C

/* ********************************************************
一部のステータスレジスタを更新、必要に応じて割り込みを入れます。
$Id: task_status.c 462 2012-06-13 05:44:19Z n2232 $
********************************************************* */
#ifndef _WIN32
#pragma SFR
#pragma NOP
#pragma HALT
#pragma STOP
#endif
#include "incs_loader.h"
#include "renge\renge.h"
#include "pm.h"
#include "accero.h"
#include "adc.h"
#include "i2c_mcu.h"
#include "led.h"
/********************************************//**
ステータスレジスタの、
- 蓋開閉
で割り込みが必要であれば発生させます。
todo: 統合?
***********************************************/
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
// REG_BIT_BT_CHG_START/STOP
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( is_bt_charging ) // 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( is_shell_open )
{
set_irq( VREG_C_IRQ0, REG_BIT_SHELL_OPEN );
}
else
{
set_irq( VREG_C_IRQ0, REG_BIT_SHELL_CLOSE );
}
}
}
}
}