From 611a0cbf8445a1d7f3624b280ef47bcdad09ef16 Mon Sep 17 00:00:00 2001 From: N2232 Date: Thu, 3 Jun 2010 08:39:03 +0000 Subject: [PATCH] =?UTF-8?q?=E6=88=BB=E3=82=8A=E5=80=A4=E3=81=AE=E5=9E=8B?= =?UTF-8?q?=E3=81=8C=E8=AA=A4=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8B=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=80=E5=8B=95=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E8=A7=A6?= =?UTF-8?q?=E3=82=8B=E3=81=AA=E3=81=A8=E8=A8=80=E3=81=86=E6=A0=BC=E8=A8=80?= =?UTF-8?q?=E3=82=82=E3=81=82=E3=82=8B=E3=81=8C=E2=80=A6=20=E7=84=A1?= =?UTF-8?q?=E5=90=8D=E3=81=AA=E5=88=97=E6=8C=99=E5=9E=8B=E3=80=81=E4=B8=80?= =?UTF-8?q?=E9=80=9A=E3=82=8A=E5=90=8D=E5=89=8D=E3=82=92=E4=BB=98=E3=81=91?= =?UTF-8?q?=E3=81=9F=E3=80=82VS=E3=81=AE=E3=83=A1=E3=83=B3=E3=83=90?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=AE=E5=8F=AF=E8=AA=AD=E3=82=92=E4=B8=8A?= =?UTF-8?q?=E3=81=92=E3=81=9F=E3=81=84=E3=81=9F=E3=82=81=E3=80=82=E4=BB=8A?= =?UTF-8?q?=E6=9B=B4=E3=80=82=20LED=20=E3=81=8A=E7=9F=A5=E3=82=89=E3=81=9B?= =?UTF-8?q?LED=E3=80=81=E3=83=AA=E3=83=94=E3=83=BC=E3=83=88=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=AA=E3=81=8F=E3=81=A6=E3=82=82=E6=9C=80?= =?UTF-8?q?=E7=B5=82=E3=83=95=E3=83=AC=E3=83=BC=E3=83=A0=E3=83=95=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=82=92=E7=AB=8B=E3=81=A6=E3=82=8B=20=EF=BC=88?= =?UTF-8?q?=E3=83=91=E3=82=BF=E3=83=BC=E3=83=B3=E3=82=92=E5=B7=AE=E3=81=97?= =?UTF-8?q?=E6=9B=BF=E3=81=88=E3=82=8B=E3=81=A8=E3=81=8D=E3=81=AB=E4=BD=BF?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=BB=E3=81=97=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=8C=E6=84=8F=E5=91=B3=E3=81=AA=E3=81=84=E3=81=8B=E3=82=82?= =?UTF-8?q?=E3=81=A8=E3=81=AE=E3=81=93=E3=81=A8=EF=BC=89=20WiFiLED?= =?UTF-8?q?=E3=81=AE=E7=82=B9=E6=BB=85=E3=81=AF=E7=8F=BE=E7=8A=B6=EF=BC=88?= =?UTF-8?q?TWL=E5=90=8C=E7=AD=89=EF=BC=89=E3=81=A7=E8=89=AF=E3=81=84?= =?UTF-8?q?=E3=82=89=E3=81=97=E3=81=84=E3=80=82=20=E3=82=B9=E3=83=AA?= =?UTF-8?q?=E3=83=BC=E3=83=97=E4=B8=AD=E3=81=A0=E3=81=8C=E3=80=81masterBri?= =?UTF-8?q?ghtness=E3=81=A7=E4=B8=8B=E3=81=92=E3=81=9F=E7=8A=B6=E6=85=8B?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=A6=E3=82=82=E3=82=89=E3=81=86=E3=81=93?= =?UTF-8?q?=E3=81=A8=E3=81=AB=E3=81=AA=E3=82=8A=E3=81=9D=E3=81=86=E3=80=82?= =?UTF-8?q?=20=E3=80=80=E3=81=86=E3=81=A3=E3=81=99=E3=82=89=E3=81=A4?= =?UTF-8?q?=E3=81=84=E3=81=A6=E3=82=8B=E3=81=8B=E3=82=8F=E3=81=8B=E3=82=8B?= =?UTF-8?q?=E3=81=8B=E7=A8=8B=E5=BA=A6=E3=81=AA=E3=82=89=E6=B6=88=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=97=E3=81=BE=E3=81=88=E3=81=B0=E3=81=84=E3=81=84?= =?UTF-8?q?=E3=81=AE=E3=81=AB...=20=E5=85=85=E9=9B=BB=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E3=83=BB=E5=86=8D=E9=96=8B=E6=B8=A9=E5=BA=A6=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82=E3=81=9F=E3=81=A0=E3=81=97=E8=A9=95=E4=BE=A1?= =?UTF-8?q?=E3=82=92=E5=BE=85=E3=81=A3=E3=81=A6=E3=81=BE=E3=81=9F=E3=81=84?= =?UTF-8?q?=E3=81=98=E3=82=89=E3=82=8C=E3=82=8B=E3=81=8B=E3=82=82=E3=81=97?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=20=E3=80=80=E9=9B=BB=E6=B1=A0?= =?UTF-8?q?=E6=AE=8B=E9=87=8F=E5=89=B2=E3=82=8A=E8=BE=BC=E3=81=BF=E3=81=AE?= =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=82=92=E5=85=A5=E3=82=8C=E3=81=9F=E3=80=82=20=E3=80=80?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E5=BA=A6=E3=82=BB=E3=83=B3=E3=82=B5=E3=81=8C?= =?UTF-8?q?=E5=8B=95=E3=81=84=E3=81=A6=E3=81=84=E3=82=8B=E3=81=A8=E3=80=81?= =?UTF-8?q?=E5=BC=B7=E5=88=B6=E3=82=AA=E3=83=95=E3=81=AB=E6=99=82=E9=96=93?= =?UTF-8?q?=E3=81=8C=E6=8E=9B=E3=81=8B=E3=82=8B=E3=81=A8=E3=81=AE=E4=BA=8B?= =?UTF-8?q?=E3=81=A7=E3=82=B7=E3=82=B9=E3=83=86=E3=83=A0=E3=83=81=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=82=A4=E3=83=9E=E3=82=92=E6=95=B0=E3=81=88?= =?UTF-8?q?=E3=81=A6=E3=81=BF=E3=81=9F=E3=81=8C=E3=80=81=E3=82=B8=E3=83=83?= =?UTF-8?q?=E3=82=BF=E3=81=AF=E5=A2=97=E3=81=88=E3=82=8B=E3=82=82=E3=81=AE?= =?UTF-8?q?=E3=81=AE=E3=80=81=E5=95=8F=E9=A1=8C=E7=84=A1=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AA=E6=B0=97=E3=81=8C=E3=81=99=E3=82=8B=E3=81=97?= =?UTF-8?q?=E3=80=81=E6=89=8B=E5=85=83=E3=81=A7=E8=A9=A6=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=82=82=E5=90=8C=E3=81=98=E6=B0=97=E3=81=8C=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=80=82=E6=9D=A1=E4=BB=B6=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=97?= =?UTF-8?q?=E3=82=88=E3=81=86=20=E3=80=80?= 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@189 013db118-44a6-b54f-8bf7-843cb86687b1 --- trunk/accero.c | 16 ++--- trunk/batt_params.h | 3 +- trunk/bsr_system.h | 5 +- trunk/i2c_ctr.c | 2 +- trunk/incs.h | 2 +- trunk/jhl_defs.h | 43 +++++++++++-- trunk/led.c | 10 +-- trunk/led.h | 18 +++--- trunk/pm.c | 106 ++++++++++++++++++-------------- trunk/pm.h | 2 +- trunk/pool.h | 5 +- trunk/renge/renge.c | 5 +- trunk/renge/renge.h | 3 +- trunk/renge/renge_defs.h | 14 ++--- trunk/renge/renge_task_intval.h | 3 +- trunk/rtc.c | 2 + trunk/sw.h | 4 +- trunk/task_sys.c | 8 ++- trunk/vreg_ctr.c | 4 ++ trunk/vreg_ctr.h | 2 +- trunk/vreg_twl.h | 3 +- trunk/yav_mcu_bsr.plg | 27 ++++---- trunk/yav_mcu_bsr.pri | 53 +++------------- trunk/yav_mcu_bsr.prk | 8 +-- 24 files changed, 182 insertions(+), 166 deletions(-) diff --git a/trunk/accero.c b/trunk/accero.c index ea7ad31..e4e2a52 100644 --- a/trunk/accero.c +++ b/trunk/accero.c @@ -91,7 +91,7 @@ task_status_immed tsk_cbk_accero( ) vreg_ctr[ VREG_C_ACC_CONFIG ] &= ~( VREG_BITMASK_ACC_CONF_HOSU | VREG_BITMASK_ACC_CONF_ACQ ); acc_hosu_set(); vreg_ctr[ VREG_C_STATUS_1 ] |= REG_BIT_ACCERO_ERR; - return ( ERR_SUCCESS ); // タスクの削除は必要 + return ( ERR_FINISED ); // タスクの削除は必要 } } else @@ -119,7 +119,7 @@ task_status_immed tsk_cbk_accero( ) pedometer(); // 歩数計 } } - return ( ERR_SUCCESS ); + return ( ERR_FINISED ); } @@ -138,7 +138,7 @@ task_status_immed acc_read( ) { IRQ0_ast; } - return ( ERR_SUCCESS ); + return ( ERR_FINISED ); } @@ -154,7 +154,7 @@ task_status_immed acc_write( ) { IRQ0_ast; } - return ( ERR_SUCCESS ); + return ( ERR_FINISED ); } @@ -173,7 +173,7 @@ task_status_immed acc_hosu_set( ) #ifdef _MCU_BSR_ // PMK23 = 1; #endif - return ( ERR_SUCCESS ); // とりあえず、タスクは削除しなくてはならない + return ( ERR_FINISED ); // とりあえず、タスクは削除しなくてはならない }else{ vreg_ctr[ VREG_C_STATUS_1 ] &= ~REG_BIT_ACCERO_ERR; } @@ -239,7 +239,7 @@ if( system_status.model == MODEL_TS_BOARD ) iic_mcu_write( IIC_SLA_ACCEL, ( ACC_REG_CTRL1 | 0x80 ), 4, str_send_buf ); // カラ読み - if( ACC_VALID == 1 ) + if( ACC_VALID ) { if( system_status.pwr_state == ON ) { @@ -247,7 +247,7 @@ if( system_status.model == MODEL_TS_BOARD ) iic_mcu_read( IIC_SLA_ACCEL, ( ACC_REG_X | 0x80 ), 6, temp ); } } - return ( ERR_SUCCESS ); + return ( ERR_FINISED ); } @@ -263,7 +263,7 @@ __interrupt void intp23_ACC_ready( ) { if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) ) { - if( ACC_VALID == 1 ) + if( ACC_VALID ) { renge_task_immed_add( tsk_cbk_accero ); } diff --git a/trunk/batt_params.h b/trunk/batt_params.h index 6f2fa53..b1a339d 100644 --- a/trunk/batt_params.h +++ b/trunk/batt_params.h @@ -104,7 +104,8 @@ const u8 BT_PARAM[][64] = { -typedef struct { +typedef struct _st_bt_comp +{ unsigned char rcomp; signed short temp_co_up; // 256倍したものを入れとく signed short temp_co_dn; // 〃 diff --git a/trunk/bsr_system.h b/trunk/bsr_system.h index e86fb71..cbf2f35 100644 --- a/trunk/bsr_system.h +++ b/trunk/bsr_system.h @@ -36,7 +36,7 @@ enum model_ }; // タスクシステムの状態情報など -typedef struct +typedef struct _system_status_ { enum pwr_state_ pwr_state; enum poweron_reason_ poweron_reason; @@ -47,8 +47,7 @@ typedef struct unsigned char info_fullcolor:1; enum model_ model; unsigned short cnt_force_off; -} -system_status_; +}system_status_; extern system_status_ system_status; diff --git a/trunk/i2c_ctr.c b/trunk/i2c_ctr.c index cae9e2b..0f2a16d 100644 --- a/trunk/i2c_ctr.c +++ b/trunk/i2c_ctr.c @@ -60,7 +60,7 @@ u8 iic_burst_state; /* ======================================================== ======================================================== */ -enum +enum IIC_STATE { IIC_IDLE = 0, IIC_RCV_REG_ADRS, diff --git a/trunk/incs.h b/trunk/incs.h index 3ef2066..8cdc0dc 100644 --- a/trunk/incs.h +++ b/trunk/incs.h @@ -19,7 +19,7 @@ #include "user_define.h" #include "bsr_system.h" -#include "renge.h" +#include "renge\renge.h" #include "vreg_ctr.h" #include "vreg_twl.h" diff --git a/trunk/jhl_defs.h b/trunk/jhl_defs.h index 8a73844..adc225a 100644 --- a/trunk/jhl_defs.h +++ b/trunk/jhl_defs.h @@ -9,13 +9,10 @@ typedef signed short s16; typedef unsigned short ux16; typedef signed short sx16; -typedef unsigned char err; - +// typedef unsigned char err; #include "config.h" - - #define set_bit( cond, reg, pos ) \ { \ if( cond ){ \ @@ -26,4 +23,42 @@ typedef unsigned char err; } +# ifdef _WIN32 + +typedef bool bit; + +void EI(){}; +void DI(){}; +void HALT(){}; +void NOP(){}; + +#define __interrupt +#define __far + + +typedef struct +{ + unsigned 7 :1; + unsigned 6 :1; + unsigned 5 :1; + unsigned 4 :1; + unsigned 3 :1; + unsigned 2 :1; + unsigned 1 :1; + unsigned 0 :1; +}mcu_reg; + +mcu_reg P20; +mcu_reg P7; +mcu_reg P4; +mcu_reg P2; + +unsigned char PMK23; +unsigned char RTCIMK; +unsigned char WDTE; +unsigned char PM2; + + +# endif + #endif diff --git a/trunk/led.c b/trunk/led.c index 085ed23..7ad2559 100644 --- a/trunk/led.c +++ b/trunk/led.c @@ -550,14 +550,10 @@ void tsk_led_notify( ) { time_to_next_frame = info_LED.info_LED.term; - // 最後のフレームリピート( bool ) if( frame >= NOTIFY_LED_TERM -1 ) { - if( info_LED.info_LED.last_loop == 255 ) - { - vreg_ctr[ VREG_C_LED_NOTIFY_FLAG ] |= REG_BIT_IN_LOOP; - } - else + vreg_ctr[ VREG_C_LED_NOTIFY_FLAG ] |= REG_BIT_IN_LOOP; + if( info_LED.info_LED.last_loop != 255 ) // 255:無限ループ { if( loops_to_go != 0 ) { @@ -573,7 +569,7 @@ void tsk_led_notify( ) else { vreg_ctr[ VREG_C_LED_NOTIFY_FLAG ] &= ~REG_BIT_IN_LOOP; - frame = (( frame + 1 ) & 0x1F ); + frame = (( frame + 1 ) & 0x1F ); // ←ここでマスクをかけておかないと最終フレーム〜先頭間のグラデが効かない } LED_dim_status_info_R.to = info_LED.info_LED.red[frame] * 128; diff --git a/trunk/led.h b/trunk/led.h index 602ec5c..3637da4 100644 --- a/trunk/led.h +++ b/trunk/led.h @@ -70,7 +70,7 @@ enum LED_MODE_TUNE // VREG_C_WIFI_LED -enum +enum WIFI_LED_MODE { WIFI_LED_OFF = 0, WIFI_LED_ON @@ -78,7 +78,7 @@ enum // VREG_C_WIFI_NOTIFY -enum +enum NOTIFY_LED_MODE { NOTIFY_LED_OFF = 0, NOTIFY_LED_ON, @@ -89,7 +89,7 @@ enum // VREG_C_CAM_LED -enum +enum CAM_LED_MODE { CAM_LED_OFF = 0, CAM_LED_BLINK, @@ -102,7 +102,8 @@ enum // お知らせLED調光関係 // -typedef struct{ +typedef struct _st_info_LED +{ u8 term; // 1フレーム何チック? u8 fade_time; // 何チックで次のフレームの色に達するか u8 last_loop; // 最終フレームを繰り返す? @@ -112,7 +113,8 @@ typedef struct{ u8 blu[32]; }st_info_LED; -typedef union{ +typedef union _uni_info_LED +{ st_info_LED info_LED; u8 bindata[ sizeof( st_info_LED ) ]; }uni_info_LED; @@ -121,7 +123,8 @@ extern uni_info_LED info_LED; // 赤LED 点滅向け // -typedef struct{ +typedef struct _st_led_red_batt_empty +{ u8 dats[4]; }st_led_red_batt_empty; @@ -131,7 +134,8 @@ extern st_led_red_batt_empty led_red_batt_empty; /* お知らせLED */ -typedef struct{ +typedef struct _st_LED_dim_status +{ sx16 to; sx16 delta; sx16 now; // 小数点以下を覚えておかなくてはならないため diff --git a/trunk/pm.c b/trunk/pm.c index 862c4b1..0d960f2 100644 --- a/trunk/pm.c +++ b/trunk/pm.c @@ -10,7 +10,7 @@ #include "adc.h" #include "led.h" #include "pm.h" -#include "renge.h" +#include "renge\renge.h" #include "batt_params.h" @@ -59,20 +59,21 @@ err PM_LCD_on( ) rv = PM_chk_LDSW( ); - if( rv != 0 ) + if( rv != 0 ) { // 電源起動エラーなら電源も切れてしまう。ここではケアしない vreg_ctr[VREG_C_STATUS] |= REG_BIT_LCD_POW; set_irq( VREG_C_IRQ3, REG_BIT_LCD_ON ); SND_DEPOP_SND_ENABLE; + return ( ERR_ERR ); } #ifdef _PMIC_TWL_ PM_TEG_LCD_dis( 0 ); blset = ( PM_REG_BIT_BL_U | PM_REG_BIT_BL_L ); #endif - return ( rv ); + return ( ERR_SUCCESS ); } // BSR // @@ -542,13 +543,13 @@ task_status_immed ntr_pmic_comm( ) task_status_immed tski_PM_LCD_on() { PM_LCD_on(); - return( ERR_SUCCESS ); + return( ERR_FINISED ); } task_status_immed tski_PM_LCD_off() { PM_LCD_off(); - return( ERR_SUCCESS ); + return( ERR_FINISED ); } task_status_immed tski_PM_BL_set() @@ -563,7 +564,7 @@ task_status_immed tski_PM_BL_set() while( cmd_BL != vreg_ctr[VREG_C_COMMAND2] ); // <- PM_BL_setが更新する vreg_ctr[VREG_C_COMMAND2] = 0; - return( ERR_SUCCESS ); + return( ERR_FINISED ); } @@ -624,13 +625,13 @@ void tsk_batt( ) // 充電 /////////////////////////// // 温度付きヒステリシス - if(( 86 < raw_adc_temperature ) - && ( raw_adc_temperature < 185 )) + if(( 75 <= raw_adc_temperature ) + && ( raw_adc_temperature <= 184 )) { temp_zone_charge_enable = 1; // 充電許可 } - else if(( raw_adc_temperature < 70 ) - || ( 189 < raw_adc_temperature )) + else if(( raw_adc_temperature <= 61 ) + || ( 189 <= raw_adc_temperature )) { temp_zone_charge_enable = 0; // 充電禁止 } @@ -945,7 +946,7 @@ task_status_immed BT_temp_update( ) vreg_ctr[ VREG_C_STATUS_1 ] |= REG_BIT_GASGAUGE_ERR; } } - return ( ERR_SUCCESS ); + return ( ERR_FINISED ); } @@ -960,41 +961,52 @@ void BT_get_left(){ u8 temp[2]; // 電池残量更新 // - if( system_status.model == MODEL_TS_BOARD ) - { - vreg_ctr[ VREG_C_BT_REMAIN ] = 99; - } - else - { - if(( vreg_ctr[ VREG_C_STATUS_1 ] & REG_BIT_GASGAUGE_ERR ) == 0 ) - { - temp[0] = iic_mcu_read_a_byte( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL ); - if( iic_mcu_bus_status != ERR_SUCCESS ) - { - // バッテリ残量が取れなくなった - vreg_ctr[ VREG_C_STATUS_1 ] |= REG_BIT_GASGAUGE_ERR; - bt_chg_ready = 0; - vreg_ctr[ VREG_C_BT_REMAIN ] = 0; - } - else - { - if( temp[0] < ( 3100 / 16 / 1.25 ) ) - { - // 電圧が規定値になってしまったので強制off - vreg_ctr[ VREG_C_BT_REMAIN ] = 0; - } - else - { - // 電圧はまだ大丈夫、電池残量ICとの通信もOK - vreg_ctr[ VREG_C_BT_VOLTAGE ] = temp[0]; - iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_SOC, 2, temp ); - vreg_ctr[ VREG_C_BT_REMAIN ] = temp[0]; - vreg_ctr[ VREG_C_BT_REMAIN_FINE ] = temp[1]; - } - } - } - // もう特に何もすること無いと思う... - } + +#ifdef _debug_bt_irq_ + if( vreg_ctr[ VREG_C_COMMAND3 ] == 'd' ) + { + vreg_ctr[ VREG_C_BT_REMAIN ] = vreg_ctr[ VREG_C_DBG01 ]; + } + else +#endif + { + if( system_status.model == MODEL_TS_BOARD ) + { + vreg_ctr[ VREG_C_BT_REMAIN ] = 99; + } + else + { + if(( vreg_ctr[ VREG_C_STATUS_1 ] & REG_BIT_GASGAUGE_ERR ) == 0 ) + { + temp[0] = iic_mcu_read_a_byte( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL ); + if( iic_mcu_bus_status != ERR_SUCCESS ) + { + // バッテリ残量が取れなくなった + vreg_ctr[ VREG_C_STATUS_1 ] |= REG_BIT_GASGAUGE_ERR; + bt_chg_ready = 0; + vreg_ctr[ VREG_C_BT_REMAIN ] = 0; + } + else + { + if( temp[0] < ( 3100 / 16 / 1.25 ) ) + { + // 電圧が規定値になってしまったので強制off + vreg_ctr[ VREG_C_BT_REMAIN ] = 0; + } + else + { + // 電圧はまだ大丈夫、電池残量ICとの通信もOK + vreg_ctr[ VREG_C_BT_VOLTAGE ] = temp[0]; + iic_mcu_read( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_SOC, 2, temp ); + vreg_ctr[ VREG_C_BT_REMAIN ] = temp[0]; + vreg_ctr[ VREG_C_BT_REMAIN_FINE ] = temp[1]; + } + } + } + // もう特に何もすること無いと思う... + } + } + // 残量で割り込み。急激に減ると飛ぶことがある // @@ -1032,7 +1044,7 @@ static unsigned long bt_relax_timer; **********************************************************/ void BT_set_relax_timer() { - // RTCを使うと楽かと思ったがそうでもなかった + // RTCを使うと楽かと思ったがとんでもなかった bt_relax_timer = (unsigned long)( BT_RELAX_TIME_MIN * 60 * 1000 / SYS_INTERVAL_TICK ); } diff --git a/trunk/pm.h b/trunk/pm.h index 6bfbbb4..eecf47d 100644 --- a/trunk/pm.h +++ b/trunk/pm.h @@ -48,7 +48,7 @@ enum BT_GAUGE_REG_ADRS }; -typedef enum +typedef enum BT_VENDER { BT_VENDER_MAXELL = 0, // ショート BT_VENDER_1, // 120 diff --git a/trunk/pool.h b/trunk/pool.h index 3093b4f..81c8091 100644 --- a/trunk/pool.h +++ b/trunk/pool.h @@ -7,12 +7,13 @@ #define VREG_C_FREE_SIZE 200 // 空いてるメモリ -typedef struct { +typedef struct _st_vreg_c_ext{ unsigned short pedo_log[ PEDOMETER_LOG_SIZE ]; unsigned char vreg_c_free[ VREG_C_FREE_SIZE ]; }st_vreg_c_ext; -typedef union{ +typedef union _uni_pool +{ st_vreg_c_ext vreg_c_ext; u8 self_update_work[ 256 ]; // 256以上はまとめ書きできない }uni_pool; diff --git a/trunk/renge/renge.c b/trunk/renge/renge.c index d079981..1c5a5de 100644 --- a/trunk/renge/renge.c +++ b/trunk/renge/renge.c @@ -17,6 +17,7 @@ #include "..\config.h" #include "..\user_define.h" + #define _renge_test_ //****************************************************************************** @@ -93,9 +94,7 @@ err renge_task_interval_run(){ EI(); for( i = 0; i != TSK_LAST; i += 1 ) { - DBG_LED_on; tasks[ i ](); - DBG_LED_off; // 逐次起動タスクがあったら起動しておく renge_task_immed_run(); } @@ -135,7 +134,7 @@ void renge_task_immed_init(){ 逐次実行タスクの登録 割り込み禁止 36us → **************************************/ -err renge_task_immed_add( task_status* new_task ){ +err renge_task_immed_add( task_status_immed* new_task ){ u8 i; // リストの空きの先頭に登録 diff --git a/trunk/renge/renge.h b/trunk/renge/renge.h index b968c3e..58bf013 100644 --- a/trunk/renge/renge.h +++ b/trunk/renge/renge.h @@ -10,12 +10,11 @@ #include "renge_task_immediate.h" // #include "renge_task_interval_run.h" // 外から強制起動禁止! - //****************************************************************************** void renge_init(); void renge_task_immed_init(); err renge_task_immed_run(); -err renge_task_immed_add( task_immed ); +err renge_task_immed_add( task_status_immed* ); // static err renge_task_immed_del( u8 ); void wait_ms( u8 ); diff --git a/trunk/renge/renge_defs.h b/trunk/renge/renge_defs.h index 8b725b7..0199d76 100644 --- a/trunk/renge/renge_defs.h +++ b/trunk/renge/renge_defs.h @@ -17,9 +17,6 @@ typedef signed char s8; typedef unsigned short u16; typedef signed short s16; -typedef unsigned char err; - - // ************************************ #define SYS_INTERVAL_TICK 1.953 @@ -27,14 +24,15 @@ typedef unsigned char err; // ************************************ -typedef enum{ +typedef enum _ERR +{ ERR_SUCCESS = 0, - ERR_ERR, - ERR_SYSTEM_OFF -}ERR; + ERR_ERR +}err; -typedef enum{ +typedef enum _IMMED_TASK_ERR +{ ERR_FINISED = 0, ERR_CONTINUE }IMMED_TASK_ERR; diff --git a/trunk/renge/renge_task_intval.h b/trunk/renge/renge_task_intval.h index 7505c19..58a997e 100644 --- a/trunk/renge/renge_task_intval.h +++ b/trunk/renge/renge_task_intval.h @@ -5,7 +5,8 @@ #include "renge_defs.h" -enum { +enum TSK +{ TSK_SW, TSK_ADC, TSK_BATT, TSK_LED_POW, TSK_LED_WIFI, TSK_LED_NOTIFY, TSK_LED_CAM, TSK_MISC, TSK_STATUS, TSK_DEBUG, TSK_DEBUG2, TSK_SYS, TSK_LAST }; diff --git a/trunk/rtc.c b/trunk/rtc.c index 340daa2..7ac36fa 100644 --- a/trunk/rtc.c +++ b/trunk/rtc.c @@ -176,5 +176,7 @@ void rtc_unlock( ) ======================================================== */ __interrupt void int_rtc_int( ) { + DBG_LED_on; renge_flg_interval += 1; // インクリメント/デクリメント命令を使うので DI()不要 + DBG_LED_off; } diff --git a/trunk/sw.h b/trunk/sw.h index 656e326..eb5120b 100644 --- a/trunk/sw.h +++ b/trunk/sw.h @@ -11,10 +11,10 @@ extern bit SW_pow_mask; #ifdef _FORCE_OFF_1SEC_ #define HOLD_THREASHOLD (u8)( 800 / INTERVAL_TSK_SW ) -#define FORCEOFF_THREASHOLD (u8)( 1200 / INTERVAL_TSK_SW /10 ) +#define FORCEOFF_THREASHOLD (u8)( 1200 / SYS_INTERVAL_TICK /64 ) #else #define HOLD_THREASHOLD (u8)( 2000 / INTERVAL_TSK_SW ) -#define FORCEOFF_THREASHOLD (u8)( 4000 / INTERVAL_TSK_SW /10 ) +#define FORCEOFF_THREASHOLD (u8)( 4000 / SYS_INTERVAL_TICK /64 ) #endif #endif diff --git a/trunk/task_sys.c b/trunk/task_sys.c index fb8fbb9..35f65fe 100644 --- a/trunk/task_sys.c +++ b/trunk/task_sys.c @@ -77,6 +77,12 @@ void tsk_sys( ) timeout = 0; + // todo debug +#ifdef _debug_bt_irq_ + vreg_ctr[ VREG_C_DBG01 ] = 63; // todo (仮) +#endif + vreg_ctr[ VREG_C_COMMAND3 ] = 0; + // 電源投入 // iic_mcu_start( ); BT_chk(); @@ -448,7 +454,7 @@ static void force_off_check() if( system_status.cnt_force_off != 0 ) { system_status.cnt_force_off += 1; - if( system_status.cnt_force_off >= ( vreg_ctr[ VREG_C_OFF_DELAY ] * 80 /2 ) ) + if( system_status.cnt_force_off >= ( vreg_ctr[ VREG_C_OFF_DELAY ] * 64 ) ) { system_status.pwr_state = OFF_TRIG; renge_task_interval_run_force = 1; diff --git a/trunk/vreg_ctr.c b/trunk/vreg_ctr.c index 10bd9d5..63454ae 100644 --- a/trunk/vreg_ctr.c +++ b/trunk/vreg_ctr.c @@ -41,6 +41,7 @@ extern task_status_immed tski_mcu_info_read(); // ******************************************************** // 非ゼロの初期値の指定が必要なアドレス +// マイコンリセット時に呼ばれます void vreg_ctr_init( ) { vreg_ctr[ VREG_C_LED_BRIGHT ] = 0xFF; @@ -51,6 +52,9 @@ void vreg_ctr_init( ) vreg_ctr[ VREG_C_OFF_DELAY ] = FORCEOFF_THREASHOLD; } + +// ******************************************************** +// 本体の電源投入時にセットされます void vreg_ctr_reset( ) { #ifdef _PMIC_TWL_ diff --git a/trunk/vreg_ctr.h b/trunk/vreg_ctr.h index 2aaa230..55516db 100644 --- a/trunk/vreg_ctr.h +++ b/trunk/vreg_ctr.h @@ -143,7 +143,7 @@ extern u8 vreg_ctr[]; /*============================================================================*/ -enum VREG_C +enum VREG_C_ADRS { // 未定義アドレスへ書き込んだ際の動作は不定 VREG_C_MCU_VER_MAJOR = 0x00, VREG_C_MCU_VER_MINOR, diff --git a/trunk/vreg_twl.h b/trunk/vreg_twl.h index 93eda99..37c73ff 100644 --- a/trunk/vreg_twl.h +++ b/trunk/vreg_twl.h @@ -103,7 +103,8 @@ enum REG_TWL_ADRS_INT #define REG_TWL_ADRS_MODE__VOL32 ( 1 << 7 ) -typedef enum { +typedef enum CAM_LED_TWL_MODE +{ TWL_CAMLED_OFF, TWL_CAMLED_ON, TWL_CAMLED_BLINK, diff --git a/trunk/yav_mcu_bsr.plg b/trunk/yav_mcu_bsr.plg index 25527c2..9a72375 100644 --- a/trunk/yav_mcu_bsr.plg +++ b/trunk/yav_mcu_bsr.plg @@ -1,23 +1,18 @@ C:\WINDOWS\system32\cmd.exe /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 -qvjl2w -sainter_asm -zpb -no pm.c -pm.c(60) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(97) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(181) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(189) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(477) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(480) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(922) : CC78K0R warning W0401: Conversion may lose significant digits -pm.c(1019) : CC78K0R warning W0401: Conversion may lose significant digits -batt_params.h(117) : CC78K0R warning W0401: Conversion may lose significant digits -batt_params.h(117) : CC78K0R warning W0401: Conversion may lose significant digits -batt_params.h(122) : CC78K0R warning W0401: Conversion may lose significant digits -Compilation complete, 0 error(s) and 11 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\pm.asm -Assembly complete, 0 error(s) and 0 warning(s) found. "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 -qvjl2w -sainter_asm -zpb -no magic.c Compilation complete, 0 error(s) and 0 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\magic.asm Assembly complete, 0 error(s) and 0 warning(s) found. +"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 -qvjl2w -sainter_asm -zpb -no rtc.c +Compilation complete, 0 error(s) and 0 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\rtc.asm +Assembly complete, 0 error(s) and 0 warning(s) found. +"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 -qvjl2w -sainter_asm -zpb -no renge\renge.c +renge\renge.c(149) : CC78K0R warning W0411: Illegal pointer combination +renge\renge.c(157) : CC78K0R warning W0412: Illegal pointer combination in conditional expression +Compilation complete, 0 error(s) and 2 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\renge.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 -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 led.rel rtc.rel vreg_ctr.rel vreg_twl.rel adc.rel renge.rel accero.rel self_flash.rel sw.rel task_debug.rel task_misc.rel task_sys.rel pedo_alg_thre_det2.rel ini_VECT.rel task_status.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 @@ -28,4 +23,4 @@ intel-HEX to bsr bin converter file converted! -Build Total error(s) : 0 Total warning(s) : 11 +Build Total error(s) : 0 Total warning(s) : 2 diff --git a/trunk/yav_mcu_bsr.pri b/trunk/yav_mcu_bsr.pri index 2a6a9b2..b359b80 100644 --- a/trunk/yav_mcu_bsr.pri +++ b/trunk/yav_mcu_bsr.pri @@ -80,8 +80,8 @@ Kanji=SJIS [Source] Geometry=71, 28, 844, 790 Window=Normal -DispStart=38 -CaretPos=77,0 +DispStart=269 +CaretPos=319,0 Mode=Normal DispFile= Address1= @@ -141,9 +141,9 @@ SaveEnd= Accumulative=ON [Assemble] Geometry=282, 92, 968, 626 -Window=Hide -DispStart=864531456 -CaretPos=0,0 +Window=Normal +DispStart=15201 +CaretPos=15201,27 Address1= Address2= Address3= @@ -894,17 +894,7 @@ Manager=ON Sort by=Unsort Detail=OFF Last Name= -Name0=bt_ch001 -Status0=W -Access Size0=B -Address Range0=EQ -Address0= - <> -Mask Address0=00000000 -Data Range0=NC -Data0=<00000000> - <00000000> -Mask Data0=FFFFFFFF -Pass0=0001 -Count=1 +Count=0 [Event Link] Geometry=0, 0, 0, 0 Window=Hide @@ -920,10 +910,7 @@ Manager=ON Sort by=Unsort Detail=OFF Last Name= -Name0=bt_ch002 -Element0=bt_ch001 -Set0=OFF -Count=1 +Count=0 [Trace] Geometry=0, 0, 0, 0 Window=Hide @@ -1018,31 +1005,7 @@ Line=23 Geometry=408, 387, 756, 532 Window=Normal Width=150 30 200 100 -Name0=Swb00002 -Address0=renge.c#_renge_task_immed_run+0x3d -Window0=ASM -Status0=ON -Name1=Swb00003 -Address1=renge.c#_renge_task_immed_run+0x11c -Window1=ASM -Status1=ON -Name2=Swb00005 -Address2=task_sys.c#_force_off_check+0x9 -Window2=ASM -Status2=ON -Name3=Swb00001 -Address3=vreg_ctr.c#_set_irq+0x23 -Window3=ASM -Status3=ON -Name4=Swb00007 -Address4=task_sys.c#_tsk_sys+0x224 -Window4=ASM -Status4=ON -Name5=Swb00008 -Address5=task_sys.c#_tsk_sys+0x21a -Window5=ASM -Status5=ON -Count=6 +Count=0 [Reset] Debugger=ON Symbol=OFF diff --git a/trunk/yav_mcu_bsr.prk b/trunk/yav_mcu_bsr.prk index 6dd2659..d62aa72 100644 --- a/trunk/yav_mcu_bsr.prk +++ b/trunk/yav_mcu_bsr.prk @@ -4,11 +4,11 @@ FrameX=68 FrameY=16 FrameCX=1299 FrameCY=1044 -OpenFile1=ProjectWindow -PrjPos=0,2,754,3,253 -OpenFile2=OutputWindow +OpenFile1=OutputWindow OutputPos=0,44,989,1000,1587 -OpenFile3=pm.c,0,176,176,1420,933,0,1036,0,0 +OpenFile2=pm.c,0,176,176,1420,933,0,1036,0,0 +OpenFile3=ProjectWindow +PrjPos=0,2,754,3,253 ActivePRJ=yav_mcu_bsr.prj [ProjectWindow] ProjectWindowDispType=0