mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-10-31 13:51:10 -04:00
過去3つのうちの、中間のデータを返す という関数のバグ修正(for ADC)
RF TXの監視の仕様変更(割り込み使わない) 電源offのトラップを削除 git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@17 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
parent
50a1948303
commit
8bcafd8793
32
trunk/adc.c
32
trunk/adc.c
@ -137,34 +137,30 @@ void tsk_adc( )
|
||||
======================================================== */
|
||||
static u8 getmean3( u8 * hist )
|
||||
{
|
||||
u8 temp;
|
||||
|
||||
// ちょっと並び替え
|
||||
if( *hist < *( hist + 1 ) )
|
||||
if( *hist > *( hist + 1 ) )
|
||||
{
|
||||
temp = *hist;
|
||||
*hist = *( hist + 1 );
|
||||
*( hist + 1 ) = temp;
|
||||
}
|
||||
|
||||
if( !( *hist > *( hist + 1 ) ) )
|
||||
{
|
||||
return *hist;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( *( hist + 1 ) > *( hist + 2 ) )
|
||||
if( *hist > *( hist + 2 ) )
|
||||
{
|
||||
return *( hist + 1 );
|
||||
return( ( *( hist + 1 ) > *( hist + 2 ) ) ? *( hist + 1 ) : *( hist + 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return *( hist + 2 );
|
||||
return( *hist );
|
||||
}
|
||||
}else{
|
||||
if( *hist > *( hist + 2 ) )
|
||||
{
|
||||
return( *hist );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( ( *( hist + 1 ) < *( hist + 2 ) ) ? *( hist + 1 ) : *( hist + 2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
自前で次のチャンネル
|
||||
一通り終わったら止める
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
#pragma interrupt INTP5 intp5_shell // SHELL_CLOSE, ただし電源offから起こすのみ。通常はポーリング
|
||||
#pragma interrupt INTP6 intp6_PM_irq // CODEC経由で旧PMICへのコマンド書き込み
|
||||
|
||||
#ifdef _MCU_BSR_
|
||||
#pragma interrupt INTP21 intp21_RFTx // 電波送信パルス
|
||||
#else
|
||||
#pragma interrupt INTP7 intp21_RFTx
|
||||
#endif
|
||||
//#ifdef _MCU_BSR_ // 割り込みそのものは使いません
|
||||
//#pragma interrupt INTP21 intp21_RFTx // 電波送信パルス
|
||||
//#else
|
||||
//#pragma interrupt INTP7 intp21_RFTx
|
||||
//#endif
|
||||
|
||||
#ifdef _MCU_BSR_
|
||||
#pragma interrupt INTP23 intp23_ACC_ready // 加速度センサ、データ準備完了
|
||||
@ -115,6 +115,16 @@ __interrupt void fn_intp3( )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__interrupt void intp21_RFTx( )
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
NOP();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//__interrupt void fn_intp4(){ while(1){} } // pm.c
|
||||
//__interrupt void fn_intp5(){ while(1){} } // pm.c
|
||||
//__interrupt void fn_intp6(){ while(1){} } // pm.c
|
||||
|
||||
50
trunk/led.c
50
trunk/led.c
@ -30,10 +30,6 @@ static void led_pow_hotaru( );
|
||||
|
||||
|
||||
|
||||
// ========================================================
|
||||
u8 wifi_TX;
|
||||
|
||||
|
||||
// ========================================================
|
||||
static const char MSG_MAIL[] = { 0b11110110, 0b11011010, 0b01101110, 0b10010100 };
|
||||
#define MSG_SPD 60
|
||||
@ -299,8 +295,8 @@ static void led_pow_hotaru( )
|
||||
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
* 割り込みそのものは使いません *
|
||||
LED_Wifi 3
|
||||
2 P24 (未)
|
||||
======================================================== */
|
||||
@ -309,6 +305,8 @@ void tsk_led_wifi( )
|
||||
static u8 task_interval;
|
||||
static u8 remain_wifi_tx;
|
||||
static u8 state_wifi_tx;
|
||||
static u8 flag_wifi_TX;
|
||||
|
||||
|
||||
if( task_interval != 0 )
|
||||
{
|
||||
@ -316,11 +314,26 @@ void tsk_led_wifi( )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 送信パルスのラッチ
|
||||
if( vreg_ctr[VREG_C_LED_WIFI] == WIFI_LED_TXAUTO )
|
||||
{
|
||||
if( WIFI_txLatch )
|
||||
{
|
||||
WIFI_txLatch = 0;
|
||||
flag_wifi_TX = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag_wifi_TX = 0;
|
||||
}
|
||||
|
||||
|
||||
switch ( vreg_ctr[VREG_C_LED_WIFI] )
|
||||
{
|
||||
case ( WIFI_LED_OFF ):
|
||||
LED_duty_WiFi = 0;
|
||||
wifi_TX = 0;
|
||||
state_wifi_tx = 0;
|
||||
remain_wifi_tx = 0;
|
||||
LED_WIFI_2 = 0;
|
||||
@ -329,7 +342,6 @@ void tsk_led_wifi( )
|
||||
case ( WIFI_LED_ON ):
|
||||
default:
|
||||
LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
|
||||
wifi_TX = 0;
|
||||
state_wifi_tx = 0;
|
||||
remain_wifi_tx = 0;
|
||||
LED_WIFI_2 = 1;
|
||||
@ -337,14 +349,9 @@ void tsk_led_wifi( )
|
||||
|
||||
case ( WIFI_LED_TXAUTO ):
|
||||
// 短いパルスを捕まえるために、割り込みフラグを見る
|
||||
if( wifi_TX != 0 )
|
||||
{
|
||||
wifi_TX = 0;
|
||||
remain_wifi_tx = 2;
|
||||
}
|
||||
|
||||
// 送信パターン
|
||||
if( remain_wifi_tx != 0 )
|
||||
if( flag_wifi_TX != 0 )
|
||||
{ // TX active
|
||||
switch ( state_wifi_tx )
|
||||
{
|
||||
@ -362,7 +369,7 @@ void tsk_led_wifi( )
|
||||
if( state_wifi_tx == 32 )
|
||||
{
|
||||
state_wifi_tx = 0;
|
||||
remain_wifi_tx--;
|
||||
flag_wifi_TX -= 1;
|
||||
}
|
||||
task_interval = 22;
|
||||
return;
|
||||
@ -378,6 +385,7 @@ void tsk_led_wifi( )
|
||||
break;
|
||||
|
||||
case ( WIFI_LED_PTN0 ):
|
||||
// ゆっくりバースト
|
||||
LED_WIFI_2 = 1;
|
||||
switch ( state_wifi_tx )
|
||||
{
|
||||
@ -396,9 +404,9 @@ void tsk_led_wifi( )
|
||||
}
|
||||
task_interval = 50;
|
||||
return;
|
||||
break;
|
||||
|
||||
case ( WIFI_LED_PTN1 ):
|
||||
// データテーブルに従って点滅
|
||||
LED_WIFI_2 = 1;
|
||||
{
|
||||
u8 dat;
|
||||
@ -443,22 +451,12 @@ void tsk_led_wifi( )
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************//**
|
||||
wifi_TXピン割り込み
|
||||
\n LED点滅のフラグ操作のみ
|
||||
\n 実際の点滅などは tsk_led_wifi で行う
|
||||
*********************************************************/
|
||||
__interrupt void intp21_RFTx( )
|
||||
{
|
||||
wifi_TX = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************//**
|
||||
LED_Cam TO02
|
||||
|
||||
10
trunk/led.h
10
trunk/led.h
@ -16,6 +16,16 @@
|
||||
|
||||
#define LED_BRIGHT_MAX 0x00FF
|
||||
|
||||
|
||||
// ====================================
|
||||
#ifdef _MCU_BSR_ // 電波送信パルス
|
||||
#define WIFI_txLatch PIF21
|
||||
#else
|
||||
#define WIFI_txLatch PIF7
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// ====================================
|
||||
enum LED_ILUM_MODE
|
||||
{
|
||||
|
||||
@ -261,13 +261,6 @@ err renge_task_immed_run(){
|
||||
for( task_id = 0; task_id < IMMED_RSV_TASKS_NUM; task_id += 1 ){
|
||||
if( tasks_immed[ task_id ] != 0 ){
|
||||
if( tasks_immed[ task_id ]() == ERR_FINISED ){
|
||||
// トラップ
|
||||
if( system_status.pwr_state == OFF_TRIG ){
|
||||
u8 i = 0;
|
||||
while( i == 0 ){
|
||||
NOP();
|
||||
}
|
||||
}
|
||||
DI();
|
||||
renge_task_immed_del( task_id );
|
||||
EI();
|
||||
|
||||
@ -179,10 +179,16 @@ void tsk_debug2( )
|
||||
|
||||
if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) )
|
||||
{
|
||||
/*
|
||||
str[3] = vreg_ctr[ VREG_C_FREE0 ];
|
||||
str[2] = vreg_ctr[ VREG_C_FREE1 ];
|
||||
str[1] = vreg_ctr[ VREG_C_STATUS ];
|
||||
str[0] = vreg_ctr[ VREG_C_RTC_SEC ];
|
||||
*/
|
||||
str[3] = vreg_ctr[ VREG_C_IRQ1 ];
|
||||
str[2] = vreg_ctr[ VREG_C_IRQ2 ];
|
||||
str[1] = vreg_ctr[ VREG_C_IRQ3 ];
|
||||
str[0] = vreg_ctr[ VREG_C_STATUS ];
|
||||
|
||||
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_IRQ1 ] );
|
||||
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, boot_ura );
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
C:\WINDOWS\system32\cmd.exe /c echo touch magic.c
|
||||
touch magic.c
|
||||
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -qcvjl1wt -sainter_asm -zp -no led.c
|
||||
led.c(422) : CC78K0R warning W0401: Conversion may lose significant digits
|
||||
Compilation complete, 0 error(s) and 1 warning(s) found.
|
||||
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\led.asm
|
||||
Assembly complete, 0 error(s) and 0 warning(s) found.
|
||||
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\lk78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -obsr.lmf "..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r\s0rm.rel" -go85h,0FC00h,1024 -gi0FFFFFFFFFFFFFFFFFFFFh -pbsr_k0r.map -nkd -kp -gb7EFBFFh -b"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib" -bcl0rdm.lib -bcl0rm.lib -bcl0rmf.lib -i"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r" -dbsr_mcu.dr -s -w0 loader.rel pm.rel i2c_ctr.rel main.rel magic.rel WDT.rel i2c_mcu.rel i2c_twl.rel ini_VECT.rel led.rel rtc.rel vreg_ctr.rel vreg_twl.rel tasks.rel adc.rel renge.rel tasks_sys.rel accero.rel self_flash.rel reboot.rel
|
||||
Link complete, 0 error(s) and 0 warning(s) found.
|
||||
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\oc78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -o.\bsr.hex -nu -ki bsr.lmf
|
||||
Object Conversion Complete, 0 error(s) and 0 warning(s) found.
|
||||
C:\WINDOWS\system32\cmd.exe /c ruby C:\Cygwin\home\fujita_ryohei\ctr\nec_s_2_bsrbin.rb bsr.hex
|
||||
C:/Cygwin/home/fujita_ryohei/ctr/nec_s_2_bsrbin.rb:2: warning: variable $KCODE is no longer effective; ignored
|
||||
|
||||
Build Total error(s) : 0 Total warning(s) : 0
|
||||
Build Total error(s) : 0 Total warning(s) : 1
|
||||
|
||||
@ -78,10 +78,10 @@ Symbol Type=OFF
|
||||
Language=C
|
||||
Kanji=SJIS
|
||||
[Source]
|
||||
Geometry=162, 219, 1090, 857
|
||||
Geometry=36, 41, 1090, 857
|
||||
Window=Normal
|
||||
DispStart=167
|
||||
CaretPos=168,0
|
||||
DispStart=288
|
||||
CaretPos=289,0
|
||||
Mode=Normal
|
||||
DispFile=
|
||||
Address1=
|
||||
@ -142,8 +142,8 @@ Accumulative=ON
|
||||
[Assemble]
|
||||
Geometry=118, 76, 600, 937
|
||||
Window=Normal
|
||||
DispStart=356
|
||||
CaretPos=356,27
|
||||
DispStart=14886
|
||||
CaretPos=14886,27
|
||||
Address1=
|
||||
Address2=
|
||||
Address3=
|
||||
@ -274,7 +274,7 @@ Address13=
|
||||
Address14=
|
||||
Address15=
|
||||
Address16=
|
||||
Boundary=202, 89
|
||||
Boundary=0, 0
|
||||
Mode=Hex
|
||||
Attribute=Show
|
||||
Sort=Unsort
|
||||
@ -873,15 +873,15 @@ Boundary=62
|
||||
Pickup=OFF
|
||||
Name=Functional
|
||||
Register Bank=0
|
||||
RP0=7
|
||||
RP1=3
|
||||
RP2=3
|
||||
RP0=1
|
||||
RP1=1
|
||||
RP2=1
|
||||
RP3=3
|
||||
PC=3
|
||||
SP=3
|
||||
PSW=3
|
||||
PC=1
|
||||
SP=1
|
||||
PSW=1
|
||||
ES=3
|
||||
CS=3
|
||||
CS=1
|
||||
[Event Manager]
|
||||
Geometry=0, 0, 0, 0
|
||||
Window=Hide
|
||||
@ -960,13 +960,15 @@ Count=0
|
||||
Geometry=1138, 6, 440, 300
|
||||
Window=Normal
|
||||
Boundary=13762700
|
||||
0=.system_status.pwr_state,P,N,A,+,1
|
||||
1=.P12.0,P,S,A,+,1
|
||||
2=.system_status,.,N,A,+,1
|
||||
3=.vreg_twl,P,N,A,+,1
|
||||
4=.wifi_TX,P,N,A,+,1
|
||||
5=.temp,P,N,A,+,1
|
||||
Line=6
|
||||
0=.PIF21,P,S,A,+,1
|
||||
1=.PMK21,P,S,A,+,1
|
||||
2=.system_status.pwr_state,P,N,A,+,1
|
||||
3=.P12.0,P,S,A,+,1
|
||||
4=.system_status,.,N,A,+,1
|
||||
5=.vreg_twl,P,N,A,+,1
|
||||
6=.wifi_TX,P,N,A,+,1
|
||||
7=.temp,P,N,A,+,1
|
||||
Line=8
|
||||
[Quick Watch]
|
||||
0=temp,P,A,1
|
||||
1=wifi_TX,P,A,1
|
||||
@ -980,9 +982,9 @@ Line=6
|
||||
9=system_status.pwr_state,P,A,1
|
||||
10=pm12,P,A,1
|
||||
11=vreg_twl,P,A,1
|
||||
12=
|
||||
13=
|
||||
14=
|
||||
12=PMK21,P,A,1
|
||||
13=IFP21,P,A,1
|
||||
14=PIF21,P,A,1
|
||||
15=
|
||||
[Software Break]
|
||||
Geometry=51, 459, 500, 200
|
||||
@ -1000,7 +1002,19 @@ Name2=Swb00002
|
||||
Address2=vreg_twl.c#_vreg_twl_read+0x18
|
||||
Window2=ASM
|
||||
Status2=ON
|
||||
Count=3
|
||||
Name3=Swb00005
|
||||
Address3=tasks_sys.c#_tsk_sys+0x13a
|
||||
Window3=ASM
|
||||
Status3=ON
|
||||
Name4=Swb00003
|
||||
Address4=tasks.c#_do_command0+0x8
|
||||
Window4=ASM
|
||||
Status4=ON
|
||||
Name5=Swb00006
|
||||
Address5=led.c#_tsk_led_wifi+0x0
|
||||
Window5=ASM
|
||||
Status5=ON
|
||||
Count=6
|
||||
[Reset]
|
||||
Debugger=ON
|
||||
Symbol=OFF
|
||||
|
||||
@ -9,20 +9,21 @@ OpenFile2=renge\\renge_defs.h,0,330,330,1574,1087,0,47,0,0
|
||||
OpenFile3=user_define.h,0,176,176,1420,933,0,33,20,0
|
||||
OpenFile4=rtc.c,0,308,308,1491,934,0,31,17,0
|
||||
OpenFile5=magic.c,0,242,242,1486,999,3,8,0,0
|
||||
OpenFile6=vreg_twl.c,0,314,110,1558,867,21,72,21,0
|
||||
OpenFile7=accero.c,0,154,154,1398,911,25,237,25,0
|
||||
OpenFile8=inter_asm\self_flash.asm,0,118,281,1362,1038,0,933,0,0
|
||||
OpenFile9=loader.c,0,255,224,1438,850,14,85,0,0
|
||||
OpenFile10=main.c,0,124,87,1368,844,0,45,0,0
|
||||
OpenFile11=vreg_ctr.c,0,345,273,1060,932,14,23,0,0
|
||||
OpenFile12=i2c_ctr.c,0,242,242,1425,868,14,108,0,0
|
||||
OpenFile13=reboot.c,0,110,110,1354,867,5,14,14,0
|
||||
OpenFile14=led.c,0,286,286,1469,912,0,420,6,0
|
||||
OpenFile15=ProjectWindow
|
||||
OpenFile6=accero.c,0,154,154,1398,911,25,237,25,0
|
||||
OpenFile7=inter_asm\self_flash.asm,0,118,281,1362,1038,0,933,0,0
|
||||
OpenFile8=loader.c,0,255,224,1438,850,14,85,0,0
|
||||
OpenFile9=main.c,0,124,87,1368,844,0,45,0,0
|
||||
OpenFile10=vreg_ctr.c,0,345,273,1060,932,14,23,0,0
|
||||
OpenFile11=i2c_ctr.c,0,242,242,1425,868,14,108,0,0
|
||||
OpenFile12=reboot.c,0,110,110,1354,867,5,14,14,0
|
||||
OpenFile13=config.h,0,374,323,1618,1080,15,18,22,0
|
||||
OpenFile14=vreg_twl.c,0,314,110,1558,867,74,90,75,0
|
||||
OpenFile15=renge\renge.c,0,154,154,1398,911,0,264,0,0
|
||||
OpenFile16=adc.c,0,275,163,1065,610,0,145,0,0
|
||||
OpenFile17=ProjectWindow
|
||||
PrjPos=0,2,754,3,253
|
||||
OpenFile16=adc.c,0,0,0,790,447,0,97,0,0
|
||||
OpenFile17=config.h,0,374,323,1618,1080,15,18,22,0
|
||||
OpenFile18=OutputWindow
|
||||
OpenFile18=led.c,0,286,286,1469,912,12,323,0,0
|
||||
OpenFile19=OutputWindow
|
||||
OutputPos=0,360,1128,478,1503
|
||||
ActivePRJ=yav_mcu_bsr.prj
|
||||
[ProjectWindow]
|
||||
|
||||
@ -11,7 +11,7 @@ T=4ae7c536
|
||||
7=rtc.h
|
||||
8=reboot.h
|
||||
[pm.c]
|
||||
T=4ae8dfa1
|
||||
T=4ae8edfa
|
||||
1=incs.h
|
||||
2=adc.h
|
||||
3=led.h
|
||||
@ -42,10 +42,10 @@ T=4add157f
|
||||
1=incs.h
|
||||
2=i2c_twl_defs.h
|
||||
[ini_VECT.c]
|
||||
T=4ae6b094
|
||||
T=4ae986c0
|
||||
1=config.h
|
||||
[led.c]
|
||||
T=4ae65639
|
||||
T=4ae991e4
|
||||
1=incs.h
|
||||
2=led.h
|
||||
[rtc.c]
|
||||
@ -60,24 +60,25 @@ T=4ae6477f
|
||||
5=accero.h
|
||||
6=pm.h
|
||||
[vreg_twl.c]
|
||||
T=4ade5fd9
|
||||
T=4ae916d9
|
||||
1=incs.h
|
||||
2=jhl_defs.h
|
||||
3=vreg_twl.h
|
||||
4=vreg_ctr.h
|
||||
[tasks.c]
|
||||
T=4ae80ac4
|
||||
T=4ae9424d
|
||||
1=incs.h
|
||||
2=renge\renge.h
|
||||
3=pm.h
|
||||
4=accero.h
|
||||
[adc.c]
|
||||
T=4ae7e02a
|
||||
T=4ae955ff
|
||||
1=incs.h
|
||||
2=adc.h
|
||||
3=pm.h
|
||||
4=led.h
|
||||
[renge\renge.c]
|
||||
T=4ac96eb4
|
||||
T=4ae94be1
|
||||
1=renge\renge_defs.h
|
||||
2=renge\renge_task_intval.h
|
||||
3=renge\renge_task_immediate.h
|
||||
@ -157,7 +158,7 @@ T=4aca8c17
|
||||
T=4ae64633
|
||||
1=jhl_defs.h
|
||||
[led.h]
|
||||
T=4aca8c17
|
||||
T=4ae98e8b
|
||||
[incs.h]
|
||||
T=4ae508d8
|
||||
1=jhl_defs.h
|
||||
@ -169,7 +170,7 @@ T=4ae508d8
|
||||
7=i2c_mcu.h
|
||||
8=rtc.h
|
||||
[vreg_twl.h]
|
||||
T=4ade50c3
|
||||
T=4ae8ea1f
|
||||
[accero.h]
|
||||
T=4aca8c17
|
||||
1=jhl_defs.h
|
||||
|
||||
Loading…
Reference in New Issue
Block a user