mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-06-19 00:55:37 -04:00
91 lines
2.2 KiB
C
91 lines
2.2 KiB
C
#pragma SFR
|
|
#pragma NOP
|
|
#pragma HALT
|
|
#pragma STOP
|
|
|
|
#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
|
|
|
|
|
|
|
|
/* ========================================================
|
|
ステータスレジスタなど
|
|
======================================================== */
|
|
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 )
|
|
{
|
|
// 充電状態に以下略
|
|
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;
|
|
}
|
|
|