From 91c33279a78b90ad03d562dfc92114424ebf22d2 Mon Sep 17 00:00:00 2001 From: fujita_ryohei Date: Thu, 28 Jan 2010 00:33:22 +0000 Subject: [PATCH] =?UTF-8?q?I2C=5FCTR.FREE=20=E3=82=92=E3=83=9E=E3=82=A4?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=81=AE=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E3=81=AB=E4=BD=BF=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=80=82?= =?UTF-8?q?=20=E3=80=80SoC=E3=81=A7=E4=BD=BF=E3=81=86=E3=81=9D=E3=81=86?= =?UTF-8?q?=E3=81=AA=E3=81=AE=E3=81=A7=E8=A7=A3=E6=94=BE=20I2C=5FCTR?= =?UTF-8?q?=E3=81=AE=E3=82=A6=E3=82=A7=E3=82=A4=E3=83=88=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=83=87=E3=82=A3=E3=82=B7=E3=83=A7=E3=83=B3=E8=A7=A3=E9=99=A4?= =?UTF-8?q?=E3=81=AE=E3=82=BF=E3=82=A4=E3=83=9F=E3=83=B3=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E3=80=80=E6=AC=A1=E3=81=AE=E6=BA=96?= =?UTF-8?q?=E5=82=99=E3=81=8C=E3=81=A7=E3=81=8D=E3=81=A6=E3=81=8B=E3=82=89?= =?UTF-8?q?=E8=A7=A3=E6=94=BE=E3=81=99=E3=82=8B=E3=80=82=E6=9C=AC=E6=9D=A5?= =?UTF-8?q?=E3=81=AF=E3=81=93=E3=81=86=E3=81=82=E3=82=8B=E3=81=B9=E3=81=8D?= =?UTF-8?q?=EF=BC=9F=E6=88=BB=E3=81=99=E3=81=8B=E3=82=82=E3=81=97=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84?= 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@87 013db118-44a6-b54f-8bf7-843cb86687b1 --- trunk/config.h | 2 +- trunk/i2c_ctr.c | 36 +++++++++++----------- trunk/i2c_twl.c | 12 ++------ trunk/pm.c | 2 -- trunk/task_debug.c | 11 ++++--- trunk/yav_mcu_bsr.pri | 69 +++++++++++++++++++++---------------------- trunk/yav_mcu_bsr.prj | 36 +++++++++++----------- trunk/yav_mcu_bsr.sdb | 20 ++++++------- 8 files changed, 86 insertions(+), 102 deletions(-) diff --git a/trunk/config.h b/trunk/config.h index 17296de..5da9509 100644 --- a/trunk/config.h +++ b/trunk/config.h @@ -8,7 +8,7 @@ #define MCU_VER_MAJOR 0x00 #define MCU_VER_MINOR 0x0D -#define _OVERCLOCK_ +//#define _OVERCLOCK_ // 古い(C)電源ボード //#define _PM_BUG_ diff --git a/trunk/i2c_ctr.c b/trunk/i2c_ctr.c index 944de0a..c3085e2 100644 --- a/trunk/i2c_ctr.c +++ b/trunk/i2c_ctr.c @@ -38,6 +38,7 @@ #define WTIM WTIM1 #define TRC TRC1 #define SMC SMC1 +#define DFC DFC1 #endif @@ -65,7 +66,9 @@ __interrupt void int_iic_ctr( ) static u8 state = IIC_IDLE; static u8 reg_adrs; static u8 reg_adrs_internal; - static u8 trx_buf; + static u8 tx_buf; + u8 rx_buf; + u8 tx_buf_temp; EI(); @@ -125,16 +128,16 @@ __interrupt void int_iic_ctr( ) // 自局呼び出しに応答。 // 初期化など SPIE = 1; - WREL = 1; // ウェイト解除 state = IIC_RCV_REG_ADRS; + WREL = 1; // ウェイト解除 break; case ( IIC_RCV_REG_ADRS ): // 2バイト目(レジスタアドレス)受信後に来る // レジスタアドレス受信 reg_adrs = IICA; - WREL = 1; - trx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく + tx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく state = IIC_TX_OR_RX; + WREL = 1; break; case ( IIC_TX_OR_RX ): // ↑の次に来る割り込み。STなら送信準備、データが来たら書き込まれ @@ -165,13 +168,13 @@ __interrupt void int_iic_ctr( ) default: // バースト R/W でここが何回も呼ばれることになる if( state == IIC_TX ) { // 送信 - IICA = trx_buf; +// IICA = tx_buf; vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理 } else { // 受信 - trx_buf = IICA; - vreg_ctr_write( reg_adrs, trx_buf ); + rx_buf = IICA; + vreg_ctr_write( reg_adrs, rx_buf ); WREL = 1; } if( reg_adrs != VREG_C_ACC_HOSU_HIST ) @@ -181,11 +184,12 @@ __interrupt void int_iic_ctr( ) if( state == IIC_TX ) { // さらにつぎに送るデータの準備だけシテオク。SPが来て使われないかもしれない - trx_buf = vreg_ctr_read( reg_adrs ); + tx_buf_temp = vreg_ctr_read( reg_adrs ); + IICA = tx_buf; + tx_buf = tx_buf_temp; } break; } - } @@ -204,11 +208,7 @@ void IIC_ctr_Init( void ) IICAPR0 = 1; /* set INTIICA high priority */ IICAPR1 = 0; /* set INTIICA high priority */ -#ifdef _MODEL_WM0_ P20 &= ~0x3; -#else - P6 &= ~0x3; -#endif SVA = IIC_C_SLAVEADDRESS; IICF = 0x01; @@ -220,19 +220,17 @@ void IIC_ctr_Init( void ) WTIM = 1; // 自動でACKを返した後clkをLに固定する ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない - IICWH = 8; + IICWH = 5; IICWL = 10; // L期間の長さ SMC = 1; // 高速モード + DFC = 1; // デジタルフィルタon (@fast mode) IICAMK = 0; // 割り込みを許可 IICE = 1; -#ifdef _MODEL_WM0_ - PM20 &= ~0x3; /* set clock pin for IICA */ -#else - PM6 &= ~0x3; /* set clock pin for IICA */ -#endif + + PM20 &= ~0x3; /* set clock pin for IICA */ } diff --git a/trunk/i2c_twl.c b/trunk/i2c_twl.c index 3286d41..2e99d4c 100644 --- a/trunk/i2c_twl.c +++ b/trunk/i2c_twl.c @@ -168,11 +168,7 @@ void IIC_twl_Init( void ) IICAPR0 = 0; /* set INTIICA high priority */ IICAPR1 = 0; /* set INTIICA high priority */ -#ifdef _MODEL_WM0_ P6 &= ~0x3; -#else - P20 &= ~0x3; -#endif SVA = IIC_T_SLAVEADDRESS; IICF = 0x01; @@ -184,7 +180,7 @@ void IIC_twl_Init( void ) WTIM = 1; // 自動でACKを返した後clkをLに固定する ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない - IICWH = 8; + IICWH = 5; IICWL = 10; // L期間の長さ(?) SMC = 1; @@ -192,11 +188,7 @@ void IIC_twl_Init( void ) IICAMK = 0; // 割り込みを許可 IICE = 1; -#ifdef _MODEL_WM0_ - PM6 &= ~0x3; /* set clock pin for IICA */ -#else - PM20 &= ~0x3; /* set clock pin for IICA */ -#endif + PM6 &= ~0x3; /* set clock pin for IICA */ LREL = 1; } diff --git a/trunk/pm.c b/trunk/pm.c index b95045b..e5ffac8 100644 --- a/trunk/pm.c +++ b/trunk/pm.c @@ -189,7 +189,6 @@ task_status_immed PM_bt_temp_update( ) DBG_P_n = 1; temperature = 81.45 - 111.9 * raw_adc_temperature/256.0; vreg_ctr[VREG_C_BT_TEMP] = (u8)temperature; - vreg_ctr[VREG_C_FREE0 ] = (u8)( temperature % 100 * 100 ); DBG_P_n = 0; } @@ -707,7 +706,6 @@ void tsk_batt( ) PM_get_batt_left(); // dubug monitor - vreg_ctr[ VREG_C_FREE1 ] = iic_mcu_read_a_byte( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL ); return; } diff --git a/trunk/task_debug.c b/trunk/task_debug.c index d1ab4a1..63c9595 100644 --- a/trunk/task_debug.c +++ b/trunk/task_debug.c @@ -38,8 +38,6 @@ void tsk_debug2( ) { u8 str[4]; - return; - if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) ) { /* @@ -48,10 +46,11 @@ void tsk_debug2( ) str[1] = vreg_ctr[ VREG_C_STATUS ]; str[0] = vreg_ctr[ VREG_C_RTC_SEC ]; */ - str[3] = vreg_ctr[ VREG_C_BT_TEMP ]; - str[2] = vreg_ctr[ VREG_C_FREE0 ]; - str[1] = vreg_ctr[ VREG_C_FREE1 ]; - str[0] = MIN; + str[3] = vreg_ctr[ VREG_C_DBG1 ]; + str[2] = vreg_ctr[ VREG_C_DBG2 ]; + str[1] = vreg_ctr[ VREG_C_DBG3 ]; +// str[1] = MIN; + str[0] = SEC; // 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.pri b/trunk/yav_mcu_bsr.pri index 52fd87f..5a99e35 100644 --- a/trunk/yav_mcu_bsr.pri +++ b/trunk/yav_mcu_bsr.pri @@ -80,8 +80,8 @@ Kanji=SJIS [Source] Geometry=173, 154, 1012, 920 Window=Normal -DispStart=209 -CaretPos=210,0 +DispStart=274 +CaretPos=275,0 Mode=Normal DispFile= Address1= @@ -142,8 +142,8 @@ Accumulative=ON [Assemble] Geometry=605, 2, 600, 400 Window=Normal -DispStart=14008 -CaretPos=14008,27 +DispStart=16374 +CaretPos=16374,27 Address1= Address2= Address3= @@ -858,32 +858,33 @@ Count=0 Geometry=1225, 6, 354, 910 Window=Normal Boundary=13762700 -0=.new_task,.,N,A,+,1 -1=.if2h,P,S,A,+,1 -2=.pool,P,N,A,+,1 -3=.new_task,.,N,A,+,1 -4=.vreg_ctr,P,N,A,+,1 -5=.cmd_BL,P,N,A,+,1 -6=.P7,B,S,A,+,1 -7=.p5,B,S,A,+,1 -Line=8 +0=.tx_buf,P,N,A,+,1 +1=.new_task,P,N,A,+,1 +2=.if2h,P,S,A,+,1 +3=.pool,P,N,A,+,1 +4=.new_task,P,N,A,+,1 +5=.vreg_ctr,P,N,A,+,1 +6=.cmd_BL,P,N,A,+,1 +7=.P7,B,S,A,+,1 +8=.p5,B,S,A,+,1 +Line=9 [Quick Watch] -0=SEC,P,A,1 -1=rtcif,P,A,1 -2=vreg_twl,P,A,1 -3=pm0,P,A,1 -4=data,P,A,1 -5=P5.3,P,A,1 -6=p4.3,P,A,1 -7=pu0,P,A,1 -8=p5,B,A,1 -9=P7,B,A,1 -10=cmd_BL,P,A,1 -11=vreg_ctr,P,A,1 -12=pool,P,A,1 -13=if2,P,A,1 -14=if2h,P,A,1 -15=new_task,P,A,1 +0=rtcif,P,A,1 +1=vreg_twl,P,A,1 +2=pm0,P,A,1 +3=data,P,A,1 +4=P5.3,P,A,1 +5=p4.3,P,A,1 +6=pu0,P,A,1 +7=p5,B,A,1 +8=P7,B,A,1 +9=cmd_BL,P,A,1 +10=vreg_ctr,P,A,1 +11=pool,P,A,1 +12=if2,P,A,1 +13=if2h,P,A,1 +14=new_task,P,A,1 +15=tx_buf,P,A,1 [Software Break] Geometry=1204, 674, 500, 428 Window=Normal @@ -904,15 +905,11 @@ Name3=Swb00006 Address3=self_flash.c#_firm_duplicate+0x0 Window3=ASM Status3=ON -Name4=Swb00010 -Address4=renge.c#_renge_task_immed_run+0xe3 +Name4=Swb00003 +Address4=task_misc.c#_do_command0+0x10 Window4=ASM Status4=ON -Name5=Swb00003 -Address5=task_misc.c#_do_command0+0x10 -Window5=ASM -Status5=ON -Count=6 +Count=5 [Reset] Debugger=ON Symbol=OFF diff --git a/trunk/yav_mcu_bsr.prj b/trunk/yav_mcu_bsr.prj index 95532a0..446ffef 100644 --- a/trunk/yav_mcu_bsr.prj +++ b/trunk/yav_mcu_bsr.prj @@ -596,9 +596,9 @@ Floatingpoint=0 Muldivunit=1 Mulunit=1 Startup=s0rml.rel -Library1=cl0rdm.lib -Library2=cl0rm.lib -Library3=cl0rmf.lib +Library1=cl0rm.lib +Library2=cl0rmf.lib +Library3= VfiFileBoot0= VfiFileBoot1=boot.vfi VF78K0Rchk=0 @@ -668,9 +668,9 @@ Floatingpoint=0 Muldivunit=1 Mulunit=1 Startup=s0rll.rel -Library1=cl0rdm.lib -Library2=cl0rm.lib -Library3=cl0rmf.lib +Library1=cl0rm.lib +Library2=cl0rmf.lib +Library3= VF78K0Rchk=0 VF78K0Rvs= [Options.CC78K0R 2] @@ -747,9 +747,9 @@ Floatingpoint=0 Muldivunit=1 Mulunit=1 Startup=s0rm.rel -Library1=cl0rdm.lib -Library2=cl0rm.lib -Library3=cl0rmf.lib +Library1=cl0rm.lib +Library2=cl0rmf.lib +Library3= VfiFileBoot0= VfiFileBoot1=boot.vfi VF78K0Rchk=0 @@ -828,9 +828,9 @@ Floatingpoint=0 Muldivunit=1 Mulunit=1 Startup=s0rml.rel -Library1=cl0rdm.lib -Library2=cl0rm.lib -Library3=cl0rmf.lib +Library1=cl0rm.lib +Library2=cl0rmf.lib +Library3= VfiFileBoot0= VfiFileBoot1=boot.vfi VF78K0Rchk=0 @@ -905,9 +905,9 @@ Floatingpoint=0 Muldivunit=1 Mulunit=1 Startup=s0rml.rel -Library1=cl0rdm.lib -Library2=cl0rm.lib -Library3=cl0rmf.lib +Library1=cl0rm.lib +Library2=cl0rmf.lib +Library3= VfiFileBoot0= VfiFileBoot1=boot.vfi VF78K0Rchk=0 @@ -986,9 +986,9 @@ Floatingpoint=0 Muldivunit=1 Mulunit=1 Startup=s0rml.rel -Library1=cl0rdm.lib -Library2=cl0rm.lib -Library3=cl0rmf.lib +Library1=cl0rm.lib +Library2=cl0rmf.lib +Library3= VfiFileBoot0= VfiFileBoot1=boot.vfi VF78K0Rchk=0 diff --git a/trunk/yav_mcu_bsr.sdb b/trunk/yav_mcu_bsr.sdb index 577eb32..917f7d4 100644 --- a/trunk/yav_mcu_bsr.sdb +++ b/trunk/yav_mcu_bsr.sdb @@ -11,14 +11,14 @@ T=4b445f00 7=rtc.h 8=reboot.h [pm.c] -T=4b4d808f +T=4b5d7b67 1=incs.h 2=adc.h 3=led.h 4=pm.h 5=renge\renge.h [i2c_ctr.c] -T=4b57f645 +T=4b5e46d7 1=incs.h 2=accero.h [main.c] @@ -31,7 +31,7 @@ T=4b57fe0b 6=led.h 7=adc.h [magic.c] -T=4b58003f +T=4b5e3f7f 1=config.h [WDT.c] T=4afd21ca @@ -41,7 +41,7 @@ T=4b0bae4b 1=incs.h 2=i2c_mcu.h [i2c_twl.c] -T=4b580039 +T=4b5e46a6 1=incs.h 2=i2c_twl_defs.h [ini_VECT.c] @@ -55,7 +55,7 @@ T=4b4438bb T=4b4438a1 1=incs.h [vreg_ctr.c] -T=4b57f3e1 +T=4b5e46c1 1=incs.h 2=vreg_ctr.h 3=rtc.h @@ -78,7 +78,7 @@ T=4b502014 3=pm.h 4=led.h [renge\renge.c] -T=4b5802da +T=4b5d73b9 1=renge\renge.h 2=renge\renge_task_intval.h 3=renge\renge_task_immediate.h @@ -87,7 +87,7 @@ T=4b5802da 6=user_define.h 7=bsr_system.h [accero.c] -T=4b57fc13 +T=4b5d7f5b 1=incs.h 2=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h [self_flash.c] @@ -109,13 +109,13 @@ T=4b4d6c9b 6=pm.h 7=rtc.h [task_debug.c] -T=4b42e64f +T=4b5d91b9 1=incs.h 2=renge\renge.h 3=pm.h 4=accero.h [task_misc.c] -T=4b42ee33 +T=4b595e25 1=incs.h 2=renge\renge.h 3=pm.h @@ -147,7 +147,7 @@ T=4b023fdb [user_define.h] T=4b442a95 [config.h] -T=4b4fe6cf +T=4b5e3100 [bsr_system.h] T=4b3064de [renge\renge.h]