ctr_mcu/branches/sim/task_status.c
n2232 33808e9a92 まず、vcでコンパイルが通るようにifdefや書き方を変えるなど。
VC 2010 Express でとりあえずビルドできます。
とりあえず実機上でも動いてる

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@345 013db118-44a6-b54f-8bf7-843cb86687b1
2011-06-20 04:13:39 +00:00

99 lines
2.3 KiB
C

#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"
// ========================================================
#define INTERVAL_TSK_STATUS 4
extern bit BT_CHG_STAT_Change;
/* ========================================================
ステータスレジスタなど
======================================================== */
void tsk_status( )
{
static u8 interval_task_status = 0;
static u8 state_old; // ステータス変化検出→割り込み の為
u8 diff;
if( interval_task_status != 0 )
{
interval_task_status -= 1;
return;
}
else
{
interval_task_status = (u8)( INTERVAL_TSK_STATUS / SYS_INTERVAL_TICK );
}
// 蓋開けチェック
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 )
{
BT_CHG_STAT_Change = true;
// 充電状態に以下略
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_BATT_CHARGE )
{
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 );
}
}
}
}
return;
}