V0.6 ベータ

全ファイルをindentに通した
ほか、たくさん修正

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@12 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
fujita_ryohei 2009-10-19 11:16:14 +00:00
parent 9453e8fbfe
commit 5e9ec34e61
47 changed files with 4748 additions and 4172 deletions

View File

@ -8,7 +8,7 @@
//========================================================= //=========================================================
// ウォッチドッグタイマのリスタート // ウォッチドッグタイマのリスタート
// 0xACはマジック // 0xACはマジック
void WDT_Restart( void ){ void WDT_Restart( void )
WDTE = WDT_RESTART_MAGIC; {
WDTE = WDT_RESTART_MAGIC;
} }

View File

@ -9,7 +9,7 @@
//========================================================= //=========================================================
void WDT_Restart(void); void WDT_Restart( void );
// 規定値以外を書くと例外でリセットがかかる // 規定値以外を書くと例外でリセットがかかる
#define mcu_reset WDTE = 0x5A #define mcu_reset WDTE = 0x5A

View File

@ -9,8 +9,12 @@
#pragma NOP #pragma NOP
#pragma HALT #pragma HALT
#pragma STOP #pragma STOP
#pragma ROT
// rorb, rolb, rorw, rolw
#pragma MUL
#include "incs.h" #include "incs.h"
#include <math.h>
// ======================================================== // ========================================================
@ -44,11 +48,13 @@
#define VREG_BITMASK_ACC_CONF_HOSU ( 1 << 1 ) #define VREG_BITMASK_ACC_CONF_HOSU ( 1 << 1 )
#define VREG_BITMASK_ACC_CONF_ACQ ( 1 << 0 ) #define VREG_BITMASK_ACC_CONF_ACQ ( 1 << 0 )
// ========================================================
static u8 hyst_pedometer[256];
// ======================================================== // ========================================================
task_interval tsk_soft_int(); task_interval tsk_soft_int( );
@ -58,43 +64,149 @@ task_interval tsk_soft_int();
I2Cが使用中だったら I2Cが使用中だったら
======================================================== */ ======================================================== */
task_status_immed tsk_cbk_accero(){ // 疑似isrから登録されます task_status_immed tsk_cbk_accero( )
{ // 疑似isrから登録されます
if( system_status.pwr_state == ON ){ if( system_status.pwr_state == ON )
{
// 加速度センサデータレジスタへの反映
iic_mcu_read( IIC_SLA_ACCEL, ( ACC_REG_X | 0x80 ), 6, &vreg_ctr[VREG_C_ACC_XL] );
// 加速度センサデータレジスタへの反映 {
iic_mcu_read( IIC_SLA_ACCEL, ( ACC_REG_X | 0x80 ), 6, &vreg_ctr[VREG_C_ACC_XL] ); // 歩数計 //
if(( vreg_ctr[ VREG_C_ACC_CONFIG ] & ( VREG_BITMASK_ACC_CONF_ACQ | VREG_BITMASK_ACC_CONF_HOSU ) ) != 0 ){ unsigned int mean; // 二乗平均はあまりにも処理が重いので(!) 絶対値の合計にします
set_irq( VREG_C_IRQ1, REG_BIT_ACC_DAT_RDY ); static u8 direction;
static s16 th_H = 0x2380; // 閾値。暫定。動的変更とかしたい…
static s16 th_L = 0x2180;
static u16 interval; // 山と谷の間の時間。短すぎても長すぎてもはじく。
s16 sx16 = vreg_ctr[VREG_C_ACC_XH] * 256 + vreg_ctr[VREG_C_ACC_XL];
s16 sy16 = vreg_ctr[VREG_C_ACC_YH] * 256 + vreg_ctr[VREG_C_ACC_YL];
s16 sz16 = vreg_ctr[VREG_C_ACC_ZH] * 256 + vreg_ctr[VREG_C_ACC_ZL];
// そのうちローコストな方法を考え
mean = sqrt( (long)abs( sx16 ) * abs( sx16 ) /4 +
(long)abs( sy16 ) * abs( sy16 ) /4 +
(long)abs( sz16 ) * abs( sz16 ) /4 );
{
static u8 count_H = 0;
static u8 count_L = 0;
if( direction == 0 ) // 前回に下限を下回っていて
{
if( mean > th_H ) // 今回、上の閾値を上回った
{
if( count_H == 5 ){ // 突発的なノイズは省く...
direction = 1;
count_L = 0;
}
if( count_H <= 5 ){
count_H += 1;
}
}
else
{
count_H = 0;
}
}
if( count_H >= 5 ){
interval += 1;
}
if( 500 < interval ){
interval = 0;
direction = 0;
count_H = 0;
count_L = 0;
}
// 下の閾値を超えるのを待つ
if( direction == 1 )
{
if( mean < th_L )
{
if( count_L == 5 ){
direction = 0; // 次は上の閾値を待つ
if( count_H >= 5 ){
if( 70 < interval )
{
vreg_ctr[ VREG_C_ACC_HOSU_L ] += 1; // 一歩加算
hyst_pedometer[0] += 1;
}
}
count_H = 0;
}
if( count_L <= 5 ){
count_L += 1;
}
}
else
{
count_L = 0;
}
}
}
// debug
if( mean > th_H )
{
DBG_LED_WIFI_on;
DBG_LED_WIFI_2_off;
}
if( mean < th_L )
{
DBG_LED_WIFI_off;
DBG_LED_WIFI_2_on;
}
}
if( ( vreg_ctr[VREG_C_ACC_CONFIG] &
( VREG_BITMASK_ACC_CONF_ACQ | VREG_BITMASK_ACC_CONF_HOSU ) ) != 0 )
{
set_irq( VREG_C_IRQ1, REG_BIT_ACC_DAT_RDY );
}
} }
}
// 歩数計 offでなければ、電源off中でも計測 // 歩数計 offでなければ、電源off中でも計測
if(( vreg_ctr[ VREG_C_ACC_CONFIG ] & VREG_BITMASK_ACC_CONF_HOSU ) != 0x00 ){ if( ( vreg_ctr[VREG_C_ACC_CONFIG] & VREG_BITMASK_ACC_CONF_HOSU ) != 0x00 )
if(( vreg_ctr[ VREG_C_ACC_CONFIG ] & VREG_BITMASK_ACC_CONF_ACQ ) != 0x00 ){ {
// 歩数計アルゴリズム 100Hz版 if( ( vreg_ctr[VREG_C_ACC_CONFIG] & VREG_BITMASK_ACC_CONF_ACQ ) != 0x00 )
}else{ {
// 同 省電力版 // 歩数計アルゴリズム 100Hz版
}
else
{
// 同 省電力版
}
} }
} return ( ERR_SUCCESS );
return( ERR_SUCCESS );
} }
/*========================================================= /*=========================================================
     
========================================================*/ ========================================================*/
task_status_immed acc_read(){ task_status_immed acc_read( )
vreg_ctr[ VREG_C_ACC_W_BUF ] = iic_mcu_read_a_byte( IIC_SLA_ACCEL, vreg_ctr[VREG_C_ACC_R_ADRS] ); {
vreg_ctr[VREG_C_ACC_W_BUF] = iic_mcu_read_a_byte( IIC_SLA_ACCEL, vreg_ctr[VREG_C_ACC_R_ADRS] );
// vreg_ctr[ VREG_C_ACC_R_BUF ] = iic_mcu_read_a_byte( IIC_SLA_ACCEL, vreg_ctr[VREG_C_ACC_R_ADRS] ); // vreg_ctr[ VREG_C_ACC_R_BUF ] = iic_mcu_read_a_byte( IIC_SLA_ACCEL, vreg_ctr[VREG_C_ACC_R_ADRS] );
vreg_ctr[ VREG_C_IRQ1 ] |= REG_BIT_ACC_ACK; vreg_ctr[VREG_C_IRQ1] |= REG_BIT_ACC_ACK;
if( ( vreg_ctr[ VREG_C_IRQ_MASK1 ] & REG_BIT_ACC_ACK ) == 0 ){ if( ( vreg_ctr[VREG_C_IRQ_MASK1] & REG_BIT_ACC_ACK ) == 0 )
IRQ0_ast; {
} IRQ0_ast;
return( ERR_SUCCESS ); }
return ( ERR_SUCCESS );
} }
@ -102,13 +214,15 @@ task_status_immed acc_read(){
/*========================================================= /*=========================================================
     
========================================================*/ ========================================================*/
task_status_immed acc_write(){ task_status_immed acc_write( )
iic_mcu_write_a_byte( IIC_SLA_ACCEL, vreg_ctr[VREG_C_ACC_W_ADRS], vreg_ctr[VREG_C_ACC_W_BUF] ); {
vreg_ctr[ VREG_C_IRQ1 ] |= REG_BIT_ACC_ACK; iic_mcu_write_a_byte( IIC_SLA_ACCEL, vreg_ctr[VREG_C_ACC_W_ADRS], vreg_ctr[VREG_C_ACC_W_BUF] );
if( ( vreg_ctr[ VREG_C_IRQ_MASK1 ] & REG_BIT_ACC_ACK ) == 0 ){ vreg_ctr[VREG_C_IRQ1] |= REG_BIT_ACC_ACK;
IRQ0_ast; if( ( vreg_ctr[VREG_C_IRQ_MASK1] & REG_BIT_ACC_ACK ) == 0 )
} {
return( ERR_SUCCESS ); IRQ0_ast;
}
return ( ERR_SUCCESS );
} }
@ -118,42 +232,70 @@ task_status_immed acc_write(){
todo todo
========================================================*/ ========================================================*/
task_status_immed acc_hosu_set(){ task_status_immed acc_hosu_set( )
u8 str_send_buf[4]; {
u8 str_send_buf[4];
iic_mcu_read_a_byte( IIC_SLA_ACCEL, ACC_REG_WHOAMI ); iic_mcu_read_a_byte( IIC_SLA_ACCEL, ACC_REG_WHOAMI );
if( iic_mcu_bus_status == ERR_NOSLAVE ){ if( iic_mcu_bus_status == ERR_NOSLAVE )
return( ERR_SUCCESS ); // とりあえず、タスクは削除しなくてはならない
}
str_send_buf[1] = 0x10; // ctrl2 HPF:normal, filterd, HPF for IRQ : dis/dis, HPF coeff:norm
#ifdef _MCU_WM0_
str_send_buf[2] = 0x10; // 3 IRQ pol :Active HI, Drive:Pushpull,
// IRQ2flg latch: auto clear after read, IRQ2 conf: IRQ( fall,shock,...)
// 1 : auto clear after read, conf: data ready
#else
str_send_buf[2] = 0x02; // 3 IRQ pol :Active HI, Drive:Pushpull,
// IRQ2flg latch: auto clear after read, IRQ2 conf: IRQ( fall,shock,...)
// 1 : auto clear after read, conf: data ready
#endif
str_send_buf[3] = 0x80; // ctrl3 block update:enable, MSB first, scale: +-2G(default), selftest: dis
if(( vreg_ctr[ VREG_C_ACC_CONFIG ] & ( VREG_BITMASK_ACC_CONF_HOSU | VREG_BITMASK_ACC_CONF_ACQ ) ) == 0 ){
// 完全停止
str_send_buf[0] = ( ACC_BITS_PM_PDN << ACC_bP_PM0 | 0 << ACC_bP_DR0 | ACC_BITS_ALL_AXIS_ON );
}
else
{ {
if(( vreg_ctr[ VREG_C_ACC_CONFIG ] & VREG_BITMASK_ACC_CONF_ACQ ) != 0x00 ){ return ( ERR_SUCCESS ); // とりあえず、タスクは削除しなくてはならない
// 100Hz 自動取り込み
str_send_buf[0] = ( ACC_BITS_PM_NORM << ACC_bP_PM0 | ACC_BITS_DR_100Hz << ACC_bP_DR0 | ACC_BITS_ALL_AXIS_ON );
}else{
// 10Hz 自動取り込み(歩数計向け省電力モード)
str_send_buf[0] = ( ACC_BITS_PM_LP10 << ACC_bP_PM0 | ACC_BITS_ALL_AXIS_ON );
}
} }
iic_mcu_write( IIC_SLA_ACCEL, ( ACC_REG_CTRL1 | 0x80 ), 4, str_send_buf );
return( ERR_SUCCESS ); str_send_buf[1] = 0x00; // ctrl2 HPF:normal, filterd, HPF for IRQ : dis/dis, HPF coeff:norm
#ifdef _MODEL_WM0_
str_send_buf[2] = 0x10; // 3 IRQ pol :Active HI, Drive:Pushpull,
/// IRQ2flg latch: auto clear after read, IRQ2 conf: IRQ( fall,shock,...)
/// 1 : auto clear after read, conf: data ready
#else
str_send_buf[2] = 0x02; // 3 IRQ pol :Active HI, Drive:Pushpull,
/// IRQ2flg latch: auto clear after read, IRQ2 conf: IRQ( fall,shock,...)
/// 1 : auto clear after read, conf: data ready
#endif
str_send_buf[3] = 0x80; // ctrl3 block update:enable, MSB first, scale: +-2G(default), selftest: dis
if( ( vreg_ctr[VREG_C_ACC_CONFIG] &
( VREG_BITMASK_ACC_CONF_HOSU | VREG_BITMASK_ACC_CONF_ACQ ) ) == 0 )
{
#ifdef _MCU_BSR_
PMK23 = 1;
#endif
// 完全停止
str_send_buf[0] =
( ACC_BITS_PM_PDN << ACC_bP_PM0 | 0 << ACC_bP_DR0 | ACC_BITS_ALL_AXIS_ON );
}
else
{
#ifdef _MCU_BSR_
PMK23 = 0;
#endif
if( ( vreg_ctr[VREG_C_ACC_CONFIG] & VREG_BITMASK_ACC_CONF_ACQ ) != 0x00 )
{
// 100Hz 自動取り込み
str_send_buf[0] =
( ACC_BITS_PM_NORM << ACC_bP_PM0 | ACC_BITS_DR_100Hz <<
ACC_bP_DR0 | ACC_BITS_ALL_AXIS_ON );
}
else
{
// 100Hz 自動取り込み
str_send_buf[0] =
( ACC_BITS_PM_NORM << ACC_bP_PM0 | ACC_BITS_DR_100Hz <<
ACC_bP_DR0 | ACC_BITS_ALL_AXIS_ON );
// // 10Hz 自動取り込み(歩数計向け省電力モード)
// str_send_buf[0] = ( ACC_BITS_PM_LP10 << ACC_bP_PM0 | ACC_BITS_ALL_AXIS_ON );
}
}
iic_mcu_write( IIC_SLA_ACCEL, ( ACC_REG_CTRL1 | 0x80 ), 4, str_send_buf );
if( ACC_VALID == 1 )
{
if( system_status.pwr_state == ON )
{
renge_task_immed_add( tsk_cbk_accero );
}
}
return ( ERR_SUCCESS );
} }
@ -162,37 +304,16 @@ task_status_immed acc_hosu_set(){
I2Cが使用中かもしれないので I2Cが使用中かもしれないので
======================================================== */ ======================================================== */
__interrupt void intp23_ACC_ready(){ __interrupt void intp23_ACC_ready( )
if( ( vreg_ctr[ VREG_C_ACC_CONFIG ] & 0x03 ) != 0x00 ){ {
if(( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) ){ if( ( vreg_ctr[VREG_C_ACC_CONFIG] & 0x03 ) != 0x00 )
if( ACC_VALID ){ {
renge_task_immed_add( tsk_cbk_accero ); if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) )
} {
if( ACC_VALID )
{
renge_task_immed_add( tsk_cbk_accero );
}
}
} }
}
} }
/* ========================================================
todo : // 本物のマイコンなら、割り込みでタスクを登録
======================================================== */
task_interval tsk_soft_int(){
if( ( vreg_ctr[ VREG_C_ACC_CONFIG ] & 0x03 ) != 0x00 ){
if(( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) ){
// Hエッジ検出
// pin = ( pin << 1 ) + ( ACC_VALID? 1: 0 );
// if( ( pin & 0x03 ) == 0x01 ){
if( ACC_VALID ){
renge_task_immed_add( tsk_cbk_accero );
}
}
return( 0 );
}
return( 248 );
}

View File

@ -4,8 +4,8 @@
#include "jhl_defs.h" #include "jhl_defs.h"
task_status_immed tsk_cbk_accero(); task_status_immed tsk_cbk_accero( );
task_status_immed acc_hosu_set(); task_status_immed acc_hosu_set( );
#endif #endif

View File

@ -9,9 +9,10 @@
#include "led.h" #include "led.h"
bit adc_updated; bit adc_updated;
#define INTERVAL_TSK_ADC 16
/* ======================================================== /* ========================================================
ADC設定と ADC設定と
@ -26,86 +27,118 @@ bit adc_updated;
8tics毎に呼ばれADCを停止します 8tics毎に呼ばれADCを停止します
   
======================================================== */ ======================================================== */
task_interval tsk_adc(){ void tsk_adc( )
static u8 old_tune; {
static u8 sndvol_codec; static u8 task_interval = 0;
static u8 bt_temp_old; static u8 old_tune;
static u8 sndvol_codec;
static u8 bt_temp_old;
if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) )
{
if( adc_updated )
{
if( task_interval != 0 )
{
task_interval -= 1;
return;
}
else
{
task_interval = ( INTERVAL_TSK_ADC / SYS_INTERVAL_TICK );
}
if(( system_status.pwr_state == ON )
|| ( system_status.pwr_state == SLEEP )){
if( adc_updated ){
#if 0 #if 0
tune tune <EFBFBD>
// tune // tune
if( abs( old_tune - vreg_ctr[ VREG_TUNE ] ) >= 4 ){ if( abs( old_tune - vreg_ctr[VREG_TUNE] ) >= 4 )
old_tune = vreg_ctr[ VREG_TUNE ]; {
vreg_ctr[ VREG_C_IRQ0 ] |= REG_BIT_VR_TUNE_CHANGE; old_tune = vreg_ctr[VREG_TUNE];
if( ( vreg_ctr[ VREG_C_IRQ_MASK0 ] & REG_BIT_VR_TUNE_CHANGE ) == 0 ){ vreg_ctr[VREG_C_IRQ0] |= REG_BIT_VR_TUNE_CHANGE;
IRQ0_ast; if( ( vreg_ctr[VREG_C_IRQ_MASK0] & REG_BIT_VR_TUNE_CHANGE ) == 0 )
} {
} IRQ0_ast;
}
}
#endif #endif
// Volume // Volume
{ {
static u8 class_old; static u8 vol_old;
u8 class; static u8 class_old;
static u8 direction = 0; // 0:上り方向 u8 class;
u8 comp; // 補正値 static u8 direction = 0; // 0:上り方向
u8 comp; // 補正値
class = ( vreg_ctr[ VREG_C_SND_VOL ] + ( ( direction != 0 )? 0: 2 ) ) / ( 200 / 8 ) ; //*
if( class != class_old ){ if( abs( vol_old - vreg_ctr[VREG_C_SND_VOL] ) > 3 )
direction = ( class > class_old )? 0: 1; {
class_old = class; vol_old = vreg_ctr[VREG_C_SND_VOL];
class = vreg_ctr[VREG_C_SND_VOL] / ( 256 / 8 );
if( class != class_old )
{
class_old = class;
/*/
if( vol_old != vreg_ctr[ VREG_C_SND_VOL ] ){
vol_old = vreg_ctr[ VREG_C_SND_VOL ];
class = ( vreg_ctr[ VREG_C_SND_VOL ] + ( ( direction != 0 )? 0: 2 ) ) / ( 200 / 8 ) ;
if( class != class_old ){
direction = ( class > class_old )? 0: 1;
class_old = class;
*/
set_irq( VREG_C_IRQ0, REG_BIT_VR_SNDVOL_CHANGE );
}
}
set_irq( VREG_C_IRQ0, REG_BIT_VR_SNDVOL_CHANGE ); }
}
} // codecに伝える
if( vreg_ctr[VREG_C_SND_VOL] != sndvol_codec )
// codecに伝える {
if( vreg_ctr[ VREG_C_SND_VOL ] != sndvol_codec ){ sndvol_codec = ( vreg_ctr[VREG_C_SND_VOL] / 2 + vreg_ctr[VREG_C_SND_VOL] / 4 );
sndvol_codec = vreg_ctr[ VREG_C_SND_VOL ];
#ifndef _CODEC_CTR_ #ifndef _CODEC_CTR_
iic_mcu_write_a_byte( IIC_SLA_DCP, 0, sndvol_codec ); iic_mcu_write_a_byte( IIC_SLA_DCP, 0, sndvol_codec );
// iic_mcu_write_a_byte( IIC_SLA_DCP, 0, (u8)((unsigned int)sndvol_codec * 4 / 5 ) ); // iic_mcu_write_a_byte( IIC_SLA_DCP, 0, (u8)((unsigned int)sndvol_codec * 4 / 5 ) );
#else #else
iic_mcu_write_a_byte( IIC_SLA_CODEC, REG_ADRS_CODEC_VOL, sndvol_codec );
iic_mcu_write_a_byte( IIC_SLA_CODEC, REG_ADRS_CODEC_VOL, sndvol_codec );
#endif #endif
} }
adc_updated = 0; adc_updated = 0;
} }
ADCEN = 1; ADCEN = 1;
ADM = 0b00011011; // セレクトモード、章圧、fCLK/6 ///ここから ADM = 0b00011011; // セレクトモード、章圧、fCLK/6 ///ここから
ADPC = 0x06; // ADCポートのセレクト ADPC = 0x06; // ADCポートのセレクト
ADS = ADC_SEL_TUNE; ADS = ADC_SEL_TUNE;
// NOP(); // NOP();
ADCS = 1; // AD開始。 /// ここまでに、1us以上開ける ADCS = 1; // AD開始。 /// ここまでに、1us以上開ける
ADIF = 0; ADIF = 0;
ADMK = 0; ADMK = 0;
// TUNE_LED ここかよ! // TUNE_LED ここかよ!
switch( vreg_ctr[ VREG_C_LED_TUNE ] ){ switch ( vreg_ctr[VREG_C_LED_TUNE] )
case( 1 ): // 点灯 {
LED_duty_TUNE = 0; case ( 1 ): // 点灯
break; LED_duty_TUNE = vreg_ctr[VREG_C_LED_BRIGHT];
break;
case( 2 ): // case ( 2 ): //
LED_duty_TUNE = LED_BRIGHT_MAX - vreg_ctr[ VREG_C_TUNE ]; LED_duty_TUNE = LED_BRIGHT_MAX - vreg_ctr[VREG_C_TUNE];
break; break;
default: // 消灯 default: // 消灯
LED_duty_TUNE = vreg_ctr[ VREG_C_LED_BRIGHT ]; LED_duty_TUNE = 0;
break; break;
}
} }
return( 8 );
}
} }
@ -114,24 +147,32 @@ task_interval tsk_adc(){
   
 使  使
======================================================== */ ======================================================== */
static u8 getmean3( u8* hist ){ static u8 getmean3( u8 * hist )
u8 temp; {
u8 temp;
if( *hist < *( hist+1 ) ){ if( *hist < *( hist + 1 ) )
temp = *hist; {
*hist = *(hist+1); temp = *hist;
*(hist+1) = temp; *hist = *( hist + 1 );
} *( hist + 1 ) = temp;
}
if( !( *hist > *(hist+1) )){
return *hist; if( !( *hist > *( hist + 1 ) ) )
}else{ {
if( *(hist+1) > *(hist+2) ){ return *hist;
return *(hist+1); }
}else{ else
return *(hist+2); {
if( *( hist + 1 ) > *( hist + 2 ) )
{
return *( hist + 1 );
}
else
{
return *( hist + 2 );
}
} }
}
} }
@ -139,46 +180,51 @@ static u8 getmean3( u8* hist ){
   
     
======================================================== */ ======================================================== */
__interrupt void int_adc(){ __interrupt void int_adc( )
static u8 hist_tune[3]; {
static u8 hist_snd_vol[3]; static u8 hist_tune[3];
static u8 hist_bt_temp[3]; static u8 hist_snd_vol[3];
static u8 index; static u8 hist_bt_temp[3];
u8 temp; static u8 index;
u8 temp;
EI(); EI( );
switch( ADS ){ switch ( ADS )
case( ADC_SEL_TUNE ): {
hist_tune[ index ] = ADCRH; case ( ADC_SEL_TUNE ):
vreg_ctr[ VREG_C_TUNE ] = getmean3( hist_tune ); hist_tune[index] = ADCRH;
break; vreg_ctr[VREG_C_TUNE] = getmean3( hist_tune );
break;
case( ADC_SEL_VOL ): case ( ADC_SEL_VOL ):
hist_snd_vol[ index ] = ADCRH; hist_snd_vol[index] = ADCRH;
vreg_ctr[ VREG_C_SND_VOL ] = getmean3( hist_snd_vol ); vreg_ctr[VREG_C_SND_VOL] = getmean3( hist_snd_vol );
break; break;
case( ADC_SEL_BATT_TEMP ): case ( ADC_SEL_BATT_TEMP ):
hist_bt_temp[ index ] = ADCRH; hist_bt_temp[index] = ADCRH;
raw_adc_temperature = getmean3( hist_tune ); raw_adc_temperature = getmean3( hist_tune );
renge_task_immed_add( PM_bt_temp_update ); renge_task_immed_add( PM_bt_temp_update );
break; break;
case( ADC_SEL_BATT_DET ): case ( ADC_SEL_BATT_DET ):
// vreg_ctr[ VREG_C_DBG_BATT_DET ] = ADCRH; // vreg_ctr[ VREG_C_DBG_BATT_DET ] = ADCRH;
break; break;
} }
// もっとまともな書き方がありそうだ // もっとまともな書き方がありそうだ
// if( ADS == ADC_SEL_BATT_DET ){ // if( ADS == ADC_SEL_BATT_DET ){
if( ADS != ADC_SEL_BATT_TEMP ){ // 電池判別は電源投入の一回のみ if( ADS != ADC_SEL_BATT_TEMP )
ADS += 1; // 次のチャンネル { // 電池判別は電源投入の一回のみ
}else{ ADS += 1; // 次のチャンネル
ADCEN = 0; // 止めてしまう }
adc_updated = 1; else
index = ( index == 2 )? 0: ( index + 1 ); {
} ADCEN = 0; // 止めてしまう
adc_updated = 1;
index = ( index == 2 ) ? 0 : ( index + 1 );
}
} }
@ -186,25 +232,27 @@ __interrupt void int_adc(){
/* ======================================================== /* ========================================================
tsk_adcと競合することを考慮していません tsk_adcと競合することを考慮していません
======================================================== */ ======================================================== */
u8 get_adc( u8 ch ){ u8 get_adc( u8 ch )
u8 temp; {
u8 temp;
ADMK = 1; ADMK = 1;
ADIF = 0; ADIF = 0;
ADCEN = 1; ADCEN = 1;
ADCS = 0; ADCS = 0;
ADM = 0b00100011; // セレクトモード、章圧、fCLK/6 ///ここから ADM = 0b00100011; // セレクトモード、章圧、fCLK/6 ///ここから
ADPC = 0x06; // ADCポートのセレクト ADPC = 0x06; // ADCポートのセレクト
ADS = ch; ADS = ch;
ADCS = 1; // AD開始。 /// ここまでに、1us以上開ける ADCS = 1; // AD開始。 /// ここまでに、1us以上開ける
ADMK = 0; ADMK = 0;
while( ADIF == 0 ){;} while( ADIF == 0 )
temp = ADCRH; {;
ADCEN = 0; }
temp = ADCRH;
ADCEN = 0;
return( temp ); return ( temp );
} }

View File

@ -3,6 +3,7 @@
MEMORY BCL0:(00000H, 01000H ) MEMORY BCL0:(00000H, 01000H )
;MEMORY BCL1:(01000H, 01000H ) ; バックアップ領域 ;MEMORY BCL1:(01000H, 01000H ) ; バックアップ領域
MEMORY ROM :(02000H, 02800H ) MEMORY ROM :(02000H, 02800H )
;MEMORY ROM :(02000H, 04000H )
;MEMORY ROM_:(04800H, 02800H ) ; バックアップ領域 ;MEMORY ROM_:(04800H, 02800H ) ; バックアップ領域
;MEMORY FSL :(07000H, 00C00H ) ; 過去の名残。いらない ;MEMORY FSL :(07000H, 00C00H ) ; 過去の名残。いらない
;MEMORY OCD :(0FC00H, 00400H ) ; OCDが使っているらしい ;MEMORY OCD :(0FC00H, 00400H ) ; OCDが使っているらしい
@ -13,7 +14,8 @@ MEMORY ROM :(02000H, 02800H )
; ブートブロック0に割り当てる ; ブートブロック0に割り当てる
MERGE LDR_CODE: =BCL0 MERGE LDR_CODE: =BCL0
MERGE LDR_CODL: =BCL0 MERGE LDR_CODL: =BCL0
MERGE @@LCODE : AT( 0E00H ) =BCL0 ; スタートアップルーチン ;MERGE @@LCODE : AT( 0E00H ) =BCL0 ; スタートアップルーチン
MERGE @@LCODE : =BCL0 ; スタートアップルーチン
;MERGE LDR_RINT:=BCL0 ;MERGE LDR_RINT:=BCL0
;MERGE LDR_CNST:=BCL0 ;MERGE LDR_CNST:=BCL0
@ -44,7 +46,7 @@ MERGE FSL_CODE:=BCL0
; RAM1,RAM2領域はユーザープログラムで使用しても良いですが、セルフプログラム時は ; RAM1,RAM2領域はユーザープログラムで使用しても良いですが、セルフプログラム時は
; セルフプログラムのライブラリが使用するため、値は破壊されます。 ; セルフプログラムのライブラリが使用するため、値は破壊されます。
; ;
memory RAM2 : (0FFE20H, 00C0H) ; セルフプログラム時、使用禁止領域 memory RAM2 : (0FFE20H, 00C0H) ; セルフプログラム時、使用禁止領域
;memory SLF_RAM : (0FFE00H ,0020H) ; Slef Program予約領域[使用禁止] ;memory SLF_RAM : (0FFE00H, 0020H) ; Slef Program予約領域[使用禁止]
memory RAM : (0FF900H, 0500H) ; ユーザーRAM領域 memory RAM : (0FF900H, 0500H) ; ユーザーRAM領域
;memory SLF_RAM : (0FF900H ,0020H) ; Slef Program予約領域[使用禁止] ;memory SLF_RAM : (0FF900H, 0020H) ; Slef Program予約領域[使用禁止]

View File

@ -2,7 +2,8 @@
#define __bsr_system__ #define __bsr_system__
// イベントループのステート // イベントループのステート
enum pwr_state_{ enum pwr_state_
{
OFF_TRIG = 0, OFF_TRIG = 0,
OFF, OFF,
ON_TRIG, ON_TRIG,
@ -12,21 +13,24 @@ enum pwr_state_{
// WAKE, // WAKE,
}; };
enum poweron_reason_{ enum poweron_reason_
PWSW = 0, {
RTC_ALARM, PWSW = 0,
RTC_ALARM,
}; };
// タスクシステムの状態情報など // タスクシステムの状態情報など
typedef struct{ typedef struct
enum pwr_state_ pwr_state; {
enum poweron_reason_ poweron_reason; enum pwr_state_ pwr_state;
unsigned char dipsw0 :1; enum poweron_reason_ poweron_reason;
unsigned char dipsw1 :1; unsigned char dipsw0:1;
unsigned char dipsw2 :1; unsigned char dipsw1:1;
unsigned char reboot :1; unsigned char dipsw2:1;
}system_status_; unsigned char reboot:1;
}
system_status_;
extern system_status_ system_status; extern system_status_ system_status;

View File

@ -3,11 +3,10 @@
#define _debug_ #define _debug_
// #define _debug_led_ //#define _debug_led_
#define MCU_VER_MAJOR 0; #define MCU_VER_MAJOR 0;
#define MCU_VER_MINOR 4; #define MCU_VER_MINOR 6;
//#define _MODEL_TEG2_ //#define _MODEL_TEG2_

View File

@ -41,7 +41,7 @@
/*==============================================================================================*/ /*==============================================================================================*/
/* Environment: PM plus (V6.30) */ /* Environment: PM plus (V6.30) */
/* RA78K0(V1.20) */ /* RA78K0(V1.20) */
/* CC78K0(V2.00) */ /* CC78K0(V2.00) */
/*==============================================================================================*/ /*==============================================================================================*/
#ifndef __FSL_H_INCLUDED #ifndef __FSL_H_INCLUDED
@ -51,9 +51,9 @@
/*==============================================================================================*/ /*==============================================================================================*/
/* FSL type definitions */ /* FSL type definitions */
/*==============================================================================================*/ /*==============================================================================================*/
typedef unsigned char fsl_u08; typedef unsigned char fsl_u08;
typedef unsigned int fsl_u16; typedef unsigned int fsl_u16;
typedef unsigned long int fsl_u32; typedef unsigned long int fsl_u32;
/*==============================================================================================*/ /*==============================================================================================*/
@ -98,8 +98,8 @@ typedef unsigned long int fsl_u32;
/* = 0x00(FSL_OK), normal and means initialization OK */ /* = 0x00(FSL_OK), normal and means initialization OK */
/* = 0x1F(FSL_ERR_INTERRUPTION), initialization interrupted by user interrupt*/ /* = 0x1F(FSL_ERR_INTERRUPTION), initialization interrupted by user interrupt*/
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_Init(fsl_u08* data_buffer_pu08); extern fsl_u08 FSL_Init( fsl_u08 * data_buffer_pu08 );
extern fsl_u08 FSL_Init_cont(fsl_u08* data_buffer_pu08); extern fsl_u08 FSL_Init_cont( fsl_u08 * data_buffer_pu08 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -112,7 +112,7 @@ extern fsl_u08 FSL_Init_cont(fsl_u08* data_buffer_pu08);
/* = 0x00(FSL_OK), normal and means FLMD0=HIGH */ /* = 0x00(FSL_OK), normal and means FLMD0=HIGH */
/* = 0x01(FSL_ERR_FLMD0), error, FLMD0=LOW */ /* = 0x01(FSL_ERR_FLMD0), error, FLMD0=LOW */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_ModeCheck(void); extern fsl_u08 FSL_ModeCheck( void );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -127,7 +127,7 @@ extern fsl_u08 FSL_ModeCheck(void);
/* = 0x1B(FSL_ERR_BLANKCHECK), blank-check error, means "block not blank" */ /* = 0x1B(FSL_ERR_BLANKCHECK), blank-check error, means "block not blank" */
/* = 0x1F(FSL_ERR_INTERRUPTION), blank-check interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), blank-check interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_BlankCheck(fsl_u16 block_u16); extern fsl_u08 FSL_BlankCheck( fsl_u16 block_u16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -143,7 +143,7 @@ extern fsl_u08 FSL_BlankCheck(fsl_u16 block_u16);
/* = 0x1A(FSL_ERR_ERASE), erase error, retry up to max. 255 times */ /* = 0x1A(FSL_ERR_ERASE), erase error, retry up to max. 255 times */
/* = 0x1F(FSL_ERR_INTERRUPTION), erasing interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), erasing interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_Erase(fsl_u16 block_u16); extern fsl_u08 FSL_Erase( fsl_u16 block_u16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -158,7 +158,7 @@ extern fsl_u08 FSL_Erase(fsl_u16 block_u16);
/* = 0x1B(FSL_ERR_IVERIFY), internal verify error */ /* = 0x1B(FSL_ERR_IVERIFY), internal verify error */
/* = 0x1F(FSL_ERR_INTERRUPTION), verify interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), verify interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_IVerify(fsl_u16 block_u16); extern fsl_u08 FSL_IVerify( fsl_u16 block_u16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -181,7 +181,7 @@ extern fsl_u08 FSL_IVerify(fsl_u16 block_u16);
/* = 0x1C(FSL_ERR_WRITE), write error */ /* = 0x1C(FSL_ERR_WRITE), write error */
/* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_Write(fsl_u32 s_address_u32, fsl_u08 word_count_u08); extern fsl_u08 FSL_Write( fsl_u32 s_address_u32, fsl_u08 word_count_u08 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -205,7 +205,8 @@ extern fsl_u08 FSL_Write(fsl_u32 s_address_u32, fsl_u08 word_count_u08);
/* = 0x1E(FSL_ERR_EEP_BLANKCHECK), blankcheck error */ /* = 0x1E(FSL_ERR_EEP_BLANKCHECK), blankcheck error */
/* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_EEPROMWrite(fsl_u32 s_address_u32, fsl_u08 word_count_u08); extern fsl_u08 FSL_EEPROMWrite( fsl_u32 s_address_u32,
fsl_u08 word_count_u08 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -228,7 +229,7 @@ extern fsl_u08 FSL_EEPROMWrite(fsl_u32 s_address_u32, fsl_u08 word_count_u08);
/* = 0x00(FSL_OK), normal */ /* = 0x00(FSL_OK), normal */
/* = 0x05(FSL_ERR_PARAMETER), parameter error */ /* = 0x05(FSL_ERR_PARAMETER), parameter error */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_GetSecurityFlags(fsl_u16* destination_pu16); extern fsl_u08 FSL_GetSecurityFlags( fsl_u16 * destination_pu16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -244,7 +245,7 @@ extern fsl_u08 FSL_GetSecurityFlags(fsl_u16* destination_pu16);
/* = 0x00(FSL_OK), normal */ /* = 0x00(FSL_OK), normal */
/* = 0x05(FSL_ERR_PARAMETER), parameter error */ /* = 0x05(FSL_ERR_PARAMETER), parameter error */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_GetActiveBootCluster(fsl_u08* destination_pu08); extern fsl_u08 FSL_GetActiveBootCluster( fsl_u08 * destination_pu08 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -259,7 +260,8 @@ extern fsl_u08 FSL_GetActiveBootCluster(fsl_u08* destination_pu08);
/* = 0x00(FSL_OK), normal */ /* = 0x00(FSL_OK), normal */
/* = 0x05(FSL_ERR_PARAMETER), parameter error */ /* = 0x05(FSL_ERR_PARAMETER), parameter error */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_GetBlockEndAddr(fsl_u32* destination_pu32, fsl_u16 block_u16); extern fsl_u08 FSL_GetBlockEndAddr( fsl_u32 * destination_pu32,
fsl_u16 block_u16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -273,7 +275,8 @@ extern fsl_u08 FSL_GetBlockEndAddr(fsl_u32* destination_pu32, fsl_u16 block_u16
/* = 0x00(FSL_OK), normal */ /* = 0x00(FSL_OK), normal */
/* = 0x05(FSL_ERR_PARAMETER), parameter error */ /* = 0x05(FSL_ERR_PARAMETER), parameter error */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_GetFlashShieldWindow(fsl_u16* start_block_pu16, fsl_u16* end_block_pu16); extern fsl_u08 FSL_GetFlashShieldWindow( fsl_u16 * start_block_pu16,
fsl_u16 * end_block_pu16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -291,7 +294,8 @@ extern fsl_u08 FSL_GetFlashShieldWindow(fsl_u16* start_block_pu16, fsl_u16* end
/* = 0x1B(FSL_ERR_IVERIFY), internal verify error */ /* = 0x1B(FSL_ERR_IVERIFY), internal verify error */
/* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_SetFlashShieldWindow(fsl_u16 start_block_u16, fsl_u16 end_block_u16); extern fsl_u08 FSL_SetFlashShieldWindow( fsl_u16 start_block_u16,
fsl_u16 end_block_u16 );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -311,7 +315,7 @@ extern fsl_u08 FSL_SetFlashShieldWindow(fsl_u16 start_block_u16, fsl_u16 end_bl
/* = 0x1B(FSL_ERR_IVERIFY), internal verify error */ /* = 0x1B(FSL_ERR_IVERIFY), internal verify error */
/* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_SwapBootCluster(void); extern fsl_u08 FSL_SwapBootCluster( void );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -338,10 +342,10 @@ extern fsl_u08 FSL_SwapBootCluster(void);
/* = 0x1B(FSL_ERR_IVERIFY), internal verify error */ /* = 0x1B(FSL_ERR_IVERIFY), internal verify error */
/* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */ /* = 0x1F(FSL_ERR_INTERRUPTION), write interrupted by user interrupt */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern fsl_u08 FSL_SetChipEraseProtectFlag(void); extern fsl_u08 FSL_SetChipEraseProtectFlag( void );
extern fsl_u08 FSL_SetBlockEraseProtectFlag(void); extern fsl_u08 FSL_SetBlockEraseProtectFlag( void );
extern fsl_u08 FSL_SetWriteProtectFlag(void); extern fsl_u08 FSL_SetWriteProtectFlag( void );
extern fsl_u08 FSL_SetBootClusterProtectFlag(void); extern fsl_u08 FSL_SetBootClusterProtectFlag( void );
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
@ -353,6 +357,6 @@ extern fsl_u08 FSL_SetBootClusterProtectFlag(void);
/* Changed: - */ /* Changed: - */
/* Returned: - */ /* Returned: - */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
extern void FSL_SetInterruptMode(fsl_u08 mode_u08); extern void FSL_SetInterruptMode( fsl_u08 mode_u08 );
#endif #endif

View File

@ -85,12 +85,12 @@
/*#define FSL_MK2L_MASK 0xF7 -> allow INTP6 interrupt during selfprogramming */ /*#define FSL_MK2L_MASK 0xF7 -> allow INTP6 interrupt during selfprogramming */
/*#define FSL_MK2H_MASK 0xFF -> all interrupts disabled during selfprogramming */ /*#define FSL_MK2H_MASK 0xFF -> all interrupts disabled during selfprogramming */
/*------------------------------------------------------------------------------------------ */ /*------------------------------------------------------------------------------------------ */
#define FSL_MK0L_MASK 0xFF /* all interrupts disabled during selfprogramming */ #define FSL_MK0L_MASK 0xFF /* all interrupts disabled during selfprogramming */
#define FSL_MK0H_MASK 0xFF /* all interrupts disabled during selfprogramming */ #define FSL_MK0H_MASK 0xFF /* all interrupts disabled during selfprogramming */
#define FSL_MK1L_MASK 0xFF /* all interrupts disabled during selfprogramming */ #define FSL_MK1L_MASK 0xFF /* all interrupts disabled during selfprogramming */
#define FSL_MK1H_MASK 0xFF /* all interrupts disabled during selfprogramming */ #define FSL_MK1H_MASK 0xFF /* all interrupts disabled during selfprogramming */
#define FSL_MK2L_MASK 0xFF /* all interrupts disabled during selfprogramming */ #define FSL_MK2L_MASK 0xFF /* all interrupts disabled during selfprogramming */
#define FSL_MK2H_MASK 0xFF /* all interrupts disabled during selfprogramming */ #define FSL_MK2H_MASK 0xFF /* all interrupts disabled during selfprogramming */
/* FLMD0 control bit */ /* FLMD0 control bit */
@ -102,7 +102,7 @@
/* switch interrupt backu functionality ON/OFF using #define/#undef */ /* switch interrupt backu functionality ON/OFF using #define/#undef */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
/* #define FSL_INT_BACKUP */ /* #define FSL_INT_BACKUP */
#undef FSL_INT_BACKUP #undef FSL_INT_BACKUP
#endif #endif

View File

@ -10,8 +10,10 @@
#ifndef _PMIC_CTR_ #ifndef _PMIC_CTR_
#define IRQ0_neg { PM3.0 = 1; } #define IRQ0_neg { PM3.0 = 1; }
#define IRQ0 ( P3.0 )
#else #else
#define IRQ0_neg { PM7.6 = 1; } #define IRQ0_neg { PM7.6 = 1; }
#define IRQ0 ( P7.6 )
#endif #endif
@ -54,234 +56,289 @@
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
enum{ enum
IIC_IDLE = 0, {
IIC_RCV_REG_ADRS, IIC_IDLE = 0,
IIC_TX_OR_RX, IIC_RCV_REG_ADRS,
IIC_TX, IIC_TX_OR_RX,
IIC_RX IIC_TX,
IIC_RX
}; };
// 1バイト送受の度に割り込みが発生するバージョン // 1バイト送受の度に割り込みが発生するバージョン
__interrupt void int_iic_ctr(){ __interrupt void int_iic_ctr( )
static u8 state = IIC_IDLE; {
static u8 reg_adrs; static u8 state = IIC_IDLE;
static u8 reg_adrs_internal; static u8 reg_adrs;
static u8 trx_buf; static u8 reg_adrs_internal;
static u8 trx_buf;
if( SPD ){ if( SPD )
state = IIC_IDLE; {
SPIE = 0; state = IIC_IDLE;
// I2C終了時に何かする物 //
rtc_unlock();
return;
}
// 読み出し終了
if( !ACKD ){
state = IIC_IDLE;
SPIE = 0;
LREL = 1;
rtc_unlock();
// レジスタリードで、割り込みピンの設定
IRQ0_neg;
if(! (( vreg_ctr[ VREG_C_IRQ0 ] == 0 )
&& ( vreg_ctr[ VREG_C_IRQ1 ] == 0 )
&& ( vreg_ctr[ VREG_C_IRQ2 ] == 0 )
&& ( vreg_ctr[ VREG_C_IRQ3 ] == 0 )
) ){
IRQ0_ast;
}
return;
}
switch( state ){
case( IIC_IDLE ):
// 自局呼び出しに応答。
// 初期化など
SPIE = 1;
WREL = 1; // ウェイト解除
state = IIC_RCV_REG_ADRS;
break;
case( IIC_RCV_REG_ADRS ):
// レジスタアドレス受信
reg_adrs = IICA;
WREL = 1;
// reg_adrs_internal = adrs_table_ctr_ext2int( reg_adrs );
trx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
state = IIC_TX_OR_RX;
break;
case( IIC_TX_OR_RX ):
// if( TRC ){ // 送信方向フラグ
if( STD ){ // スタートコンディション検出フラグ
// リードされる
if( COI ){ // アドレス一致フラグ
state = IIC_TX;
// no break, no return //
}else{
// リスタートで違うデバイスが呼ばれた!
state = IIC_IDLE; // 終了処理
SPIE = 0; SPIE = 0;
LREL = 1; // ウェイト解除? // I2C終了時に何かする物 //
rtc_unlock( );
return; return;
}
}else{
state = IIC_RX; // データ1バイト受信の割り込みだった
// no break, no return //
} }
default: // 読み出し終了
if( state == IIC_TX ){ // 送信 if( !ACKD )
IICA = trx_buf; {
vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理 state = IIC_IDLE;
}else{ SPIE = 0;
// RX LREL = 1;
trx_buf = IICA;
vreg_ctr_write( reg_adrs, trx_buf ); rtc_unlock( );
WREL = 1;
// レジスタリードで、割り込みピンの設定
// if( ( reg_adrs - 1 ) == VREG_C_IRQ3 ){
// IRQ0_neg;
if( !( ( vreg_ctr[VREG_C_IRQ0] == 0 )
&& ( vreg_ctr[VREG_C_IRQ1] == 0 )
&& ( vreg_ctr[VREG_C_IRQ2] == 0 ) && ( vreg_ctr[VREG_C_IRQ3] == 0 ) ) )
{
IRQ0_neg;
while( !IRQ0 )
{;
}
IRQ0_ast;
}
else
{
IRQ0_neg;
// }
}
return;
} }
reg_adrs += 1;
if( STD )
{
if( ( state == IIC_TX ) || ( state == IIC_RX ) )
{
state = IIC_IDLE;
rtc_unlock( );
}
}
switch ( state )
{
case ( IIC_IDLE ):
// 自局呼び出しに応答。
// 初期化など
SPIE = 1;
WREL = 1; // ウェイト解除
state = IIC_RCV_REG_ADRS;
break;
case ( IIC_RCV_REG_ADRS ):
// レジスタアドレス受信
reg_adrs = IICA;
WREL = 1;
// reg_adrs_internal = adrs_table_ctr_ext2int( reg_adrs ); // reg_adrs_internal = adrs_table_ctr_ext2int( reg_adrs );
if( state == IIC_TX ){ trx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
trx_buf = vreg_ctr_read( reg_adrs ); state = IIC_TX_OR_RX;
break;
case ( IIC_TX_OR_RX ):
// if( TRC ){ // 送信方向フラグ
if( STD )
{ // スタートコンディション検出フラグ
// リードされる
if( COI )
{ // アドレス一致フラグ
state = IIC_TX;
// no break, no return //
}
else
{
// リスタートで違うデバイスが呼ばれた!
state = IIC_IDLE; // 終了処理
SPIE = 0;
LREL = 1; // ウェイト解除?
return;
}
}
else
{
state = IIC_RX; // データ1バイト受信の割り込みだった
// no break, no return //
}
default:
if( state == IIC_TX )
{ // 送信
IICA = trx_buf;
vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理
}
else
{
// RX
trx_buf = IICA;
vreg_ctr_write( reg_adrs, trx_buf );
WREL = 1;
}
reg_adrs += 1;
// reg_adrs_internal = adrs_table_ctr_ext2int( reg_adrs );
if( state == IIC_TX )
{
trx_buf = vreg_ctr_read( reg_adrs );
// temp = vreg_ctr[ reg_adrs ]; // temp = vreg_ctr[ reg_adrs ];
}
break;
} }
break;
}
} }
#if 0 #if 0
// 一度通信が始まったら終わるまで戻らないバージョン // 一度通信が始まったら終わるまで戻らないバージョン
__interrupt void int_iic_ctr(){ __interrupt void int_iic_ctr( )
static u8 state = 0; {
static u8 reg_adrs; static u8 state = 0;
static u8 reg_adrs;
// static u8 reg_adrs_internal; // static u8 reg_adrs_internal;
static u8 trx_buf; static u8 trx_buf;
if( SPD ){ if( SPD )
return; {
} return;
// 自局呼び出しに応答。
// 初期化など
WREL = 1; // ウェイト解除
while( !IICAIF ){;}
IICAIF = 0;
// レジスタアドレス受信
reg_adrs = IICA;
WREL = 1;
trx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
while( !IICAIF ){;}
IICAIF = 0;
if( STD ){ // リスタートコンディション
// リードされる
if( COI ){
state = IIC_TX;
}else{
// リスタートで違うデバイスが呼ばれた!
WREL = 1; // ウェイト解除?
state = IIC_IDLE; // 終了処理
SPIE = 0;
return;
} }
}else{ // ライト続行
state = IIC_RX;
}
if( state == IIC_TX ){ // 自局呼び出しに応答。
// 送信 // // 初期化など
do{ WREL = 1; // ウェイト解除
IICA = trx_buf;
vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理
reg_adrs += 1;
trx_buf = vreg_ctr_read( reg_adrs );
while( !IICAIF ){;}
IICAIF = 0;
}while( ACKD );
LREL = 1;
}else{ while( !IICAIF )
// 受信 // {;
SPIE = 1; }
do{ IICAIF = 0;
trx_buf = IICA;
vreg_ctr_write( reg_adrs, trx_buf ); // レジスタアドレス受信
reg_adrs += 1; reg_adrs = IICA;
WREL = 1; WREL = 1;
while( !IICAIF ){;} trx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
IICAIF = 0;
}while( !SPD ); while( !IICAIF )
SPIE = 0; {;
} }
state = IIC_IDLE; IICAIF = 0;
if( STD )
{ // リスタートコンディション
// リードされる
if( COI )
{
state = IIC_TX;
}
else
{
// リスタートで違うデバイスが呼ばれた!
WREL = 1; // ウェイト解除?
state = IIC_IDLE; // 終了処理
SPIE = 0;
return;
}
}
else
{ // ライト続行
state = IIC_RX;
}
if( state == IIC_TX )
{
// 送信 //
do
{
IICA = trx_buf;
vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理
reg_adrs += 1;
trx_buf = vreg_ctr_read( reg_adrs );
while( !IICAIF )
{;
}
IICAIF = 0;
}
while( ACKD );
LREL = 1;
}
else
{
// 受信 //
SPIE = 1;
do
{
trx_buf = IICA;
vreg_ctr_write( reg_adrs, trx_buf );
reg_adrs += 1;
WREL = 1;
while( !IICAIF )
{;
}
IICAIF = 0;
}
while( !SPD );
SPIE = 0;
}
state = IIC_IDLE;
} }
#endif #endif
// ======================================================== // ========================================================
void IIC_ctr_Init( void ){ void IIC_ctr_Init( void )
{
IICAEN = 1; IICAEN = 1;
IICE = 0; /* IICA disable */ IICE = 0; /* IICA disable */
IICAMK = 1; /* INTIICA disable */ IICAMK = 1; /* INTIICA disable */
IICAIF = 0; /* clear INTIICA interrupt flag */ IICAIF = 0; /* clear INTIICA interrupt flag */
IICAPR0 = 0; /* set INTIICA high priority */ IICAPR0 = 0; /* set INTIICA high priority */
IICAPR1 = 0; /* set INTIICA high priority */ IICAPR1 = 0; /* set INTIICA high priority */
#ifdef _MODEL_WM0_ #ifdef _MODEL_WM0_
P20 &= ~0x3; P20 &= ~0x3;
#else #else
P6 &= ~0x3; P6 &= ~0x3;
#endif #endif
SVA = IIC_C_SLAVEADDRESS; SVA = IIC_C_SLAVEADDRESS;
IICF = 0x01; IICF = 0x01;
STCEN = 1; // リスタートの許可 STCEN = 1; // リスタートの許可
IICRSV = 1; // 通信予約をさせない:スレーブに徹する IICRSV = 1; // 通信予約をさせない:スレーブに徹する
SPIE = 0; // ストップコンディションでの割り込みを禁止 SPIE = 0; // ストップコンディションでの割り込みを禁止
WTIM = 1; // 自動でACKを返した後clkをLに固定する WTIM = 1; // 自動でACKを返した後clkをLに固定する
ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない
IICWH = 8; IICWH = 8;
IICWL = 10; // L期間の長さ IICWL = 10; // L期間の長さ
SMC = 1; SMC = 1; // 高速モード
IICAMK = 0; // 割り込みを許可 IICAMK = 0; // 割り込みを許可
IICE = 1; IICE = 1;
#ifdef _MODEL_WM0_ #ifdef _MODEL_WM0_
PM20 &= ~0x3; /* set clock pin for IICA */ PM20 &= ~0x3; /* set clock pin for IICA */
#else #else
PM6 &= ~0x3; /* set clock pin for IICA */ PM6 &= ~0x3; /* set clock pin for IICA */
#endif #endif
} }
// ======================================================== // ========================================================
void IIC_ctr_Stop( void ){ void IIC_ctr_Stop( void )
IICE = 0; /* IICA disable */ {
IICAEN = 0; IICE = 0; /* IICA disable */
IICAEN = 0;
} }

View File

@ -4,109 +4,109 @@
/* IIC operation enable (IICE0) */ /* IIC operation enable (IICE0) */
#define IIC0_OPERATION 0x80 #define IIC0_OPERATION 0x80
#define IIC0_OPERATION_DISABLE 0x00 /* stop operation */ #define IIC0_OPERATION_DISABLE 0x00 /* stop operation */
#define IIC0_OPERATION_ENABLE 0x80 /* enable operation */ #define IIC0_OPERATION_ENABLE 0x80 /* enable operation */
/* Exit from communications (LREL0) */ /* Exit from communications (LREL0) */
#define IIC0_COMMUNICATION 0x40 #define IIC0_COMMUNICATION 0x40
#define IIC0_COMMUNICATION_NORMAL 0x00 /* normal operation */ #define IIC0_COMMUNICATION_NORMAL 0x00 /* normal operation */
#define IIC0_COMMUNICATION_EXIT 0x40 /* exit from current communication */ #define IIC0_COMMUNICATION_EXIT 0x40 /* exit from current communication */
/* Wait cancellation (WREL0) */ /* Wait cancellation (WREL0) */
#define IIC0_WAITCANCEL 0x20 #define IIC0_WAITCANCEL 0x20
#define IIC0_WAIT_NOTCANCEL 0x00 /* do not cancel wait */ #define IIC0_WAIT_NOTCANCEL 0x00 /* do not cancel wait */
#define IIC0_WAIT_CANCEL 0x20 /* cancel wait */ #define IIC0_WAIT_CANCEL 0x20 /* cancel wait */
/* Generation of interrupt when stop condition (SPIE0) */ /* Generation of interrupt when stop condition (SPIE0) */
#define IIC0_STOPINT 0x10 #define IIC0_STOPINT 0x10
#define IIC0_STOPINT_DISABLE 0x00 /* disable */ #define IIC0_STOPINT_DISABLE 0x00 /* disable */
#define IIC0_STOPINT_ENABLE 0x10 /* enable */ #define IIC0_STOPINT_ENABLE 0x10 /* enable */
/* Wait and interrupt generation (WTIM0) */ /* Wait and interrupt generation (WTIM0) */
#define IIC0_WAITINT 0x08 #define IIC0_WAITINT 0x08
#define IIC0_WAITINT_CLK8FALLING 0x00 /* generate at the eighth clocks falling edge */ #define IIC0_WAITINT_CLK8FALLING 0x00 /* generate at the eighth clocks falling edge */
#define IIC0_WAITINT_CLK9FALLING 0x08 /* generated at the ninth clocks falling edge */ #define IIC0_WAITINT_CLK9FALLING 0x08 /* generated at the ninth clocks falling edge */
/* Acknowledgement control (ACKE0) */ /* Acknowledgement control (ACKE0) */
#define IIC0_ACK 0x04 #define IIC0_ACK 0x04
#define IIC0_ACK_DISABLE 0x00 /* enable acknowledgement */ #define IIC0_ACK_DISABLE 0x00 /* enable acknowledgement */
#define IIC0_ACK_ENABLE 0x04 /* disable acknowledgement */ #define IIC0_ACK_ENABLE 0x04 /* disable acknowledgement */
/* Start condition trigger (STT0) */ /* Start condition trigger (STT0) */
#define IIC0_STARTCONDITION 0x02 #define IIC0_STARTCONDITION 0x02
#define IIC0_START_NOTGENERATE 0x00 /* do not generate start condition */ #define IIC0_START_NOTGENERATE 0x00 /* do not generate start condition */
#define IIC0_START_GENERATE 0x02 /* generate start condition */ #define IIC0_START_GENERATE 0x02 /* generate start condition */
/* Stop condition trigger (SPT0) */ /* Stop condition trigger (SPT0) */
#define IIC0_STOPCONDITION 0x01 #define IIC0_STOPCONDITION 0x01
#define IIC0_STOP_NOTGENERATE 0x00 /* do not generate stop condition */ #define IIC0_STOP_NOTGENERATE 0x00 /* do not generate stop condition */
#define IIC0_STOP_GENERATE 0x01 /* generate stop condition */ #define IIC0_STOP_GENERATE 0x01 /* generate stop condition */
/* /*
IIC Status Register 0 (IICS0) IIC Status Register 0 (IICS0)
*/ */
/* Master device status (MSTS0) */ /* Master device status (MSTS0) */
#define IIC0_MASTERSTATUS 0x80 #define IIC0_MASTERSTATUS 0x80
#define IIC0_STATUS_NOTMASTER 0x00 /* slave device status or communication standby status */ #define IIC0_STATUS_NOTMASTER 0x00 /* slave device status or communication standby status */
#define IIC0_STATUS_MASTER 0x80 /* master device communication status */ #define IIC0_STATUS_MASTER 0x80 /* master device communication status */
/* Detection of arbitration loss (ALD0) */ /* Detection of arbitration loss (ALD0) */
#define IIC0_ARBITRATION 0x40 #define IIC0_ARBITRATION 0x40
#define IIC0_ARBITRATION_NO 0x00 /* arbitration win or no arbitration */ #define IIC0_ARBITRATION_NO 0x00 /* arbitration win or no arbitration */
#define IIC0_ARBITRATION_LOSS 0x40 /* arbitration loss */ #define IIC0_ARBITRATION_LOSS 0x40 /* arbitration loss */
/* Detection of extension code reception (EXC0) */ /* Detection of extension code reception (EXC0) */
#define IIC0_EXTENSIONCODE 0x20 #define IIC0_EXTENSIONCODE 0x20
#define IIC0_EXTCODE_NOT 0x00 /* extension code not received */ #define IIC0_EXTCODE_NOT 0x00 /* extension code not received */
#define IIC0_EXTCODE_RECEIVED 0x20 /* extension code received */ #define IIC0_EXTCODE_RECEIVED 0x20 /* extension code received */
/* Detection of matching addresses (COI0) */ /* Detection of matching addresses (COI0) */
#define IIC0_ADDRESSMATCH 0x10 #define IIC0_ADDRESSMATCH 0x10
#define IIC0_ADDRESS_NOTMATCH 0x00 /* addresses do not match */ #define IIC0_ADDRESS_NOTMATCH 0x00 /* addresses do not match */
#define IIC0_ADDRESS_MATCH 0x10 /* addresses match */ #define IIC0_ADDRESS_MATCH 0x10 /* addresses match */
/* Detection of transmit/receive status (TRC0) */ /* Detection of transmit/receive status (TRC0) */
#define IIC0_STATUS 0x08 #define IIC0_STATUS 0x08
#define IIC0_STATUS_RECEIVE 0x00 /* receive status */ #define IIC0_STATUS_RECEIVE 0x00 /* receive status */
#define IIC0_STATUS_TRANSMIT 0x08 /* transmit status */ #define IIC0_STATUS_TRANSMIT 0x08 /* transmit status */
/* Detection of acknowledge signal (ACKD0) */ /* Detection of acknowledge signal (ACKD0) */
#define IIC0_ACKDETECTION 0x04 #define IIC0_ACKDETECTION 0x04
#define IIC0_ACK_NOTDETECTED 0x00 /* ACK signal was not detected */ #define IIC0_ACK_NOTDETECTED 0x00 /* ACK signal was not detected */
#define IIC0_ACK_DETECTED 0x04 /* ACK signal was detected */ #define IIC0_ACK_DETECTED 0x04 /* ACK signal was detected */
/* Detection of start condition (STD0) */ /* Detection of start condition (STD0) */
#define IIC0_STARTDETECTION 0x02 #define IIC0_STARTDETECTION 0x02
#define IIC0_START_NOTDETECTED 0x00 /* start condition not detected */ #define IIC0_START_NOTDETECTED 0x00 /* start condition not detected */
#define IIC0_START_DETECTED 0x02 /* start condition detected */ #define IIC0_START_DETECTED 0x02 /* start condition detected */
/* Detection of stop condition (SPD0) */ /* Detection of stop condition (SPD0) */
#define IIC0_STOPDETECTION 0x01 #define IIC0_STOPDETECTION 0x01
#define IIC0_STOP_NOTDETECTED 0x00 /* stop condition not detected */ #define IIC0_STOP_NOTDETECTED 0x00 /* stop condition not detected */
#define IIC0_STOP_DETECTED 0x01 /* stop condition detected */ #define IIC0_STOP_DETECTED 0x01 /* stop condition detected */
/* /*
IIC Flag Register 0 (IICF0) IIC Flag Register 0 (IICF0)
*/ */
/* STT0 clear flag (STCF) */ /* STT0 clear flag (STCF) */
#define IIC0_STARTFLAG 0x80 #define IIC0_STARTFLAG 0x80
#define IIC0_STARTFLAG_GENERATE 0x00 /* generate start condition */ #define IIC0_STARTFLAG_GENERATE 0x00 /* generate start condition */
#define IIC0_STARTFLAG_UNSUCCESSFUL 0x80 /* start condition generation unsuccessful */ #define IIC0_STARTFLAG_UNSUCCESSFUL 0x80 /* start condition generation unsuccessful */
/* IIC bus status flag (IICBSY) */ /* IIC bus status flag (IICBSY) */
#define IIC0_BUSSTATUS 0x40 #define IIC0_BUSSTATUS 0x40
#define IIC0_BUS_RELEASE 0x00 /* bus release status */ #define IIC0_BUS_RELEASE 0x00 /* bus release status */
#define IIC0_BUS_COMMUNICATION 0x40 /* bus communication status */ #define IIC0_BUS_COMMUNICATION 0x40 /* bus communication status */
/* Initial start enable trigger (STCEN) */ /* Initial start enable trigger (STCEN) */
#define IIC0_STARTWITHSTOP 0x02 #define IIC0_STARTWITHSTOP 0x02
#define IIC0_START_WITHSTOP 0x00 /* generation of a start condition without detecting a stop condition */ #define IIC0_START_WITHSTOP 0x00 /* generation of a start condition without detecting a stop condition */
#define IIC0_START_WITHOUTSTOP 0x02 /* generation of a start condition upon detection of a stop condition */ #define IIC0_START_WITHOUTSTOP 0x02 /* generation of a start condition upon detection of a stop condition */
/* Communication reservation function disable bit (IICRSV) */ /* Communication reservation function disable bit (IICRSV) */
#define IIC0_RESERVATION 0x01 #define IIC0_RESERVATION 0x01
#define IIC0_RESERVATION_ENABLE 0x00 /* enable communication reservation */ #define IIC0_RESERVATION_ENABLE 0x00 /* enable communication reservation */
#define IIC0_RESERVATION_DISABLE 0x01 /* disable communication reservation */ #define IIC0_RESERVATION_DISABLE 0x01 /* disable communication reservation */
/* /*
IIC clock selection register 0 (IICCL0) IIC clock selection register 0 (IICCL0)
@ -114,23 +114,23 @@
#define IICCL0_INITIALVALUE 0x00 #define IICCL0_INITIALVALUE 0x00
/* Detection of SCL0 pin level (CLD0) */ /* Detection of SCL0 pin level (CLD0) */
#define IIC0_SCLLEVEL 0x20 #define IIC0_SCLLEVEL 0x20
#define IIC0_SCL_LOW 0x00 /* clock line at low level */ #define IIC0_SCL_LOW 0x00 /* clock line at low level */
#define IIC0_SCL_HIGH 0x20 /* clock line at high level */ #define IIC0_SCL_HIGH 0x20 /* clock line at high level */
/* Detection of SDA0 pin level (DAD0) */ /* Detection of SDA0 pin level (DAD0) */
#define IIC0_SDALEVEL 0x10 #define IIC0_SDALEVEL 0x10
#define IIC0_SDA_LOW 0x00 /* data line at low level */ #define IIC0_SDA_LOW 0x00 /* data line at low level */
#define IIC0_SDA_HIGH 0x10 /* data line at high level */ #define IIC0_SDA_HIGH 0x10 /* data line at high level */
/* Operation mode switching (SMC0) */ /* Operation mode switching (SMC0) */
#define IIC0_OPERATIONMODE 0x08 #define IIC0_OPERATIONMODE 0x08
#define IIC0_MODE_STANDARD 0x00 /* operates in standard mode */ #define IIC0_MODE_STANDARD 0x00 /* operates in standard mode */
#define IIC0_MODE_HIGHSPEED 0x08 /* operates in high-speed mode */ #define IIC0_MODE_HIGHSPEED 0x08 /* operates in high-speed mode */
/* Digital filter operation control (DFC0) */ /* Digital filter operation control (DFC0) */
#define IIC0_DIGITALFILTER 0x04 #define IIC0_DIGITALFILTER 0x04
#define IIC0_FILTER_OFF 0x00 /* digital filter off */ #define IIC0_FILTER_OFF 0x00 /* digital filter off */
#define IIC0_FILTER_ON 0x04 /* digital filter on */ #define IIC0_FILTER_ON 0x04 /* digital filter on */
/* Operation mode switching (CL01, CL00) */ /* Operation mode switching (CL01, CL00) */
#define IIC0_CLOCKSELECTION 0x03 #define IIC0_CLOCKSELECTION 0x03

View File

@ -35,25 +35,25 @@
// ======================================================== // ========================================================
static void iic_mcu_send_st(); static void iic_mcu_send_st( );
static void iic_mcu_send_re_st(); static void iic_mcu_send_re_st( );
static void iic_mcu_send_sp(); static void iic_mcu_send_sp( );
static err iic_mcu_send_a_byte( u8 ); static err iic_mcu_send_a_byte( u8 );
static err iic_mcu_call_slave( u8 slave ); static err iic_mcu_call_slave( u8 slave );
// ======================================================== // ========================================================
bit iic_mcu_wo_dma; bit iic_mcu_wo_dma;
volatile bit iic_mcu_busy; volatile bit iic_mcu_busy;
volatile bit iic_mcu_initialized; volatile bit iic_mcu_initialized;
u8 iic_send_work[4]; u8 iic_send_work[4];
u8* p_iic_send_wo_dma_dat; u8 *p_iic_send_wo_dma_dat;
u8 iic_send_wo_dma_len; u8 iic_send_wo_dma_len;
u8 iic_mcu_bus_status; // 一文字リードの時はデータを返す。 u8 iic_mcu_bus_status; // 一文字リードの時はデータを返す。
// ステータスが必要ならこっちを呼んで // ステータスが必要ならこっちを呼んで
@ -63,54 +63,62 @@ u8 iic_mcu_bus_status; //
======================================================== */ ======================================================== */
u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ){ u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs )
u8 dat; {
u8 dat;
if( iic_mcu_initialized == 0 ){ if( iic_mcu_initialized == 0 )
{
#ifdef _debug_ #ifdef _debug_
iic_mcu_start(); iic_mcu_start( );
#else #else
while(1){}; while( 1 )
{
};
#endif #endif
} }
while( iic_mcu_busy ){ while( iic_mcu_busy )
NOP(); {
} NOP( );
iic_mcu_busy = 1; }
iic_mcu_busy = 1;
iic_mcu_bus_status = ERR_OK; iic_mcu_bus_status = ERR_OK;
// スタートコンディションとスレーブの呼び出し、レジスタアドレスの送信 // スタートコンディションとスレーブの呼び出し、レジスタアドレスの送信
if( iic_mcu_call_slave( SLA ) != 0 ){ if( iic_mcu_call_slave( SLA ) != 0 )
iic_mcu_bus_status = ERR_NOSLAVE; {
iic_mcu_bus_status = ERR_NOSLAVE;
iic_mcu_busy = 0;
return ( 0 );
}
// レジスタアドレスの送信
iic_mcu_send_a_byte( adrs ); // 終わるまで帰ってこない
// if( err != ERR_SUCCESS )
// データ受信 //
iic_mcu_send_re_st( ); // リスタートコンディション
iic_mcu_send_a_byte( SLA | 0x01 ); // 送信完了まで戻ってきません。
ST0 = 0x0004; // 受信モードに設定を変えるのでロジック停止
SCR02 = RXE0 | 1 << SLC02 | 7 << DLS02; // 受信設定
SS0 = 0x0004; // 通信待機
SOE0 = 0x0000; // 1バイト送信なので、最後のNAKを送る
IICIF10 = 0;
SIO10 = 0xFF; // ダミーデータを書くと受信開始
while( IICIF10 == 0 )
{ // 受信完了待ち
;
}
dat = SIO10;
iic_mcu_send_sp( );
IICIF10 = 0; // 後を濁さないこと
iic_mcu_busy = 0; iic_mcu_busy = 0;
return( 0 ); return ( dat );
}
// レジスタアドレスの送信
iic_mcu_send_a_byte( adrs ); // 終わるまで帰ってこない
// if( err != ERR_SUCCESS )
// データ受信 //
iic_mcu_send_re_st(); // リスタートコンディション
iic_mcu_send_a_byte( SLA | 0x01 ); // 送信完了まで戻ってきません。
ST0 = 0x0004; // 受信モードに設定を変えるのでロジック停止
SCR02 = RXE0 | 1 << SLC02 | 7 << DLS02; // 受信設定
SS0 = 0x0004; // 通信待機
SOE0 = 0x0000; // 1バイト送信なので、最後のNAKを送る
IICIF10 = 0;
SIO10 = 0xFF; // ダミーデータを書くと受信開始
while( IICIF10 == 0 ){ // 受信完了待ち
;}
dat = SIO10;
iic_mcu_send_sp();
IICIF10 = 0; // 後を濁さないこと
iic_mcu_busy = 0;
return( dat );
} }
@ -125,20 +133,25 @@ u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ){
======================================================== */ ======================================================== */
err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8* dest ){ err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8 * dest )
{
//* //*
// 使用中なら待つ // 使用中なら待つ
if( iic_mcu_initialized == 0 ){ if( iic_mcu_initialized == 0 )
{
#ifdef _debug_ #ifdef _debug_
iic_mcu_start(); iic_mcu_start( );
#else #else
while(1){}; while( 1 )
{
};
#endif #endif
} }
while( iic_mcu_busy ){ while( iic_mcu_busy )
NOP(); {
} NOP( );
}
/*/ /*/
// 使用中なら帰る // 使用中なら帰る
if( iic_mcu_initialized == 0 ){ if( iic_mcu_initialized == 0 ){
@ -149,44 +162,50 @@ err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8* dest ){
} }
//*/ //*/
iic_mcu_busy = 1; iic_mcu_busy = 1;
// スタートコンディションとスレーブの呼び出し、レジスタアドレスの送信 // スタートコンディションとスレーブの呼び出し、レジスタアドレスの送信
if( iic_mcu_call_slave( slave ) != 0 ){ if( iic_mcu_call_slave( slave ) != 0 )
iic_mcu_busy = 0; {
return( ERR_NAK ); iic_mcu_busy = 0;
} return ( ERR_NAK );
}
// レジスタアドレスの送信 // レジスタアドレスの送信
iic_mcu_send_a_byte( adrs ); // 終わるまで帰ってこない iic_mcu_send_a_byte( adrs ); // 終わるまで帰ってこない
// if( err != ERR_SUCCESS ) // if( err != ERR_SUCCESS )
// データ受信 // // データ受信 //
iic_mcu_send_re_st(); // リスタートコンディション iic_mcu_send_re_st( ); // リスタートコンディション
iic_mcu_send_a_byte( slave | 0x01 ); // 送信完了まで戻ってきません。 iic_mcu_send_a_byte( slave | 0x01 ); // 送信完了まで戻ってきません。
// データ受信 // データ受信
ST0 = 0x0004; // 受信モードに設定を変えるのでロジック停止 ST0 = 0x0004; // 受信モードに設定を変えるのでロジック停止
SCR02 = RXE0 | 1 << SLC02 | 7 << DLS02; // 受信設定 SCR02 = RXE0 | 1 << SLC02 | 7 << DLS02; // 受信設定
SS0 = 0x0004; // 通信待機 SS0 = 0x0004; // 通信待機
do{ do
if( len == 1 ){ {
SOE0 = 0x0000; // 最後のNAK if( len == 1 )
} {
IICIF10 = 0; SOE0 = 0x0000; // 最後のNAK
SIO10 = 0xFF; // ダミーデータを書くと受信開始 }
while( IICIF10 == 0 ){ // 受信完了待ち IICIF10 = 0;
;} SIO10 = 0xFF; // ダミーデータを書くと受信開始
*dest = SIO10; while( IICIF10 == 0 )
dest++; { // 受信完了待ち
len--; ;
}while( len != 0 ); }
*dest = SIO10;
dest++;
len--;
}
while( len != 0 );
iic_mcu_send_sp(); iic_mcu_send_sp( );
IICIF10 = 0; IICIF10 = 0;
iic_mcu_busy = 0; iic_mcu_busy = 0;
return( ERR_SUCCESS ); return ( ERR_SUCCESS );
} }
@ -198,35 +217,41 @@ err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8* dest ){
 iic_mcu_write   iic_mcu_write 
======================================================== */ ======================================================== */
err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat ){ err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat )
{
if( iic_mcu_initialized == 0 ){ if( iic_mcu_initialized == 0 )
{
#ifdef _debug_ #ifdef _debug_
iic_mcu_start(); iic_mcu_start( );
#else #else
while(1){}; while( 1 )
{
};
#endif #endif
} }
while( iic_mcu_busy ){ while( iic_mcu_busy )
NOP(); {
} NOP( );
iic_mcu_busy = 1; }
iic_mcu_busy = 1;
#if 0 #if 0
temp = dat; temp = dat;
return( iic_mcu_write( SLA, adrs, 1, &temp ) ); return ( iic_mcu_write( SLA, adrs, 1, &temp ) );
} }
#else #else
// スタートコンディションとスレーブの呼び出し... // スタートコンディションとスレーブの呼び出し...
IICMK10 = 1; IICMK10 = 1;
if( iic_mcu_call_slave( SLA ) != 0 ){ if( iic_mcu_call_slave( SLA ) != 0 )
{
iic_mcu_busy = 0;
return ( ERR_NAK );
}
iic_mcu_send_a_byte( adrs );
iic_mcu_send_a_byte( dat );
iic_mcu_send_sp( );
iic_mcu_busy = 0; iic_mcu_busy = 0;
return( ERR_NAK ); return ( ERR_SUCCESS );
}
iic_mcu_send_a_byte( adrs );
iic_mcu_send_a_byte( dat );
iic_mcu_send_sp();
iic_mcu_busy = 0;
return( ERR_SUCCESS );
#endif #endif
} }
@ -247,19 +272,24 @@ err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat ){
DMA1を使用します DMA1を使用します
******************************************************************************/ ******************************************************************************/
err iic_mcu_write( u8 slave, u8 adrs, u8 len, u8* src ){ err iic_mcu_write( u8 slave, u8 adrs, u8 len, u8 * src )
{
//* //*
// 使用中なら待つ // 使用中なら待つ
if( iic_mcu_initialized == 0 ){ if( iic_mcu_initialized == 0 )
{
#ifdef _debug_ #ifdef _debug_
iic_mcu_start(); iic_mcu_start( );
#else #else
while(1){}; while( 1 )
{
};
#endif #endif
} }
while( iic_mcu_busy ){ while( iic_mcu_busy )
NOP(); {
} NOP( );
}
/*/ /*/
// 使用中なら帰る // 使用中なら帰る
if( iic_mcu_initialized == 0 ){ if( iic_mcu_initialized == 0 ){
@ -269,49 +299,55 @@ err iic_mcu_write( u8 slave, u8 adrs, u8 len, u8* src ){
return( 3 ); return( 3 );
} }
//*/ //*/
iic_mcu_busy = 1; iic_mcu_busy = 1;
// スタートコンディションとスレーブの呼び出し... // スタートコンディションとスレーブの呼び出し...
IICMK10 = 1; IICMK10 = 1;
IICIF10 = 0; IICIF10 = 0;
if( iic_mcu_call_slave( slave ) != 0 ){ if( iic_mcu_call_slave( slave ) != 0 )
iic_mcu_busy = 0; {
EI(); iic_mcu_busy = 0;
return( ERR_NAK ); EI( );
} return ( ERR_NAK );
}
IICIF10 = 0; IICIF10 = 0;
if( !iic_mcu_wo_dma ){ if( !iic_mcu_wo_dma )
// DMAを使用する通常 {
// DMAを使用する通常
// レジスタアドレスを送り、データの準備 // レジスタアドレスを送り、データの準備
memcpy( iic_send_work, src, 4 ); //バッファとして4バイトしか用意して無いため。 memcpy( iic_send_work, src, 4 ); //バッファとして4バイトしか用意して無いため。
// DMAセット // DMAセット
while( DST1 ){;}; while( DST1 )
{;
};
DEN1 = 1; DEN1 = 1;
DSA1 = (u8)( &SIO10 ); DSA1 = ( u8 ) ( &SIO10 );
DRA1 = (u16)iic_send_work; DRA1 = ( u16 ) iic_send_work;
DBC1 = len; DBC1 = len;
DMC1 = DRS | 8; // RAM -> SFR, 8bit, IRQ, IIC10 DMC1 = DRS | 8; // RAM -> SFR, 8bit, IRQ, IIC10
DMAIF1 = 0; DMAIF1 = 0;
DMAMK1 = 0; DMAMK1 = 0;
DST1 = 1; DST1 = 1;
SIO10 = adrs; // 書きっぱなし! 割り込みが発生してDMAスタート SIO10 = adrs; // 書きっぱなし! 割り込みが発生してDMAスタート
// 残りは割り込みルーチン内で // 残りは割り込みルーチン内で
}else{ }
// DMAを使用しない // else
{
// DMAを使用しない //
// レジスタアドレスの送信 // レジスタアドレスの送信
SIO10 = adrs; SIO10 = adrs;
IICMK10 = 0; IICMK10 = 0;
iic_send_wo_dma_len = len; iic_send_wo_dma_len = len;
p_iic_send_wo_dma_dat = src; p_iic_send_wo_dma_dat = src;
// 残りは割り込みルーチン内で // 残りは割り込みルーチン内で
} }
return( ERR_SUCCESS ); return ( ERR_SUCCESS );
} }
@ -321,77 +357,81 @@ err iic_mcu_write( u8 slave, u8 adrs, u8 len, u8* src ){
DMA転送終了割り込み DMA転送終了割り込み
IIC_mcu IIC_mcu
DMA転送が終わっただけでI2Cの転送は終わってません DMA転送が終わっただけでI2Cの転送は終わってません
  DMA1の処理が遅延した場合
IIC10の割り込みの準備ができずに
 DMA仕様の差異は
======================================================== */ ======================================================== */
__interrupt void int_dma1(){ __interrupt void int_dma1( )
IICIF10 = 0; {
DMAMK1 = 1; u16 i = 0;
DEN1 = 0;
IICMK10 = 1;
while(( SSR02L & TSF0 ) != 0 ){;
}
// 最後のバイト転送後、I2C割り込みが発生する
// ↓
// 共通(最終バイト送信完了) DMAMK1 = 1;
IICMK10 = 1; DEN1 = 0;
// ISR中で外の関数を呼ぶのは都合が悪いので展開 while( ( SSR02L & TSF0 ) != 0 )
// iic_mcu_send_sp(); {
{ if( ++i == 0 ) // タイムアウト?
ST0 = 0x0004; {
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力) break;
SO0 = 0x0000 | TAUS_MASK; // SCL }
NOP(); }
NOP();
NOP();
NOP();
SO0 = 0x0400 | TAUS_MASK; // SCL
NOP();
NOP();
NOP();
NOP();
SO0 = 0x0404 | TAUS_MASK;
}
iic_mcu_wo_dma = 0;
iic_mcu_busy = 0;
// iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪いので展開
{
ST0 = 0x0004;
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
SO0 = 0x0000 | TAUS_MASK; // SCL
NOP( );
NOP( );
NOP( );
NOP( );
SO0 = 0x0400 | TAUS_MASK; // SCL
NOP( );
NOP( );
NOP( );
NOP( );
SO0 = 0x0404 | TAUS_MASK;
}
iic_mcu_busy = 0;
} }
/* ======================================================== /* ========================================================
IIC MCUのバイト送出完了割り込み IIC MCUのバイト送出完了割り込み
DMA使用時は使用されません
======================================================== */ ======================================================== */
__interrupt void int_iic10(){ __interrupt void int_iic10( )
if( iic_mcu_wo_dma ){ {
// DMA使用せず、転送途中 if( iic_send_wo_dma_len != 0 )
if( iic_send_wo_dma_len != 0 ){ {
SIO10 = *p_iic_send_wo_dma_dat; SIO10 = *p_iic_send_wo_dma_dat;
p_iic_send_wo_dma_dat++; p_iic_send_wo_dma_dat++;
iic_send_wo_dma_len--; iic_send_wo_dma_len--;
return; return;
}
// 最後のバイト送信完了
IICMK10 = 1;
// iic_mcu_send_sp(); // ISR中で外の関数を呼ぶのは都合が悪いので展開
{
ST0 = 0x0004;
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
SO0 = 0x0000 | TAUS_MASK; // SCL
NOP( );
NOP( );
NOP( );
NOP( );
SO0 = 0x0400 | TAUS_MASK; // SCL
NOP( );
NOP( );
NOP( );
NOP( );
SO0 = 0x0404 | TAUS_MASK;
} }
iic_mcu_wo_dma = 0; iic_mcu_wo_dma = 0;
} iic_mcu_busy = 0;
// 共通(最終バイト送信完了)
IICMK10 = 1;
// ISR中で外の関数を呼ぶのは都合が悪いので展開
// iic_mcu_send_sp();
{
ST0 = 0x0004;
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
SO0 = 0x0000 | TAUS_MASK; // SCL
NOP();
NOP();
NOP();
NOP();
SO0 = 0x0400 | TAUS_MASK; // SCL
NOP();
NOP();
NOP();
NOP();
SO0 = 0x0404 | TAUS_MASK;
}
iic_mcu_busy = 0;
} }
@ -402,16 +442,18 @@ __interrupt void int_iic10(){
ACK                  0 ACK                  0
 NACK   1  NACK   1
======================================================== */ ======================================================== */
static err iic_mcu_call_slave( u8 slave ){ static err iic_mcu_call_slave( u8 slave )
iic_mcu_send_st(); {
iic_mcu_send_st( );
// SIR02 = SSR02; // NAKエラーのフラグクリア // SIR02 = SSR02; // NAKエラーのフラグクリア
if( iic_mcu_send_a_byte( slave ) != 0 ){ if( iic_mcu_send_a_byte( slave ) != 0 )
iic_mcu_send_sp(); {
return( ERR_NAK ); // 指定のスレーブがいない / busy iic_mcu_send_sp( );
} return ( ERR_NAK ); // 指定のスレーブがいない / busy
}
return( ERR_SUCCESS ); return ( ERR_SUCCESS );
} }
@ -420,18 +462,21 @@ static err iic_mcu_call_slave( u8 slave ){
======================================================== */ ======================================================== */
static err iic_mcu_send_a_byte( u8 dat ){ static err iic_mcu_send_a_byte( u8 dat )
{
IICIF10 = 0; IICIF10 = 0;
SIO10 = dat; SIO10 = dat;
while( IICIF10 == 0 ){ while( IICIF10 == 0 )
NOP(); {
} // 通信中 NOP( );
if( SSR02 != 0 ){ } // 通信中
SIR02 = SSR02; if( SSR02 != 0 )
return( ERR_NAK ); {
} SIR02 = SSR02;
return( ERR_SUCCESS ); return ( ERR_NAK );
}
return ( ERR_SUCCESS );
} }
@ -440,17 +485,18 @@ static err iic_mcu_send_a_byte( u8 dat ){
======================================================== */ ======================================================== */
static void iic_mcu_send_st(){ static void iic_mcu_send_st( )
SO0 &= ~0x0004; // SDA {
NOP(); SO0 &= ~0x0004; // SDA
NOP(); NOP( );
NOP(); NOP( );
NOP(); NOP( );
SO0 &= ~0x0400; // SCL NOP( );
SOE0 = 0x0004; // ハード制御へ SO0 &= ~0x0400; // SCL
SOE0 = 0x0004; // ハード制御へ
SCR02 = TXE0 | 1 << SLC02 | 7 << DLS02; // 送信許可、データは8ビット単位 SCR02 = TXE0 | 1 << SLC02 | 7 << DLS02; // 送信許可、データは8ビット単位
SS0 = 0x0004; // 通信待機 SS0 = 0x0004; // 通信待機
} }
@ -458,19 +504,20 @@ static void iic_mcu_send_st(){
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
static void iic_mcu_send_re_st(){ static void iic_mcu_send_re_st( )
ST0 |= 0x0004; {
SO0 |= 0x0400 | TAUS_MASK; // ( SDA = H ), SCL -> H ST0 |= 0x0004;
NOP(); SO0 |= 0x0400 | TAUS_MASK; // ( SDA = H ), SCL -> H
NOP(); NOP( );
NOP(); NOP( );
NOP(); NOP( );
SOE0 &= ~0x0004; // ( SCL = H ), SDA -> L NOP( );
NOP(); SOE0 &= ~0x0004; // ( SCL = H ), SDA -> L
NOP(); NOP( );
NOP(); NOP( );
NOP(); NOP( );
iic_mcu_send_st(); NOP( );
iic_mcu_send_st( );
} }
@ -479,20 +526,21 @@ static void iic_mcu_send_re_st(){
======================================================== */ ======================================================== */
static void iic_mcu_send_sp(){ static void iic_mcu_send_sp( )
ST0 = 0x0004; {
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力) ST0 = 0x0004;
SO0 = 0x0000 | TAUS_MASK; // SCL SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
NOP(); SO0 = 0x0000 | TAUS_MASK; // SCL
NOP(); NOP( );
NOP(); NOP( );
NOP(); NOP( );
SO0 = 0x0400 | TAUS_MASK; // SCL NOP( );
NOP(); SO0 = 0x0400 | TAUS_MASK; // SCL
NOP(); NOP( );
NOP(); NOP( );
NOP(); NOP( );
SO0 = 0x0404 | TAUS_MASK; NOP( );
SO0 = 0x0404 | TAUS_MASK;
} }
@ -501,7 +549,8 @@ static void iic_mcu_send_sp(){
( (
======================================================== */ ======================================================== */
void iic2m_bus_reset(){ void iic2m_bus_reset( )
{
/* /*
u8 count; u8 count;
for( count = 19; count != 0; count-- ){ for( count = 19; count != 0; count-- ){
@ -525,23 +574,24 @@ void iic2m_bus_reset(){
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
void iic_mcu_start(){ void iic_mcu_start( )
DST1 = 0; {
DEN1 = 0; DST1 = 0;
I2C_PU = 1; DEN1 = 0;
SAU0EN = 1; I2C_PU = 1;
NOP(); // 4clkあける SAU0EN = 1;
NOP(); NOP( ); // 4clkあける
NOP(); NOP( );
NOP(); NOP( );
SPS0 = 0x0000; // シリアルユニットのクロック0。(8M/2)/1 NOP( );
SMR02 = 0 << 15 | 0 << 14 | 0 << 7 | 0 << 5 | 1 << 4 | 1 << 2; // I2Cとそのクロックなど設定 SPS0 = 0x0000; // シリアルユニットのクロック0。(8M/2)/1
SDR02 = 5 << 9; // ボーレート設定 (8M/2)/1/(x+1)/2 SMR02 = 0 << 15 | 0 << 14 | 0 << 7 | 0 << 5 | 1 << 4 | 1 << 2; // I2Cとそのクロックなど設定
SDR02 = 5 << 9; // ボーレート設定 (8M/2)/1/(x+1)/2
SO0 = 0x0404 | TAUS_MASK; // 最初はHH SO0 = 0x0404 | TAUS_MASK; // 最初はHH
iic_mcu_busy = 0; iic_mcu_busy = 0;
iic_mcu_wo_dma = 0; iic_mcu_wo_dma = 0;
iic_mcu_initialized = 1; iic_mcu_initialized = 1;
} }
@ -551,10 +601,13 @@ void iic_mcu_start(){
使 使
======================================================== */ ======================================================== */
void iic_mcu_stop(){ void iic_mcu_stop( )
while( iic_mcu_busy ){;} // DMA動作中はもう少し待つ {
iic_mcu_send_re_st(); // SCL,SDAをLLにする while( iic_mcu_busy )
I2C_PU = 0; {;
SAU0EN = 0; } // DMA動作中はもう少し待つ
iic_mcu_initialized = 0; iic_mcu_send_re_st( ); // SCL,SDAをLLにする
I2C_PU = 0;
SAU0EN = 0;
iic_mcu_initialized = 0;
} }

View File

@ -18,18 +18,18 @@ extern u8 iic_mcu_bus_status;
// ======================================================== // ========================================================
err iic_mcu_read( u8 SLA, u8 adrs, u8 len, u8* dest ); err iic_mcu_read( u8 SLA, u8 adrs, u8 len, u8 * dest );
u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ); u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs );
err iic_mcu_write( u8 SLA, u8 adrs, u8 len, u8* src ); err iic_mcu_write( u8 SLA, u8 adrs, u8 len, u8 * src );
err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat ); err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat );
// ↓その通信が完了したら解除されます。 // ↓その通信が完了したら解除されます。
#define iic_mcu_set_wo_dma() { while( iic_mcu_busy ){;} iic_mcu_wo_dma = 1; } #define iic_mcu_set_wo_dma() { while( iic_mcu_busy ){;} iic_mcu_wo_dma = 1; }
void iic2m_bus_reset(); void iic2m_bus_reset( );
void iic_mcu_start(); void iic_mcu_start( );
void iic_mcu_stop(); void iic_mcu_stop( );
#endif #endif

View File

@ -1,4 +1,4 @@
#pragma sfr /* 特殊機能レジスタ使用 */ #pragma sfr /* 特殊機能レジスタ使用 */
@ -44,18 +44,22 @@ extern u8 vreg_twl[];
#ifndef _MCU_BSR_ #ifndef _MCU_BSR_
// ke3の時はダミー関数 // ke3の時はダミー関数
void IIC_twl_Stop( void ){} void IIC_twl_Stop( void )
void IIC_twl_Init( void ){} {
}
void IIC_twl_Init( void )
{
}
#else #else
/*============================================================================*/ /*============================================================================*/
u8 vreg_adrs; u8 vreg_adrs;
u8 pre_dat; u8 pre_dat;
u16 tot; u16 tot;
// 注 ↓はマクロなので、returnはメインループに戻ります。 // 注 ↓はマクロなので、returnはメインループに戻ります。
@ -75,12 +79,13 @@ u16 tot;
} }
__interrupt void int_iic_twl(){ __interrupt void int_iic_twl( )
u8 temp; {
u16 tot = 0; u8 temp;
u16 tot = 0;
// WDT_Restart(); // WDT_Restart();
// フラグ1回目 スレーブアドレス,R/W // フラグ1回目 スレーブアドレス,R/W
/* COI != 1 なら、割り込みはいらない /* COI != 1 なら、割り込みはいらない
if( COI != 1 ){ // 被呼び出し? if( COI != 1 ){ // 被呼び出し?
LREL = 1; // 呼ばれたのは他のID LREL = 1; // 呼ばれたのは他のID
@ -90,110 +95,119 @@ __interrupt void int_iic_twl(){
WREL = 1; // ウェイト解除して次のバイトを待つ WREL = 1; // ウェイト解除して次のバイトを待つ
} }
*/ */
WREL = 1; // ウェイト解除して次のバイトを待つ WREL = 1; // ウェイト解除して次のバイトを待つ
wait_next; // 1バイト受信完了を待つ wait_next; // 1バイト受信完了を待つ
// 2回目 R/W レジスタアドレス // 2回目 R/W レジスタアドレス
temp = IICA; temp = IICA;
WREL = 1; WREL = 1;
IICAIF = 0; IICAIF = 0;
vreg_adrs = adrs_table_twl_ext2int( temp ); vreg_adrs = adrs_table_twl_ext2int( temp );
// 3回目 // 3回目
// スタートコンディションか、データ受信完了フラグ待ち // スタートコンディションか、データ受信完了フラグ待ち
while( 1 ){ while( 1 )
if( IICAIF == 1 ){ {
// 受信 // if( IICAIF == 1 )
IICAIF = 0; {
temp = IICA; // 受信 //
IICA = 0xFF; IICAIF = 0;
temp = IICA;
IICA = 0xFF;
// WREL = 1; // WREL = 1;
// 通常アクセス(ライト) // // 通常アクセス(ライト) //
LREL = 1; // スタートコンディション待ちへ(連続書き込み未対応のため) LREL = 1; // スタートコンディション待ちへ(連続書き込み未対応のため)
vreg_twl_write( vreg_adrs, temp ); vreg_twl_write( vreg_adrs, temp );
return; // 受信おしまい // return; // 受信おしまい //
}else if( STD ){ }
// 送信 // (スタートコンディション検出) else if( STD )
pre_dat = vreg_twl_read( vreg_adrs ); // mcu内部アドレスを渡す。一バイト目の準備 IICBに書き込むとウェイト解除 {
// 送信 // (スタートコンディション検出)
pre_dat = vreg_twl_read( vreg_adrs ); // mcu内部アドレスを渡す。一バイト目の準備 IICBに書き込むとウェイト解除
// 自局をRで呼ばれるのを待つ // 自局をRで呼ばれるのを待つ
wait_next; wait_next;
IICAIF = 0; IICAIF = 0;
if( COI != 1 ){ // 被呼び出し? if( COI != 1 )
LREL = 1; // 呼ばれたのは他のIDあれ { // 被呼び出し?
return; LREL = 1; // 呼ばれたのは他のIDあれ
} return;
IICA = pre_dat; // データを送る。ウェイトも解除される。 }
IICA = pre_dat; // データを送る。ウェイトも解除される。
wait_next; wait_next;
// 4回目。(送信データ後の、ACK/NACK後) どうしても発生してしまう。 // 4回目。(送信データ後の、ACK/NACK後) どうしても発生してしまう。
IICAIF = 0; // おしまい IICAIF = 0; // おしまい
LREL = 1; LREL = 1;
return; return;
}else if( SPD ){ // 強制終了 }
LREL = 1; else if( SPD )
return; { // 強制終了
LREL = 1;
return;
}
} }
}
} }
/*****************************************************/ /*****************************************************/
void IIC_twl_Init( void ){ void IIC_twl_Init( void )
{
IICAEN = 1; IICAEN = 1;
IICE = 0; /* IICA disable */ IICE = 0; /* IICA disable */
IICAMK = 1; /* INTIICA disable */ IICAMK = 1; /* INTIICA disable */
IICAIF = 0; /* clear INTIICA interrupt flag */ IICAIF = 0; /* clear INTIICA interrupt flag */
IICAPR0 = 0; /* set INTIICA high priority */ IICAPR0 = 0; /* set INTIICA high priority */
IICAPR1 = 0; /* set INTIICA high priority */ IICAPR1 = 0; /* set INTIICA high priority */
#ifdef _MODEL_WM0_ #ifdef _MODEL_WM0_
P6 &= ~0x3; P6 &= ~0x3;
#else #else
P20 &= ~0x3; P20 &= ~0x3;
#endif #endif
SVA = IIC_T_SLAVEADDRESS; SVA = IIC_T_SLAVEADDRESS;
IICF = 0x01; IICF = 0x01;
STCEN = 1; // リスタートの許可 STCEN = 1; // リスタートの許可
IICRSV = 1; // 通信予約をさせない:スレーブに徹する IICRSV = 1; // 通信予約をさせない:スレーブに徹する
SPIE = 0; // ストップコンディションでの割り込みを禁止 SPIE = 0; // ストップコンディションでの割り込みを禁止
WTIM = 1; // 自動でACKを返した後clkをLに固定する WTIM = 1; // 自動でACKを返した後clkをLに固定する
ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない
IICWH = 8; IICWH = 8;
IICWL = 10; // L期間の長さ IICWL = 10; // L期間の長さ
SMC = 1; SMC = 1;
IICAMK = 0; // 割り込みを許可 IICAMK = 0; // 割り込みを許可
IICE = 1; IICE = 1;
#ifdef _MODEL_WM0_ #ifdef _MODEL_WM0_
PM6 &= ~0x3; /* set clock pin for IICA */ PM6 &= ~0x3; /* set clock pin for IICA */
#else #else
PM20 &= ~0x3; /* set clock pin for IICA */ PM20 &= ~0x3; /* set clock pin for IICA */
#endif #endif
LREL = 1; LREL = 1;
} }
//**************************************************************************** //****************************************************************************
void IIC_twl_Stop( void ){ void IIC_twl_Stop( void )
IICE = 0; /* IICA disable */ {
IICAEN = 0; IICE = 0; /* IICA disable */
IICAEN = 0;
} }

View File

@ -4,109 +4,109 @@
/* IIC operation enable (IICE0) */ /* IIC operation enable (IICE0) */
#define IIC0_OPERATION 0x80 #define IIC0_OPERATION 0x80
#define IIC0_OPERATION_DISABLE 0x00 /* stop operation */ #define IIC0_OPERATION_DISABLE 0x00 /* stop operation */
#define IIC0_OPERATION_ENABLE 0x80 /* enable operation */ #define IIC0_OPERATION_ENABLE 0x80 /* enable operation */
/* Exit from communications (LREL0) */ /* Exit from communications (LREL0) */
#define IIC0_COMMUNICATION 0x40 #define IIC0_COMMUNICATION 0x40
#define IIC0_COMMUNICATION_NORMAL 0x00 /* normal operation */ #define IIC0_COMMUNICATION_NORMAL 0x00 /* normal operation */
#define IIC0_COMMUNICATION_EXIT 0x40 /* exit from current communication */ #define IIC0_COMMUNICATION_EXIT 0x40 /* exit from current communication */
/* Wait cancellation (WREL0) */ /* Wait cancellation (WREL0) */
#define IIC0_WAITCANCEL 0x20 #define IIC0_WAITCANCEL 0x20
#define IIC0_WAIT_NOTCANCEL 0x00 /* do not cancel wait */ #define IIC0_WAIT_NOTCANCEL 0x00 /* do not cancel wait */
#define IIC0_WAIT_CANCEL 0x20 /* cancel wait */ #define IIC0_WAIT_CANCEL 0x20 /* cancel wait */
/* Generation of interrupt when stop condition (SPIE0) */ /* Generation of interrupt when stop condition (SPIE0) */
#define IIC0_STOPINT 0x10 #define IIC0_STOPINT 0x10
#define IIC0_STOPINT_DISABLE 0x00 /* disable */ #define IIC0_STOPINT_DISABLE 0x00 /* disable */
#define IIC0_STOPINT_ENABLE 0x10 /* enable */ #define IIC0_STOPINT_ENABLE 0x10 /* enable */
/* Wait and interrupt generation (WTIM0) */ /* Wait and interrupt generation (WTIM0) */
#define IIC0_WAITINT 0x08 #define IIC0_WAITINT 0x08
#define IIC0_WAITINT_CLK8FALLING 0x00 /* generate at the eighth clocks falling edge */ #define IIC0_WAITINT_CLK8FALLING 0x00 /* generate at the eighth clocks falling edge */
#define IIC0_WAITINT_CLK9FALLING 0x08 /* generated at the ninth clocks falling edge */ #define IIC0_WAITINT_CLK9FALLING 0x08 /* generated at the ninth clocks falling edge */
/* Acknowledgement control (ACKE0) */ /* Acknowledgement control (ACKE0) */
#define IIC0_ACK 0x04 #define IIC0_ACK 0x04
#define IIC0_ACK_DISABLE 0x00 /* enable acknowledgement */ #define IIC0_ACK_DISABLE 0x00 /* enable acknowledgement */
#define IIC0_ACK_ENABLE 0x04 /* disable acknowledgement */ #define IIC0_ACK_ENABLE 0x04 /* disable acknowledgement */
/* Start condition trigger (STT0) */ /* Start condition trigger (STT0) */
#define IIC0_STARTCONDITION 0x02 #define IIC0_STARTCONDITION 0x02
#define IIC0_START_NOTGENERATE 0x00 /* do not generate start condition */ #define IIC0_START_NOTGENERATE 0x00 /* do not generate start condition */
#define IIC0_START_GENERATE 0x02 /* generate start condition */ #define IIC0_START_GENERATE 0x02 /* generate start condition */
/* Stop condition trigger (SPT0) */ /* Stop condition trigger (SPT0) */
#define IIC0_STOPCONDITION 0x01 #define IIC0_STOPCONDITION 0x01
#define IIC0_STOP_NOTGENERATE 0x00 /* do not generate stop condition */ #define IIC0_STOP_NOTGENERATE 0x00 /* do not generate stop condition */
#define IIC0_STOP_GENERATE 0x01 /* generate stop condition */ #define IIC0_STOP_GENERATE 0x01 /* generate stop condition */
/* /*
IIC Status Register 0 (IICS0) IIC Status Register 0 (IICS0)
*/ */
/* Master device status (MSTS0) */ /* Master device status (MSTS0) */
#define IIC0_MASTERSTATUS 0x80 #define IIC0_MASTERSTATUS 0x80
#define IIC0_STATUS_NOTMASTER 0x00 /* slave device status or communication standby status */ #define IIC0_STATUS_NOTMASTER 0x00 /* slave device status or communication standby status */
#define IIC0_STATUS_MASTER 0x80 /* master device communication status */ #define IIC0_STATUS_MASTER 0x80 /* master device communication status */
/* Detection of arbitration loss (ALD0) */ /* Detection of arbitration loss (ALD0) */
#define IIC0_ARBITRATION 0x40 #define IIC0_ARBITRATION 0x40
#define IIC0_ARBITRATION_NO 0x00 /* arbitration win or no arbitration */ #define IIC0_ARBITRATION_NO 0x00 /* arbitration win or no arbitration */
#define IIC0_ARBITRATION_LOSS 0x40 /* arbitration loss */ #define IIC0_ARBITRATION_LOSS 0x40 /* arbitration loss */
/* Detection of extension code reception (EXC0) */ /* Detection of extension code reception (EXC0) */
#define IIC0_EXTENSIONCODE 0x20 #define IIC0_EXTENSIONCODE 0x20
#define IIC0_EXTCODE_NOT 0x00 /* extension code not received */ #define IIC0_EXTCODE_NOT 0x00 /* extension code not received */
#define IIC0_EXTCODE_RECEIVED 0x20 /* extension code received */ #define IIC0_EXTCODE_RECEIVED 0x20 /* extension code received */
/* Detection of matching addresses (COI0) */ /* Detection of matching addresses (COI0) */
#define IIC0_ADDRESSMATCH 0x10 #define IIC0_ADDRESSMATCH 0x10
#define IIC0_ADDRESS_NOTMATCH 0x00 /* addresses do not match */ #define IIC0_ADDRESS_NOTMATCH 0x00 /* addresses do not match */
#define IIC0_ADDRESS_MATCH 0x10 /* addresses match */ #define IIC0_ADDRESS_MATCH 0x10 /* addresses match */
/* Detection of transmit/receive status (TRC0) */ /* Detection of transmit/receive status (TRC0) */
#define IIC0_STATUS 0x08 #define IIC0_STATUS 0x08
#define IIC0_STATUS_RECEIVE 0x00 /* receive status */ #define IIC0_STATUS_RECEIVE 0x00 /* receive status */
#define IIC0_STATUS_TRANSMIT 0x08 /* transmit status */ #define IIC0_STATUS_TRANSMIT 0x08 /* transmit status */
/* Detection of acknowledge signal (ACKD0) */ /* Detection of acknowledge signal (ACKD0) */
#define IIC0_ACKDETECTION 0x04 #define IIC0_ACKDETECTION 0x04
#define IIC0_ACK_NOTDETECTED 0x00 /* ACK signal was not detected */ #define IIC0_ACK_NOTDETECTED 0x00 /* ACK signal was not detected */
#define IIC0_ACK_DETECTED 0x04 /* ACK signal was detected */ #define IIC0_ACK_DETECTED 0x04 /* ACK signal was detected */
/* Detection of start condition (STD0) */ /* Detection of start condition (STD0) */
#define IIC0_STARTDETECTION 0x02 #define IIC0_STARTDETECTION 0x02
#define IIC0_START_NOTDETECTED 0x00 /* start condition not detected */ #define IIC0_START_NOTDETECTED 0x00 /* start condition not detected */
#define IIC0_START_DETECTED 0x02 /* start condition detected */ #define IIC0_START_DETECTED 0x02 /* start condition detected */
/* Detection of stop condition (SPD0) */ /* Detection of stop condition (SPD0) */
#define IIC0_STOPDETECTION 0x01 #define IIC0_STOPDETECTION 0x01
#define IIC0_STOP_NOTDETECTED 0x00 /* stop condition not detected */ #define IIC0_STOP_NOTDETECTED 0x00 /* stop condition not detected */
#define IIC0_STOP_DETECTED 0x01 /* stop condition detected */ #define IIC0_STOP_DETECTED 0x01 /* stop condition detected */
/* /*
IIC Flag Register 0 (IICF0) IIC Flag Register 0 (IICF0)
*/ */
/* STT0 clear flag (STCF) */ /* STT0 clear flag (STCF) */
#define IIC0_STARTFLAG 0x80 #define IIC0_STARTFLAG 0x80
#define IIC0_STARTFLAG_GENERATE 0x00 /* generate start condition */ #define IIC0_STARTFLAG_GENERATE 0x00 /* generate start condition */
#define IIC0_STARTFLAG_UNSUCCESSFUL 0x80 /* start condition generation unsuccessful */ #define IIC0_STARTFLAG_UNSUCCESSFUL 0x80 /* start condition generation unsuccessful */
/* IIC bus status flag (IICBSY) */ /* IIC bus status flag (IICBSY) */
#define IIC0_BUSSTATUS 0x40 #define IIC0_BUSSTATUS 0x40
#define IIC0_BUS_RELEASE 0x00 /* bus release status */ #define IIC0_BUS_RELEASE 0x00 /* bus release status */
#define IIC0_BUS_COMMUNICATION 0x40 /* bus communication status */ #define IIC0_BUS_COMMUNICATION 0x40 /* bus communication status */
/* Initial start enable trigger (STCEN) */ /* Initial start enable trigger (STCEN) */
#define IIC0_STARTWITHSTOP 0x02 #define IIC0_STARTWITHSTOP 0x02
#define IIC0_START_WITHSTOP 0x00 /* generation of a start condition without detecting a stop condition */ #define IIC0_START_WITHSTOP 0x00 /* generation of a start condition without detecting a stop condition */
#define IIC0_START_WITHOUTSTOP 0x02 /* generation of a start condition upon detection of a stop condition */ #define IIC0_START_WITHOUTSTOP 0x02 /* generation of a start condition upon detection of a stop condition */
/* Communication reservation function disable bit (IICRSV) */ /* Communication reservation function disable bit (IICRSV) */
#define IIC0_RESERVATION 0x01 #define IIC0_RESERVATION 0x01
#define IIC0_RESERVATION_ENABLE 0x00 /* enable communication reservation */ #define IIC0_RESERVATION_ENABLE 0x00 /* enable communication reservation */
#define IIC0_RESERVATION_DISABLE 0x01 /* disable communication reservation */ #define IIC0_RESERVATION_DISABLE 0x01 /* disable communication reservation */
/* /*
IIC clock selection register 0 (IICCL0) IIC clock selection register 0 (IICCL0)
@ -114,23 +114,23 @@
#define IICCL0_INITIALVALUE 0x00 #define IICCL0_INITIALVALUE 0x00
/* Detection of SCL0 pin level (CLD0) */ /* Detection of SCL0 pin level (CLD0) */
#define IIC0_SCLLEVEL 0x20 #define IIC0_SCLLEVEL 0x20
#define IIC0_SCL_LOW 0x00 /* clock line at low level */ #define IIC0_SCL_LOW 0x00 /* clock line at low level */
#define IIC0_SCL_HIGH 0x20 /* clock line at high level */ #define IIC0_SCL_HIGH 0x20 /* clock line at high level */
/* Detection of SDA0 pin level (DAD0) */ /* Detection of SDA0 pin level (DAD0) */
#define IIC0_SDALEVEL 0x10 #define IIC0_SDALEVEL 0x10
#define IIC0_SDA_LOW 0x00 /* data line at low level */ #define IIC0_SDA_LOW 0x00 /* data line at low level */
#define IIC0_SDA_HIGH 0x10 /* data line at high level */ #define IIC0_SDA_HIGH 0x10 /* data line at high level */
/* Operation mode switching (SMC0) */ /* Operation mode switching (SMC0) */
#define IIC0_OPERATIONMODE 0x08 #define IIC0_OPERATIONMODE 0x08
#define IIC0_MODE_STANDARD 0x00 /* operates in standard mode */ #define IIC0_MODE_STANDARD 0x00 /* operates in standard mode */
#define IIC0_MODE_HIGHSPEED 0x08 /* operates in high-speed mode */ #define IIC0_MODE_HIGHSPEED 0x08 /* operates in high-speed mode */
/* Digital filter operation control (DFC0) */ /* Digital filter operation control (DFC0) */
#define IIC0_DIGITALFILTER 0x04 #define IIC0_DIGITALFILTER 0x04
#define IIC0_FILTER_OFF 0x00 /* digital filter off */ #define IIC0_FILTER_OFF 0x00 /* digital filter off */
#define IIC0_FILTER_ON 0x04 /* digital filter on */ #define IIC0_FILTER_ON 0x04 /* digital filter on */
/* Operation mode switching (CL01, CL00) */ /* Operation mode switching (CL01, CL00) */
#define IIC0_CLOCKSELECTION 0x03 #define IIC0_CLOCKSELECTION 0x03

View File

@ -28,6 +28,6 @@
//========================================================= //=========================================================
err firm_update(); err firm_update( );
#endif #endif

View File

@ -32,6 +32,5 @@
//========================================================= //=========================================================
err firm_update(); err firm_update( );
err firm_restore(); err firm_restore( );

View File

@ -1,50 +1,50 @@
#include "config.h" #include "config.h"
//#pragma interrupt INTWDTI fn_intwdti // 未使用 //#pragma interrupt INTWDTI fn_intwdti // 未使用
//#pragma interrupt INTLVI fn_intlvi // 未使用 //#pragma interrupt INTLVI fn_intlvi // 未使用
#pragma interrupt INTP0 intp0_slp // SLP (CPUより、要求 #pragma interrupt INTP0 intp0_slp // SLP (CPUより、要求
//#pragma interrupt INTP1 fn_intp1 // (I2C) //#pragma interrupt INTP1 fn_intp1 // (I2C)
//#pragma interrupt INTP2 fn_intp2 // (I2C) //#pragma interrupt INTP2 fn_intp2 // (I2C)
//#pragma interrupt INTP3 fn_intp3 // 未搭載 //#pragma interrupt INTP3 fn_intp3 // 未搭載
#pragma interrupt INTP4 intp4_extdc // EXTDC, ただし電源offから起こすのみ。通常はポーリング #pragma interrupt INTP4 intp4_extdc // EXTDC, ただし電源offから起こすのみ。通常はポーリング
#pragma interrupt INTP5 intp5_shell // SHELL_CLOSE, ただし電源offから起こすのみ。通常はポーリング #pragma interrupt INTP5 intp5_shell // SHELL_CLOSE, ただし電源offから起こすのみ。通常はポーリング
#pragma interrupt INTP6 intp6_PM_irq // CODEC経由で旧PMICへのコマンド書き込み #pragma interrupt INTP6 intp6_PM_irq // CODEC経由で旧PMICへのコマンド書き込み
#ifdef _MCU_BSR_ #ifdef _MCU_BSR_
#pragma interrupt INTP21 intp21_RFTx // 電波送信パルス #pragma interrupt INTP21 intp21_RFTx // 電波送信パルス
#else #else
#pragma interrupt INTP7 intp21_RFTx #pragma interrupt INTP7 intp21_RFTx
#endif #endif
#ifdef _MCU_BSR_ #ifdef _MCU_BSR_
#pragma interrupt INTP23 intp23_ACC_ready // 加速度センサ、データ準備完了 #pragma interrupt INTP23 intp23_ACC_ready // 加速度センサ、データ準備完了
#endif #endif
//#pragma interrupt INTCMP0 fn_intcmp0 //#pragma interrupt INTCMP0 fn_intcmp0
//#pragma interrupt INTCMP1 fn_intcmp1 //#pragma interrupt INTCMP1 fn_intcmp1
//#pragma interrupt INTDMA0 fn_intdma0 //#pragma interrupt INTDMA0 fn_intdma0
#pragma interrupt INTDMA1 int_dma1 #pragma interrupt INTDMA1 int_dma1
//#pragma interrupt INTST0 fn_intst0 //#pragma interrupt INTST0 fn_intst0
/* #pragma interrupt INTCSI00 fn_intcsi00 */ /* #pragma interrupt INTCSI00 fn_intcsi00 */
//#pragma interrupt INTSR0 fn_intsr0 //#pragma interrupt INTSR0 fn_intsr0
/* #pragma interrupt INTCSI01 fn_intcsi01 */ /* #pragma interrupt INTCSI01 fn_intcsi01 */
//#pragma interrupt INTSRE0 fn_intsre0 //#pragma interrupt INTSRE0 fn_intsre0
//#pragma interrupt INTST1 fn_intst1 //#pragma interrupt INTST1 fn_intst1
/* #pragma interrupt INTCSI10 fn_intcsi10 */ /* #pragma interrupt INTCSI10 fn_intcsi10 */
#pragma interrupt INTIIC10 int_iic10 #pragma interrupt INTIIC10 int_iic10
//#pragma interrupt INTSR1 fn_intsr1 //#pragma interrupt INTSR1 fn_intsr1
//#pragma interrupt INTSRE1 fn_intsre1 //#pragma interrupt INTSRE1 fn_intsre1
#ifdef _MCU_KE3_ #ifdef _MCU_KE3_
#pragma interrupt INTIICA int_iic_ctr // CTR側 #pragma interrupt INTIICA int_iic_ctr // CTR側
#else #else
//#ifdef _MODEL_WM0_ //#ifdef _MODEL_WM0_
#pragma interrupt INTIICA0 int_iic_twl // テレコのWM0仕様 #pragma interrupt INTIICA0 int_iic_twl // テレコのWM0仕様
#pragma interrupt INTIICA1 int_iic_ctr #pragma interrupt INTIICA1 int_iic_ctr
/* /*
#else #else
@ -55,68 +55,190 @@
#endif #endif
//#pragma interrupt INTTM00 fn_inttm00 //#pragma interrupt INTTM00 fn_inttm00
//#pragma interrupt INTTM01 fn_inttm01 //#pragma interrupt INTTM01 fn_inttm01
//#pragma interrupt INTTM02 fn_inttm02 //#pragma interrupt INTTM02 fn_inttm02
//#pragma interrupt INTTM03 fn_inttm03 //#pragma interrupt INTTM03 fn_inttm03
#pragma interrupt INTAD int_adc #pragma interrupt INTAD int_adc
#pragma interrupt INTRTC int_rtc #pragma interrupt INTRTC int_rtc
#pragma interrupt INTRTCI int_rtc_int #pragma interrupt INTRTCI int_rtc_int
#pragma interrupt INTKR int_kr #pragma interrupt INTKR int_kr
//#pragma interrupt INTMD fn_intmd //#pragma interrupt INTMD fn_intmd
//#pragma interrupt INTTM04 fn_inttm04 //#pragma interrupt INTTM04 fn_inttm04
//#pragma interrupt INTTM05 fn_inttm05 //#pragma interrupt INTTM05 fn_inttm05
//#pragma interrupt INTTM06 fn_inttm06 //#pragma interrupt INTTM06 fn_inttm06
//#pragma interrupt INTTM07 fn_inttm07 //#pragma interrupt INTTM07 fn_inttm07
/****************************************************/ /****************************************************/
/* 未使用時のダミー関数定義 */ /* 未使用時のダミー関数定義 */
/****************************************************/ /****************************************************/
__interrupt void fn_intwdti(){ while(1){}; } __interrupt void fn_intwdti( )
__interrupt void fn_intlvi(){ while(1){}; } {
//__interrupt void fn_intp0(){} // tasks.c while( 1 )
__interrupt void fn_intp1(){ while(1){}; } // {
__interrupt void fn_intp2(){ while(1){}; } };
__interrupt void fn_intp3(){ while(1){}; } }
//__interrupt void fn_intp4(){ while(1){}; } // pm.c __interrupt void fn_intlvi( )
//__interrupt void fn_intp5(){ while(1){}; } // pm.c {
//__interrupt void fn_intp6(){ while(1){}; } // pm.c while( 1 )
//__interrupt void fn_intp7(){ while(1){}; } // led.c {
//__interrupt void fn_intp21(){ while(1){}; } // led.c };
}
__interrupt void fn_intcmp0(){ while(1){}; } //__interrupt void fn_intp0(){} // tasks.c
__interrupt void fn_intcmp1(){ while(1){}; } __interrupt void fn_intp1( )
__interrupt void fn_intdma0(){ while(1){}; } {
//__interrupt void fn_intdma1(){} // i2c_mcu.cにある while( 1 )
{
};
} //
__interrupt void fn_intp2( )
{
while( 1 )
{
};
}
__interrupt void fn_intp3( )
{
while( 1 )
{
};
}
//__interrupt void fn_intp4(){ while(1){}; } // pm.c
//__interrupt void fn_intp5(){ while(1){}; } // pm.c
//__interrupt void fn_intp6(){ while(1){}; } // pm.c
//__interrupt void fn_intp7(){ while(1){}; } // led.c
//__interrupt void fn_intp21(){ while(1){}; } // led.c
__interrupt void fn_intcmp0( )
{
while( 1 )
{
};
}
__interrupt void fn_intcmp1( )
{
while( 1 )
{
};
}
__interrupt void fn_intdma0( )
{
while( 1 )
{
};
}
//__interrupt void fn_intdma1(){} // i2c_mcu.cにある
__interrupt void fn_intst0( )
{
while( 1 )
{
};
}
__interrupt void fn_intst0(){ while(1){}; }
/* __interrupt void fn_intcsi00(){} */ /* __interrupt void fn_intcsi00(){} */
__interrupt void fn_intsr0(){ while(1){}; } __interrupt void fn_intsr0( )
{
while( 1 )
{
};
}
/* __interrupt void fn_intcsi01(){} */ /* __interrupt void fn_intcsi01(){} */
__interrupt void fn_intsre0(){ while(1){}; } __interrupt void fn_intsre0( )
{
while( 1 )
{
};
}
__interrupt void fn_intst1( )
{
while( 1 )
{
};
}
__interrupt void fn_intst1(){ while(1){}; }
/* __interrupt void fn_intcsi10(){} */ /* __interrupt void fn_intcsi10(){} */
//__interrupt void fn_intiic10(){ while(1){}; } //__interrupt void fn_intiic10(){ while(1){}; }
__interrupt void fn_intsr1(){ while(1){}; } __interrupt void fn_intsr1( )
__interrupt void fn_intsre1(){ while(1){}; } {
while( 1 )
{
};
}
__interrupt void fn_intsre1( )
{
while( 1 )
{
};
}
//__interrupt void fn_intiica(){} // i2c.cにある //__interrupt void fn_intiica(){} // i2c.cにある
/* __interrupt void fn_inttm00(){} */ /* sub.cにて定義 */ /* __interrupt void fn_inttm00(){} *//* sub.cにて定義 */
__interrupt void fn_inttm01(){ while(1){}; } __interrupt void fn_inttm01( )
__interrupt void fn_inttm02(){ while(1){}; } {
__interrupt void fn_inttm03(){ while(1){}; } while( 1 )
{
};
}
__interrupt void fn_inttm02( )
{
while( 1 )
{
};
}
__interrupt void fn_inttm03( )
{
while( 1 )
{
};
}
//__interrupt void fn_intad(){ while(1){}; } // adc.c //__interrupt void fn_intad(){ while(1){}; } // adc.c
__interrupt void fn_intrtc(){ while(1){}; } __interrupt void fn_intrtc( )
//__interrupt void int_rtcint(){} // rtc.cにある {
//__interrupt void fn_intkr(){} // main.c while( 1 )
__interrupt void fn_intmd(){ while(1){}; } {
};
}
__interrupt void fn_inttm04(){ while(1){}; } //__interrupt void int_rtcint(){} // rtc.cにある
__interrupt void fn_inttm05(){ while(1){}; } //__interrupt void fn_intkr(){} // main.c
__interrupt void fn_inttm06(){ while(1){}; } __interrupt void fn_intmd( )
__interrupt void fn_inttm07(){ while(1){}; } {
while( 1 )
{
};
}
__interrupt void fn_inttm04( )
{
while( 1 )
{
};
}
__interrupt void fn_inttm05( )
{
while( 1 )
{
};
}
__interrupt void fn_inttm06( )
{
while( 1 )
{
};
}
__interrupt void fn_inttm07( )
{
while( 1 )
{
};
}

View File

@ -1,12 +1,12 @@
#ifndef __jhl_defs_h__ #ifndef __jhl_defs_h__
#define __jhl_defs_h__ #define __jhl_defs_h__
typedef unsigned char u8; typedef unsigned char u8;
typedef char s8; typedef char s8;
typedef unsigned short u16; typedef unsigned short u16;
typedef short s16; typedef short s16;
typedef unsigned char err; typedef unsigned char err;
#define set_bit( cond, reg, pos ) \ #define set_bit( cond, reg, pos ) \

View File

@ -2,9 +2,6 @@
LED.c LED.c
======================================================== */ ======================================================== */
#pragma sfr #pragma sfr
@ -12,6 +9,7 @@
#include "led.h" #include "led.h"
// ======================================================== // ========================================================
// TPS0 // TPS0
#define BIT_PRS01 4 #define BIT_PRS01 4
@ -27,21 +25,22 @@
#define BIT_MD0 0 #define BIT_MD0 0
// ======================================================== // ========================================================
static task_interval led_pow_normal(); static void led_pow_normal( );
static task_interval led_pow_hotaru(); static void led_pow_hotaru( );
// ======================================================== // ========================================================
u8 wifi_TX; u8 wifi_TX;
// ======================================================== // ========================================================
static const char MSG_MAIL[] = { 0b11110110, 0b11011010, 0b01101110, 0b10010100 }; static const char MSG_MAIL[] = { 0b11110110, 0b11011010, 0b01101110, 0b10010100 };
#define MSG_SPD 70 #define MSG_SPD 60
// ======================================================== // ========================================================
void LED_init(){ void LED_init( )
{
/** /**
PWMのセット PWMのセット
@ -54,37 +53,33 @@ void LED_init(){
                   
                   
*/ */
TAU0EN = 1; TAU0EN = 1;
TPS0 = 1 << BIT_PRS01 | 1 << BIT_PRS00; // マスタークロックはCK01,8M/2/2^4 = 250kHz TPS0 = 1 << BIT_PRS01 | 1 << BIT_PRS00; // マスタークロックはCK01,8M/2/2^4 = 250kHz
TMR00 = 1 << BIT_CKS0 | 0 << BIT_CCS0 | 1 << BIT_MASTER0 | 0 << BIT_STS0 | 0 << BIT_CIS0 | 0 << BIT_MD123 | 1 << BIT_MD0; TMR00 =
TMR01 = TMR02 = TMR03 = TMR04 = TMR05 = TMR06 = TMR07 \ 1 << BIT_CKS0 | 0 << BIT_CCS0 | 1 << BIT_MASTER0 | 0 << BIT_STS0 | 0
= 1 << BIT_CKS0 | 0 << BIT_CCS0 | 0 << BIT_MASTER0 | 4 << BIT_STS0 | 0 << BIT_CIS0 | 4 << BIT_MD123 | 1 << BIT_MD0; << BIT_CIS0 | 0 << BIT_MD123 | 1 << BIT_MD0;
ISC = 0; TMR01 = TMR02 = TMR03 = TMR04 = TMR05 = TMR06 = TMR07 =
TOM0 = 0b0000000011111110; // 出力モード。4はPWM出力しないが1にしないとTO5以降にクロックが届かない 1 << BIT_CKS0 | 0 << BIT_CCS0 | 0 << BIT_MASTER0 | 4 << BIT_STS0 | 0
#if 0 << BIT_CIS0 | 4 << BIT_MD123 | 1 << BIT_MD0;
#ifdef _MODEL_WM0_ ISC = 0;
TOL0 = 0b0000000000000010; // 出力を反転させるかフラグ TOM0 = 0b0000000011111110; // 出力モード。4はPWM出力しないが1にしないとTO5以降にクロックが届かない
#else TOL0 = 0b0000000000000100; // 出力を反転させるかフラグ
#ifdef _MODEL_TS0_
TOL0 = 0b0000000000000110;
#endif
TOL0 = 0b0000000000000110;
#endif
#endif
TO0 = 0; // タイマー動作中で、タイマー出力にしてないときのピンのラッチ。タイマー出力を使わないなら0
TOE0 = 0b0000000011101110; // TOxをタイマーモジュールが制御
TS0 = 0b0000000011101111; // 動作開始
TDR00 = LED_BRIGHT_MAX - 1; // 10bit, 周期 TO0 = 0; // タイマー動作中で、タイマー出力にしてないときのピンのラッチ。タイマー出力を使わないなら0
TOE0 = 0b0000000011101110; // TOxをタイマーモジュールが制御
TS0 = 0b0000000011101111; // 動作開始
TDR00 = LED_BRIGHT_MAX - 1; // 10bit, 周期
} }
void LED_stop(){ void LED_stop( )
TT0 = 0b0000000011101111; // 一斉停止(しないとだめ) {
TOE0 = 0b0000000000000000; // TOxをタイマーモジュールが制御(GPIOになる) TT0 = 0b0000000011101111; // 一斉停止(しないとだめ)
TAU0EN = 0; TOE0 = 0b0000000000000000; // TOxをタイマーモジュールが制御(GPIOになる)
TAU0EN = 0;
} }
@ -113,60 +108,56 @@ enum LED_ILUM_MODE{
LED_POW_ILM_CEOFF LED_POW_ILM_CEOFF
}; };
======================================================== */ ======================================================== */
task_interval tsk_led_pow(){ void tsk_led_pow( )
{
switch ( vreg_ctr[VREG_C_LED_POW] )
{
// 自動切り替え
case ( LED_POW_ILM_AUTO ):
switch ( system_status.pwr_state )
{
case ( SLEEP ):
led_pow_hotaru( );
break;
switch( vreg_ctr[ VREG_C_LED_POW ] ){ case ( ON ):
case( LED_POW_ILM_AUTO ): default:
switch( system_status.pwr_state ){ led_pow_normal( );
case( SLEEP ): break;
return( led_pow_hotaru() );
break;
case( ON ): case ( ON_TRIG ):
case ( SLEEP_TRIG ):
case ( OFF_TRIG ):
case ( OFF ):
break;
}
break;
// 強制
case ( LED_POW_ILM_OFF ):
LED_duty_pow_H -= ( LED_duty_pow_H == 0x0000 ) ? 0 : 1;
LED_duty_pow_L -= ( LED_duty_pow_L == 0x0000 ) ? 0 : 1;
break;
case ( LED_POW_ILM_HOTARU ):
led_pow_hotaru( );
break;
case ( LED_POW_ILM_ON ):
default: default:
return( led_pow_normal() ); led_pow_normal( );
break; break;
case( ON_TRIG ): case ( LED_POW_ILM_ONLY_RED ):
case( SLEEP_TRIG ): LED_duty_pow_H = 0x0000;
case( OFF_TRIG ): LED_duty_pow_L = LED_BRIGHT_MAX;
case( OFF ): break;
return( 250 );
break; case ( LED_POW_ILM_ONLY_BLUE ):
LED_duty_pow_H = LED_BRIGHT_MAX;
LED_duty_pow_L = 0x0000;
break;
} }
break;
case( LED_POW_ILM_OFF ):
LED_duty_pow_H -= ( LED_duty_pow_H == 0x0000 )? 0: 1;
LED_duty_pow_L -= ( LED_duty_pow_L == 0x0000 )? 0: 1;
if(( LED_duty_pow_H == 0 ) && ( LED_duty_pow_L == 0 )){
return( 250 );
}else{
return( 0 );
}
break;
case( LED_POW_ILM_HOTARU ):
return( led_pow_hotaru() );
break;
case( LED_POW_ILM_ON ):
default:
return( led_pow_normal() );
break;
case( LED_POW_ILM_ONLY_RED ):
LED_duty_pow_H = 0x0000;
LED_duty_pow_L = LED_BRIGHT_MAX;
return( 250 );
break;
case( LED_POW_ILM_ONLY_BLUE ):
LED_duty_pow_H = LED_BRIGHT_MAX;
LED_duty_pow_L = 0x0000;
return( 250 );
break;
}
} }
@ -176,51 +167,54 @@ task_interval tsk_led_pow(){
   
======================================================== */ ======================================================== */
static task_interval led_pow_normal(){ static void led_pow_normal( )
static u8 state; {
u8 dirty; static u8 state;
dirty = 0; if( vreg_ctr[VREG_C_BT_REMAIN] < ( 255 * 0.05 ) )
if( vreg_ctr[ VREG_C_BT_REMAIN ] < ( 255 * 0.05 ) ){ {
// 赤点滅 // 赤点滅
if( state == 0 ){ state++;
LED_duty_pow_H = 0x0000; if( state < 127 )
LED_duty_pow_L = 0x0000; {
state = 1; LED_duty_pow_H = 0x0000;
}else{ LED_duty_pow_L = 0x0000;
LED_duty_pow_L = vreg_ctr[ VREG_C_LED_BRIGHT ]; }
state = 0; else
} {
return( 250 ); LED_duty_pow_L = vreg_ctr[VREG_C_LED_BRIGHT];
}
return;
}else if( vreg_ctr[ VREG_C_BT_REMAIN ] < ( 255 * 0.2 ) ){
// 赤点灯
if( LED_duty_pow_H != 0x0000 ){
LED_duty_pow_H -= 1;
dirty = 1;
} }
if( LED_duty_pow_L != vreg_ctr[ VREG_C_LED_BRIGHT ] ){ else if( vreg_ctr[VREG_C_BT_REMAIN] < ( 255 * 0.2 ) )
dirty = 1; {
LED_duty_pow_L += ( LED_duty_pow_L < vreg_ctr[ VREG_C_LED_BRIGHT ] )? 1 : -1; // 赤点灯
if( LED_duty_pow_H != 0x0000 )
{ // 青フェードアウト
LED_duty_pow_H -= 1;
}
if( LED_duty_pow_L != vreg_ctr[VREG_C_LED_BRIGHT] )
{ // 赤フェードイン
LED_duty_pow_L += ( LED_duty_pow_L < vreg_ctr[VREG_C_LED_BRIGHT] ) ? 1 : -1;
}
return;
}
else
{
// 青点灯
if( LED_duty_pow_H != vreg_ctr[VREG_C_LED_BRIGHT] )
{
LED_duty_pow_H += ( LED_duty_pow_H < vreg_ctr[VREG_C_LED_BRIGHT] ) ? 1 : -1;
}
if( LED_duty_pow_L != 0x0000 )
{
LED_duty_pow_L -= 1;
}
} }
}else{ return;
// 青点灯
if( LED_duty_pow_H != vreg_ctr[ VREG_C_LED_BRIGHT ] ){
dirty = 1;
LED_duty_pow_H += ( LED_duty_pow_H < vreg_ctr[ VREG_C_LED_BRIGHT ] )? 1 : -1;
}
if( LED_duty_pow_L != 0x0000 ){
LED_duty_pow_L -= 1;
dirty = 1;
}
}
if( dirty == 0 ){
return( 250 );
}else{
return( 0 );
}
} }
@ -229,60 +223,84 @@ static task_interval led_pow_normal(){
======================================================== */ ======================================================== */
static task_interval led_pow_hotaru(){ static void led_pow_hotaru( )
static u8 state; {
// static u8 delay; static u8 delay;
static u16 blue_to; static u8 state;
static u16 red_to; static u16 blue_to;
u8 dirty; static u16 red_to;
if( delay != 0 )
// LED 調光? {
dirty = 0; delay -= 1;
if( LED_duty_pow_H != blue_to ){ return;
dirty = 1;
if( LED_duty_pow_H > blue_to ){
LED_duty_pow_H -= 1;
}else{
LED_duty_pow_H += 2;
} }
} else
{
if( LED_duty_pow_L != red_to ){ delay = 3;
dirty = 1;
if( LED_duty_pow_L > red_to ){
LED_duty_pow_L -= 1;
}else{
LED_duty_pow_L += 2;
} }
}
if( LED_duty_pow_L != red_to )
{
if( LED_duty_pow_L > red_to )
{
LED_duty_pow_L -= 1;
}
else
{
LED_duty_pow_L += 2;
}
}
if( LED_duty_pow_H != blue_to )
{
if( LED_duty_pow_H > blue_to )
{
LED_duty_pow_H -= 1;
}
else
{
LED_duty_pow_H += 2;
}
}
switch ( state )
{
// フェードイン
case ( 0 ):
case ( 2 ):
case ( 4 ):
if( vreg_ctr[VREG_C_BT_REMAIN] < ( 255 * 0.2 ) )
{
// 赤いとき
blue_to = 0;
red_to = vreg_ctr[VREG_C_LED_BRIGHT];
}
else
{
blue_to = vreg_ctr[VREG_C_LED_BRIGHT];
red_to = 0;
}
break;
if( dirty == 0 ){
switch( state ){
// フェードイン
case( 0 ):
case( 2 ):
case( 4 ):
if( vreg_ctr[ VREG_C_BT_REMAIN ] < ( 255 * 0.2 ) ){
red_to = vreg_ctr[ VREG_C_LED_BRIGHT ];
blue_to = 0;
}else{
red_to = 0;
blue_to = vreg_ctr[ VREG_C_LED_BRIGHT ];
}
break;
default: default:
// フェードアウト // フェードアウト
red_to = 0; if( vreg_ctr[VREG_C_BT_REMAIN] < ( 255 * 0.2 ) )
blue_to = 0; {
break; red_to = 2;
}
else
{
blue_to = 2;
}
break;
} }
state += 1; if( ( LED_duty_pow_H == blue_to ) && ( LED_duty_pow_L == red_to ) )
{
} state += 1;
return( 5 ); }
return;
} }
@ -292,124 +310,146 @@ static task_interval led_pow_hotaru(){
LED_Wifi 3 LED_Wifi 3
2 P24 2 P24
======================================================== */ ======================================================== */
task_interval tsk_led_wifi(){ void tsk_led_wifi( )
static u8 remain_wifi_tx; {
static u8 state_wifi_tx; static u8 task_interval;
static u8 remain_wifi_tx;
static u8 state_wifi_tx;
switch( vreg_ctr[ VREG_C_LED_WIFI ] ){ if( task_interval != 0 )
case( WIFI_LED_OFF ): {
LED_duty_WiFi = 0; task_interval -= 1;
wifi_TX = 0; return;
state_wifi_tx = 0;
remain_wifi_tx = 0;
LED_WIFI_2 = 0;
return( 250 );
break;
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;
return( 250 );
break;
case( WIFI_LED_TXAUTO ):
// 短いパルスを捕まえるために、割り込みフラグを見る
if( wifi_TX != 0 ){
wifi_TX = 0;
remain_wifi_tx = 2;
} }
// 送信パターン switch ( vreg_ctr[VREG_C_LED_WIFI] )
if( remain_wifi_tx != 0 ){ // TX active {
switch( state_wifi_tx ){ case ( WIFI_LED_OFF ):
case( 1 ):
case( 3 ):
case( 5 ):
LED_duty_WiFi = 0; LED_duty_WiFi = 0;
wifi_TX = 0;
state_wifi_tx = 0;
remain_wifi_tx = 0;
LED_WIFI_2 = 0; LED_WIFI_2 = 0;
break; break;
default:
LED_duty_WiFi = vreg_ctr[ VREG_C_LED_BRIGHT ];
LED_WIFI_2 = 1;
}
state_wifi_tx++;
if( state_wifi_tx == 32 ){
state_wifi_tx = 0;
remain_wifi_tx--;
}
return( 22 );
}else{
LED_duty_WiFi = vreg_ctr[ VREG_C_LED_BRIGHT ];
LED_WIFI_2 = 1;
return( 200 );
}
break;
case( WIFI_LED_PTN0 ): case ( WIFI_LED_ON ):
LED_WIFI_2 = 1;
switch( state_wifi_tx ){
case( 1 ):
case( 3 ):
case( 5 ):
LED_duty_WiFi = vreg_ctr[ VREG_C_LED_BRIGHT ];
break;
default: default:
LED_duty_WiFi = 0; LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
} wifi_TX = 0;
state_wifi_tx++; state_wifi_tx = 0;
if( state_wifi_tx == 16 ){
state_wifi_tx = 0;
}
return( 50 );
break;
case( WIFI_LED_PTN1 ):
LED_WIFI_2 = 1;
{
u8 dat;
if( remain_wifi_tx != 0 ){
LED_duty_WiFi = 0;
remain_wifi_tx = 0; remain_wifi_tx = 0;
return( MSG_SPD ); LED_WIFI_2 = 1;
}
dat = ( MSG_MAIL[ state_wifi_tx / 4 ] << (( state_wifi_tx % 4 ) *2 ) ) & 0xC0;
state_wifi_tx = ( dat == 0 )? 0: ( state_wifi_tx + 1 );
switch( dat ){
case( 0b00000000 ):
LED_duty_WiFi = 0;
remain_wifi_tx = 0;
return( MSG_SPD * 3 );
break; break;
case( 0b01000000 ): case ( WIFI_LED_TXAUTO ):
default: // 短いパルスを捕まえるために、割り込みフラグを見る
LED_duty_WiFi = 0; if( wifi_TX != 0 )
remain_wifi_tx = 1; {
return( MSG_SPD ); wifi_TX = 0;
remain_wifi_tx = 2;
}
// 送信パターン
if( remain_wifi_tx != 0 )
{ // TX active
switch ( state_wifi_tx )
{
case ( 1 ):
case ( 3 ):
case ( 5 ):
LED_duty_WiFi = 0;
LED_WIFI_2 = 0;
break;
default:
LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
LED_WIFI_2 = 1;
}
state_wifi_tx++;
if( state_wifi_tx == 32 )
{
state_wifi_tx = 0;
remain_wifi_tx--;
}
task_interval = 22;
return;
}
else
{
LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
LED_WIFI_2 = 1;
task_interval = 200;
return;
}
break; break;
case( 0b10000000 ): case ( WIFI_LED_PTN0 ):
LED_duty_WiFi = vreg_ctr[ VREG_C_LED_BRIGHT ]; LED_WIFI_2 = 1;
remain_wifi_tx = 1; switch ( state_wifi_tx )
return( MSG_SPD ); {
case ( 1 ):
case ( 3 ):
case ( 5 ):
LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
break;
default:
LED_duty_WiFi = 0;
}
state_wifi_tx++;
if( state_wifi_tx == 16 )
{
state_wifi_tx = 0;
}
task_interval = 50;
return;
break; break;
case( 0b11000000 ): case ( WIFI_LED_PTN1 ):
LED_duty_WiFi = vreg_ctr[ VREG_C_LED_BRIGHT ]; LED_WIFI_2 = 1;
remain_wifi_tx = 1; {
return( MSG_SPD * 3 ); u8 dat;
break;
} if( remain_wifi_tx != 0 )
{
LED_duty_WiFi = 0;
remain_wifi_tx = 0;
task_interval = MSG_SPD;
return;
}
dat = ( MSG_MAIL[state_wifi_tx / 4] << ( ( state_wifi_tx % 4 ) * 2 ) ) & 0xC0;
state_wifi_tx = ( dat == 0 ) ? 0 : ( state_wifi_tx + 1 );
switch ( dat )
{
case ( 0b00000000 ):
LED_duty_WiFi = 0;
remain_wifi_tx = 0;
task_interval = ( MSG_SPD * 3 );
break;
case ( 0b01000000 ):
default:
LED_duty_WiFi = 0;
remain_wifi_tx = 1;
task_interval = ( MSG_SPD );
break;
case ( 0b10000000 ):
LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
remain_wifi_tx = 1;
task_interval = ( MSG_SPD );
break;
case ( 0b11000000 ):
LED_duty_WiFi = vreg_ctr[VREG_C_LED_BRIGHT];
remain_wifi_tx = 1;
task_interval = ( MSG_SPD * 3 );
break;
}
return;
}
} }
}
} }
@ -418,8 +458,9 @@ task_interval tsk_led_wifi(){
 LED点滅のフラグ操作のみ  LED点滅のフラグ操作のみ
  tsk_led_wifi   tsk_led_wifi
======================================================== */ ======================================================== */
__interrupt void intp21_RFTx(){ __interrupt void intp21_RFTx( )
wifi_TX = 1; {
wifi_TX = 1;
} }
@ -427,59 +468,86 @@ __interrupt void intp21_RFTx(){
/* ======================================================== /* ========================================================
LED_Cam TO02 LED_Cam TO02
======================================================== */ ======================================================== */
task_interval tsk_led_cam(){ void tsk_led_cam( )
static u8 state_led_cam = 0; {
static u8 state_led_cam = 0;
static u8 task_interval;
static u8 reg_old;
switch( vreg_ctr[ VREG_C_LED_CAM ] ){ /*
case( CAM_LED_OFF ): if( reg_old != vreg_ctr[ VREG_C_LED_CAM ] ){
default: reg_old = vreg_ctr[ VREG_C_LED_CAM ];
LED_duty_CAM = 0; task_interval = 1;
state_led_cam = 0; }
break; */
case( CAM_LED_ON ): if( task_interval != 0 )
LED_duty_CAM = vreg_ctr[ VREG_C_LED_BRIGHT ]; {
state_led_cam = 0; task_interval -= 1;
break; return;
case( CAM_LED_BLINK ):
case( CAM_LED_BY_TWL ):
if( state_led_cam == 0 ){
LED_duty_CAM = vreg_ctr[ VREG_C_LED_BRIGHT ];
state_led_cam = 1;
}else{
LED_duty_CAM = 0;
state_led_cam = 0;
} }
break;
case( CAM_LED_ON_PLUSE ): switch ( vreg_ctr[VREG_C_LED_CAM] )
if( state_led_cam == 0 ){ {
LED_duty_CAM = vreg_ctr[ VREG_C_LED_BRIGHT ]; case ( CAM_LED_OFF ):
state_led_cam = 1; default:
}else{ LED_duty_CAM = 0;
vreg_ctr[ VREG_C_LED_CAM ] = CAM_LED_OFF; state_led_cam = 0;
return( 0 ); break;
case ( CAM_LED_ON ):
LED_duty_CAM = vreg_ctr[VREG_C_LED_BRIGHT];
state_led_cam = 0;
break;
case ( CAM_LED_BLINK ):
case ( CAM_LED_BY_TWL ):
if( state_led_cam == 0 )
{
LED_duty_CAM = vreg_ctr[VREG_C_LED_BRIGHT];
state_led_cam = 1;
}
else
{
LED_duty_CAM = 0;
state_led_cam = 0;
}
task_interval = 250;
break;
case ( CAM_LED_ON_PLUSE ):
if( state_led_cam == 0 )
{
LED_duty_CAM = vreg_ctr[VREG_C_LED_BRIGHT];
state_led_cam = 1;
task_interval = 250;
}
else
{
vreg_ctr[VREG_C_LED_CAM] = CAM_LED_OFF;
}
break;
case ( CAM_LED_OFF_PLUSE ):
if( state_led_cam == 0 )
{
LED_duty_CAM = 0;
state_led_cam = 1;
task_interval = 250;
}
else
{
vreg_ctr[VREG_C_LED_CAM] = CAM_LED_ON;
}
break;
} }
break; return;
case( CAM_LED_OFF_PLUSE ):
if( state_led_cam == 0 ){
LED_duty_CAM = 0;
state_led_cam = 1;
}else{
vreg_ctr[ VREG_C_LED_CAM ] = CAM_LED_ON;
return( 0 );
}
break;
}
return( 250 );
} }
// 捨て看板 // 捨て看板
/* ======================================================== /* ========================================================
// LED_Charge 5     →PM // LED_Charge 5     →PM
LED_TUNE 4 LED_TUNE 4
======================================================== */ ======================================================== */

View File

@ -17,7 +17,8 @@
#define LED_BRIGHT_MAX 0x00FF #define LED_BRIGHT_MAX 0x00FF
// ==================================== // ====================================
enum LED_ILUM_MODE{ enum LED_ILUM_MODE
{
LED_POW_ILM_AUTO = 0, LED_POW_ILM_AUTO = 0,
LED_POW_ILM_ON, LED_POW_ILM_ON,
LED_POW_ILM_HOTARU, LED_POW_ILM_HOTARU,
@ -28,8 +29,8 @@ enum LED_ILUM_MODE{
// ==================================== // ====================================
void LED_init(); void LED_init( );
void LED_stop(); void LED_stop( );

View File

@ -28,18 +28,18 @@
// ======================================================== // ========================================================
#if (FSL_DATA_BUFFER_SIZE>0) #if (FSL_DATA_BUFFER_SIZE>0)
fsl_u08 fsl_data_buffer[FSL_DATA_BUFFER_SIZE]; fsl_u08 fsl_data_buffer[FSL_DATA_BUFFER_SIZE];
#endif #endif
#ifdef FSL_INT_BACKUP #ifdef FSL_INT_BACKUP
static fsl_u08 fsl_MK0L_bak_u08; /* if (interrupt backup required) */ static fsl_u08 fsl_MK0L_bak_u08; /* if (interrupt backup required) */
static fsl_u08 fsl_MK0H_bak_u08; /* { */ static fsl_u08 fsl_MK0H_bak_u08; /* { */
static fsl_u08 fsl_MK1L_bak_u08; /* reserve space for backup information */ static fsl_u08 fsl_MK1L_bak_u08; /* reserve space for backup information */
static fsl_u08 fsl_MK1H_bak_u08; /* of interrupt mask flags */ static fsl_u08 fsl_MK1H_bak_u08; /* of interrupt mask flags */
static fsl_u08 fsl_MK2L_bak_u08; /* */ static fsl_u08 fsl_MK2L_bak_u08; /* */
static fsl_u08 fsl_MK2H_bak_u08; /* } */ static fsl_u08 fsl_MK2H_bak_u08; /* } */
#endif #endif
@ -52,68 +52,80 @@
// ======================================================== // ========================================================
void FSL_Open(void); void FSL_Open( void );
void FSL_Close(void); void FSL_Close( void );
void hdwinit(void); void hdwinit( void );
void power_save(); void power_save( );
static void hdwinit2(); static void hdwinit2( );
extern void main_loop(); extern void main_loop( );
extern void chk_bootCluster(); extern void chk_bootCluster( );
// ======================================================== // ========================================================
void main(){ void main( )
while(1){ {
while( 1 )
{
WDT_Restart(); WDT_Restart( );
if( RTCEN ){ if( RTCEN )
system_status.reboot = 1; {
}else{ system_status.reboot = 1;
u8 pwup_delay0 = 0; }
u8 pwup_delay1 = 0; else
{
u8 pwup_delay0 = 0;
u8 pwup_delay1 = 0;
do{ // 電池接続時、16ms待ってみる do
pwup_delay0 += 1; { // 電池接続時、16ms待ってみる(チャタリング対策)
do{ pwup_delay0 += 1;
pwup_delay1 += 1; do
}while( pwup_delay1 != 0 ); // コンパイラが不出来のため…。 {
}while( pwup_delay0 != 0 ); pwup_delay1 += 1;
}
while( pwup_delay1 != 0 ); // u16にするとコンパイラが怒るため…。
}
while( pwup_delay0 != 0 );
hdwinit2(); hdwinit2( ); // ?
} }
#if 1 #if 1
// ファームの整合性チェック // // ファームの整合性チェック //
{ {
u8 i; u8 i;
u8 comp = 0; u8 comp = 0;
// ローダーと本体は同じバージョンか? // ローダーと本体は同じバージョンか?
for( i = 0; i < sizeof( __TIME__ ); i++ ){ // sizeof( __TIME__ ) = 8 らし for( i = 0; i < sizeof( __TIME__ ); i++ )
comp += ( *(u8*)( MGC_HEAD + i ) == *(__far u8*)( MGC_LOAD + i ) )? 0: 1; { // sizeof( __TIME__ ) = 8 らし
} comp += ( *( u8 * ) ( MGC_HEAD + i ) == *( __far u8 * ) ( MGC_LOAD + i ) ) ? 0 : 1;
}
// 本体は壊れていないか? // 本体は壊れていないか?
comp += ( *(u8*)( MGC_HEAD ) == 0xFF ) ? 1: 0; comp += ( *( u8 * ) ( MGC_HEAD ) == 0xFF ) ? 1 : 0;
for( i = 0; i < sizeof( __TIME__ ); i++ ){ for( i = 0; i < sizeof( __TIME__ ); i++ )
comp += ( *(u8*)( MGC_HEAD + i ) == *(u8*)( MGC_FOOT + i ) )? 0: 1; {
} comp += ( *( u8 * ) ( MGC_HEAD + i ) == *( u8 * ) ( MGC_FOOT + i ) ) ? 0 : 1;
}
if( comp != 0 ){ if( comp != 0 )
// ファームリストアを試みる {
firm_restore(); // ファームリストアを試みる
// 帰ってこない。リセットをかける。 firm_restore( );
} // 帰ってこない。リセットをかける。
} }
}
#endif #endif
chk_bootCluster(); chk_bootCluster( );
// 通常運転 // 通常運転
main_loop(); main_loop( );
} }
} }
@ -121,8 +133,9 @@ void main(){
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
void power_save(){ void power_save( )
HALT(); {
HALT( );
} }
@ -130,10 +143,12 @@ void power_save(){
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
__interrupt void int_kr(){ __interrupt void int_kr( )
if( system_status.pwr_state == OFF ){ {
// 電源onのカウント。特にすることはない if( system_status.pwr_state == OFF )
} {
// 電源onのカウント。特にすることはない
}
} }
@ -141,194 +156,195 @@ __interrupt void int_kr(){
/* ======================================================== /* ========================================================
ext dc ext dc
======================================================== */ ======================================================== */
__interrupt void intp4(){ __interrupt void intp4( )
{
} }
/* ======================================================== /* ========================================================
shell close shell close
======================================================== */ ======================================================== */
__interrupt void intp5(){ __interrupt void intp5( )
{
} }
// ======================================================== // ========================================================
void hdwinit(void){ // スタートアップルーチンが勝手に呼びます void hdwinit( void )
DI(); /* マスタ割り込み禁止 */ { // スタートアップルーチンが勝手に呼びます
DI( ); /* マスタ割り込み禁止 */
CMC = 0b00010110; /* X1発振せず(入力ポート)、XT1使用、推奨の推奨で超低電力発振 */ CMC = 0b00010110; /* X1発振せず(入力ポート)、XT1使用、推奨の推奨で超低電力発振 */
CSC = 0b10000000; /* X1発振なし、XT1発振あり、高速内蔵発振動作 */ CSC = 0b10000000; /* X1発振なし、XT1発振あり、高速内蔵発振動作 */
// OSMC = 0x00; /* フラッシュ・メモリの高速動作用昇圧回路 */ // OSMC = 0x00; /* フラッシュ・メモリの高速動作用昇圧回路 */
CKC = 0b00001001; /* CPU/周辺クロック=fMAIN、fMAIN=fMX、fCLK=fMX */ CKC = 0b00001001; /* CPU/周辺クロック=fMAIN、fMAIN=fMX、fCLK=fMX */
/*--- 低電圧検出回路の設定 ---*/ /*--- 低電圧検出回路の設定 ---*/
/* リセット解除時のデフォルトは、オプション・バイトにて指定される */ /* リセット解除時のデフォルトは、オプション・バイトにて指定される */
LVIS = 0b00000000; /* VLVI = 4.22±0.1V */ LVIS = 0b00000000; /* VLVI = 4.22±0.1V */
LVIM = 0b00000000; /* LVI動作禁止 */ LVIM = 0b00000000; /* LVI動作禁止 */
/* 電源電圧(VDD)<検出電圧(VLVI)時に割込発生 */ /* 電源電圧(VDD)<検出電圧(VLVI)時に割込発生 */
/* 電源電圧(VDD)≧検出電圧<VLVI)、または動作禁止時に低電圧検出 */ /* 電源電圧(VDD)≧検出電圧<VLVI)、または動作禁止時に低電圧検出 */
} }
void hdwinit2(){ void hdwinit2( )
// ポート設定 {
P0 = 0b00000000; // ポート設定
P1 = 0b00000000; P0 = 0b00000000;
P2 = 0b00000000; P1 = 0b00000000;
P3 = 0b00000110; // 簡易I2Cは出力ラッチを1にする P2 = 0b00000000;
P4 = 0b00000000; P3 = 0b00000110; // 簡易I2Cは出力ラッチを1にする
P5 = 0b00000000; P4 = 0b00000000;
P6 = 0b00000000; P5 = 0b00000000;
P7 = 0b01000000; P6 = 0b00000000;
P12 = 0b00000000; P7 = 0b01000000;
P14 = 0b00000000; P12 = 0b00000000;
P14 = 0b00000000;
#ifdef _MCU_KE3_ #ifdef _MCU_KE3_
P8 = 0b00000000; P8 = 0b00000000;
#else #else
P20 = 0b00000000; P20 = 0b00000000;
#endif #endif
P15 = 0b00000000; P15 = 0b00000000;
// プルアップ // プルアップ
PU0 = 0b00000000; // バッテリ認証後にそれぞれセット PU0 = 0b00000000; // バッテリ認証後にそれぞれセット
PU1 = 0b00000000; PU1 = 0b00000000;
PU3 = 0b00000000; // 外部でプルアップしないと具合が悪い。CPUがプルアップする PU3 = 0b00000000; // 外部でプルアップしないと具合が悪い。CPUがプルアップする
PU4 = 0b00000000; // 外部でプルアップしてほしいtool0,1) PU4 = 0b00000000; // 外部でプルアップしてほしいtool0,1)
PU5 = 0b00000011; PU5 = 0b00000011;
PU7 = 0b00011001; PU7 = 0b00011001;
PU12 = 0b00000000; PU12 = 0b00000000;
PU14 = 0b00000000; PU14 = 0b00000000;
#ifndef _MCU_KE3_ #ifndef _MCU_KE3_
PU20 = 0b00000000; PU20 = 0b00000000;
#endif #endif
#ifdef _MCU_KE3_ #ifdef _MCU_KE3_
PM0 = 0b00000000; // 0で出力 PM0 = 0b00000000; // 0で出力
#else #else
PM0 = 0b00000001; // BSRマイコンでは、reset1は監視のみになる。 PM0 = 0b00000001; // BSRマイコンでは、reset1は監視のみになる。
#endif #endif
PM1 = 0b00000000; PM1 = 0b00000000;
PM2 = 0b11101001; PM2 = 0b11101001;
PM3 = 0b00000001; // P31,32は簡易I2C PM3 = 0b00000001; // P31,32は簡易I2C
#ifdef _PMIC_CTR_ #ifdef _PMIC_CTR_
PM4 = 0b00000111; PM4 = 0b00000111;
#else #else
PM4 = 0b00001011; PM4 = 0b00001011;
#endif #endif
PM5 = 0b00000011; PM5 = 0b00000011;
PM6 = 0b00000000; // I2CのラインがL出力になってしまうが、システムがOFFなのでかまわない PM6 = 0b00000000; // I2CのラインがL出力になってしまうが、システムがOFFなのでかまわない
PM7 = 0b00011111; PM7 = 0b00011111;
PM12 = 0b00011111; // 32kHzクロックのピン設定はどっちでもよい PM12 = 0b00011111; // 32kHzクロックのピン設定はどっちでもよい
PM14 = 0b00000001; // debugger[1] とりあえず出力 PM14 = 0b00000001; // debugger[1] とりあえず出力
PM15 = 0b00000111; PM15 = 0b00000111;
#ifdef _MCU_KE3_ #ifdef _MCU_KE3_
PM8 = 0b11111111; PM8 = 0b11111111;
#else #else
PM20 = 0b00111100; PM20 = 0b00111100;
#endif #endif
// ポート入力モード・レジスタ設定 // ポート入力モード・レジスタ設定
// [0:通常入力バッファ 1:TTL入力バッファ] // [0:通常入力バッファ 1:TTL入力バッファ]
PIM3 = 0b00000000; PIM3 = 0b00000000;
PIM7 = 0b00000000; PIM7 = 0b00000000;
// ポート出力モード・レジスタ設定 // ポート出力モード・レジスタ設定
// [0:通常出力モード 1:N-chオープン・ドレーン出力] // [0:通常出力モード 1:N-chオープン・ドレーン出力]
POM3 = 0b00000110; POM3 = 0b00000110;
POM7 = 0b00000000; POM7 = 0b00000000;
/*--- 割り込み設定 ---------*/ /*--- 割り込み設定 ---------*/
IF0 = 0x0000; /* 割り込み要求フラグクリア */ IF0 = 0x0000; /* 割り込み要求フラグクリア */
IF1 = 0x0000; IF1 = 0x0000;
#ifdef _MCU_BSR_ #ifdef _MCU_BSR_
IF2 = 0x0000; IF2 = 0x0000;
#else #else
IF2L = 0x00; IF2L = 0x00;
#endif #endif
MK0 = 0xFFFF; /* 割り込み禁止 */ MK0 = 0xFFFF; /* 割り込み禁止 */
MK1 = 0xFFFF; MK1 = 0xFFFF;
#ifdef _MCU_BSR_ #ifdef _MCU_BSR_
MK2 = 0xFFFF; MK2 = 0xFFFF;
#else #else
MK2L = 0xFF; MK2L = 0xFF;
#endif #endif
PR00L = 0b11111111; /* 割り込み優先順位、全て低位(LV3) */ PR00L = 0b11111111; /* 割り込み優先順位、全て低位(LV3) */
PR10L = 0b11111111; PR10L = 0b11111111;
PR00H = 0b11111111; PR00H = 0b11111111;
PR10H = 0b11111111; PR10H = 0b11111111;
PR01L = 0b11111111; PR01L = 0b11111111;
PR11L = 0b11111110; PR11L = 0b11111110;
PR01H = 0b11111111; PR01H = 0b11111111;
PR11H = 0b11111111; PR11H = 011111111;
PR02L = 0b11111111; PR02L = 0b11111111;
PR12L = 0b11111111; PR12L = 0b11111111;
/*--- 外部割込の有効エッジ設定 ---*/ /*--- 外部割込の有効エッジ設定 ---*/
#ifdef _MCU_BSR_ #ifdef _MCU_BSR_
EGP0 = 0b00110001; EGP0 = 0b00110001;
EGN0 = 0b01110001; EGN0 = 0b01110001;
EGP2 = 0b00000010; EGP2 = 0b00001010;
EGN2 = 0b00000000; EGN2 = 0b00000000;
// EGP2 = 0b00001010;
// EGN2 = 0b00000000;
#else #else
EGP0 = 0b10110001; EGP0 = 0b10110001;
EGN0 = 0b01110001; EGN0 = 0b01110001;
#endif #endif
/*--- キー割り込み設定 ---*/ /*--- キー割り込み設定 ---*/
KRM = 0b00000000; /* 全キー割り込み信号を検出しない */ KRM = 0b00000000; /* 全キー割り込み信号を検出しない */
/*--- タイマ・アレイ・ユニットの動作停止 ---*/ /*--- タイマ・アレイ・ユニットの動作停止 ---*/
TAU0EN = 0; /* タイマ・アレイ・ユニットへのクロック供給停止 */ TAU0EN = 0; /* タイマ・アレイ・ユニットへのクロック供給停止 */
TT0 = 0x00ff; /* 全タイマ・チャネルの動作停止 */ TT0 = 0x00ff; /* 全タイマ・チャネルの動作停止 */
/*--- RTCの動作停止 ---*/ /*--- RTCの動作停止 ---*/
// RTCEN = 0; /* RTCへのクロック供給停止 */ // RTCEN = 0; /* RTCへのクロック供給停止 */
// RTCC0 = 0b00000000; /* カウンタ動作停止 */ // RTCC0 = 0b00000000; /* カウンタ動作停止 */
// 別途初期化関数 // 別途初期化関数
#ifdef _MCU_KE3_ #ifdef _MCU_KE3_
/*--- コンパレータ/プログラマブル・ゲイン・アップの動作停止 ---*/ /*--- コンパレータ/プログラマブル・ゲイン・アップの動作停止 ---*/
OACMPEN = 0; /* クロック供給停止 */ OACMPEN = 0; /* クロック供給停止 */
OAM = 0x00; /* プログラマブル・ゲイン・アップの動作停止 */ OAM = 0x00; /* プログラマブル・ゲイン・アップの動作停止 */
C0CTL = 0x00; /* コンパレータ0動作停止 */ C0CTL = 0x00; /* コンパレータ0動作停止 */
C1CTL = 0x00; /* コンパレータ1動作停止 */ C1CTL = 0x00; /* コンパレータ1動作停止 */
#endif #endif
/*--- クロック出力/ブザー出力停止 ---*/ /*--- クロック出力/ブザー出力停止 ---*/
CKS0 = 0b0000000; CKS0 = 0b0000000;
CKS1 = 0b0000000; CKS1 = 0b0000000;
/*--- ADCの動作停止 ---*/ /*--- ADCの動作停止 ---*/
ADCEN = 0; /* ADCへのクロック供給停止 */ ADCEN = 0; /* ADCへのクロック供給停止 */
ADM = 0b00000000; /* 変換動作停止 */ ADM = 0b00000000; /* 変換動作停止 */
/*--- シリアル・アレイ・ユニットの動作停止 ---*/ /*--- シリアル・アレイ・ユニットの動作停止 ---*/
SAU0EN = 0; /* シリアル・アレイ・ユニット0へのクロック供給停止 */ SAU0EN = 0; /* シリアル・アレイ・ユニット0へのクロック供給停止 */
SCR00 = 0x0087; /* 各チャンネルの通信禁止 */ SCR00 = 0x0087; /* 各チャンネルの通信禁止 */
SCR01 = 0x0087; SCR01 = 0x0087;
SCR02 = 0x0087; SCR02 = 0x0087;
SCR03 = 0x0087; SCR03 = 0x0087;
#ifdef _MCU_KE3_ #ifdef _MCU_KE3_
/*--- IICAの動作停止 ---*/ /*--- IICAの動作停止 ---*/
IICAEN = 0; /* IICAへのクロック供給停止 */ IICAEN = 0; /* IICAへのクロック供給停止 */
IICCTL0 = 0x00; /* IICA動作停止 */ IICCTL0 = 0x00; /* IICA動作停止 */
#else #else
// IICの動作停止 // IICの動作停止
IICA0EN = 0; /* IICA0(CTR)へのクロック供給停止 */ IICA0EN = 0; /* IICA0(CTR)へのクロック供給停止 */
IICCTL00 = 0x00; /* IICA1動作停止 */ IICCTL00 = 0x00; /* IICA1動作停止 */
IICA1EN = 0; // IICA1(TWL)へのクロック供給停止 IICA1EN = 0; // IICA1(TWL)へのクロック供給停止
IICCTL01 = 0x00; // IICA1動作停止 IICCTL01 = 0x00; // IICA1動作停止
#endif #endif
/*--- DMAの動作停止 ---*/ /*--- DMAの動作停止 ---*/
DRC0 = 0b00000000; /* DMAチャネル0の動作禁止 */ DRC0 = 0b00000000; /* DMAチャネル0の動作禁止 */
DRC1 = 0b00000000; /* DMAチャネル1の動作禁止 */ DRC1 = 0b00000000; /* DMAチャネル1の動作禁止 */
} }

View File

@ -1,5 +1,4 @@
#include "jhl_defs.h" #include "jhl_defs.h"
err firm_update(); err firm_update( );

View File

@ -5,18 +5,19 @@
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
// V0.5 (ƒjƒZ0.1‰ü)
#pragma section @@CNSTL MGC_LOAD AT 0x0FF6 #pragma section @@CNSTL MGC_LOAD AT 0x0FF6
__far static const unsigned char MGC_LOAD[] = __TIME__; __far static const unsigned char MGC_LOAD[] =
{ 0x30, 0x38, 0x3A, 0x34, 0x35, 0x3A, 0x33, 0x39, 0x00, 0x00 };
#pragma section @@CNST MGC_MIMI AT 0x2100 #pragma section @@CNST MGC_MIMI AT 0x2100
static const unsigned char MGC_HEAD[] = __TIME__; static const unsigned char MGC_HEAD[] =
{ 0x30, 0x38, 0x3A, 0x34, 0x35, 0x3A, 0x33, 0x39, 0x00, 0x00 };
#pragma section @@CNST MGC_TAIL AT 0x47F6 #pragma section @@CNST MGC_TAIL AT 0x47F6
static const unsigned char MGC_TAIL[] = __TIME__; static const unsigned char MGC_TAIL[] =
{ 0x30, 0x38, 0x3A, 0x34, 0x35, 0x3A, 0x33, 0x39, 0x00, 0x00 };
/* /*
@ -39,7 +40,6 @@ bsr_V0.2_090828_WM2
*/ */
/* /*
// V0.1の署名(日付) 30 38 3A 34 35 3A 33 39 00 00 // V0.1の署名(日付) 30 38 3A 34 35 3A 33 39 00 00
#pragma section @@CNSTL MGC_LOAD AT 0x0FF6 #pragma section @@CNSTL MGC_LOAD AT 0x0FF6
@ -67,4 +67,3 @@ static const unsigned char MGC_TAIL[] = __TIME__;
*/ */

View File

@ -23,40 +23,42 @@
// ======================================================== // ========================================================
err to_sleep(); err to_sleep( );
static void read_dipsw(); static void read_dipsw( );
unsigned char temp_teg; unsigned char temp_teg;
extern void power_save(); extern void power_save( );
// ======================================================== // ========================================================
bit active; bit active;
bit sleep; bit sleep;
bit rsv_to_sleep; bit rsv_to_sleep;
bit rsv_LCD_on; bit rsv_LCD_on;
bit rsv_BL_on; bit rsv_BL_on;
system_status_ system_status; system_status_ system_status;
u8 off_delay; // 電源 OFF から PWSW 等で電源オンする際、押してる時間をカウントするのに使う u8 off_delay; // 電源 OFF から PWSW 等で電源オンする際、押してる時間をカウントするのに使う
extern u8 boot_ura; extern u8 boot_ura;
/* ======================================================== /* ========================================================
loader.c loader.c
======================================================== */ ======================================================== */
void main_loop( void ){ void main_loop( void )
{
// 電池投入時の1回のみ // 電池投入時の1回のみ
iic_mcu_stop(); RTC_init( ); // 内部でリブートか判定しています
RTCEN = 0;
RTC_init(); // 電池初投入ビットも立てます iic_mcu_stop( );
if( system_status.reboot == 0 ){ if( system_status.reboot == 0 )
{
/* /*
@ -74,62 +76,46 @@ void main_loop( void ){
} }
*/ */
system_status.pwr_state = OFF_TRIG; system_status.pwr_state = OFF_TRIG;
}else{
system_status.pwr_state = ON;
}
vreg_ctr_init();
vreg_twl_init();
iic_mcu_start();
read_dipsw();
// 特定スイッチで何かするか?
renge_init();
/*
if(( vreg_ctr[ VREG_C_IRQ1 ] & REG_BIT_WDT_DET ) != 0 ){
system_status.pwr_state = OFF;
}else{
system_status.pwr_state = OFF_TRIG;
}
*/
renge_task_interval_run_force = 1;
EI();
// メインループ //
while(1){ // システムtick、または割り込みで廻ります。
WDT_Restart();
renge_task_interval_run(); // 内部で、システムtickまたは強制起動します
renge_task_immed_run(); // ここのループが廻る度に実行されます
power_save();
/*
{
u8 str[4];
if(( system_status.pwr_state != OFF )){
str[3] = system_status.pwr_state;
str[2] = MK1H;
str[1] = vreg_ctr[ VREG_C_STATUS ];
str[0] = SEC;
iic_mcu_write( 0x44, 0, 4, &str[0] );
}
} }
*/ else
{
system_status.pwr_state = ON;
}
vreg_ctr_init( );
vreg_twl_init( );
iic_mcu_start( );
} read_dipsw( );
// 特定スイッチで何かするか?
renge_init( );
renge_task_interval_run_force = 1;
EI( );
// メインループ //
while( 1 )
{ // システムtick、または割り込みで廻ります。
WDT_Restart( );
renge_task_interval_run( ); // 内部で、システムtickまたは強制起動します
while( renge_task_interval_run_force != 0 )
{
renge_task_interval_run_force = 0;
renge_task_interval_run( );
}
renge_task_immed_run( ); // ここのループが廻る度に実行されます
power_save( );
}
} }
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
static void read_dipsw(){ static void read_dipsw( )
// ソフトディップスイッチ読み込み {
// ソフトディップスイッチ読み込み
// PU4 |= 0x03; // dip sw 0,1 // PU4 |= 0x03; // dip sw 0,1
system_status.dipsw0 = ( DIPSW_0 == 0 )? 0: 1; system_status.dipsw0 = ( DIPSW_0 == 0 ) ? 0 : 1;
system_status.dipsw1 = ( DIPSW_1 == 0 )? 0: 1; system_status.dipsw1 = ( DIPSW_1 == 0 ) ? 0 : 1;
// PU4 &= ~0x03; // PU4 &= ~0x03;
} }

File diff suppressed because it is too large Load Diff

View File

@ -7,18 +7,21 @@
//========================================================= //=========================================================
enum BT_GAUGE_REG_ADRS{ enum BT_GAUGE_REG_ADRS
BT_GAUGE_REG_VCELL = 0x02, // それぞれ16ビットのため {
BT_GAUGE_REG_VCELL = 0x02, // »ê¼ê16ƒrƒbƒg̽ß
BT_GAUGE_REG_SOC = 0x04, BT_GAUGE_REG_SOC = 0x04,
BT_GAUGE_REG_MODE = 0x06, BT_GAUGE_REG_MODE = 0x06,
BT_GAUGE_REG_VERSION = 0x08, BT_GAUGE_REG_VERSION = 0x08,
BT_GAUGE_REG_OCV = 0x0E, BT_GAUGE_REG_OCV = 0x0E,
BT_GAUGE_REG_RCOMP = 0xC0, BT_GAUGE_REG_RCOMP = 0x0C,
BT_GAUGE_REG_LOCK = 0x3E, BT_GAUGE_REG_LOCK = 0x3E,
BT_GAUGE_REG_BT_PARAM = 0x40,
BT_GAUGE_REG_COMMAND = 0xFE BT_GAUGE_REG_COMMAND = 0xFE
}; };
enum PMIC_REG_ADRS{ enum PMIC_REG_ADRS
{
PM_REG_ADRS_VER = 0x00, // verinfo など PM_REG_ADRS_VER = 0x00, // verinfo など
PM_REG_ADRS_VDD_SYS, // システムが使用する電源 PM_REG_ADRS_VDD_SYS, // システムが使用する電源
PM_REG_ADRS_VDD_LCD, // 液晶電源 PM_REG_ADRS_VDD_LCD, // 液晶電源
@ -46,6 +49,7 @@ enum PMIC_REG_ADRS{
#define DELAY_PM_TW_PWUP 16 #define DELAY_PM_TW_PWUP 16
#define DELAY_PM_TSS_50B 5 #define DELAY_PM_TSS_50B 5
#define DELAY_PM_5V_TO_VCOM 17
@ -55,22 +59,22 @@ extern u8 raw_adc_temperature;
//========================================================= //=========================================================
err PM_sys_pow_on(); err PM_sys_pow_on( );
err PM_sys_pow_off(); err PM_sys_pow_off( );
err PM_LCD_on(); err PM_LCD_on( );
err PM_bt_auth(); err PM_bt_auth( );
task_status_immed PM_bt_temp_update(); task_status_immed PM_bt_temp_update( );
void PM_init(); void PM_init( );
err PM_LCD_vcom_set(); err PM_LCD_vcom_set( );
task_status_immed tski_vcom_set(); task_status_immed tski_vcom_set( );
err PM_BL_on(); err PM_BL_on( );
err PM_BL_off(); err PM_BL_off( );
task_status_immed tski_PM_BL_on(); task_status_immed tski_PM_BL_on( );
task_status_immed tski_PM_BL_off(); task_status_immed tski_PM_BL_off( );
task_status_immed tski_PM_LCD_on(); task_status_immed tski_PM_LCD_on( );
task_status_immed tski_PM_LCD_off(); task_status_immed tski_PM_LCD_off( );

View File

@ -22,7 +22,7 @@
bit renge_flg_interval; bit renge_flg_interval;
bit renge_task_interval_run_force; bit renge_task_interval_run_force;
extern task_info tasks[]; extern const task_info tasks[];
#include "..\bsr_system.h" #include "..\bsr_system.h"
extern system_status_ system_status; extern system_status_ system_status;
@ -74,29 +74,10 @@ err renge_task_interval_run(){
for( current_task = &tasks[0]; for( current_task = &tasks[0];
current_task != &tasks[TSK_LAST]; current_task != &tasks[TSK_LAST];
current_task += 1 ) current_task += 1 )
{ {
current_task -> task();
// if( current_task -> dispatch_type == INTERVAL ){ }
if( current_task -> interval == 0 ){
current_task -> interval = current_task -> task();
}else{
current_task -> interval -= 1;
}
// }
}
} }
// ***_TRIG等で強制起動
while( renge_task_interval_run_force ){
renge_task_interval_run_force = 0; // とりあえず、何が何でもフラグ消しちゃうけど...
for( current_task = &tasks[0];
current_task != &tasks[TSK_LAST];
current_task += 1 )
{
current_task -> interval = current_task -> task();
}
}
return( ERR_SUCCESS ); return( ERR_SUCCESS );
} }

View File

@ -25,6 +25,12 @@ typedef short s16;
typedef unsigned char err; typedef unsigned char err;
//*/ //*/
// *****************************************************************************
#define SYS_INTERVAL_TICK 1.953
//****************************************************************************** //******************************************************************************
@ -42,8 +48,6 @@ typedef task_interval ( *p_task )(); // p_task
typedef struct{ typedef struct{
p_task task; p_task task;
// dispatch_type dispatch_type;
task_interval interval;
}task_info; }task_info;
/************************************** /**************************************

View File

@ -13,7 +13,6 @@
extern task_status_immed ntr_pmic_comm(); extern task_status_immed ntr_pmic_comm();
extern task_status_immed tsk_cbk_accero(); extern task_status_immed tsk_cbk_accero();
extern task_status_immed do_command0(); extern task_status_immed do_command0();
extern task_status_immed do_command1();
extern task_status_immed acc_read(); extern task_status_immed acc_read();
extern task_status_immed acc_write(); extern task_status_immed acc_write();

View File

@ -6,35 +6,31 @@
#include "renge_defs.h" #include "renge_defs.h"
enum { enum {
TSK_SW, TSK_WIFI, TSK_ADC, TSK_BATT, TSK_LED_POW, TSK_LED_WIFI, TSK_LED_CAM, TSK_MISC_STAT, TSK_DEBUG, TSK_DEBUG2, TSK_SOFT_INT, TSK_SYS, TSK_LAST TSK_SW, TSK_ADC, TSK_BATT, TSK_LED_POW, TSK_LED_WIFI, TSK_LED_CAM, TSK_MISC_STAT, TSK_DEBUG, TSK_DEBUG2, TSK_SYS, TSK_LAST
}; };
extern task_interval tsk_sw(); extern void tsk_sw();
extern task_interval tsk_wifi(); extern void tsk_adc();
extern task_interval tsk_adc(); extern void tsk_batt();
extern task_interval tsk_batt(); extern void tsk_led_pow();
extern task_interval tsk_led_pow(); extern void tsk_led_wifi();
extern task_interval tsk_led_wifi(); extern void tsk_led_cam();
extern task_interval tsk_led_cam(); extern void tsk_misc_stat();
extern task_interval tsk_misc_stat(); extern void tsk_debug();
extern task_interval tsk_debug(); extern void tsk_debug2();
extern task_interval tsk_debug2(); extern void tsk_sys();
extern task_interval tsk_soft_int();
extern task_interval tsk_sys();
task_info tasks[ TSK_LAST ] = { static const task_info tasks[ TSK_LAST ] = {
{ tsk_sw, 0 }, tsk_sw,
{ tsk_wifi, 0 }, tsk_adc,
{ tsk_adc, 0 }, tsk_batt,
{ tsk_batt, 0 }, tsk_led_pow,
{ tsk_led_pow, 0 }, tsk_led_wifi,
{ tsk_led_wifi, 0 }, tsk_led_cam,
{ tsk_led_cam, 0 }, tsk_misc_stat,
{ tsk_misc_stat, 0 }, tsk_debug,
{ tsk_debug, 0 }, tsk_debug2,
{ tsk_debug2, 0 }, tsk_sys,
{ tsk_soft_int, 0 },
{ tsk_sys, 0 },
}; };

View File

@ -1,5 +1,4 @@
sw sw
wifi
adc adc
batt batt
led_pow led_pow
@ -8,5 +7,4 @@ led_cam
misc_stat misc_stat
debug debug
debug2 debug2
soft_int
sys sys

View File

@ -10,24 +10,26 @@
// ======================================================== // ========================================================
u8 rtc_work[7]; u8 rtc_work[7];
bit rtc_lock; bit rtc_lock;
bit rtc_dirty; bit rtc_dirty;
bit rtc_alarm_dirty; bit rtc_alarm_dirty;
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
void RTC_init(void){ void RTC_init( void )
{
// if( !RTCEN ){ if( !RTCEN )
RTCEN = 1; // モジュールON {
RTCEN = 1; // モジュールON
// RTC設定 // RTC設定
RTCC0 = 0b00001000; /* 動作停止、24時間制、32k出力「まだなし」、定周期割り込みなし */ RTCC0 = 0b00001000; /* 動作停止、24時間制、32k出力「まだなし」、定周期割り込みなし */
RTCC1 = 0b11000000; /* アラーム割り込み有効&動作開始 */ RTCC1 = 0b11000000; /* アラーム割り込み有効&動作開始 */
RTCC2 = 0b10000000; /* インターバル:32k/2^6=2ms、RTCDIV出力なし */ RTCC2 = 0b10000000; /* インターバル:32k/2^6=2ms、RTCDIV出力なし */
/* /*
SEC = 0; SEC = 0;
MIN = 0; MIN = 0;
@ -37,26 +39,28 @@ SEC = 0;
MONTH = 9; MONTH = 9;
YEAR = 9; YEAR = 9;
*/ */
ALARMWW = 0x7F; ALARMWW = 0x7F;
vreg_ctr[ VREG_C_MCU_STATUS ] = REG_BIT_RTC_BLACKOUT; vreg_ctr[VREG_C_MCU_STATUS] = REG_BIT_RTC_BLACKOUT;
// } }
// 割り込み設定 // 割り込み設定
RTCIF = 0; RTCIF = 0;
RTCIIF = 0; RTCIIF = 0;
RTCMK = 1; /* 割り込み(定周期)禁止 */ RTCMK = 1; /* 割り込み(定周期)禁止 */
RTCIMK = 0; /* 割り込み(アラーム&インターバル)許可 */ RTCIMK = 0; /* 割り込み(アラーム&インターバル)許可 */
RTCE = 1; /* 動作開始 */ RTCE = 1; /* 動作開始 */
RWAIT = 1; RWAIT = 1;
while( !RWST ){;} while( !RWST )
RWAIT = 0; {;
}
RWAIT = 0;
rtc_lock = 0; rtc_lock = 0;
rtc_dirty = 0; rtc_dirty = 0;
rtc_alarm_dirty = 0; rtc_alarm_dirty = 0;
} }
@ -65,10 +69,9 @@ SEC = 0;
RTC RTC
2^6/fXT1.953125 ms 2^6/fXT1.953125 ms
======================================================== */ ======================================================== */
__interrupt void int_rtc_int(){ __interrupt void int_rtc_int( )
DBG_LED_WIFI_2_on; {
renge_flg_interval = 1; renge_flg_interval = 1;
DBG_LED_WIFI_2_off;
} }
@ -76,19 +79,22 @@ __interrupt void int_rtc_int(){
RTC RTC
2^6/fXT1.953125 ms 2^6/fXT1.953125 ms
======================================================== */ ======================================================== */
__interrupt void int_rtc(){ __interrupt void int_rtc( )
if(( vreg_ctr[ VREG_C_RTC_ALARM_DAY ] == DAY ) {
&& ( vreg_ctr[ VREG_C_RTC_ALARM_MONTH ] == MONTH ) if( ( vreg_ctr[VREG_C_RTC_ALARM_DAY] == DAY )
&& ( vreg_ctr[ VREG_C_RTC_ALARM_YEAR ] == YEAR )) && ( vreg_ctr[VREG_C_RTC_ALARM_MONTH] == MONTH )
&& ( vreg_ctr[VREG_C_RTC_ALARM_YEAR] == YEAR ) )
{ {
if( ( vreg_ctr[ VREG_C_IRQ_MASK1 ] & REG_BIT_RTC_ALARM ) == 0 ){ if( ( vreg_ctr[VREG_C_IRQ_MASK1] & REG_BIT_RTC_ALARM ) == 0 )
vreg_ctr[ VREG_C_IRQ1 ] |= REG_BIT_RTC_ALARM; {
IRQ0_ast; vreg_ctr[VREG_C_IRQ1] |= REG_BIT_RTC_ALARM;
// マスクをしてあったら、電源を入れません IRQ0_ast;
if( system_status.pwr_state == OFF ){ // マスクをしてあったら、電源を入れません
system_status.poweron_reason = RTC_ALARM; if( system_status.pwr_state == OFF )
{
system_status.poweron_reason = RTC_ALARM;
}
} }
}
} }
} }
@ -98,16 +104,20 @@ __interrupt void int_rtc(){
RTC RTC
sec,min,hour,week,day,month,year sec,min,hour,week,day,month,year
======================================================== */ ======================================================== */
void get_rtc(){ void get_rtc( )
if( rtc_lock == 0 ){ {
rtc_lock = 1; if( rtc_lock == 0 )
RWAIT = 1; {
while( !RWST ){;} rtc_lock = 1;
RWAIT = 1;
while( !RWST )
{;
}
memcpy( &vreg_ctr[ VREG_C_RTC_SEC ], &SEC, 7 ); memcpy( &vreg_ctr[VREG_C_RTC_SEC], &SEC, 7 );
RWAIT = 0; RWAIT = 0;
// renge_task_immed_add( tski_rtc_close ); // renge_task_immed_add( tski_rtc_close );
} }
} }
@ -118,13 +128,15 @@ void get_rtc(){
RTCにセットするのはset_rtc_close() RTCにセットするのはset_rtc_close()
======================================================== */ ======================================================== */
void set_rtc( u8 adrs, u8 data ){ void set_rtc( u8 adrs, u8 data )
if( rtc_dirty == 0 ){ {
rtc_dirty = 1; if( rtc_dirty == 0 )
memcpy( rtc_work, &SEC, 7 ); {
rtc_dirty = 1;
memcpy( rtc_work, &SEC, 7 );
// renge_task_immed_add( tski_rtc_close ); // renge_task_immed_add( tski_rtc_close );
} }
rtc_work[ adrs ] = data; rtc_work[adrs] = data;
} }
@ -133,29 +145,32 @@ void set_rtc( u8 adrs, u8 data ){
RTCレジスタの更新 RTCレジスタの更新
======================================================== */ ======================================================== */
// task_status_immed tski_rtc_close(){ // task_status_immed tski_rtc_close(){
void rtc_unlock(){ void rtc_unlock( )
// リードロック {
// リードロック
// if( rtc_lock != 0 ){ // if( rtc_lock != 0 ){
rtc_lock = 0; rtc_lock = 0;
// } // }
// ライトロック // ライトロック
if( rtc_dirty != 0 ){ if( rtc_dirty != 0 )
rtc_dirty = 0; {
RWAIT = 1; rtc_dirty = 0;
while( !RWST ){;} RWAIT = 1;
memcpy( &SEC, rtc_work, 7 ); while( !RWST )
RWAIT = 0; {;
} }
memcpy( &SEC, rtc_work, 7 );
RWAIT = 0;
}
// アラームセット // アラームセット
if( rtc_alarm_dirty ){ if( rtc_alarm_dirty )
WALE = 0; {
ALARMWM = vreg_ctr[ VREG_C_RTC_ALARM_MIN ]; WALE = 0;
ALARMWH = vreg_ctr[ VREG_C_RTC_ALARM_HOUR ]; ALARMWM = vreg_ctr[VREG_C_RTC_ALARM_MIN];
rtc_dirty = 0; ALARMWH = vreg_ctr[VREG_C_RTC_ALARM_HOUR];
WALE = 1; rtc_dirty = 0;
} WALE = 1;
}
} }

View File

@ -2,13 +2,13 @@
#define __rtc_h__ #define __rtc_h__
void RTC_init(void); void RTC_init( void );
__interrupt void int_rtc_int(); __interrupt void int_rtc_int( );
void get_rtc(); void get_rtc( );
void set_rtc(); void set_rtc( );
//task_status_immed tski_rtc_close(); //task_status_immed tski_rtc_close();
void rtc_unlock(); void rtc_unlock( );
// ------------------------------------ // ------------------------------------
#define RTC_32k_on() { RCLOE0 = 1; } #define RTC_32k_on() { RCLOE0 = 1; }

View File

@ -66,9 +66,9 @@ const u8 fsl_low_voltage_u08 = 1;
// ======================================================== // ========================================================
static void FSL_Open(void); static void FSL_Open( void );
static void FSL_Close(void); static void FSL_Close( void );
err firm_restore(); err firm_restore( );
extern void self_update_reboot( u8 flag ); extern void self_update_reboot( u8 flag );
@ -79,156 +79,181 @@ extern void self_update_reboot( u8 flag );
// ======================================================== // ========================================================
u8 boot_ura; // ブートクラスタ 0/1 u8 boot_ura; // ブートクラスタ 0/1
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
err firm_update(){ err firm_update( )
u8 buffer_fill; {
u8 target_block; u8 buffer_fill;
u8 data_buffer[ SELF_UPDATE_BUFF_SIZE ]; u8 target_block;
u8 split_write_count; // ブロックへちまちま書き込むカウンタ u8 data_buffer[SELF_UPDATE_BUFF_SIZE];
fsl_u08 err; u8 split_write_count; // ブロックへちまちま書き込むカウンタ
__far u8* p_rom; fsl_u08 err;
__far u8 *p_rom;
TOE0 = 0x0000; TOE0 = 0x0000;
TOE0 = 0x0020; TOE0 = 0x0020;
// 書き替え前準備 // // 書き替え前準備 //
FSL_Open(); // 割り込み禁止など FSL_Open( ); // 割り込み禁止など
DI(); DI( );
err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず
err += FSL_ModeCheck(); // ライトプロテクトチェック。失敗することを考慮せず err += FSL_ModeCheck( ); // ライトプロテクトチェック。失敗することを考慮せず
// ファームのバックアップ // // ファームのバックアップ //
/* /*
0x2000 - 0x47FF ( 8 - 17) 0x2000 - 0x47FF ( 8 - 17)
0x4800 - 0x7FFF ( 18 - 27) 0x4800 - 0x7FFF ( 18 - 27)
*/ */
p_rom = (__far u8*)0x2000; p_rom = ( __far u8 * ) 0x2000;
// 書き込み先ブロックの数だけ繰り返す // 書き込み先ブロックの数だけ繰り返す
for( target_block = ( FIRM_TOP + FIRM_SIZE ); for( target_block = ( FIRM_TOP + FIRM_SIZE );
target_block < ( FIRM_TOP + FIRM_SIZE + FIRM_SIZE ); target_block < ( FIRM_TOP + FIRM_SIZE + FIRM_SIZE ); target_block += 1 )
target_block += 1 ){ {
WDT_Restart(); WDT_Restart( );
// ブロック消去 // ブロック消去
while( FSL_BlankCheck( target_block ) != FSL_OK ){ while( FSL_BlankCheck( target_block ) != FSL_OK )
err = FSL_Erase( target_block ); {
err = FSL_Erase( target_block );
}
// 分割書き込み分繰り返す
for( split_write_count = 0;
split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM; split_write_count += 1 )
{
// 書き込みデータをバッファにためる
buffer_fill = 0;
do
{
data_buffer[buffer_fill] = *p_rom;
p_rom += 1;
buffer_fill++;
}
while( buffer_fill != ( u8 ) SELF_UPDATE_BUFF_SIZE );
// 書き込み
err = FSL_Write( ( fsl_u32 ) ( target_block * SAM_BLOCK_SIZE
+
split_write_count *
SELF_UPDATE_BUFF_SIZE ),
( fsl_u08 ) ( SELF_UPDATE_BUFF_SIZE / SAM_WORD_SIZE ) );
if( err != FSL_OK )
{
FSL_Close( );
NOP( );
return ( ERR_ERR );
}
}
// 1ブロック書き込み完了。内部電圧チェックを行う
while( FSL_IVerify( target_block ) != FSL_OK )
{;
}
} }
// 分割書き込み分繰り返す // 書き替え //
for( split_write_count = 0; /*
split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM;
split_write_count += 1 ){ 0x1000 - 0x47FF
WDTリセットなので自分でわかる
*/
// 書き込みデータをバッファにためる // 全ブロック消去
buffer_fill = 0; for( target_block = INACTIVE_BOOTSECT_TOP;
do{ target_block <= UPDATE_BLOCK_LAST; target_block += 1 )
data_buffer[ buffer_fill ] = *p_rom; {
p_rom += 1; err = FSL_Erase( target_block );
buffer_fill++;
}while( buffer_fill != (u8)SELF_UPDATE_BUFF_SIZE );
// 書き込み
err = FSL_Write( (fsl_u32)( target_block * SAM_BLOCK_SIZE
+ split_write_count * SELF_UPDATE_BUFF_SIZE ),
(fsl_u08)( SELF_UPDATE_BUFF_SIZE / SAM_WORD_SIZE ) );
if( err != FSL_OK ){
FSL_Close();
NOP();
return( ERR_ERR );
}
} }
// 1ブロック書き込み完了。内部電圧チェックを行う WREL = 1;
while( FSL_IVerify( target_block ) != FSL_OK ){ ; }
}
// 書き替え // // ブロックの数だけ繰り返し
/* for( target_block = INACTIVE_BOOTSECT_TOP;
target_block <= UPDATE_BLOCK_LAST; target_block += 1 )
0x1000 - 0x47FF {
WDTリセットなので自分でわかる // 分割書き込み
*/ for( split_write_count = 0;
( ( split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM )
&& ( !SPD ) ); split_write_count += 1 )
{
// 全ブロック消去 WDT_Restart( );
for( target_block = INACTIVE_BOOTSECT_TOP; // I2Cから書き込みデータをバッファにためる
target_block <= UPDATE_BLOCK_LAST ; do
target_block += 1 ){ {
err = FSL_Erase( target_block ); while( !IICAIF && !SPD )
} {;
}
IICAIF = 0;
data_buffer[buffer_fill] = IICA;
WREL = 1;
buffer_fill += 1;
}
while( ( buffer_fill != ( u8 ) SELF_UPDATE_BUFF_SIZE ) && !SPD );
WREL = 1; // 書き込み
// 最後だと、ゴミをパディングするが別にかまわない
err = FSL_Write( ( fsl_u32 ) ( target_block * SAM_BLOCK_SIZE
+
split_write_count *
SELF_UPDATE_BUFF_SIZE ),
( fsl_u08 ) ( SELF_UPDATE_BUFF_SIZE / SAM_WORD_SIZE ) );
// ブロックの数だけ繰り返し if( err != FSL_OK )
for( target_block = INACTIVE_BOOTSECT_TOP; {
target_block <= UPDATE_BLOCK_LAST; FSL_Close( );
target_block += 1 ){ return ( ERR_ERR );
// 分割書き込み }
for( split_write_count = 0;
(( split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM ) && ( !SPD ));
split_write_count += 1 ){
WDT_Restart(); }
// I2Cから書き込みデータをバッファにためる // 1ブロック書き込み完了。内部ベリファイを行う
do{ while( FSL_IVerify( target_block ) != FSL_OK )
while( !IICAIF && !SPD ){;} {;
IICAIF = 0; }
data_buffer[ buffer_fill ] = IICA;
WREL = 1;
buffer_fill += 1;
}while(( buffer_fill != (u8)SELF_UPDATE_BUFF_SIZE ) && !SPD );
// 書き込み
// 最後だと、ゴミをパディングするが別にかまわない
err = FSL_Write( (fsl_u32)( target_block * SAM_BLOCK_SIZE
+ split_write_count * SELF_UPDATE_BUFF_SIZE ),
(fsl_u08)( SELF_UPDATE_BUFF_SIZE / SAM_WORD_SIZE ) );
if( err != FSL_OK ){
FSL_Close();
return( ERR_ERR );
}
if( SPD )
{
goto firm_update_end;
}
} }
// 1ブロック書き込み完了。内部ベリファイを行う
while( FSL_IVerify( target_block ) != FSL_OK ){;}
if( SPD ){ firm_update_end:
goto firm_update_end; LREL = 1;
// 書き込んだファームのチェック //
{
u8 i;
u8 comp = 0;
// 少なくとも、ローダーのマジックと、本文の末尾のマジックは同じか確認
for( i = 0; i < sizeof( __TIME__ ); i++ )
{
comp += ( *( u8 * ) ( N_MGC_L + i ) == *( u8 * ) ( N_MGC_T + i ) ) ? 0 : 1;
}
if( comp == 0 )
{
FSL_InvertBootFlag( );
// FSL_ForceReset();
FSL_SwapBootCluster( );
// 戻ってこない //
}
else
{
FSL_Close( );
firm_restore( );
// 戻ってこない //
}
} }
}
firm_update_end:
LREL = 1;
// 書き込んだファームのチェック //
{
u8 i;
u8 comp = 0;
// 少なくとも、ローダーのマジックと、本文の末尾のマジックは同じか確認
for( i = 0; i < sizeof( __TIME__ ); i++ ){
comp += ( *(u8*)( N_MGC_L + i ) == *(u8*)( N_MGC_T + i ) )? 0: 1;
}
if( comp == 0 ){
FSL_InvertBootFlag();
FSL_SwapBootCluster();
// 戻ってこない //
}else{
FSL_Close();
firm_restore();
// 戻ってこない //
}
}
} }
@ -240,118 +265,130 @@ firm_update_end:
======================================================== */ ======================================================== */
err firm_restore(){ err firm_restore( )
u8 buffer_fill; {
u8 target_block; u8 buffer_fill;
u8 data_buffer[ SELF_UPDATE_BUFF_SIZE ]; u8 target_block;
u8 split_write_count; // ブロックへちまちま書き込むカウンタ u8 data_buffer[SELF_UPDATE_BUFF_SIZE];
fsl_u08 err; u8 split_write_count; // ブロックへちまちま書き込むカウンタ
__far u8* p_rom; fsl_u08 err;
__far u8 *p_rom;
RTCE = 0; RTCE = 0;
TOE0 = 0x0000; TOE0 = 0x0000;
TOE0 = 0x0080; TOE0 = 0x0080;
// 書き替え前準備 // // 書き替え前準備 //
DI(); DI( );
FSL_Open(); // 割り込み禁止など FSL_Open( ); // 割り込み禁止など
err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず
err += FSL_ModeCheck(); // ライトプロテクトチェック。失敗することを考慮せず err += FSL_ModeCheck( ); // ライトプロテクトチェック。失敗することを考慮せず
// ファームのリストア // ファームのリストア
/* /*
0x4800 - 0x7FFF ( 18 - 27) 0x4800 - 0x7FFF ( 18 - 27)
0x2000 - 0x47FF ( 8 - 17) 0x2000 - 0x47FF ( 8 - 17)
*/ */
p_rom = (__far u8*)0x4800; p_rom = ( __far u8 * ) 0x4800;
// 転送先ブロックの数だけ繰り返す // 転送先ブロックの数だけ繰り返す
for( target_block = FIRM_TOP; for( target_block = FIRM_TOP; target_block <= UPDATE_BLOCK_LAST; target_block += 1 )
target_block <= UPDATE_BLOCK_LAST; {
target_block += 1 ){
WDT_Restart(); WDT_Restart( );
// 壊れたファームを消し // 壊れたファームを消し
err = FSL_Erase( target_block ); err = FSL_Erase( target_block );
// 分割書き込み分繰り返す // 分割書き込み分繰り返す
for( split_write_count = 0; for( split_write_count = 0;
split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM; split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM; split_write_count += 1 )
split_write_count += 1 ){ {
// 書き込みデータをバッファにためる // 書き込みデータをバッファにためる
buffer_fill = 0; buffer_fill = 0;
do{ do
data_buffer[ buffer_fill ] = *p_rom; {
p_rom += 1; data_buffer[buffer_fill] = *p_rom;
buffer_fill++; p_rom += 1;
}while( buffer_fill != (u8)SELF_UPDATE_BUFF_SIZE ); buffer_fill++;
}
while( buffer_fill != ( u8 ) SELF_UPDATE_BUFF_SIZE );
// 書き込み // 書き込み
err = FSL_Write( (fsl_u32)( target_block * SAM_BLOCK_SIZE err = FSL_Write( ( fsl_u32 ) ( target_block * SAM_BLOCK_SIZE
+ split_write_count * SELF_UPDATE_BUFF_SIZE ), +
(fsl_u08)( SELF_UPDATE_BUFF_SIZE / SAM_WORD_SIZE ) ); split_write_count *
SELF_UPDATE_BUFF_SIZE ),
( fsl_u08 ) ( SELF_UPDATE_BUFF_SIZE / SAM_WORD_SIZE ) );
if( err != FSL_OK ){ if( err != FSL_OK )
FSL_Close(); {
return( ERR_ERR ); FSL_Close( );
} return ( ERR_ERR );
}
}
// 1ブロック書き込み完了したので内部ベリファイを行う
while( FSL_IVerify( target_block ) != FSL_OK )
{;
}
} }
// todo
//  それでもだなら、LEDちかちかとかさせて、サービス送りにしてもらう
// 1ブロック書き込み完了したので内部ベリファイを行う // リブート
while( FSL_IVerify( target_block ) != FSL_OK ){ ; } // スワップは不要です!
} FSL_ForceReset( );
// todo return ( ERR_SUCCESS );
//  それでもだなら、LEDちかちかとかさせて、サービス送りにしてもらう
// リブート
// スワップは不要です!
FSL_ForceReset();
return( ERR_SUCCESS );
} }
void chk_bootCluster(){ void chk_bootCluster( )
u8 data_buffer[ SELF_UPDATE_BUFF_SIZE ]; {
u8 err; u8 data_buffer[SELF_UPDATE_BUFF_SIZE];
u8 err;
DI(); DI( );
FSL_Open(); // 割り込み禁止など FSL_Open( ); // 割り込み禁止など
err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず
err |= FSL_ModeCheck(); // ライトプロテクトチェック。失敗することを考慮せず err |= FSL_ModeCheck( ); // ライトプロテクトチェック。失敗することを考慮せず
err |= FSL_GetActiveBootCluster( &boot_ura ); err |= FSL_GetActiveBootCluster( &boot_ura );
FSL_Close(); FSL_Close( );
} }
// ======================================================== // ========================================================
static void FSL_Open(void) static void FSL_Open( void )
{ {
/* save the configuration of the interrupt controller and set */ /* save the configuration of the interrupt controller and set */
#ifdef FSL_INT_BACKUP #ifdef FSL_INT_BACKUP
fsl_MK0L_bak_u08 = MK0L; /* if (interrupt backup required) */ fsl_MK0L_bak_u08 = MK0L; /* if (interrupt backup required) */
fsl_MK0H_bak_u08 = MK0H; /* { */ fsl_MK0H_bak_u08 = MK0H; /* { */
fsl_MK1L_bak_u08 = MK1L; /* */ fsl_MK1L_bak_u08 = MK1L; /* */
fsl_MK1H_bak_u08 = MK1H; /* save interrupt controller */ fsl_MK1H_bak_u08 = MK1H; /* save interrupt controller */
fsl_MK2L_bak_u08 = MK2L; /* configuration */ fsl_MK2L_bak_u08 = MK2L; /* configuration */
fsl_MK2H_bak_u08 = MK2H; /* */ fsl_MK2H_bak_u08 = MK2H; /* */
MK0L = FSL_MK0L_MASK; /* */ MK0L = FSL_MK0L_MASK; /* */
MK0H = FSL_MK0H_MASK; /* */ MK0H = FSL_MK0H_MASK; /* */
MK1L = FSL_MK1L_MASK; /* prepare interrupt controller */ MK1L = FSL_MK1L_MASK; /* prepare interrupt controller */
MK1H = FSL_MK1H_MASK; /* for selfprogramming */ MK1H = FSL_MK1H_MASK; /* for selfprogramming */
MK2L = FSL_MK2L_MASK; /* */ MK2L = FSL_MK2L_MASK; /* */
MK2H = FSL_MK2H_MASK; /* } */ MK2H = FSL_MK2H_MASK; /* } */
#endif #endif
// 何か前準備? // 何か前準備?
// todo DMAを止める // todo DMAを止める
while( DST1 )
{;
}
DEN1 = 0;
FSL_FLMD0_HIGH; // フラッシュ書き替え許可 FSL_FLMD0_HIGH; // フラッシュ書き替え許可
} }
@ -359,19 +396,19 @@ static void FSL_Open(void)
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
/* leave the "user room" and restore previous conditions */ /* leave the "user room" and restore previous conditions */
/*----------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------*/
static void FSL_Close(void) static void FSL_Close( void )
{ {
// 何か後始末? // 何か後始末?
FSL_FLMD0_LOW; // フラッシュライトプロテクト FSL_FLMD0_LOW; // フラッシュライトプロテクト
#ifdef FSL_INT_BACKUP #ifdef FSL_INT_BACKUP
MK0L = fsl_MK0L_bak_u08; /* do{ */ MK0L = fsl_MK0L_bak_u08; /* do{ */
MK0H = fsl_MK0H_bak_u08; /* restore interrupt controller */ MK0H = fsl_MK0H_bak_u08; /* restore interrupt controller */
MK1L = fsl_MK1L_bak_u08; /* configuration */ MK1L = fsl_MK1L_bak_u08; /* configuration */
MK1H = fsl_MK1H_bak_u08; /* */ MK1H = fsl_MK1H_bak_u08; /* */
MK2L = fsl_MK2L_bak_u08; /* */ MK2L = fsl_MK2L_bak_u08; /* */
MK2H = fsl_MK2H_bak_u08; /* } */ MK2H = fsl_MK2H_bak_u08; /* } */
#endif #endif
} }

View File

@ -10,102 +10,141 @@
extern u8 boot_ura; extern u8 boot_ura;
#define INTERVAL_TSK_MISC_STAT 4
/* ========================================================
WiFi
WL_TX,RX
LED_wifi
32kHz
======================================================== */
task_interval tsk_wifi(){
return 10;
}
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
task_interval tsk_misc_stat(){ void tsk_misc_stat( )
static u8 state_old; // ステータス変化検出→割り込み の為 {
u8 diff; static u8 interval_task_misc_stat = 0;
static u8 state_old; // ステータス変化検出→割り込み の為
u8 diff;
SHELL_CLOSE_P = 1; if( interval_task_misc_stat != 0 )
set_bit( EXT_OPT_OPEN, vreg_ctr[ VREG_C_STATUS ], REG_BIT_ST_EXT_OPT_OPEN ); {
set_bit( SHELL_CLOSE, vreg_ctr[ VREG_C_STATUS ], REG_BIT_ST_SHELL_CLOSED ); interval_task_misc_stat -= 1;
SHELL_CLOSE_P = 0; return;
}
else
// ステータスレジスタ関係 → 割り込み // {
if( ( system_status.pwr_state == ON ) interval_task_misc_stat = ( INTERVAL_TSK_MISC_STAT / SYS_INTERVAL_TICK );
|| ( system_status.pwr_state == SLEEP ) ){
diff = vreg_ctr[ VREG_C_STATUS ] ^ state_old;
if( diff != 0 ){
if( diff & REG_BIT_LCD_POW ){
// 液晶電源セット完了
if( vreg_ctr[ VREG_C_STATUS ] & REG_BIT_LCD_POW ){
// on
set_irq( VREG_C_IRQ3, REG_BIT_LCD_ON );
}else{
// off
set_irq( VREG_C_IRQ3, REG_BIT_LCD_OFF );
}
}
if( diff & REG_BIT_BL ){
// バックライトに変化有り
if( vreg_ctr[ VREG_C_STATUS ] & REG_BIT_BL ){
// ついた
set_irq( VREG_C_IRQ3, REG_BIT_BL_ON );
}else{
// 消えた
set_irq( VREG_C_IRQ3, REG_BIT_BL_OFF );
}
}
if( diff & REG_BIT_BATT_CHARGE ){
// 充電状態に以下略
if( vreg_ctr[ VREG_C_STATUS ] & REG_BIT_BATT_CHARGE ){
set_irq( VREG_C_IRQ2, REG_BIT_BT_CHG_START );
}else{
set_irq( VREG_C_IRQ2, REG_BIT_BT_CHG_STOP );
}
}
if( diff & REG_BIT_POW_SUPPLY ){
// 電源供給
if( vreg_ctr[ VREG_C_STATUS ] & REG_BIT_POW_SUPPLY ){
set_irq( VREG_C_IRQ2, REG_BIT_BT_DC_CONNECT );
}else{
set_irq( VREG_C_IRQ2, REG_BIT_BT_DC_DISC );
}
}
if( diff & REG_BIT_ST_EXT_OPT_OPEN ){
// オプション蓋ロック
if( vreg_ctr[ VREG_C_STATUS ] & REG_BIT_ST_EXT_OPT_OPEN ){
set_irq( VREG_C_IRQ2, REG_BIT_EXTOPT_LOCK );
}else{
set_irq( VREG_C_IRQ2, REG_BIT_EXTOPT_OPEN );
}
}
if( diff & REG_BIT_ST_SHELL_CLOSED ){
// BL点灯
if( vreg_ctr[ VREG_C_STATUS ] & REG_BIT_ST_SHELL_CLOSED ){
set_irq( VREG_C_IRQ2, REG_BIT_SHELL_OPEN );
}else{
set_irq( VREG_C_IRQ2, REG_BIT_SHELL_CLOSE );
}
}
} }
state_old = vreg_ctr[ VREG_C_STATUS ]; SHELL_CLOSE_P = 1;
} set_bit( EXT_OPT_OPEN, vreg_ctr[VREG_C_STATUS], REG_BIT_ST_EXT_OPT_OPEN );
set_bit( SHELL_CLOSE, vreg_ctr[VREG_C_STATUS], REG_BIT_ST_SHELL_CLOSED );
SHELL_CLOSE_P = 0;
return( 100 );
// ステータスレジスタ関係 → 割り込み //
if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) )
{
diff = vreg_ctr[VREG_C_STATUS] ^ state_old;
if( diff != 0 )
{
state_old = vreg_ctr[VREG_C_STATUS];
if( diff & REG_BIT_LCD_POW )
{
// 液晶電源セット完了
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_LCD_POW )
{
// on
set_irq( VREG_C_IRQ3, REG_BIT_LCD_ON );
}
else
{
// off
set_irq( VREG_C_IRQ3, REG_BIT_LCD_OFF );
}
}
if( diff & REG_BIT_BL )
{
// バックライトに変化有り
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_BL )
{
// ついた
set_irq( VREG_C_IRQ3, REG_BIT_BL_ON );
}
else
{
// 消えた
set_irq( VREG_C_IRQ3, REG_BIT_BL_OFF );
}
}
if( diff & REG_BIT_BATT_CHARGE )
{
// 充電状態に以下略
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_BATT_CHARGE )
{
set_irq( VREG_C_IRQ2, REG_BIT_BT_CHG_START );
}
else
{
set_irq( VREG_C_IRQ2, REG_BIT_BT_CHG_STOP );
}
}
if( diff & REG_BIT_POW_SUPPLY )
{
// 電源供給
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_POW_SUPPLY )
{
set_irq( VREG_C_IRQ2, REG_BIT_BT_DC_CONNECT );
}
else
{
set_irq( VREG_C_IRQ2, REG_BIT_BT_DC_DISC );
}
}
if( diff & REG_BIT_ST_EXT_OPT_OPEN )
{
// オプション蓋ロック
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_ST_EXT_OPT_OPEN )
{
set_irq( VREG_C_IRQ2, REG_BIT_EXTOPT_LOCK );
}
else
{
set_irq( VREG_C_IRQ2, REG_BIT_EXTOPT_OPEN );
}
}
if( diff & REG_BIT_ST_SHELL_CLOSED )
{
// 蓋の開け閉め
if( vreg_ctr[VREG_C_STATUS] & REG_BIT_ST_SHELL_CLOSED )
{
set_irq( VREG_C_IRQ2, REG_BIT_SHELL_OPEN );
}
else
{
set_irq( VREG_C_IRQ2, REG_BIT_SHELL_CLOSE );
}
}
}
#ifdef _MCU_KE3_
/* ========================================================
BSRマイコンはaccero.cで割り込みルーチンからタスク登録します
======================================================== */
if( ( vreg_ctr[VREG_C_ACC_CONFIG] & 0x03 ) != 0x00 )
{
if( ACC_VALID )
{
renge_task_immed_add( tsk_cbk_accero );
}
}
#endif
}
return;
} }
@ -113,38 +152,41 @@ task_interval tsk_misc_stat(){
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
task_interval tsk_debug(){ void tsk_debug( )
u8 temp; {
static u8 count = 0; u8 temp;
static u8 count = 0;
static u8 task_interval;
if( !SW_SEL_n ){
/* if( system_status.pwr_state == ON_TRIG ){
temp = iic_mcu_read_a_byte( IIC_SLA_8LEDS, IIC_8LEDS_REG_DO ); renge_task_immed_add( tski_PM_LCD_on );
count += 1; wait_ms( 50 );
iic_mcu_write_a_byte( IIC_SLA_8LEDS, IIC_8LEDS_REG_DO, count ); renge_task_immed_add( tski_PM_BL_on );
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 3, count ); }
return 0; }
*/
return 255; /*
temp = iic_mcu_read_a_byte( IIC_SLA_8LEDS, IIC_8LEDS_REG_DO );
count += 1;
iic_mcu_write_a_byte( IIC_SLA_8LEDS, IIC_8LEDS_REG_DO, count );
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 3, count );
*/
return;
} }
task_interval tsk_debug2(){ void tsk_debug2( )
u8 str[4]; {
u8 str[4];
return( 3 ); 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 ];
if(( system_status.pwr_state == ON )
|| ( system_status.pwr_state == SLEEP )){
str[3] = boot_ura;
str[2] = vreg_ctr[ VREG_C_IRQ1 ];
str[1] = vreg_ctr[ VREG_C_IRQ2 ];
str[0] = vreg_ctr[ VREG_C_STATUS ];
// str[3] = vreg_ctr[ VREG_C_IRQ0 ];
// str[2] = vreg_ctr[ VREG_C_IRQ1 ];
// str[1] = vreg_ctr[ VREG_C_IRQ2 ];
// str[0] = vreg_ctr[ VREG_C_STATUS ];
// iic_mcu_write( IIC_SLA_DBG_MONITOR, 0, 4, &str[0] );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_IRQ1 ] ); // 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 ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, boot_ura );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_SND_VOL ] ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_SND_VOL ] );
@ -154,8 +196,10 @@ if(( system_status.pwr_state == ON )
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_SND_VOL ] ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_SND_VOL ] );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_STATUS ] ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_STATUS ] );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 0, vreg_ctr[ VREG_C_ACC_ZH ] ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 0, vreg_ctr[ VREG_C_ACC_ZH ] );
}
return( 3 ); iic_mcu_write( IIC_SLA_DBG_MONITOR, 0, 4, &str[0] );
}
return;
} }
@ -163,18 +207,20 @@ if(( system_status.pwr_state == ON )
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
task_interval tsk_hina(){ task_interval tsk_hina( )
switch( system_status.pwr_state ){ {
case OFF: switch ( system_status.pwr_state )
case ON_TRIG: {
case ON: case OFF:
case SLEEP_TRIG: case ON_TRIG:
case SLEEP: case ON:
case OFF_TRIG: case SLEEP_TRIG:
default: case SLEEP:
} case OFF_TRIG:
default:
}
return( tick数 ); // 毎 tic 呼ばれることになります return ( X e tick ); // 毎 tic 呼ばれることになります
} }
@ -182,12 +228,12 @@ task_interval tsk_hina(){
/* このように使う /* このように使う
renge_task_immed_add( ); renge_task_immed_add( );
*/ */
task_status_immed tsk_imm_hina( u8* arg ){ task_status_immed tsk_imm_hina( u8 * arg )
{
return( ERR_FINISED ); return ( ERR_FINISED );
// ERR_FINISED タスクを削除 // ERR_FINISED タスクを削除
// ERR_CONTINUE 次になんか割り込みなり、ユーザー操作なり、システムチックが // ERR_CONTINUE 次になんか割り込みなり、ユーザー操作なり、システムチックが
// 来たときに再度実行 // 来たときに再度実行
} }
@ -204,83 +250,82 @@ task_status_immed tsk_imm_hina( u8* arg ){
COMMANDレジスタへの書き込み COMMANDレジスタへの書き込み
  0   0
======================================================== */ ======================================================== */
task_status_immed do_command0(){ task_status_immed do_command0( )
{
// 本体電源など // 本体電源など
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_OFF_REQ ){ if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_OFF_REQ )
system_status.pwr_state = OFF_TRIG; {
system_status.pwr_state = OFF_TRIG;
}else{ }
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_RESET1_REQ ){ else
{
if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_RESET1_REQ )
{
#ifdef _PMIC_TWL_ #ifdef _PMIC_TWL_
RESETs_ast; RESETs_ast;
#else #else
PM_reset_ast(); PM_reset_ast( );
RESET2_ast; RESET2_ast;
#endif #endif
FCRAM_RST_ast; FCRAM_RST_ast;
} }
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_RESET2_REQ ){ if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_RESET2_REQ )
RESET2_ast; {
} RESET2_ast;
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_FCRAM_RESET_REQ ){ }
FCRAM_RST_ast; if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_FCRAM_RESET_REQ )
} {
wait_ms( 5 ); FCRAM_RST_ast;
}
wait_ms( 5 );
#ifdef _PMIC_TWL_ #ifdef _PMIC_TWL_
RESETs_neg; RESETs_neg;
#else #else
PM_reset_neg(); PM_reset_neg( );
RESET2_neg; RESET2_neg;
#endif #endif
FCRAM_RST_neg; FCRAM_RST_neg;
} }
// 液晶電源など // 液晶電源など
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_CMD_BL_ON ){ if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_CMD_BL_ON )
renge_task_immed_add( tski_PM_BL_on ); {
}else if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_CMD_BL_OFF ){ renge_task_immed_add( tski_PM_BL_on );
renge_task_immed_add( tski_PM_BL_off ); }
} else if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_CMD_BL_OFF )
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_CMD_LCD_ON ){ {
renge_task_immed_add( tski_PM_LCD_on ); renge_task_immed_add( tski_PM_BL_off );
}else if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_CMD_LCD_OFF ){ }
renge_task_immed_add( tski_PM_LCD_off ); if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_CMD_LCD_ON )
} {
renge_task_immed_add( tski_PM_LCD_on );
}
else if( vreg_ctr[VREG_C_COMMAND0] & REG_BIT_CMD_LCD_OFF )
{
renge_task_immed_add( tski_PM_LCD_off );
}
vreg_ctr[ VREG_C_COMMAND0 ] = 0; vreg_ctr[VREG_C_COMMAND0] = 0;
return( ERR_FINISED ); return ( ERR_FINISED );
} }
/* ======================================================== /* ========================================================
 TWLアプリへの割り込み  TWLアプリへの割り込み
  0
======================================================== */ ======================================================== */
task_status_immed do_command1(){ // task_status_immed do_command1( )
// 呼ばれません
while(1){
NOP(); // 誤り検出
}
vreg_twl[ REG_TWL_ADRS_IRQ ] = (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_PWSW_DET ) != 0 )? REG_BIT_TWL_IRQ_PWSW_DET: 0x00; //pwsw_det
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_RESET ) != 0 )? REG_BIT_TWL_IRQ_RESET: 0x00; //reset_req
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_OFF ) != 0 )? REG_BIT_TWL_IRQ_OFF: 0x00; //off_req
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_BT_LOW ) != 0 )? REG_BIT_TWL_IRQ_BT_LOW: 0x00; //batt_low
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_BT_EMPTY ) != 0 )? REG_BIT_TWL_IRQ_BT_EMPTY: 0x00; //batt_empty
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_VOL_CHANGE ) != 0 )? REG_BIT_TWL_IRQ_VOL_CHANGE: 0x00; //vol_changed
return( ERR_FINISED );
}
/* ======================================================== /* ========================================================
CPUからのスリープ要求 CPUからのスリープ要求
======================================================== */ ======================================================== */
__interrupt void intp0_slp(){ // SLP __interrupt void intp0_slp( )
{ // SLP
/* /*
if( SLP_REQ ){ if( SLP_REQ ){
system_status.pwr_state = SLEEP_TRIG; system_status.pwr_state = SLEEP_TRIG;
@ -295,5 +340,3 @@ __interrupt void intp0_slp(){ // SLP
renge_task_interval_run_force = 1; renge_task_interval_run_force = 1;
*/ */
} }

View File

@ -12,8 +12,8 @@
#include "pm.h" #include "pm.h"
#include "rtc.h" #include "rtc.h"
u8 SW_pow_count, SW_home_count, SW_tune_count, SW_wifi_count; u8 SW_pow_count, SW_home_count, SW_tune_count, SW_wifi_count;
bit SW_pow_mask, SW_home_mask, SW_tune_mask, SW_wifi_mask; bit SW_pow_mask, SW_home_mask, SW_tune_mask, SW_wifi_mask;
/* ======================================================== /* ========================================================
@ -22,193 +22,191 @@ bit SW_pow_mask, SW_home_mask, SW_tune_mask, SW_wifi_mask;
 system_status.pwr_state == OFF_TRIG  system_status.pwr_state == OFF_TRIG
======================================================== */ ======================================================== */
task_interval tsk_sys(){ void tsk_sys( )
static u8 timeout = 0; {
RTCIMK = 0; // インターバル割り込み許可 static u8 timeout = 0;
RTCIMK = 0; // インターバル割り込み許可
switch( system_status.pwr_state ){ switch ( system_status.pwr_state )
case OFF: //-------------------------------------------------------
// スイッチ操作などで割り込みが発生し、スリープが解除されるとここに来ます。
switch( system_status.poweron_reason ){
default:
// スイッチで電源on
if(( SW_pow_count != 0 ) ||
( SW_wifi_count != 0 )){
timeout = 0;
}else{
timeout += 1;
}
if( timeout > 127 ){
system_status.pwr_state = OFF_TRIG; // スイッチはノイズだった。寝る。
renge_task_interval_run_force = 1;
//iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 3, 0x81 );
return( 0 );
}
if(( SW_pow_count < 3 )&&
( SW_wifi_count < 3 )){
// もう少しスイッチの様子を見る
//iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 3, 0x82 );
return( 0 );
}
break;
case( RTC_ALARM ):
//iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 3, 0x83 );
break;
// 何か他に電源ON要因はあるか
// 蓋開け
// アダプタ(充電の温度を監視しなくてはならない)
}
timeout = 0;
// 電源投入
SW_pow_mask = 1;
SW_tune_mask = 1;
SW_wifi_mask = 1;
// 電源投入 //
iic_mcu_start();
PM_init(); // 電池残量ICの設定
// todo bt_auth
if( PM_bt_auth() != ERR_SUCCESS ){
// どうするの?
renge_task_interval_run_force = 1;
system_status.pwr_state = OFF_TRIG;
while(1){
NOP();
}
// return( 0 );
}
if( PM_sys_pow_on() != ERR_SUCCESS ){ // 電源起動不可エラー
renge_task_interval_run_force = 1;
iic_mcu_stop();
system_status.pwr_state = OFF;
return( 0 );
}
PM_LCD_vcom_set(); // LCDの対向電圧値など書き込み
// 電源スイッチでの電源投入であれば、バックライトを点ける
if( system_status.poweron_reason == PWSW ){
// パワースイッチでのonの時は、LEDを点灯させる
vreg_ctr[ VREG_C_LED_POW ] = LED_POW_ILM_AUTO;
#if 0
if( PM_LCD_on() == 0 ){
renge_task_interval_run_force = 1;
iic_mcu_stop();
system_status.pwr_state = OFF;
return( 0 );
}
if( PM_BL_on() == 0 ){
renge_task_interval_run_force = 1;
iic_mcu_stop();
system_status.pwr_state = OFF;
return( 0 );
}
#endif
}
else
{ {
// 他には? case OFF: //-------------------------------------------------------
vreg_ctr[ VREG_C_LED_POW ] = LED_POW_ILM_OFF; // スイッチ操作などで割り込みが発生し、スリープが解除されるとここに来ます。
}
// ここまで来ると、電源投入確定 switch ( system_status.poweron_reason )
system_status.pwr_state = ON_TRIG; {
renge_task_interval_run_force = 1; default:
// スイッチで電源on
if( ( SW_pow_count != 0 ) || ( SW_wifi_count != 0 ) )
{
timeout = 0;
}
else
{
timeout += 1;
}
if( timeout > 127 )
{
system_status.pwr_state = OFF_TRIG; // スイッチはノイズだった。寝る。
renge_task_interval_run_force = 1;
return;
}
if( ( SW_pow_count < 3 ) && ( SW_wifi_count < 3 ) )
{
// もう少しスイッチの様子を見る
return;
}
break;
return( 0 ); case ( RTC_ALARM ):
break; break;
case ON_TRIG: //------------------------------------------------------- // 何か他に電源ON要因はあるか
LED_init(); // 蓋開け
{ // アダプタ(充電の温度を監視しなくてはならない)
PU7 = 0b00011101; // 4:SW_WIFI 3:SW_PWSW 2:PM_IRQ 0:PM_EXTDC }
}
// アクティブ中に使用するピン変化割り込み
// I2CやDMAは個別にセットしてください
// KRM = 0b00000000;
MK0 = INT_MSK0_RSV; timeout = 0;
MK1 = INT_MSK1_RSV;
#ifdef _MCU_BSR_ // 電源投入
MK2 = INT_MSK2_RSV; SW_pow_mask = 1;
#else SW_tune_mask = 1;
MK2L= INT_MSK2L_RSV; SW_wifi_mask = 1;
// 電源投入 //
iic_mcu_start( );
PM_init( ); // 電池残量ICの設定
// todo bt_auth
if( PM_bt_auth( ) != ERR_SUCCESS )
{
// どうするの?
renge_task_interval_run_force = 1;
system_status.pwr_state = OFF_TRIG;
while( 1 )
{
NOP( );
}
// return( 0 );
}
if( PM_sys_pow_on( ) != ERR_SUCCESS )
{ // 電源起動不可エラー
renge_task_interval_run_force = 1;
iic_mcu_stop( );
system_status.pwr_state = OFF;
return;
}
PM_LCD_vcom_set( ); // LCDの対向電圧値など書き込み
#ifdef _PMIC_TWL_
PM_TEG_LCD_dis( 0 );
#endif #endif
// ほか、必要ペリフェラルの初期化
IIC_ctr_Init(); // とりあえずはここで初期化
IIC_twl_Init();
RTC_32k_on();
system_status.pwr_state = ON; if( system_status.poweron_reason == PWSW )
{
// 電源ボタンでのonの時は、LEDを点灯させる
vreg_ctr[VREG_C_LED_POW] = LED_POW_ILM_AUTO;
}
else
{
vreg_ctr[VREG_C_LED_POW] = LED_POW_ILM_OFF;
// 他には?
}
// ここまで来ると、電源投入確定
system_status.pwr_state = ON_TRIG;
renge_task_interval_run_force = 1;
return;
break;
case ON_TRIG: //-------------------------------------------------------
LED_init( );
{
PU7 = 0b00011101; // 4:SW_WIFI 3:SW_PWSW 2:PM_IRQ 0:PM_EXTDC
}
// アクティブ中に使用するピン変化割り込み
// I2CやDMAは個別にセットしてください
// KRM = 0b00000000;
MK0 = INT_MSK0_RSV;
MK1 = INT_MSK1_RSV;
#ifdef _MCU_BSR_
MK2 = INT_MSK2_RSV;
#else
MK2L = INT_MSK2L_RSV;
#endif
// ほか、必要ペリフェラルの初期化
IIC_ctr_Init( ); // とりあえずはここで初期化
IIC_twl_Init( );
RTC_32k_on( );
system_status.pwr_state = ON;
#ifndef _CODEC_CTR_ #ifndef _CODEC_CTR_
{ {
u8 temp; u8 temp;
// do{ // do{
temp = iic_mcu_write_a_byte( IIC_SLA_DCP, 0x08, 0x80 ); // ACR←0x80 揮発モードへ temp = iic_mcu_write_a_byte( IIC_SLA_DCP, 0x08, 0x80 ); // ACR←0x80 揮発モードへ
NOP(); NOP( );
// }while( temp != ERR_SUCCESS ); // }while( temp != ERR_SUCCESS );
} }
#endif #endif
system_status.poweron_reason = PWSW; system_status.poweron_reason = PWSW;
break; return;
break;
case ON: //---------------------------------------------
case ON: //--------------------------------------------- if( !RESET1_n )
if( !RESET1_n ){ {
// 電源異常チェック // 電源異常チェック
/// コマンドで、正規にリセットをかけたときには、 /// コマンドで、正規にリセットをかけたときには、
/// このチェックに引っかからないので大丈夫 /// このチェックに引っかからないので大丈夫
NOP(); NOP( );
// ステータス類の設定、電源のフラグなどの整理 // ステータス類の設定、電源のフラグなどの整理
// system_status.pwr_state = OFF_TRIG; // system_status.pwr_state = OFF_TRIG;
// renge_task_interval_run_force = 1; // renge_task_interval_run_force = 1;
} }
break; return;
break;
case SLEEP_TRIG: //------------------------------------- case SLEEP_TRIG: //-------------------------------------
system_status.pwr_state = SLEEP; system_status.pwr_state = SLEEP;
PM_BL_off(); // todo PMICのモード切替
break; // SoCとのハンドシェイク
PM_BL_off( );
return;
break;
case SLEEP: //------------------------------------------ case SLEEP: //------------------------------------------
system_status.pwr_state = ON_TRIG; system_status.pwr_state = ON_TRIG;
if( !RESET1_n ){ if( !RESET1_n )
NOP(); {
NOP( );
/* /*
// ステータス類の設定、電源のフラグなどの整理 // ステータス類の設定、電源のフラグなどの整理
system_status.pwr_state = OFF_TRIG; system_status.pwr_state = OFF_TRIG;
renge_task_interval_run_force = 1; renge_task_interval_run_force = 1;
*/ */
} }
break; return;
break;
case OFF_TRIG: //--------------------------------------- case OFF_TRIG: //---------------------------------------
DBG_LED_WIFI_2_on; LED_stop( );
DBG_LED_WIFI_2_off; IIC_ctr_Stop( );
DBG_LED_WIFI_2_on; IIC_twl_Stop( );
DBG_LED_WIFI_2_off; vreg_ctr[VREG_C_IRQ0] = 0;
vreg_ctr[VREG_C_IRQ1] = 0;
vreg_ctr[VREG_C_IRQ2] = 0;
LED_stop(); vreg_ctr[VREG_C_IRQ3] = 0;
IIC_ctr_Stop(); BT_TEMP_P = 0;
IIC_twl_Stop();
vreg_ctr[ VREG_C_IRQ0 ] = 0;
vreg_ctr[ VREG_C_IRQ1 ] = 0;
vreg_ctr[ VREG_C_IRQ2 ] = 0;
vreg_ctr[ VREG_C_IRQ3 ] = 0;
BT_TEMP_P = 0;
// 電源オン条件の割り込みセット // 電源オン条件の割り込みセット
// PWSW KR3 押すとL // PWSW KR3 押すとL
@ -217,74 +215,70 @@ task_interval tsk_sys(){
// ACアダプタ INTP4 アダプタありでL // ACアダプタ INTP4 アダプタありでL
// RTC // RTC
DI(); DI( );
PM_sys_pow_off(); #ifdef _PMIC_TWL_
DBG_LED_WIFI_2_on; PM_TEG_LCD_dis( 1 );
DBG_LED_WIFI_2_off; #endif
DBG_LED_WIFI_2_on;
DBG_LED_WIFI_2_off; PM_sys_pow_off( );
DBG_LED_WIFI_2_on;
DBG_LED_WIFI_2_off;
// iic_mcu_stop(); // iic_mcu_stop();
// pullup_off(); ↓ // pullup_off(); ↓
{ {
PU5 = 0b00000011; // PM_CHG,PM_CHGERR PU5 = 0b00000011; // PM_CHG,PM_CHGERR
PU7 = 0b00011001; // SW_WiFi,PWSWI,PM_EXTTDC PU7 = 0b00011001; // SW_WiFi,PWSWI,PM_EXTTDC
} }
// KRM = ( KR_SW_POW | KR_SW_WIFI ); // Mask ではなく、Modeなのだそうだ。紛らわしい // KRM = ( KR_SW_POW | KR_SW_WIFI ); // Mask ではなく、Modeなのだそうだ。紛らわしい
KRM = ( KR_SW_POW ); // Mask ではなく、Modeなのだそうだ。紛らわしい KRM = ( KR_SW_POW ); // Mask ではなく、Modeなのだそうだ。紛らわしい
// intp20系は後ほど // intp20系は後ほど
MK0 = 0b1111111110111111; // INT(EXTDC) MK0 = 0b1111111110111111; // INT(EXTDC)
// MK0 = 0b1111111100111111; // INT(SHELL), INT(EXTDC) // MK0 = 0b1111111100111111; // INT(SHELL), INT(EXTDC)
MK1 = 0b1111010111111111; // KR(SW_PW,SW_WiFi,...), RTC(Alarm) MK1 = 0b1111010111111111; // KR(SW_PW,SW_WiFi,...), RTC(Alarm)
MK2L= 0b11111111; MK2L = 0b11111111;
IF0 = 0; IF0 = 0;
IF1 = 0; IF1 = 0;
IF2 = 0; IF2 = 0;
timeout = 0; timeout = 0;
system_status.pwr_state = OFF; system_status.pwr_state = OFF;
while( RWST ){;} while( RWST )
{;
}
iic_mcu_stop(); iic_mcu_stop( );
STOP(); // 割り込み待ちで寝る // STOP( ); // 割り込み待ちで寝る //
DBG_LED_WIFI_2_on; // while( SW_POW_n ){;}
DBG_LED_WIFI_2_off; KRMK = 1;
DBG_LED_WIFI_2_on; RTCIMK = 0; // インターバル割り込み許可
DBG_LED_WIFI_2_off; EI( );
DBG_LED_WIFI_2_on;
DBG_LED_WIFI_2_off;
DBG_LED_WIFI_2_on;
DBG_LED_WIFI_2_off;
// while( SW_POW_n ){;}
KRMK = 1;
RTCIMK = 0; // インターバル割り込み許可
EI();
renge_task_interval_run_force = 1; renge_task_interval_run_force = 1;
break; return;
break;
default:
while( 1 )
{
NOP( );
// あり得ないステート
}
default:
while(1){
NOP();
// あり得ないステート
} }
return;
}
return 1;
} }
#define INTERVAL_TSK_SW 16
#define CLICK_THRESHOLD 3
#define LONG_PUSH_THREASHOLD ( 800 / INTERVAL_TSK_SW )
/* ======================================================== /* ========================================================
   
@ -307,82 +301,108 @@ task_interval tsk_sys(){
} \ } \
} }
task_interval tsk_sw(){ void tsk_sw( )
static u8 cnt_force_off = 0; {
static u8 sw_pow_old = 0; static u8 cnt_force_off = 0;
static u8 sw_pow_old = 0;
static u8 task_interval = 0;
if(( system_status.pwr_state == ON ) if( task_interval != 0 )
|| ( system_status.pwr_state == OFF )){ {
count_sw_n( SW_POW_n, SW_pow_count, SW_pow_mask ); task_interval -= 1;
count_sw_n( SW_WIFI_n, SW_wifi_count, SW_wifi_mask ); return;
count_sw_n( SW_TUNE_n, SW_tune_count, SW_tune_mask ); }
else
{
task_interval = ( INTERVAL_TSK_SW / SYS_INTERVAL_TICK );
}
if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == OFF ) )
{
count_sw_n( SW_POW_n, SW_pow_count, SW_pow_mask );
count_sw_n( SW_WIFI_n, SW_wifi_count, SW_wifi_mask );
count_sw_n( SW_TUNE_n, SW_tune_count, SW_tune_mask );
// count_sw_n( SW_HOME_n, SW_home_count, SW_home_mask ); // count_sw_n( SW_HOME_n, SW_home_count, SW_home_mask );
}
switch( system_status.pwr_state ){
case( OFF_TRIG ):
SW_pow_count = 0;
SW_wifi_count = 0;
SW_tune_count = 0;
cnt_force_off = 0;
break;
case( ON ):
case( SLEEP ):
// 電源スイッチの監視 //
if( SW_pow_count == 0 ){
if(( 6 < sw_pow_old ) && ( sw_pow_old < 66 )){
set_irq( VREG_C_IRQ0, REG_BIT_SW_POW_CLICK );
}
}else if( SW_pow_count == 66 ){
set_irq( VREG_C_IRQ0, REG_BIT_SW_POW_HOLD );
}else if( SW_pow_count == 254 ){ // todo
// vreg_ctr[ VREG_C_LED_POW ] = LED_POW_ONLY_RED;
system_status.pwr_state = OFF_TRIG;
renge_task_interval_run_force = 1;
} }
sw_pow_old = SW_pow_count;
// 電源OFF割り込みを入れたが… switch ( system_status.pwr_state )
if(( vreg_ctr[ VREG_C_IRQ0 ] & REG_BIT_SW_POW_HOLD ) != 0 ){ {
cnt_force_off += 1; case ( OFF_TRIG ):
if( cnt_force_off >= 13 ){ // …返事がない。強制的に切る。 SW_pow_count = 0;
vreg_ctr[ VREG_C_LED_POW ] = LED_POW_ILM_OFF; SW_wifi_count = 0;
if(( LED_duty_pow_H == 0 ) && ( LED_duty_pow_L == 0 )){ SW_tune_count = 0;
system_status.pwr_state = OFF_TRIG; cnt_force_off = 0;
renge_task_interval_run_force = 1; break;
case ( ON ):
case ( SLEEP ):
// 電源スイッチの監視 //
if( SW_pow_count == 0 )
{
if( ( CLICK_THRESHOLD < sw_pow_old ) && ( sw_pow_old < LONG_PUSH_THREASHOLD ) )
{
set_irq( VREG_C_IRQ0, REG_BIT_SW_POW_CLICK );
}
} }
} else if( SW_pow_count == LONG_PUSH_THREASHOLD )
}else{ {
cnt_force_off = 0; set_irq( VREG_C_IRQ0, REG_BIT_SW_POW_HOLD );
} }
else if( SW_pow_count == ( LONG_PUSH_THREASHOLD * 4 ) )
{ // todo
// vreg_ctr[ VREG_C_LED_POW ] = LED_POW_ONLY_RED;
system_status.pwr_state = OFF_TRIG;
renge_task_interval_run_force = 1;
}
sw_pow_old = SW_pow_count;
/* todo // 電源OFF割り込みを入れたが…
// HOME スイッチ…だと? // if( ( vreg_ctr[VREG_C_IRQ0] & REG_BIT_SW_POW_HOLD ) != 0 )
if( SW_home_count == 6 ){ {
vreg_ctr[ VREG_C_IRQ0 ] |= REG_BIT_SW_HOME_CLICK; cnt_force_off += 1;
if( ( vreg_ctr[ VREG_C_IRQ_MASK0 ] & REG_BIT_SW_HOME_CLICK ) == 0 ){ if( cnt_force_off >= 13 )
IRQ0_ast; { // …返事がない。強制的に切る。
} vreg_ctr[VREG_C_LED_POW] = LED_POW_ILM_OFF;
}else if( SW_pow_count == 66 ){ if( ( LED_duty_pow_H == 0 ) && ( LED_duty_pow_L == 0 ) )
vreg_ctr[ VREG_C_IRQ0 ] |= REG_BIT_SW_HOME_HOLD; {
if( ( vreg_ctr[ VREG_C_IRQ_MASK0 ] & REG_BIT_SW_HOME_HOLD ) == 0 ){ system_status.pwr_state = OFF_TRIG;
IRQ0_ast; renge_task_interval_run_force = 1;
} }
} }
*/ }
else
{
cnt_force_off = 0;
}
// wifi sw /* todo
if( SW_wifi_count == 10 ){ // HOME スイッチ…だと? //
set_irq( VREG_C_IRQ0, REG_BIT_SW_WIFI_CLICK ); if( SW_home_count == 6 ){
} vreg_ctr[ VREG_C_IRQ0 ] |= REG_BIT_SW_HOME_CLICK;
if( ( vreg_ctr[ VREG_C_IRQ_MASK0 ] & REG_BIT_SW_HOME_CLICK ) == 0 ){
IRQ0_ast;
}
}else if( SW_pow_count == 66 ){
vreg_ctr[ VREG_C_IRQ0 ] |= REG_BIT_SW_HOME_HOLD;
if( ( vreg_ctr[ VREG_C_IRQ_MASK0 ] & REG_BIT_SW_HOME_HOLD ) == 0 ){
IRQ0_ast;
}
}
*/
// tune sw // wifi sw
if( SW_tune_count == 10 ){ if( SW_wifi_count == 10 )
set_irq( VREG_C_IRQ0, REG_BIT_SW_TUNE_CLICK ); {
set_irq( VREG_C_IRQ0, REG_BIT_SW_WIFI_CLICK );
}
// tune sw
if( SW_tune_count == 10 )
{
set_irq( VREG_C_IRQ0, REG_BIT_SW_TUNE_CLICK );
}
break;
} }
break;
}
/* /*
@ -395,8 +415,5 @@ task_interval tsk_sw(){
} }
*/ */
return( 8 ); return;
} }

View File

@ -25,8 +25,8 @@
#endif #endif
#ifdef _debug_led_ #ifdef _debug_led_
#define DBG_LED_WIFI_on ( P1.1 = 1 ) // TO03 #define DBG_LED_WIFI_on ( P1.1 = 1 ) // TO03
#define DBG_LED_WIFI_off ( P1.1 = 0 ) // TO03 #define DBG_LED_WIFI_off ( P1.1 = 0 ) // TO03
#define DBG_LED_WIFI_2_on ( LED_WIFI_2 = 1 ) #define DBG_LED_WIFI_2_on ( LED_WIFI_2 = 1 )
#define DBG_LED_WIFI_2_off ( LED_WIFI_2 = 0 ) #define DBG_LED_WIFI_2_off ( LED_WIFI_2 = 0 )
#define DBG_LED_WIFI_2_toggle ( LED_WIFI_2 ^= 1 ) #define DBG_LED_WIFI_2_toggle ( LED_WIFI_2 ^= 1 )
@ -47,14 +47,14 @@ extern unsigned char temp_teg;
#ifdef _PMIC_TWL_ #ifdef _PMIC_TWL_
#define PM_TEG_PWSW P7.5 // TEGのみ #define PM_TEG_PWSW P7.5 // TEGのみ
#define PM_TEG_LCD_OFF P7.6 // TEGのみ #define PM_TEG_LCD_dis( val ) ( P7.6 = val ) // TEGのみ
#else #else
#endif #endif
#define IIC_SLA_CODEC 0xA4 #define IIC_SLA_CODEC 0xA4
#define IIC_SLA_ACCEL 0x30 // ST LIS331DLH #define IIC_SLA_ACCEL 0x30 // ST LIS331DLH
// PMxÍ0Å<E2809A>o—̓<C692>[ƒh // PMxÍ0Å<E2809A>o—̓<C692>[ƒh
@ -90,7 +90,8 @@ extern unsigned char temp_teg;
// CODEC // CODEC
#define PM_IRQ P7.2 // INTP6 #define PM_IRQ P7.2 // INTP6
#ifndef _PMIC_CTR_ #ifndef _PMIC_CTR_
#define SND_DEPOP P7.7 #define SND_DEPOP P7.7
#else #else
@ -98,7 +99,7 @@ extern unsigned char temp_teg;
#endif #endif
// PM // PM
#define PM_EXTDC P7.0 // INTP7 #define PM_EXTDC P7.0 // INTP7
//#define BT_TEMP P15.0 // ANI8 //#define BT_TEMP P15.0 // ANI8
//#define BT_DET P15.1 // ANI9 //#define BT_DET P15.1 // ANI9
#define BT_DET_P P1.6 #define BT_DET_P P1.6
@ -118,19 +119,19 @@ extern unsigned char temp_teg;
#endif #endif
#define SW_TUNE_n P2.0 #define SW_TUNE_n P2.0
#define SW_WIFI_n P7.4 // KR4 #define SW_WIFI_n P7.4 // KR4
#define SW_POW_n P7.3 // KR3 #define SW_POW_n P7.3 // KR3
#define SW_HOME_n P20.4 // INTP22 #define SW_HOME_n P20.4 // INTP22
#define SW_SEL_n P2.3 #define SW_SEL_n P2.3
//#define VOL P2.7 // ANI7 //#define VOL P2.7 // ANI7
// WiFi // WiFi
#ifndef _TEG_ #ifndef _TEG_
#define WL_TX P20.3 // INTP21 #define WL_TX P20.3 // INTP21
#define WL_RX P20.2 // INTP20 #define WL_RX P20.2 // INTP20
#else #else
#define WL_TX P20.3 // INTP21 #define WL_TX P20.3 // INTP21
#define WL_RX P20.2 // INTP20 #define WL_RX P20.2 // INTP20
#endif #endif
//#define LED_CAM P1.0 // TO02 //#define LED_CAM P1.0 // TO02
@ -155,10 +156,10 @@ extern unsigned char temp_teg;
//#define 32k_I1 P12.3 // XT1 //#define 32k_I1 P12.3 // XT1
//#define 32k_I2 P12.4 // XT2 //#define 32k_I2 P12.4 // XT2
#define DIPSW_0 P4.0 // mini cube ソフトウェアディップスイッチ #define DIPSW_0 P4.0 // mini cube ソフトウェアディップスイッチ
#define DIPSW_1 P4.1 // mini cube ソフトウェアディップスイッチ #define DIPSW_1 P4.1 // mini cube ソフトウェアディップスイッチ
#define SHELL_CLOSE P7.1 // INTP5 ふた開閉 (閉じると?) #define SHELL_CLOSE P7.1 // INTP5 ふた開閉 (閉じると?)
#define SHELL_CLOSE_P P3.3 #define SHELL_CLOSE_P P3.3
//#define DBG_VR P2.6 // ANI6 //#define DBG_VR P2.6 // ANI6

View File

@ -12,7 +12,7 @@ CTR MCU I2C
// ******************************************************** // ********************************************************
u8 vreg_ctr[ VREG_C_ENDMARK_ ]; u8 vreg_ctr[VREG_C_ENDMARK_];
@ -25,22 +25,27 @@ u8 vreg_ctr[ VREG_C_ENDMARK_ ];
// ******************************************************** // ********************************************************
// 非ゼロの初期値の指定が必要なアドレス // 非ゼロの初期値の指定が必要なアドレス
void vreg_ctr_init(){ void vreg_ctr_init( )
vreg_ctr[ VREG_C_LED_BRIGHT ] = 0xFF; {
vreg_ctr[VREG_C_LED_BRIGHT] = 0xFF;
#ifdef _debug_ #ifdef _debug_
vreg_ctr[ VREG_C_LED_TUNE ] = 0x01; // vreg_ctr[ VREG_C_LED_TUNE ] = 0x02;
#endif #endif
vreg_ctr[ VREG_C_MCU_VER_MAJOR ] = MCU_VER_MAJOR; vreg_ctr[VREG_C_MCU_VER_MAJOR] = MCU_VER_MAJOR;
#ifdef _MODEL_WM0_ #ifdef _MODEL_WM0_
vreg_ctr[ VREG_C_MCU_VER_MAJOR ] += 0x20; vreg_ctr[VREG_C_MCU_VER_MAJOR] += 0x20;
#endif #endif
#ifdef _MODEL_TS0_ #ifdef _MODEL_TS0_
vreg_ctr[ VREG_C_MCU_VER_MAJOR ] += 0x10; vreg_ctr[VREG_C_MCU_VER_MAJOR] += 0x10;
#endif #endif
vreg_ctr[ VREG_C_MCU_VER_MINOR ] = MCU_VER_MINOR; vreg_ctr[VREG_C_MCU_VER_MINOR] = MCU_VER_MINOR;
vreg_ctr[VREG_C_VCOM_T] = 92;
vreg_ctr[VREG_C_VCOM_B] = 95;
} }
@ -52,164 +57,168 @@ void vreg_ctr_init(){
//  書けないアドレスにアクセスした場合、何もしません。 //  書けないアドレスにアクセスした場合、何もしません。
// ●書き込んだ結果、I2C_mcu通信が発生する場合、renge_task_immed_add() // ●書き込んだ結果、I2C_mcu通信が発生する場合、renge_task_immed_add()
// を使用しないと、I2C_mcu使用中でエラー終了した場合にリトライしません。 // を使用しないと、I2C_mcu使用中でエラー終了した場合にリトライしません。
void vreg_ctr_write( u8 adrs, u8 data ){ void vreg_ctr_write( u8 adrs, u8 data )
switch( adrs ){ {
switch ( adrs )
{
case( VREG_C_MCU_STATUS ): case ( VREG_C_MCU_STATUS ):
vreg_ctr[ adrs ] = ( data & ~0x40 ); vreg_ctr[adrs] = ( data & ~0x40 );
break; break;
case( VREG_C_VCOM_T ): case ( VREG_C_VCOM_T ):
case( VREG_C_VCOM_B ): case ( VREG_C_VCOM_B ):
renge_task_immed_add( tski_vcom_set ); renge_task_immed_add( tski_vcom_set );
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_DBG1 ): case ( VREG_C_DBG1 ):
case( VREG_C_DBG2 ): case ( VREG_C_DBG2 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_DBG3 ): case ( VREG_C_DBG3 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
if(( vreg_ctr[ VREG_C_DBG1 ] == 'j' ) if( ( vreg_ctr[VREG_C_DBG1] == 'j' )
&& ( vreg_ctr[ VREG_C_DBG2 ] == 'h' ) && ( vreg_ctr[VREG_C_DBG2] == 'h' ) && ( data == 'l' ) )
&& ( data == 'l' ) {
){ firm_update( ); // 戻ってこない
firm_update(); // 戻ってこない }
} break;
break;
case( VREG_C_IRQ_MASK0 ): case ( VREG_C_IRQ_MASK0 ):
case( VREG_C_IRQ_MASK1 ): case ( VREG_C_IRQ_MASK1 ):
case( VREG_C_IRQ_MASK2 ): case ( VREG_C_IRQ_MASK2 ):
case( VREG_C_IRQ_MASK3 ): case ( VREG_C_IRQ_MASK3 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_COMMAND0 ): case ( VREG_C_COMMAND0 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
if( data != 0 ){ if( data != 0 )
renge_task_immed_add( do_command0 ); {
} renge_task_immed_add( do_command0 );
break; }
break;
case( VREG_C_COMMAND1 ): case ( VREG_C_COMMAND1 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
if( data != 0 ){ if( data != 0 )
// renge_task_immed_add( do_command1 ); {
/// 持ってきました // renge_task_immed_add( do_command1 );
vreg_twl[ REG_TWL_ADRS_IRQ ] = (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_PWSW_DET ) != 0 )? REG_BIT_TWL_IRQ_PWSW_DET: 0x00; //pwsw_det /// 持ってきました
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_RESET ) != 0 )? REG_BIT_TWL_IRQ_RESET: 0x00; //reset_req vreg_twl[REG_TWL_INT_ADRS_IRQ] = ( ( vreg_ctr[VREG_C_COMMAND1] & REG_BIT_TWL_CMD_PWSW_DET ) != 0 ) ? REG_BIT_TWL_IRQ_PWSW_DET : 0x00; //pwsw_det
vreg_twl[REG_TWL_INT_ADRS_IRQ] |= ( ( vreg_ctr[VREG_C_COMMAND1] & REG_BIT_TWL_CMD_RESET ) != 0 ) ? REG_BIT_TWL_IRQ_RESET : 0x00; //reset_req
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_OFF ) != 0 )? REG_BIT_TWL_IRQ_OFF: 0x00; //off_req vreg_twl[REG_TWL_INT_ADRS_IRQ] |= ( ( vreg_ctr[VREG_C_COMMAND1] & REG_BIT_TWL_CMD_OFF ) != 0 ) ? REG_BIT_TWL_IRQ_OFF : 0x00; //off_req
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_BT_LOW ) != 0 )? REG_BIT_TWL_IRQ_BT_LOW: 0x00; //batt_low vreg_twl[REG_TWL_INT_ADRS_IRQ] |= ( ( vreg_ctr[VREG_C_COMMAND1] & REG_BIT_TWL_CMD_BT_LOW ) != 0 ) ? REG_BIT_TWL_IRQ_BT_LOW : 0x00; //batt_low
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_BT_EMPTY ) != 0 )? REG_BIT_TWL_IRQ_BT_EMPTY: 0x00; //batt_empty vreg_twl[REG_TWL_INT_ADRS_IRQ] |= ( ( vreg_ctr[VREG_C_COMMAND1] & REG_BIT_TWL_CMD_BT_EMPTY ) != 0 ) ? REG_BIT_TWL_IRQ_BT_EMPTY : 0x00; //batt_empty
vreg_twl[ REG_TWL_ADRS_IRQ ] |= (( vreg_ctr[ VREG_C_COMMAND1 ] & REG_BIT_TWL_CMD_VOL_CHANGE ) != 0 )? REG_BIT_TWL_IRQ_VOL_CHANGE: 0x00; //vol_changed vreg_twl[REG_TWL_INT_ADRS_IRQ] |= ( ( vreg_ctr[VREG_C_COMMAND1] & REG_BIT_TWL_CMD_VOL_CHANGE ) != 0 ) ? REG_BIT_TWL_IRQ_VOL_CHANGE : 0x00; //vol_changed
} }
break; break;
case( VREG_C_FREE0 ): case ( VREG_C_FREE0 ):
case( VREG_C_FREE1 ): case ( VREG_C_FREE1 ):
case( VREG_C_FREE2 ): case ( VREG_C_FREE2 ):
case( VREG_C_FREE3 ): case ( VREG_C_FREE3 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_LED_BRIGHT ): case ( VREG_C_LED_BRIGHT ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_LED_POW ): case ( VREG_C_LED_POW ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_LED_WIFI ): case ( VREG_C_LED_WIFI ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_LED_CAM ): case ( VREG_C_LED_CAM ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_LED_TUNE ): case ( VREG_C_LED_TUNE ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_RTC_SEC ): case ( VREG_C_RTC_SEC ):
case( VREG_C_RTC_MIN ): case ( VREG_C_RTC_MIN ):
case( VREG_C_RTC_HOUR ): case ( VREG_C_RTC_HOUR ):
case( VREG_C_RTC_YOBI ): case ( VREG_C_RTC_YOBI ):
case( VREG_C_RTC_DAY ): case ( VREG_C_RTC_DAY ):
case( VREG_C_RTC_MONTH ): case ( VREG_C_RTC_MONTH ):
case( VREG_C_RTC_YEAR ): case ( VREG_C_RTC_YEAR ):
// ここでは書かない。セットするだけでstopで書く // ここでは書かない。セットするだけでstopで書く
/// 非同期で動いているため。 /// 非同期で動いているため。
set_rtc( adrs - VREG_C_RTC_SEC, data ); set_rtc( adrs - VREG_C_RTC_SEC, data );
break; break;
case( VREG_C_RTC_COMP ): case ( VREG_C_RTC_COMP ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
SUBCUD = data; SUBCUD = data;
break; break;
case( VREG_C_RTC_ALARM_MIN ): case ( VREG_C_RTC_ALARM_MIN ):
case( VREG_C_RTC_ALARM_HOUR ): case ( VREG_C_RTC_ALARM_HOUR ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
rtc_alarm_dirty = 1; rtc_alarm_dirty = 1;
break; break;
// 書くだけでよい // 書くだけでよい
case( VREG_C_RTC_ALARM_DAY ): case ( VREG_C_RTC_ALARM_DAY ):
case( VREG_C_RTC_ALARM_MONTH ): case ( VREG_C_RTC_ALARM_MONTH ):
case( VREG_C_RTC_ALARM_YEAR ): case ( VREG_C_RTC_ALARM_YEAR ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_ACC_CONFIG ): case ( VREG_C_ACC_CONFIG ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
renge_task_immed_add( acc_hosu_set ); renge_task_immed_add( acc_hosu_set );
break; break;
case( VREG_C_ACC_R_ADRS ): case ( VREG_C_ACC_R_ADRS ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
renge_task_immed_add( acc_read ); renge_task_immed_add( acc_read );
break; break;
case( VREG_C_ACC_W_ADRS ): case ( VREG_C_ACC_W_ADRS ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
case( VREG_C_ACC_W_BUF ): case ( VREG_C_ACC_W_BUF ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
renge_task_immed_add( acc_write ); renge_task_immed_add( acc_write );
break; break;
case( VREG_C_ACC_HOSU_L ): case ( VREG_C_ACC_HOSU_L ):
case( VREG_C_ACC_HOSU_M ): case ( VREG_C_ACC_HOSU_M ):
case( VREG_C_ACC_HOSU_H ): case ( VREG_C_ACC_HOSU_H ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
#ifdef _debug_ #ifdef _debug_
case( VREG_C_BT_REMAIN ): case ( VREG_C_BT_REMAIN ):
case( VREG_C_BT_TEMP ): case ( VREG_C_BT_TEMP ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
break; break;
#endif #endif
case( VREG_C_COMMAND3 ): case ( VREG_C_COMMAND3 ):
vreg_ctr[ adrs ] = data; vreg_ctr[adrs] = data;
switch( data ){ switch ( data )
case('r'): // マイコン再起動 {
WDTE = 0xAA; case ( 'r' ): // マイコン再起動
break; WDTE = 0xAA;
break;
}
break;
} }
break; return;
}
return;
} }
@ -219,26 +228,28 @@ void vreg_ctr_write( u8 adrs, u8 data ){
// 引数 adrs 外から見たときの、アドレス // 引数 adrs 外から見たときの、アドレス
// 戻り xx データ // 戻り xx データ
//  存在しないアドレスにアクセスした場合、戻り値は0x5A //  存在しないアドレスにアクセスした場合、戻り値は0x5A
u8 vreg_ctr_read( u8 adrs ){ u8 vreg_ctr_read( u8 adrs )
if(( VREG_C_RTC_SEC <= adrs ) {
&& ( adrs <= VREG_C_RTC_YEAR )){ if( ( VREG_C_RTC_SEC <= adrs ) && ( adrs <= VREG_C_RTC_YEAR ) )
get_rtc(); {
} get_rtc( );
return( vreg_ctr[ adrs ] ); }
return ( vreg_ctr[adrs] );
} }
// ******************************************************** // ********************************************************
// I2C仮想レジスタから読まれて何かするレジスタ // I2C仮想レジスタから読まれて何かするレジスタ
void vreg_ctr_after_read( u8 adrs ){ void vreg_ctr_after_read( u8 adrs )
{
// リードがトリガで何かをする↓ // リードがトリガで何かをする↓
// 割り込みビットのクリア // 割り込みビットのクリア
if( adrs == VREG_C_IRQ3 ){ if( adrs == VREG_C_IRQ3 )
vreg_ctr[ VREG_C_IRQ0 ] = vreg_ctr[ VREG_C_IRQ1 ] = {
vreg_ctr[ VREG_C_IRQ2 ] = vreg_ctr[ VREG_C_IRQ3 ] = 0; vreg_ctr[VREG_C_IRQ0] = vreg_ctr[VREG_C_IRQ1] =
vreg_ctr[VREG_C_IRQ2] = vreg_ctr[VREG_C_IRQ3] = 0;
} }
return; return;
} }

View File

@ -78,7 +78,8 @@
// VREG_C_WIFI_LED // VREG_C_WIFI_LED
enum{ enum
{
WIFI_LED_OFF = 0, WIFI_LED_OFF = 0,
WIFI_LED_ON, WIFI_LED_ON,
WIFI_LED_TXAUTO, WIFI_LED_TXAUTO,
@ -88,7 +89,8 @@ enum{
// VREG_C_CAM_LED // VREG_C_CAM_LED
enum{ enum
{
CAM_LED_OFF = 0, CAM_LED_OFF = 0,
CAM_LED_BLINK, CAM_LED_BLINK,
CAM_LED_ON, CAM_LED_ON,
@ -108,7 +110,7 @@ enum{
#define REG_BIT_TWL_CMD_VOL_CHANGE 0x20 #define REG_BIT_TWL_CMD_VOL_CHANGE 0x20
// <20>ªTWL¤ // <20>ªTWL¤
#define REG_BIT_TWL_IRQ_PWSW_DET 0x80 #define REG_BIT_TWL_IRQ_PWSW_DET 0x08
#define REG_BIT_TWL_IRQ_RESET 0x01 #define REG_BIT_TWL_IRQ_RESET 0x01
#define REG_BIT_TWL_IRQ_OFF 0x02 #define REG_BIT_TWL_IRQ_OFF 0x02
#define REG_BIT_TWL_IRQ_BT_LOW 0x20 #define REG_BIT_TWL_IRQ_BT_LOW 0x20
@ -142,52 +144,54 @@ enum{
extern u8 vreg_ctr[]; extern u8 vreg_ctr[];
/*============================================================================*/ /*============================================================================*/
enum VREG_C{ // 未定義アドレスへ書き込んだ際の動作は不定 enum VREG_C
VREG_C_MCU_VER_MAJOR = 0x00, { // 未定義アドレスへ書き込んだ際の動作は不定
VREG_C_MCU_VER_MAJOR = 0x00,
VREG_C_MCU_VER_MINOR, VREG_C_MCU_VER_MINOR,
VREG_C_MCU_STATUS, VREG_C_MCU_STATUS,
VREG_C_VCOM_T = 0x03, VREG_C_VCOM_T = 0x03,
VREG_C_VCOM_B, VREG_C_VCOM_B,
VREG_C_DBG1 = 0x05, VREG_C_DBG1 = 0x05,
VREG_C_DBG2, VREG_C_DBG2,
VREG_C_DBG3, VREG_C_DBG3,
VREG_C_TUNE = 0x08, VREG_C_TUNE = 0x08,
VREG_C_SND_VOL, VREG_C_SND_VOL,
VREG_C_BT_REMAIN, VREG_C_BT_REMAIN,
VREG_C_BT_TEMP, VREG_C_BT_TEMP,
VREG_C_STATUS = 0x0F, VREG_C_STATUS_X = 0x0E,
VREG_C_STATUS = 0x0F,
VREG_C_IRQ0 = 0x10, VREG_C_IRQ0 = 0x10,
VREG_C_IRQ1, VREG_C_IRQ1,
VREG_C_IRQ2, VREG_C_IRQ2,
VREG_C_IRQ3, VREG_C_IRQ3,
VREG_C_IRQ_MASK0 = 0x18, VREG_C_IRQ_MASK0 = 0x18,
VREG_C_IRQ_MASK1, VREG_C_IRQ_MASK1,
VREG_C_IRQ_MASK2, VREG_C_IRQ_MASK2,
VREG_C_IRQ_MASK3, VREG_C_IRQ_MASK3,
VREG_C_COMMAND0 = 0x20, VREG_C_COMMAND0 = 0x20,
VREG_C_COMMAND1, VREG_C_COMMAND1,
VREG_C_COMMAND2, VREG_C_COMMAND2,
VREG_C_COMMAND3, VREG_C_COMMAND3,
VREG_C_FREE0 = 0x24, VREG_C_FREE0 = 0x24,
VREG_C_FREE1, VREG_C_FREE1,
VREG_C_FREE2, VREG_C_FREE2,
VREG_C_FREE3, VREG_C_FREE3,
VREG_C_LED_BRIGHT = 0x28, VREG_C_LED_BRIGHT = 0x28,
VREG_C_LED_POW, VREG_C_LED_POW,
VREG_C_LED_WIFI, VREG_C_LED_WIFI,
VREG_C_LED_CAM, VREG_C_LED_CAM,
VREG_C_LED_TUNE, VREG_C_LED_TUNE,
VREG_C_RTC_SEC = 0x30, VREG_C_RTC_SEC = 0x30,
VREG_C_RTC_MIN, VREG_C_RTC_MIN,
VREG_C_RTC_HOUR, VREG_C_RTC_HOUR,
VREG_C_RTC_YOBI, VREG_C_RTC_YOBI,
@ -197,29 +201,29 @@ enum VREG_C{ //
VREG_C_RTC_COMP, VREG_C_RTC_COMP,
VREG_C_RTC_ALARM_MIN = 0x38, VREG_C_RTC_ALARM_MIN = 0x38,
VREG_C_RTC_ALARM_HOUR, VREG_C_RTC_ALARM_HOUR,
VREG_C_RTC_ALARM_DAY, VREG_C_RTC_ALARM_DAY,
VREG_C_RTC_ALARM_MONTH, VREG_C_RTC_ALARM_MONTH,
VREG_C_RTC_ALARM_YEAR, VREG_C_RTC_ALARM_YEAR,
VREG_C_ACC_CONFIG = 0x40, VREG_C_ACC_CONFIG = 0x40,
VREG_C_ACC_R_ADRS, VREG_C_ACC_R_ADRS,
VREG_C_RESERVED5, VREG_C_RESERVED5,
VREG_C_ACC_W_ADRS, VREG_C_ACC_W_ADRS,
VREG_C_ACC_W_BUF, VREG_C_ACC_W_BUF,
VREG_C_ACC_XL = 0x45, VREG_C_ACC_XL = 0x45,
VREG_C_ACC_XH, VREG_C_ACC_XH,
VREG_C_ACC_YL, VREG_C_ACC_YL,
VREG_C_ACC_YH, VREG_C_ACC_YH,
VREG_C_ACC_ZL, VREG_C_ACC_ZL,
VREG_C_ACC_ZH, VREG_C_ACC_ZH,
VREG_C_ACC_HOSU_L = 0x4B, VREG_C_ACC_HOSU_L = 0x4B,
VREG_C_ACC_HOSU_M, VREG_C_ACC_HOSU_M,
VREG_C_ACC_HOSU_H, VREG_C_ACC_HOSU_H,
VREG_C_ACC_HOSU_HIST = 0x4E, VREG_C_ACC_HOSU_HIST = 0x4E,
VREG_C_ENDMARK_ VREG_C_ENDMARK_
}; };
@ -230,14 +234,12 @@ enum VREG_C{ //
#else #else
 "がらっと変えてしまったので、旧版のディレクトリを使用して下さい。" @"がらっと変えてしまったので、旧版のディレクトリを使用して下さい。"
#endif #endif
/*============================================================================*/ /*============================================================================*/
void vreg_ctr_init(); void vreg_ctr_init( );
void vreg_ctr_write( u8 adrs, u8 data ); void vreg_ctr_write( u8 adrs, u8 data );
u8 vreg_ctr_read( u8 phy_adrs ); u8 vreg_ctr_read( u8 phy_adrs );
void vreg_ctr_after_read( u8 adrs ); void vreg_ctr_after_read( u8 adrs );

View File

@ -9,70 +9,48 @@ TWL
#include "vreg_twl.h" #include "vreg_twl.h"
u8 vreg_twl[ REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD +1 ];
#define TWL_REG_VER_INFO 0x35
u8 vreg_twl[_REG_TWL_INT_ADRS_EDNMARK];
/* ======================================================== /* ========================================================
======================================================== */ ======================================================== */
void vreg_twl_init(){ void vreg_twl_init( )
vreg_twl[ REG_TWL_INT_ADRS_VER_INFO ] = 0x35; {
vreg_twl[ REG_TWL_INT_ADRS_POWER_INFO ] = 0x0F; vreg_twl[REG_TWL_INT_ADRS_BL] = 0x03;
vreg_twl[ REG_TWL_INT_ADRS_POWER_SAVE ] = 0x07;
vreg_twl[ REG_TWL_INT_ADRS_BL ] = 0x03;
vreg_twl[ REG_TWL_INT_ADRS_CODEC_MIC_GAIN ] = 0x01;
vreg_twl[ REG_TWL_INT_ADRS_ADC_CALIB_STATUS ] = 0x01;
vreg_twl[ REG_TWL_INT_ADRS_ADC_CALIB_VALUE ] = 0x60;
} }
// ======================================================== // ========================================================
// I2C仮想レジスタに書きます。 // I2C仮想レジスタに書く・何かアクションする
// 引数 adrs は内部アドレス // 引数 adrs は内部アドレス
//  存在しないアドレスにアクセスした場合、何もしません。 //  存在しないアドレスにアクセスした場合、何もしません。
void vreg_twl_write( u8 adrs, u8 data ){ void vreg_twl_write( u8 adrs, u8 data )
switch( adrs ){ {
case( REG_TWL_INT_ADRS_COMMAND ): switch ( adrs )
case( REG_TWL_INT_ADRS_MODE ): {
case( REG_TWL_INT_ADRS_POWER_SAVE ): // case ( REG_TWL_INT_ADRS_VOL ):
case( REG_TWL_INT_ADRS_WIFI ):
case( REG_TWL_INT_ADRS_CAM ):
case( REG_TWL_INT_ADRS_VOL ):
case( REG_TWL_INT_ADRS_BL ):
/*
REG_TWL_INT_ADRS_CODEC_MIC_GAIN, // 0x50,
REG_TWL_INT_ADRS_CODEC_MIC_GAIN_RELOAD,
REG_TWL_INT_ADRS_ADC_CALIB, // 0x60,
REG_TWL_INT_ADRS_ADC_CALIB_VALUE,
REG_TWL_INT_ADRS_POWER_LED,
*/
case( REG_TWL_INT_ADRS_TEMP0 ):
case( REG_TWL_INT_ADRS_TEMP1 ):
case( REG_TWL_INT_ADRS_TEMP2 ):
case( REG_TWL_INT_ADRS_TEMP3 ):
case( REG_TWL_INT_ADRS_TEMP4 ):
case( REG_TWL_INT_ADRS_TEMP5 ):
case( REG_TWL_INT_ADRS_TEMP6 ):
case( REG_TWL_INT_ADRS_TEMP7 ):
// REG_TWL_INT_ADRS_TIME_PWSW_DELAY,
// REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD
vreg_twl[ adrs ] = data; case ( REG_TWL_INT_ADRS_MODE ):
break; case ( REG_TWL_INT_ADRS_CAM ):
} vreg_twl[adrs] = ( data & 0x03 );
break;
// TWLレジスタに書かれて何かアクションする
switch( adrs ){ case ( REG_TWL_INT_ADRS_BL ):
case( REG_TWL_INT_ADRS_COMMAND ): vreg_twl[adrs] = data;
if( data != 0 ){ break;
set_irq( VREG_C_IRQ3, REG_BIT_TWL_RESET_REQ ); //リセットしかない。他のは、SPIから来ます。
break; case ( REG_TWL_INT_ADRS_COMMAND ):
if( ( data & 0x01 ) != 0 )
{
set_irq( VREG_C_IRQ3, REG_BIT_TWL_RESET_REQ ); //リセットしかない。他のは、SPIから来ます。
break;
}
} }
return;
default:
break;
}
return;
} }
@ -82,13 +60,20 @@ void vreg_twl_write( u8 adrs, u8 data ){
// 引数 adrs 外から見たときの、アドレス // 引数 adrs 外から見たときの、アドレス
// 戻り xx データ // 戻り xx データ
//  存在しないアドレスにアクセスした場合、戻り値は0x5A //  存在しないアドレスにアクセスした場合、戻り値は0x5A
u8 vreg_twl_read( u8 phy_adrs ){ u8 vreg_twl_read( u8 phy_adrs )
u8 dat; {
u8 temp;
dat = vreg_twl[ phy_adrs ]; switch( phy_adrs ){
case( REG_TWL_INT_ADRS_VER_INFO ): return( TWL_REG_VER_INFO );
// リードがトリガで何かをするなら↓ case( REG_TWL_INT_ADRS_POWER_INFO ): return( 0x0F );
return( dat ); 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 ] );
case( 0xFF ): return( 0x00 );
}
} }
@ -96,65 +81,16 @@ u8 vreg_twl_read( u8 phy_adrs ){
// ======================================================== // ========================================================
// 外部から見える虫食いアドレスを、内部の連続アドレスに読み替える // 外部から見える虫食いアドレスを、内部の連続アドレスに読み替える
// 0xFFは存在しないアドレス。 // 0xFFは存在しないアドレス。
u8 adrs_table_twl_ext2int( u8 img ){ u8 adrs_table_twl_ext2int( u8 img )
u8 adrsH, adrsL; {
switch( img ){
adrsH = ( img & 0xF0 ); case( REG_TWL_ADRS_VER_INFO ): return( REG_TWL_INT_ADRS_VER_INFO );
adrsL = ( img & 0x0F ); case( REG_TWL_ADRS_IRQ ): return( REG_TWL_INT_ADRS_IRQ );
if( adrsH > 0x80 ){ case( REG_TWL_ADRS_COMMAND ): return( REG_TWL_INT_ADRS_COMMAND );
return( 0xFF ); case( REG_TWL_ADRS_MODE ): return( REG_TWL_INT_ADRS_MODE );
} case( REG_TWL_ADRS_POWER_INFO ): return( REG_TWL_INT_ADRS_POWER_INFO );
if( adrsH == 0x50 ){ case( REG_TWL_ADRS_CAM ): return( REG_TWL_INT_ADRS_CAM );
return( 0xFF ); case( REG_TWL_ADRS_BL ): return( REG_TWL_INT_ADRS_BL );
} default: return( 0xFF );
if( adrsH <= 0x30 ){ // 0x00 - 0x3F
if( adrsH <= 0x10 ){ // 0x00 - 0x1F
if( adrsH == 0x10 ){ // 0x1*
if( adrsL <= ( REG_TWL_ADRS_MODE & 0x0F ) ){
return( REG_TWL_INT_ADRS_IRQ + adrsL );
}
}else{ // 0x0*
if( adrsL <= ( REG_TWL_ADRS_BATT_INFO & 0x0F ) ){
return( REG_TWL_INT_ADRS_VER_INFO + adrsL );
}
}
}else{ // 0x20 - 0x3F
if( adrsH == 0x20 ){ // 0x2?
if( adrsL <= ( REG_TWL_ADRS_POWER_SAVE & 0x0F ) ){
return( REG_TWL_INT_ADRS_POWER_INFO + adrsL );
}
}else{ // 0x3*
if( adrsL <= ( REG_TWL_ADRS_CAM & 0x0F ) ){
return( REG_TWL_INT_ADRS_WIFI + adrsL );
}
}
} }
}else{
if( adrsH <= 0x60 ){
if( adrsH == 0x60 ){
if( adrsL <= ( REG_TWL_ADRS_POWER_LED & 0x0F ) ){
return( REG_TWL_INT_ADRS_ADC_CALIB + adrsL );
}
}else{ // 40台
if( adrsL <= ( REG_TWL_ADRS_BL & 0x0F ) ){
return( REG_TWL_INT_ADRS_VOL + adrsL );
}
}
}else{
if( adrsH == 0x70 ){
if( adrsL <= ( REG_TWL_ADRS_TEMP7 & 0x0F ) ){
return( REG_TWL_INT_ADRS_TEMP0 + adrsL );
}
}else{ // 80台
if( adrsL <= ( REG_TWL_ADRS_TIME_PWSW_THRESHOLD & 0x0F ) ){
return( REG_TWL_INT_ADRS_TIME_PWSW_DELAY + adrsL );
}
}
}
}
return( 0xFF );
} }

View File

@ -16,25 +16,26 @@
* 1: OFF * 1: OFF
* LSB: * LSB:
*/ */
enum REG_TWL_ADRS{ // 未定義アドレスへ書き込んだ際は無視 enum REG_TWL_ADRS
REG_TWL_ADRS_VER_INFO = 0x00, { // 未定義アドレスへ書き込んだ際は無視
REG_TWL_ADRS_VER_INFO = 0x00,
REG_TWL_ADRS_PMIC_INFO, REG_TWL_ADRS_PMIC_INFO,
REG_TWL_ADRS_BATT_INFO, REG_TWL_ADRS_BATT_INFO,
REG_TWL_ADRS_IRQ = 0x10, REG_TWL_ADRS_IRQ = 0x10,
REG_TWL_ADRS_COMMAND, REG_TWL_ADRS_COMMAND,
REG_TWL_ADRS_MODE, REG_TWL_ADRS_MODE,
REG_TWL_ADRS_POWER_INFO = 0x20, REG_TWL_ADRS_POWER_INFO = 0x20,
REG_TWL_ADRS_POWER_SAVE, REG_TWL_ADRS_POWER_SAVE,
REG_TWL_ADRS_WIFI = 0x30, REG_TWL_ADRS_WIFI = 0x30,
REG_TWL_ADRS_CAM, REG_TWL_ADRS_CAM,
REG_TWL_ADRS_VOL = 0x40, REG_TWL_ADRS_VOL = 0x40,
REG_TWL_ADRS_BL, REG_TWL_ADRS_BL,
REG_TWL_ADRS_CODEC_MIC_GAIN = 0x50, REG_TWL_ADRS_CODEC_MIC_GAIN = 0x50,
REG_TWL_ADRS_ADC_CALIB = 0x60, REG_TWL_ADRS_ADC_CALIB = 0x60,
REG_TWL_ADRS_ADC_CALIB_STATUS, REG_TWL_ADRS_ADC_CALIB_STATUS,
REG_TWL_ADRS_ADC_CALIB_VALUE, REG_TWL_ADRS_ADC_CALIB_VALUE,
REG_TWL_ADRS_POWER_LED, REG_TWL_ADRS_POWER_LED,
REG_TWL_ADRS_TEMP0 = 0x70, REG_TWL_ADRS_TEMP0 = 0x70,
REG_TWL_ADRS_TEMP1, REG_TWL_ADRS_TEMP1,
REG_TWL_ADRS_TEMP2, REG_TWL_ADRS_TEMP2,
REG_TWL_ADRS_TEMP3, REG_TWL_ADRS_TEMP3,
@ -42,7 +43,7 @@ enum REG_TWL_ADRS{ //
REG_TWL_ADRS_TEMP5, REG_TWL_ADRS_TEMP5,
REG_TWL_ADRS_TEMP6, REG_TWL_ADRS_TEMP6,
REG_TWL_ADRS_TEMP7, REG_TWL_ADRS_TEMP7,
REG_TWL_ADRS_TIME_PWSW_DELAY = 0x80, REG_TWL_ADRS_TIME_PWSW_DELAY = 0x80,
REG_TWL_ADRS_TIME_PWSW_THRESHOLD REG_TWL_ADRS_TIME_PWSW_THRESHOLD
}; };
@ -51,42 +52,44 @@ enum REG_TWL_ADRS{ //
* *
* *
*/ */
enum REG_TWL_ADRS_INT{ enum REG_TWL_ADRS_INT
{
REG_TWL_INT_ADRS_VER_INFO = 0x00, REG_TWL_INT_ADRS_VER_INFO = 0x00,
REG_TWL_INT_ADRS_PMIC_INFO, // REG_TWL_INT_ADRS_PMIC_INFO,
REG_TWL_INT_ADRS_BATT_INFO, // REG_TWL_INT_ADRS_BATT_INFO,
REG_TWL_INT_ADRS_IRQ, // 0x10, REG_TWL_INT_ADRS_IRQ, // 0x10,
REG_TWL_INT_ADRS_COMMAND, REG_TWL_INT_ADRS_COMMAND,
REG_TWL_INT_ADRS_MODE, REG_TWL_INT_ADRS_MODE,
REG_TWL_INT_ADRS_POWER_INFO, // 0x20, REG_TWL_INT_ADRS_POWER_INFO, // 0x20,
REG_TWL_INT_ADRS_POWER_SAVE, // REG_TWL_INT_ADRS_POWER_SAVE,
REG_TWL_INT_ADRS_WIFI, // 0x30, // REG_TWL_INT_ADRS_WIFI, // 0x30,
REG_TWL_INT_ADRS_CAM, REG_TWL_INT_ADRS_CAM,
REG_TWL_INT_ADRS_VOL, // 0x40, /// REG_TWL_INT_ADRS_VOL, // 0x40,
REG_TWL_INT_ADRS_BL, REG_TWL_INT_ADRS_BL,
REG_TWL_INT_ADRS_CODEC_MIC_GAIN, // 0x50, // REG_TWL_INT_ADRS_CODEC_MIC_GAIN, // 0x50,
REG_TWL_INT_ADRS_CODEC_MIC_GAIN_RELOAD, // REG_TWL_INT_ADRS_CODEC_MIC_GAIN_RELOAD,
REG_TWL_INT_ADRS_ADC_CALIB, // 0x60, // REG_TWL_INT_ADRS_ADC_CALIB, // 0x60,
REG_TWL_INT_ADRS_ADC_CALIB_STATUS, // REG_TWL_INT_ADRS_ADC_CALIB_STATUS,
REG_TWL_INT_ADRS_ADC_CALIB_VALUE, // REG_TWL_INT_ADRS_ADC_CALIB_VALUE,
REG_TWL_INT_ADRS_POWER_LED, // REG_TWL_INT_ADRS_POWER_LED,
REG_TWL_INT_ADRS_TEMP0, // 0x70 - 0x77 // REG_TWL_INT_ADRS_TEMP0, // 0x70 - 0x77
REG_TWL_INT_ADRS_TEMP1, // REG_TWL_INT_ADRS_TEMP1,
REG_TWL_INT_ADRS_TEMP2, // REG_TWL_INT_ADRS_TEMP2,
REG_TWL_INT_ADRS_TEMP3, // REG_TWL_INT_ADRS_TEMP3,
REG_TWL_INT_ADRS_TEMP4, // REG_TWL_INT_ADRS_TEMP4,
REG_TWL_INT_ADRS_TEMP5, // REG_TWL_INT_ADRS_TEMP5,
REG_TWL_INT_ADRS_TEMP6, // REG_TWL_INT_ADRS_TEMP6,
REG_TWL_INT_ADRS_TEMP7, // REG_TWL_INT_ADRS_TEMP7,
REG_TWL_INT_ADRS_TIME_PWSW_DELAY, // REG_TWL_INT_ADRS_TIME_PWSW_DELAY,
REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD // REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD
_REG_TWL_INT_ADRS_EDNMARK,
}; };
/* ========================================================================= */ /* ========================================================================= */
extern u8 vreg_twl[ REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD +1 ]; extern u8 vreg_twl[];
@ -101,11 +104,11 @@ extern u8 vreg_twl[ REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD +1 ];
/* ========================================================================= */ /* ========================================================================= */
void vreg_twl_init(); void vreg_twl_init( );
void vreg_twl_write( u8 adrs, u8 data ); void vreg_twl_write( u8 adrs, u8 data );
u8 adrs_table_twl_ext2int( u8 img ); u8 adrs_table_twl_ext2int( u8 img );
u8 vreg_twl_read( u8 phy_adrs ); u8 vreg_twl_read( u8 phy_adrs );
task_status_immed command_from_twl(); task_status_immed command_from_twl( );
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -243,6 +243,325 @@ ZF=0
S=1 S=1
E=0 E=0
CommandFile=0 CommandFile=0
[Options.LK78K0R 0]
Version=100
O0=bsr_k0r.lmf
O1=bsr.lmf
O2=flash.lmf
O3=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_k0r.map
P1=bsr.map
P2=flash.map
P3=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=0
SELFCheck=1
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LK78K0R 1]
Version=100
O0=a.lmf
G=0
E=0
E0=a.elk
GO=0
GOValue=
GOStart=FC00
GOSizeValue=1024
GI=0
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=1
MemInfoCheck=0
P=1
P0=a.map
MI=0
GB=0
GBValue=
KM=1
KD=1
KP=0
KL=0
LF=0
LL=0
S=0
W=1
SELFCheck=0
SELF=0
ZB=
CommandFile=0
[Options.LK78K0R 2]
Version=100
O0=bsr.lmf
O1=bsr_k0r.lmf
O2=flash.lmf
O3=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_k0r.map
P1=bsr.map
P2=flash.map
P3=a.map
MI=0
GB=1
GBValue=7EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=0
SELFCheck=0
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
OFILE=C:\78k_data\yav-mcu-basara\bsr.lmf
[Options.LK78K0R 3]
Version=100
O0=bsr_bsr.lmf
O1=bsr_k0r.lmf
O2=bsr.lmf
O3=flash.lmf
O4=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_bsr.map
P1=bsr_k0r.map
P2=bsr.map
P3=flash.map
P4=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=2
SELFCheck=0
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LK78K0R 4]
Version=100
O0=bsr_k0r.lmf
O1=bsr.lmf
O2=flash.lmf
O3=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_k0r.map
P1=bsr.map
P2=flash.map
P3=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=0
SELFCheck=1
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LK78K0R 5]
Version=100
O0=bsr_bsr.lmf
O1=bsr_k0r.lmf
O2=bsr.lmf
O3=flash.lmf
O4=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_bsr.map
P1=bsr_k0r.map
P2=bsr.map
P3=flash.map
P4=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=2
SELFCheck=0
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LCNV78K0R 0]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 1]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 2]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 3]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 4]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 5]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.78K0R]
BuildMode=2
BuildMode2=K0R_dbg
BuildMode3=BSR_dbg
BuildMode4=BSR_rel
BuildMode5=BSR_WM0
DefaultMode2=1
DefaultMode3=1
DefaultMode4=1
DefaultMode5=1
[IncFile]
Include1=incs_loader.h
Include2=jhl_defs.h
Include3=user_define.h
Include4=config.h
Include5=bsr_system.h
Include6=renge\renge.h
Include7=renge\renge_defs.h
Include8=renge\renge_task_immediate.h
Include9=vreg_ctr.h
Include10=loader.h
Include11=i2c_mcu.h
Include12=WDT.h
Include13=fsl.h
Include14=fsl_user.h
Include15=i2c_ctr.h
Include16=pm.h
Include17=rtc.h
Include18=adc.h
Include19=led.h
Include20=incs.h
Include21=vreg_twl.h
Include22=accero.h
Include23=i2c_twl_defs.h
Include24=renge\renge_task_intval.h
Include25=i2c_twl.h
Include26=..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h
Include27=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h
[Options.CC78K0R 0] [Options.CC78K0R 0]
Version=210 Version=210
Include0=renge,C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r Include0=renge,C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r
@ -709,324 +1028,6 @@ VfiFileBoot0=
VfiFileBoot1=boot.vfi VfiFileBoot1=boot.vfi
VF78K0Rchk=0 VF78K0Rchk=0
VF78K0Rvs= VF78K0Rvs=
[IncFile]
Include1=incs_loader.h
Include2=jhl_defs.h
Include3=user_define.h
Include4=config.h
Include5=bsr_system.h
Include6=renge\renge.h
Include7=renge\renge_defs.h
Include8=renge\renge_task_immediate.h
Include9=vreg_ctr.h
Include10=loader.h
Include11=i2c_mcu.h
Include12=WDT.h
Include13=fsl.h
Include14=fsl_user.h
Include15=i2c_ctr.h
Include16=pm.h
Include17=rtc.h
Include18=adc.h
Include19=led.h
Include20=incs.h
Include21=vreg_twl.h
Include22=accero.h
Include23=i2c_twl_defs.h
Include24=renge\renge_task_intval.h
Include25=i2c_twl.h
Include26=..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h
[Options.LK78K0R 0]
Version=100
O0=bsr_k0r.lmf
O1=bsr.lmf
O2=flash.lmf
O3=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_k0r.map
P1=bsr.map
P2=flash.map
P3=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=0
SELFCheck=1
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LK78K0R 1]
Version=100
O0=a.lmf
G=0
E=0
E0=a.elk
GO=0
GOValue=
GOStart=FC00
GOSizeValue=1024
GI=0
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=1
MemInfoCheck=0
P=1
P0=a.map
MI=0
GB=0
GBValue=
KM=1
KD=1
KP=0
KL=0
LF=0
LL=0
S=0
W=1
SELFCheck=0
SELF=0
ZB=
CommandFile=0
[Options.LK78K0R 2]
Version=100
O0=bsr.lmf
O1=bsr_k0r.lmf
O2=flash.lmf
O3=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_k0r.map
P1=bsr.map
P2=flash.map
P3=a.map
MI=0
GB=1
GBValue=7EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=0
SELFCheck=0
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
OFILE=C:\78k_data\yav-mcu-basara\bsr.lmf
[Options.LK78K0R 3]
Version=100
O0=bsr_bsr.lmf
O1=bsr_k0r.lmf
O2=bsr.lmf
O3=flash.lmf
O4=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_bsr.map
P1=bsr_k0r.map
P2=bsr.map
P3=flash.map
P4=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=2
SELFCheck=0
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LK78K0R 4]
Version=100
O0=bsr_k0r.lmf
O1=bsr.lmf
O2=flash.lmf
O3=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_k0r.map
P1=bsr.map
P2=flash.map
P3=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=0
SELFCheck=1
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LK78K0R 5]
Version=100
O0=bsr_bsr.lmf
O1=bsr_k0r.lmf
O2=bsr.lmf
O3=flash.lmf
O4=a.lmf
G=1
E=0
E0=flash.elk
E1=a.elk
GO=1
GOValue=85
GOStart=FC00
GOSizeValue=1024
GI=1
GIValue=FFFFFFFFFFFFFFFFFFFF
CCZA=0
MemInfoCheck=1
P=1
P0=bsr_bsr.map
P1=bsr_k0r.map
P2=bsr.map
P3=flash.map
P4=a.map
MI=0
GB=1
GBValue=6EFBFF
KM=1
KD=0
KP=1
KL=0
LF=0
LL=0
B0=C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib
D0=bsr_mcu.dr
D1=user_area.dr
S=1
W=2
SELFCheck=0
SELF=0
ZB=
Etcetera0=
Etcetera1=boot.lmf
CommandFile=0
[Options.LCNV78K0R 0]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 1]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 2]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 3]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 4]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.LCNV78K0R 5]
Version=100
LCNV_GO=0
E=0
CommandFile=0
[Options.78K0R]
BuildMode=2
BuildMode2=K0R_dbg
BuildMode3=BSR_dbg
BuildMode4=BSR_rel
BuildMode5=BSR_WM0
DefaultMode2=1
DefaultMode3=1
DefaultMode4=1
DefaultMode5=1
[ToolSet] [ToolSet]
ToolSetName=(•Ï<E280A2>X)78K0R Software Package V1.10 ToolSetName=(•Ï<E280A2>X)78K0R Software Package V1.10
Tool1=CC78K0R|W2.10 Tool1=CC78K0R|W2.10

View File

@ -1,15 +1,25 @@
[ProjectManager] [ProjectManager]
FrameMax=1 FrameMax=0
FrameX=102 FrameX=110
FrameY=62 FrameY=74
FrameCX=1503 FrameCX=1376
FrameCY=631 FrameCY=1066
OpenFile1=i2c_mcu.c,0,330,330,1204,1087,48,321,48,0 OpenFile1=i2c_mcu.c,0,330,330,1204,1087,48,321,48,0
OpenFile2=renge\\renge_defs.h,0,330,330,1574,1087,0,47,0,0 OpenFile2=renge\\renge_defs.h,0,330,330,1574,1087,0,47,0,0
OpenFile3=ProjectWindow OpenFile3=user_define.h,0,176,176,1420,933,0,33,20,0
OpenFile4=vreg_ctr.c,0,345,273,1060,932,0,47,0,0
OpenFile5=i2c_ctr.c,0,242,242,1425,868,0,116,0,0
OpenFile6=led.c,0,286,286,1469,912,0,454,21,0
OpenFile7=rtc.c,0,308,308,1491,934,0,31,17,0
OpenFile8=tasks_sys.c,0,220,220,1403,846,16,392,17,0
OpenFile9=loader.c,0,264,264,1447,890,0,139,0,0
OpenFile10=magic.c,0,242,242,1486,999,3,8,0,0
OpenFile11=adc.c,0,166,66,1349,692,0,210,0,0
OpenFile12=accero.c,0,154,154,1398,911,25,119,0,0
OpenFile13=pm.c,0,88,88,1144,747,50,218,32,0
OpenFile14=ProjectWindow
PrjPos=0,2,754,3,253 PrjPos=0,2,754,3,253
OpenFile4=config.h,0,168,78,1412,835,0,14,21,0 OpenFile15=OutputWindow
OpenFile5=OutputWindow
OutputPos=0,67,1023,707,1568 OutputPos=0,67,1023,707,1568
ActivePRJ=yav_mcu_bsr.prj ActivePRJ=yav_mcu_bsr.prj
[ProjectWindow] [ProjectWindow]

View File

@ -1,7 +1,7 @@
[SdbInfo] [SdbInfo]
Ver=5 Ver=5
[loader.c] [loader.c]
T=4ac169a4 T=4adbffdf
1=incs_loader.h 1=incs_loader.h
2=fsl.h 2=fsl.h
3=fsl_user.h 3=fsl_user.h
@ -10,47 +10,47 @@ T=4ac169a4
6=pm.h 6=pm.h
7=rtc.h 7=rtc.h
[pm.c] [pm.c]
T=4ac09552 T=4adc1fa6
1=incs_loader.h 1=incs.h
2=adc.h 2=adc.h
3=led.h 3=led.h
4=pm.h 4=pm.h
[i2c_ctr.c] [i2c_ctr.c]
T=4ac07479 T=4aca8ef0
1=incs.h 1=incs.h
[main.c] [main.c]
T=4ac0af62 T=4aca8ef0
1=incs.h 1=incs.h
2=WDT.h 2=WDT.h
3=rtc.h 3=rtc.h
4=pm.h 4=pm.h
5=accero.h 5=accero.h
[magic.c] [magic.c]
T=4ac01920 T=4ad3e9ff
1=config.h 1=config.h
[WDT.c] [WDT.c]
T=4a9e6e71 T=4aca8ef0
1=incs_loader.h 1=incs_loader.h
[i2c_mcu.c] [i2c_mcu.c]
T=4ac0b193 T=4ad70c7e
1=incs.h 1=incs.h
2=i2c_mcu.h 2=i2c_mcu.h
[i2c_twl.c] [i2c_twl.c]
T=4ac07a54 T=4aca8ef0
1=incs.h 1=incs.h
2=i2c_twl_defs.h 2=i2c_twl_defs.h
[ini_VECT.c] [ini_VECT.c]
T=4ac169a4 T=4adc1fec
1=config.h 1=config.h
[led.c] [led.c]
T=4ac15aa7 T=4adc1fee
1=incs.h 1=incs.h
2=led.h 2=led.h
[rtc.c] [rtc.c]
T=4ac1c178 T=4ad42ad0
1=incs.h 1=incs.h
[vreg_ctr.c] [vreg_ctr.c]
T=4ac1a405 T=4adbcc88
1=incs.h 1=incs.h
2=vreg_ctr.h 2=vreg_ctr.h
3=rtc.h 3=rtc.h
@ -58,30 +58,30 @@ T=4ac1a405
5=accero.h 5=accero.h
6=pm.h 6=pm.h
[vreg_twl.c] [vreg_twl.c]
T=4ab332c7 T=4ad6dc31
1=incs.h 1=incs.h
2=jhl_defs.h 2=jhl_defs.h
3=vreg_twl.h 3=vreg_twl.h
[tasks.c] [tasks.c]
T=4ac169a4 T=4adc2aa4
1=incs.h 1=incs.h
2=renge\renge.h 2=renge\renge.h
3=pm.h 3=pm.h
[adc.c] [adc.c]
T=4ac15aa7 T=4aca9609
1=incs.h 1=incs.h
2=adc.h 2=adc.h
3=pm.h 3=pm.h
4=led.h 4=led.h
[renge\renge.c] [renge\renge.c]
T=4ac0a6c5 T=4ac96eb4
1=renge\renge_defs.h 1=renge\renge_defs.h
2=renge\renge_task_intval.h 2=renge\renge_task_intval.h
3=renge\renge_task_immediate.h 3=renge\renge_task_immediate.h
4=WDT.h 4=WDT.h
5=bsr_system.h 5=bsr_system.h
[tasks_sys.c] [tasks_sys.c]
T=4ac1a252 T=4ad42ad0
1=incs.h 1=incs.h
2=i2c_twl.h 2=i2c_twl.h
3=i2c_ctr.h 3=i2c_ctr.h
@ -90,16 +90,17 @@ T=4ac1a252
6=pm.h 6=pm.h
7=rtc.h 7=rtc.h
[accero.c] [accero.c]
T=4ac1a5fc T=4adc2c13
1=incs.h 1=incs.h
2=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h
[self_flash.c] [self_flash.c]
T=4ac07a54 T=4aca8ef0
1=incs_loader.h 1=incs_loader.h
2=..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h 2=..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h
3=fsl_user.h 3=fsl_user.h
4=i2c_ctr.h 4=i2c_ctr.h
[incs_loader.h] [incs_loader.h]
T=4a9e6e71 T=4aca8c17
1=jhl_defs.h 1=jhl_defs.h
2=user_define.h 2=user_define.h
3=bsr_system.h 3=bsr_system.h
@ -109,50 +110,50 @@ T=4a9e6e71
7=i2c_mcu.h 7=i2c_mcu.h
8=WDT.h 8=WDT.h
[jhl_defs.h] [jhl_defs.h]
T=4ab3330b T=4aca8c17
[user_define.h] [user_define.h]
T=4ac1a76f T=4adc252d
1=config.h 1=config.h
[config.h] [config.h]
T=4ac1d2cd T=4adc2bf0
[bsr_system.h] [bsr_system.h]
T=4ac09552 T=4aca8c17
[renge\renge.h] [renge\renge.h]
T=4abc82ef T=4abc82ef
1=renge\renge_defs.h 1=renge\renge_defs.h
2=renge\renge_task_immediate.h 2=renge\renge_task_immediate.h
[renge\renge_defs.h] [renge\renge_defs.h]
T=4aa79102 T=4ac96e5c
[renge\renge_task_immediate.h] [renge\renge_task_immediate.h]
T=4a8a7575 T=4ad68780
1=renge\renge_defs.h 1=renge\renge_defs.h
[vreg_ctr.h] [vreg_ctr.h]
T=4ac14c41 T=4ad68b93
1=config.h 1=config.h
[loader.h] [loader.h]
T=4a7a31d0 T=4aca8c17
1=jhl_defs.h 1=jhl_defs.h
[i2c_mcu.h] [i2c_mcu.h]
T=4a9e6e71 T=4aca8c17
[WDT.h] [WDT.h]
T=4a9e6e71 T=4aca8c17
[fsl.h] [fsl.h]
T=47ec5c12 T=4aca8c17
[fsl_user.h] [fsl_user.h]
T=4a7bf458 T=4aca8c17
[i2c_ctr.h] [i2c_ctr.h]
T=4a7c0777 T=4aca8c17
[pm.h] [pm.h]
T=4ab47f83 T=4ad7efd5
[rtc.h] [rtc.h]
T=4ab48e99 T=4aca8c17
[adc.h] [adc.h]
T=4aa74fb6 T=4aca8c17
1=jhl_defs.h 1=jhl_defs.h
[led.h] [led.h]
T=4ac15aa7 T=4aca8c17
[incs.h] [incs.h]
T=4ac0857f T=4aca8c17
1=jhl_defs.h 1=jhl_defs.h
2=user_define.h 2=user_define.h
3=bsr_system.h 3=bsr_system.h
@ -162,16 +163,18 @@ T=4ac0857f
7=i2c_mcu.h 7=i2c_mcu.h
8=rtc.h 8=rtc.h
[vreg_twl.h] [vreg_twl.h]
T=4aa79c31 T=4ad6dc31
[accero.h] [accero.h]
T=4aa7853b T=4aca8c17
1=jhl_defs.h 1=jhl_defs.h
[i2c_twl_defs.h] [i2c_twl_defs.h]
T=4a7c074e T=4aca8c17
[renge\renge_task_intval.h] [renge\renge_task_intval.h]
T=4ab226cf T=4ac9ab84
1=renge\renge_defs.h 1=renge\renge_defs.h
[i2c_twl.h] [i2c_twl.h]
T=4a7c0786 T=4aca8c17
[..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h] [..\..\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r\fsl.h]
T=49a3bd4e T=49a3bd4e
[..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h]
T=45f12258