ctr_mcu/trunk/led_cam.c
n2232 92d54aae94 2.06
sreg,calltを積極的に使うよう、コンパイルオプション変更など
未使用変数削除


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

152 lines
2.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************//**
LED_Cam TO02
\n BLINK,*_PLUSE の時は、1周期分は必ずその状態になります。
\n その間に OFF→BLINK などされると、OFFが無視されます。
*********************************************************/
#ifndef _WIN32
#pragma sfr
#endif
#include "incs.h"
#include "led.h"
// ========================================================
static u8 state_led_cam = 0;
static u16 task_interval;
bit cam_led_update;
// ========================================================
static void cam_led_twl();
extern void DI_wt_chk();
// ========================================================
// インターバル実行タスクと、twlレジスタへの書き込みのカ所から
// 呼ばれます。
void tsk_led_cam( )
{
DI_wt_chk(); // レジスタへの書き込みで強制起動がかかることがあるため
if( !cam_led_update )
{
if( task_interval != 0 )
{
task_interval --;
return;
EI();
}
}
cam_led_update = false; // TWL のブリンク設定(一発だけ点灯)のため
EI();
if( system_status.pwr_state == SLEEP ) // sleep中、強制消灯
{
LED_CAM = 0;
state_led_cam = 0;
}
else
{
// ブリンクのように待たせたいとき以外は毎週起動する
// (レジスタの変更にすぐに反応する)
switch ( vreg_ctr[VREG_C_LED_CAM] )
{
case ( CAM_LED_OFF ):
default:
LED_CAM = 0;
state_led_cam = 0;
break;
case ( CAM_LED_ON ):
LED_CAM = 1;
state_led_cam = 0;
break;
case ( CAM_LED_BLINK ):
if( state_led_cam == 0 )
{
LED_CAM = 1;
state_led_cam = 1;
}
else
{
LED_CAM = 0;
state_led_cam = 0;
}
task_interval = 250;
break;
case ( CAM_LED_ON_PLUSE ):
if( state_led_cam == 0 )
{
LED_CAM = 1;
state_led_cam = 1;
task_interval = 250;
}
else
{
vreg_ctr[VREG_C_LED_CAM] = CAM_LED_OFF;
}
break;
case ( CAM_LED_OFF_PLUSE ):
if( state_led_cam == 0 )
{
LED_CAM = 0;
state_led_cam = 1;
task_interval = 250;
}
else
{
vreg_ctr[VREG_C_LED_CAM] = CAM_LED_ON;
}
break;
case( CAM_LED_BY_TWL ):
cam_led_twl();
}
} // if( system_status.pwr_state == sleep ) ... else ...
}
static void cam_led_twl()
{
// TWL互換 //
switch ( vreg_twl[ REG_TWL_INT_ADRS_CAM ] ){
case( TWL_CAMLED_OFF ):
LED_CAM = 0;
state_led_cam = 0;
break;
case( TWL_CAMLED_BLINK ):
if( state_led_cam == 0 )
{
LED_CAM = 1;
state_led_cam = 1;
}
else
{
LED_CAM = 0;
state_led_cam = 0;
}
task_interval = (u8)( 600 / SYS_INTERVAL_TICK ) + 250;
break;
case( TWL_CAMLED_ON ):
case( TWL_CAMLED_DEF_ON ):
default:
LED_CAM = 1;
state_led_cam = 1;
break;
}
}