From 8bcafd87933108c8c7de8bc81267e2a5001c3eca Mon Sep 17 00:00:00 2001 From: fujita_ryohei Date: Thu, 29 Oct 2009 13:06:40 +0000 Subject: [PATCH] =?UTF-8?q?=E9=81=8E=E5=8E=BB=EF=BC=93=E3=81=A4=E3=81=AE?= =?UTF-8?q?=E3=81=86=E3=81=A1=E3=81=AE=E3=80=81=E4=B8=AD=E9=96=93=E3=81=AE?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E8=BF=94=E3=81=99=E3=80=80?= =?UTF-8?q?=E3=81=A8=E3=81=84=E3=81=86=E9=96=A2=E6=95=B0=E3=81=AE=E3=83=90?= =?UTF-8?q?=E3=82=B0=E4=BF=AE=E6=AD=A3=EF=BC=88for=20ADC=EF=BC=89=20RF=20T?= =?UTF-8?q?X=E3=81=AE=E7=9B=A3=E8=A6=96=E3=81=AE=E4=BB=95=E6=A7=98?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=EF=BC=88=E5=89=B2=E3=82=8A=E8=BE=BC=E3=81=BF?= =?UTF-8?q?=E4=BD=BF=E3=82=8F=E3=81=AA=E3=81=84=EF=BC=89=20=E9=9B=BB?= =?UTF-8?q?=E6=BA=90off=E3=81=AE=E3=83=88=E3=83=A9=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- trunk/adc.c | 32 ++++++++++------------ trunk/ini_VECT.c | 20 ++++++++++---- trunk/led.c | 50 +++++++++++++++++----------------- trunk/led.h | 10 +++++++ trunk/renge/renge.c | 7 ----- trunk/tasks.c | 6 +++++ trunk/yav_mcu_bsr.plg | 11 +++++++- trunk/yav_mcu_bsr.pri | 62 ++++++++++++++++++++++++++----------------- trunk/yav_mcu_bsr.prk | 27 ++++++++++--------- trunk/yav_mcu_bsr.sdb | 19 ++++++------- 10 files changed, 141 insertions(+), 103 deletions(-) diff --git a/trunk/adc.c b/trunk/adc.c index c6f956c..f841771 100644 --- a/trunk/adc.c +++ b/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 ) ); } } } + /* ========================================================  自前で次のチャンネル   一通り終わったら止める diff --git a/trunk/ini_VECT.c b/trunk/ini_VECT.c index 7da7766..f992a4c 100644 --- a/trunk/ini_VECT.c +++ b/trunk/ini_VECT.c @@ -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 diff --git a/trunk/led.c b/trunk/led.c index ff9f60d..16aab7e 100644 --- a/trunk/led.c +++ b/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 diff --git a/trunk/led.h b/trunk/led.h index 4b218d8..de58a62 100644 --- a/trunk/led.h +++ b/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 { diff --git a/trunk/renge/renge.c b/trunk/renge/renge.c index 85f012b..6bedb5a 100644 --- a/trunk/renge/renge.c +++ b/trunk/renge/renge.c @@ -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(); diff --git a/trunk/tasks.c b/trunk/tasks.c index 4b06b06..e91a914 100644 --- a/trunk/tasks.c +++ b/trunk/tasks.c @@ -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 ); diff --git a/trunk/yav_mcu_bsr.plg b/trunk/yav_mcu_bsr.plg index b4c1368..15ab40c 100644 --- a/trunk/yav_mcu_bsr.plg +++ b/trunk/yav_mcu_bsr.plg @@ -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 diff --git a/trunk/yav_mcu_bsr.pri b/trunk/yav_mcu_bsr.pri index 0dddeaf..e0a6b22 100644 --- a/trunk/yav_mcu_bsr.pri +++ b/trunk/yav_mcu_bsr.pri @@ -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 diff --git a/trunk/yav_mcu_bsr.prk b/trunk/yav_mcu_bsr.prk index 071a454..4a133fc 100644 --- a/trunk/yav_mcu_bsr.prk +++ b/trunk/yav_mcu_bsr.prk @@ -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] diff --git a/trunk/yav_mcu_bsr.sdb b/trunk/yav_mcu_bsr.sdb index 658b00f..3e52d8f 100644 --- a/trunk/yav_mcu_bsr.sdb +++ b/trunk/yav_mcu_bsr.sdb @@ -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