From 50a1948303165a55be36732bd50d9f64752f4fd3 Mon Sep 17 00:00:00 2001 From: fujita_ryohei Date: Thu, 29 Oct 2009 06:50:26 +0000 Subject: [PATCH] =?UTF-8?q?TWL=E5=81=B4=E3=81=AE=E5=85=85=E9=9B=BB?= =?UTF-8?q?=E3=83=95=E3=83=A9=E3=82=B0=E4=BF=AE=E6=AD=A3=20TWL=E5=81=B4?= =?UTF-8?q?=E3=82=AB=E3=83=A1=E3=83=A9LED=E3=83=AC=E3=82=B8=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=81=AE=E3=80=81=E3=80=8C=EF=BC=91=E7=99=BA=E3=81=A0?= =?UTF-8?q?=E3=81=91=E6=B6=88=E7=81=AF=E3=80=8D=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=82=B3=E3=83=BC=E3=83=89=E5=89=8A=E9=99=A4?= =?UTF-8?q?=20reboot.*=E8=BF=BD=E5=8A=A0?= 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@16 013db118-44a6-b54f-8bf7-843cb86687b1 --- trunk/adc.c | 11 ++++++----- trunk/config.h | 3 ++- trunk/led.c | 5 +++-- trunk/main.c | 14 -------------- trunk/pm.c | 13 ------------- trunk/reboot.c | 24 ++++++++++++++++++++++++ trunk/reboot.h | 6 ++++++ trunk/tasks_sys.c | 3 ++- trunk/user_define.h | 6 ------ trunk/vreg_twl.c | 40 ++++++++++++++++++++++++++-------------- trunk/vreg_twl.h | 2 +- trunk/yav_mcu_bsr.plg | 11 +---------- trunk/yav_mcu_bsr.pri | 43 ++++++++++++++++++++----------------------- trunk/yav_mcu_bsr.prk | 6 ++---- trunk/yav_mcu_bsr.sdb | 10 +++++----- 15 files changed, 98 insertions(+), 99 deletions(-) create mode 100644 trunk/reboot.c create mode 100644 trunk/reboot.h diff --git a/trunk/adc.c b/trunk/adc.c index 17d343d..c6f956c 100644 --- a/trunk/adc.c +++ b/trunk/adc.c @@ -68,8 +68,6 @@ void tsk_adc( ) static u8 vol_old; static u8 class_old; u8 class; - static u8 direction = 0; // 0:上り方向 - u8 comp; // 補正値 if( abs( vol_old - vreg_ctr[VREG_C_SND_VOL] ) > 3 ) { @@ -87,14 +85,16 @@ void tsk_adc( ) } + // デバイスに伝える if( sndvol_codec != vreg_ctr[VREG_C_SND_VOL] ) { sndvol_codec = vreg_ctr[VREG_C_SND_VOL]; - // codecに伝える + // DCPにも伝えておく iic_mcu_write_a_byte( IIC_SLA_DCP, 0, - ( sndvol_codec / 2 + vreg_ctr[VREG_C_SND_VOL] / 4 )); + sndvol_codec / 2 + sndvol_codec / 4 ); // 簡易スケーリング todo + // codecに伝える iic_mcu_write_a_byte( IIC_SLA_CODEC, REG_ADRS_CODEC_VOL, - 127 - ( sndvol_codec / 2 + vreg_ctr[VREG_C_SND_VOL] / 4 )/2 ); + 127 - ( sndvol_codec / 2 + sndvol_codec / 4 )/2 ); } adc_updated = 0; } @@ -139,6 +139,7 @@ static u8 getmean3( u8 * hist ) { u8 temp; + // ちょっと並び替え if( *hist < *( hist + 1 ) ) { temp = *hist; diff --git a/trunk/config.h b/trunk/config.h index ded1f98..1eca07e 100644 --- a/trunk/config.h +++ b/trunk/config.h @@ -2,7 +2,6 @@ #define __config__ #define _debug_ - // #define _debug_led_ #define MCU_VER_MAJOR 0; @@ -19,6 +18,8 @@ #define _CODEC_CTR_ +// ---------------------------------- // + #ifdef _MODEL_TEG2_ #define _PMIC_TWL_ #define _MCU_KE3_ diff --git a/trunk/led.c b/trunk/led.c index 423de0c..ff9f60d 100644 --- a/trunk/led.c +++ b/trunk/led.c @@ -469,6 +469,7 @@ void tsk_led_cam( ) { static u8 state_led_cam = 0; static u8 task_interval; + static u8 state_led_cam_twl; if( task_interval != 0 ) { @@ -530,7 +531,7 @@ void tsk_led_cam( ) break; case ( CAM_LED_BY_TWL ): - switch ( vreg_twl[ REG_TWL_INT_ADRS_CAM ] ){ + switch ( vreg_twl[ REG_TWL_INT_ADRS_CAM ] ){ // switchのネストとか… case( TWL_CAMLED_OFF ): LED_duty_CAM = 0; state_led_cam = 0; @@ -554,7 +555,7 @@ void tsk_led_cam( ) case( TWL_CAMLED_DEF_ON ): default: LED_duty_CAM = vreg_ctr[VREG_C_LED_BRIGHT]; - state_led_cam = 0; + state_led_cam = 1; break; } } diff --git a/trunk/main.c b/trunk/main.c index ae61b78..efa0332 100644 --- a/trunk/main.c +++ b/trunk/main.c @@ -23,28 +23,14 @@ // ======================================================== -err to_sleep( ); - static void read_dipsw( ); -unsigned char temp_teg; extern void power_save( ); // ======================================================== -bit active; -bit sleep; - -bit rsv_to_sleep; -bit rsv_LCD_on; -bit rsv_BL_on; - - system_status_ system_status; - -u8 off_delay; // 電源 OFF から PWSW 等で電源オンする際、押してる時間をカウントするのに使う - extern u8 boot_ura; /* ======================================================== diff --git a/trunk/pm.c b/trunk/pm.c index 73d6830..88b790d 100644 --- a/trunk/pm.c +++ b/trunk/pm.c @@ -561,18 +561,6 @@ err PM_sys_pow_off( ) -/* ======================================================== - スリープシーケンス - ======================================================== */ -err to_sleep( ) -{ - PM_LCD_off( ); - return 0; -} - - - - /* ======================================================== 電池の管理 @@ -680,7 +668,6 @@ __interrupt void intp4_extdc( ) /*========================================================= フタ開け閉め割り込み - 電源OFFから起こす(充電の温度監視のため)のみ 普段はポーング(misc) =========================================================*/ __interrupt void intp5_shell( ) diff --git a/trunk/reboot.c b/trunk/reboot.c new file mode 100644 index 0000000..2d19e8c --- /dev/null +++ b/trunk/reboot.c @@ -0,0 +1,24 @@ +/********************************************************//* + + むりやりリブート + + ファイル中にインラインアセンブラがあると、 + そのモジュール全部最適化が聞かなくなるため追い出した + + **********************************************************/ +#pragma SFR + +#include "incs_loader.h" + + +void my_reboot(){ +#asm + + MOV PSW,#06H ; ダミーのPSWをセット + MOVW AX,#000d0h ; リセットのベクタ値を取り込んでいます。 + PUSH PSW + PUSH AX ; これでRETIのためのスタックを準備 + RETI ; これでリセット・ベクタに分岐 + +#endasm +} diff --git a/trunk/reboot.h b/trunk/reboot.h new file mode 100644 index 0000000..c20e11e --- /dev/null +++ b/trunk/reboot.h @@ -0,0 +1,6 @@ +#ifndef __MYREBOOT__ +#define __MYREBOOT__ + +void my_reboot(); + +#endif diff --git a/trunk/tasks_sys.c b/trunk/tasks_sys.c index b36920c..58684c2 100644 --- a/trunk/tasks_sys.c +++ b/trunk/tasks_sys.c @@ -173,12 +173,13 @@ void tsk_sys( ) } } - +#if 0 // SLP監視 if( SLP_REQ ){ system_status.pwr_state = SLEEP_TRIG; renge_task_interval_run_force = 1; } +#endif break; case SLEEP_TRIG: //------------------------------------- diff --git a/trunk/user_define.h b/trunk/user_define.h index 796d208..90a295c 100644 --- a/trunk/user_define.h +++ b/trunk/user_define.h @@ -40,12 +40,6 @@ #endif -#ifdef _MCU_KE3_ -extern unsigned char temp_teg; -#define P20 temp_teg -#endif - - #ifdef _PMIC_TWL_ #define PM_TEG_PWSW P7.5 // TEGのみ #define PM_TEG_LCD_dis( val ) ( P7.6 = val ) // TEGのみ diff --git a/trunk/vreg_twl.c b/trunk/vreg_twl.c index c20eb0a..210e1f7 100644 --- a/trunk/vreg_twl.c +++ b/trunk/vreg_twl.c @@ -3,16 +3,20 @@ TWL互換側のI2Cレジスタ ======================================================== */ - #include "incs.h" #include "jhl_defs.h" #include "vreg_twl.h" +#include "vreg_ctr.h" +// ======================================================== #define TWL_REG_VER_INFO 0x35 -u8 vreg_twl[_REG_TWL_INT_ADRS_EDNMARK]; + + +// ======================================================== +u8 vreg_twl[_REG_TWL_INT_ADRS_ENDMARK]; /* ======================================================== @@ -20,8 +24,7 @@ u8 vreg_twl[_REG_TWL_INT_ADRS_EDNMARK]; ======================================================== */ void vreg_twl_init( ) { - vreg_twl[0x03] = 0x03; -// vreg_twl[0x03] = 0x03; + vreg_twl[ REG_TWL_INT_ADRS_MODE ] = 0x03; } @@ -56,6 +59,7 @@ void vreg_twl_write( u8 adrs, u8 data ) } + // ======================================================== // I2C仮想レジスタから読みます。 // 引数 adrs 外から見たときの、アドレス @@ -70,24 +74,32 @@ u8 vreg_twl_read( u8 phy_adrs ) return( TWL_REG_VER_INFO ); case( REG_TWL_INT_ADRS_POWER_INFO ): - vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x0F; - if( PM_EXTDC ) - { - return ( vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] | 0x80 ); - } - else - { - return ( vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] ); + if( vreg_ctr[ VREG_C_BT_REMAIN ] > 90 ){ + vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x0F; + }else if( vreg_ctr[ VREG_C_BT_REMAIN ] > 75 ){ + vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x0B; + }else if( vreg_ctr[ VREG_C_BT_REMAIN ] > 50 ){ + vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x07; + }else if( vreg_ctr[ VREG_C_BT_REMAIN ] > 25 ){ + vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x03; + }else if( vreg_ctr[ VREG_C_BT_REMAIN ] > 5 ){ + vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x01; + }else{ + vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x00; } + return( vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] | ( !BT_CHG_n ? 0x80: 0x00 ) ); // アダプタbit + case( REG_TWL_INT_ADRS_IRQ ): temp = vreg_twl[ REG_TWL_INT_ADRS_IRQ ]; vreg_twl[ REG_TWL_INT_ADRS_IRQ ]= 0; return( temp ); - default: return( vreg_twl[ phy_adrs ] ); + default: + return( vreg_twl[ phy_adrs ] ); - case( 0xFF ): return( 0x00 ); + case( 0xFF ): + return( 0x00 ); } } diff --git a/trunk/vreg_twl.h b/trunk/vreg_twl.h index e4d5de0..aec11ea 100644 --- a/trunk/vreg_twl.h +++ b/trunk/vreg_twl.h @@ -87,7 +87,7 @@ enum REG_TWL_ADRS_INT // REG_TWL_INT_ADRS_TEMP7, // REG_TWL_INT_ADRS_TIME_PWSW_DELAY, // REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD - _REG_TWL_INT_ADRS_EDNMARK, + _REG_TWL_INT_ADRS_ENDMARK, }; diff --git a/trunk/yav_mcu_bsr.plg b/trunk/yav_mcu_bsr.plg index 81f75b7..b4c1368 100644 --- a/trunk/yav_mcu_bsr.plg +++ b/trunk/yav_mcu_bsr.plg @@ -1,15 +1,6 @@ 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 tasks_sys.c -tasks_sys.c(343) : 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\tasks_sys.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) : 1 +Build Total error(s) : 0 Total warning(s) : 0 diff --git a/trunk/yav_mcu_bsr.pri b/trunk/yav_mcu_bsr.pri index 1d831ab..0dddeaf 100644 --- a/trunk/yav_mcu_bsr.pri +++ b/trunk/yav_mcu_bsr.pri @@ -78,7 +78,7 @@ Symbol Type=OFF Language=C Kanji=SJIS [Source] -Geometry=304, 189, 1090, 857 +Geometry=162, 219, 1090, 857 Window=Normal DispStart=167 CaretPos=168,0 @@ -256,7 +256,7 @@ Window=Normal Boundary=13762687 Mode=Proper [Sfr] -Geometry=0, 0, 0, 0 +Geometry=100, 100, 400, 400 Window=Hide Address1= Address2= @@ -274,13 +274,13 @@ Address13= Address14= Address15= Address16= -Boundary=0, 0 +Boundary=202, 89 Mode=Hex Attribute=Show Sort=Unsort Pickup=OFF SelectSort=Address -Last Name= +Last Name=P0 Line=531 L1=P0 L2=P1 @@ -814,7 +814,7 @@ L529=IICWL1 L530=IICWH1 L531=SVA1 [Local Variable] -Geometry=1192, 334, 400, 300 +Geometry=1188, 318, 400, 300 Window=Normal Boundary=13041851 Mode=Proper @@ -866,7 +866,7 @@ SaveRange=Screen SaveStart= SaveEnd= [Register] -Geometry=36, 663, 250, 400 +Geometry=1329, 693, 250, 400 Window=Normal Mode=Hex Boundary=62 @@ -960,16 +960,13 @@ Count=0 Geometry=1138, 6, 440, 300 Window=Normal Boundary=13762700 -0=.P12.0,P,S,A,+,1 -1=.system_status,.,N,A,+,1 -2=.RTCEN,P,S,A,+,1 -3=.P2,B,S,A,+,1 -4=.PM2,B,S,A,+,1 -5=.PM20,B,S,A,+,1 -6=.P20,B,S,A,+,1 -7=.wifi_TX,P,N,A,+,1 -8=.temp,P,N,A,+,1 -Line=9 +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 [Quick Watch] 0=temp,P,A,1 1=wifi_TX,P,A,1 @@ -980,9 +977,9 @@ Line=9 6=RTCEN,P,A,1 7=system_status,P,A,1 8=P12.0,P,A,1 -9= -10= -11= +9=system_status.pwr_state,P,A,1 +10=pm12,P,A,1 +11=vreg_twl,P,A,1 12= 13= 14= @@ -995,12 +992,12 @@ Name0=Swb00001 Address0=self_flash.c#_firm_update+0x209 Window0=ASM Status0=ON -Name1=Swb00002 -Address1=adc.c#_tsk_adc+0x7a +Name1=Swb00004 +Address1=vreg_twl.c#_vreg_twl_read+0x56 Window1=ASM Status1=ON -Name2=Swb00003 -Address2=tasks_sys.c#_tsk_sys+0x3 +Name2=Swb00002 +Address2=vreg_twl.c#_vreg_twl_read+0x18 Window2=ASM Status2=ON Count=3 diff --git a/trunk/yav_mcu_bsr.prk b/trunk/yav_mcu_bsr.prk index c5d1e3a..071a454 100644 --- a/trunk/yav_mcu_bsr.prk +++ b/trunk/yav_mcu_bsr.prk @@ -21,10 +21,8 @@ OpenFile14=led.c,0,286,286,1469,912,0,420,6,0 OpenFile15=ProjectWindow PrjPos=0,2,754,3,253 OpenFile16=adc.c,0,0,0,790,447,0,97,0,0 -OpenFile17=config.h,0,259,332,1503,1089,2,18,21,0 -OpenFile18=pm.c,0,100,80,890,527,63,336,63,0 -OpenFile19=tasks_sys.c,0,242,242,1486,999,1,208,23,0 -OpenFile20=OutputWindow +OpenFile17=config.h,0,374,323,1618,1080,15,18,22,0 +OpenFile18=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 c86a59c..658b00f 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=4ae80b7d +T=4ae8dfa1 1=incs.h 2=adc.h 3=led.h @@ -20,7 +20,7 @@ T=4ae80b7d T=4ae78e76 1=incs.h [main.c] -T=4adee91e +T=4ae8dfa1 1=incs.h 2=WDT.h 3=rtc.h @@ -84,7 +84,7 @@ T=4ac96eb4 4=WDT.h 5=bsr_system.h [tasks_sys.c] -T=4ae82f9a +T=4ae8e00c 1=incs.h 2=i2c_twl.h 3=i2c_ctr.h @@ -118,10 +118,10 @@ T=4aca8c17 [jhl_defs.h] T=4ae647cd [user_define.h] -T=4ae7c500 +T=4ae8dfa1 1=config.h [config.h] -T=4ae82e78 +T=4ae8dd2a [bsr_system.h] T=4aca8c17 [renge\renge.h]