ファイル忘れ

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@449 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
n2232 2012-01-26 08:24:30 +00:00
parent 683798248a
commit 28b0f560a9
4 changed files with 153 additions and 17 deletions

View File

@ -0,0 +1,120 @@
/* ========================================================
I2C使
de JHL
'09 Feb -
$Id$
======================================================== */
#ifndef _WIN32
#pragma sfr
#pragma di
#pragma ei
#pragma nop
#pragma inline // memcpy()をインライン展開する(の方が小さい!)
#endif
#include "incs.h"
#include "i2c_mcu.h"
#include "loader.h"
#include "util_funcs.h"
#include "i2c_mcu_sub.h"
#include "pm.h" /// やりたくなかった…CODECのレジスタ名をひくため
// ========================================================
// ワークアラウンド用
static void iic_mcu_simple_dummy_write();
static i2c_err iic_mcu_codec_write_low( u8 adrs, u8 dat );
// i2c_mcu.c にいる
extern void iic_mcu_send_re_st( );
extern void iic_mcu_send_sp( );
extern i2c_err iic_mcu_send_a_byte( u8 );
extern i2c_err iic_mcu_call_slave( u8 slave );
/*
yamaha codecから不用意に割り込みが入ることがあるが
*/
/********************************************//**
iic_mcu_write_a_byte CODEC不具合ワークアラウンド
***********************************************/
#define YAMAHA_CODEC_ERRATA_CHECK_MASK ( 0x7D )
i2c_err iic_mcu_write_a_byte_codec( u8 adrs, u8 dat )
{
u8 pm_reg_original;
i2c_err rv;
// ヤマハcodecワークアラウンド SPIとの共用レジスタの中身を取得
if(( rv = iic_mcu_read( IIC_SLA_CODEC, CODEC_REG_PM, 1, &pm_reg_original )) != I2C_ERR_OK )
{
return( rv );
}
// phase1 ここまで
// 書き込み!
if( ( rv = iic_mcu_codec_write_low( adrs, dat ) ) != I2C_ERR_OK )
{
return( rv );
}
// ヤマハcodecワークアラウンド
if( ( pm_reg_original & YAMAHA_CODEC_ERRATA_CHECK_MASK ) == 0 ) // はじめから共有レジスタが0だったらテストもしない
// (& リセット要求が立ってたらどうせリセットかかるので)
{
return( I2C_ERR_OK );
}
{
// 共有レジスタが 0x00 に書き換わっている(エラッタ発生!)ようなら書き戻す
u8 pm_reg_after;
if(( rv = iic_mcu_read( IIC_SLA_CODEC, CODEC_REG_PM, 1, &pm_reg_after )) != I2C_ERR_OK )
{
return( rv );
}
if( ( pm_reg_after & YAMAHA_CODEC_ERRATA_CHECK_MASK ) != 0x00 )
{
// コンフリクトはなかった or リセット要求など
return( I2C_ERR_OK );
}
// else {
rv = iic_mcu_codec_write_low( CODEC_REG_PM, pm_reg_original ); // 書き戻すが、再チェックはしない
return ( rv ); // エラーが返ることもあるかも
// リトライなどは無し
}
return( rv ); // no reach //
}
static i2c_err iic_mcu_codec_write_low( u8 adrs, u8 dat )
{
IICMK10 = 1; // DMA用のISRに飛ばさないためにマスク
if( iic_mcu_call_slave( IIC_SLA_CODEC ) != I2C_ERR_OK )
{
iic_mcu_busy = false;
return ( I2C_ERR_NOSLAVE );
}
iic_mcu_send_a_byte( adrs );
iic_mcu_send_a_byte( dat );
// TIワークアラウンド
// re-stでダミーライト
{
iic_mcu_send_re_st( );
iic_mcu_send_a_byte( IIC_SLA_CODEC ); // ダミーライト
iic_mcu_send_a_byte( 0x20 ); // ゴミを書いても問題ないアドレス
iic_mcu_send_a_byte( 0xAA ); // 何でもよい
}
iic_mcu_send_sp( );
iic_mcu_busy = false;
return( I2C_ERR_OK );
}

View File

@ -0,0 +1,6 @@
#ifndef __ic2_mcu_sub__
#define __ic2_mcu_sub__
i2c_err iic_mcu_write_a_byte_codec( u8 adrs, u8 dat );
#endif

View File

@ -2,8 +2,8 @@
FrameMax=1
FrameX=4
FrameY=0
FrameCX=1235
FrameCY=1076
FrameCX=1022
FrameCY=722
OpenFile1=i2c_ctr.c,0,655,120,1628,751,0,1,0,0
OpenFile2=kanaria_c.c,0,68,138,763,769,8,5,8,0
OpenFile3=pm.c,0,373,197,1346,828,35,374,32,0
@ -17,8 +17,8 @@ OpenFile10=ProjectWindow
PrjPos=0,0,706,0,291
OpenFile11=batt_params.c,0,444,408,1697,1063,28,2,59,0
OpenFile12=OutputWindow
OutputPos=0,419,870,220,1483
OpenFile13=config.h,0,458,11,1285,414,22,21,22,0
OutputPos=0,231,682,640,1903
OpenFile13=config.h,0,458,11,1285,913,0,34,0,0
ActivePRJ=yav_mcu_bsr.prj
[ProjectWindow]
ProjectWindowDispType=0

View File

@ -1,7 +1,7 @@
[SdbInfo]
Ver=5
[loader.c]
T=4ee0527f
T=4f21086c
1=incs_loader.h
2=..\..\..\..\Program Files (x86)\NEC Electronics Tools\CC78K0R\W2.13\inc78k0r\fsl.h
3=fsl_user.h
@ -13,7 +13,7 @@ T=4ee0527f
9=WDT.h
10=magic.h
[pm.c]
T=4ee052b1
T=4f210892
1=incs.h
2=adc.h
3=led.h
@ -25,7 +25,7 @@ T=4ee052b1
9=vreg_twl.h
10=i2c_mcu.h
[i2c_ctr.c]
T=4ee051c8
T=4f210850
1=incs.h
2=rtc.h
3=pedometer.h
@ -40,27 +40,27 @@ T=4ee051c8
7=i2c_mcu.h
8=pool.h
[magic.c]
T=4ee051c8
T=4f210988
1=magic.h
2=config.h
[WDT.c]
T=4ee051c7
1=incs_loader.h
[i2c_mcu.c]
T=4ee051c7
T=4f210789
1=incs_loader.h
2=i2c_mcu.h
3=loader.h
4=util_funcs.h
[i2c_twl.c]
T=4ee051c7
T=4f21092e
1=incs.h
2=i2c_twl_defs.h
3=i2c_twl.h
4=vreg_twl.h
5=WDT.h
[led.c]
T=4ee05227
T=4f210938
1=incs.h
2=led.h
[rtc.c]
@ -88,7 +88,7 @@ T=4ee051c7
4=vreg_twl.h
5=adc.h
[adc.c]
T=4ee0528c
T=4f2106e3
1=incs.h
2=adc.h
3=pm.h
@ -106,7 +106,7 @@ T=4ee051c6
7=util_funcs.h
8=bsr_system.h
[accero.c]
T=4ee051c7
T=4f210858
1=incs.h
2=accero.h
3=i2c_mcu.h
@ -139,7 +139,7 @@ T=4ee051c8
3=pm.h
4=accero.h
[task_misc.c]
T=4ee051c7
T=4f2108a1
1=incs.h
2=renge\renge.h
3=pm.h
@ -149,7 +149,7 @@ T=4ee051c7
7=led.h
8=vreg_twl.h
[task_sys.c]
T=4ee052ba
T=4f2108dd
1=incs.h
2=i2c_twl.h
3=i2c_ctr.h
@ -173,7 +173,7 @@ T=4ee051c8
T=4ee051c7
1=config.h
[task_status.c]
T=4ee052cc
T=4f2106e4
1=incs_loader.h
2=renge\renge.h
3=pm.h
@ -215,6 +215,14 @@ T=4ee051c8
T=4ee051c7
1=incs_loader.h
2=WDT.h
[i2c_mcu-sub.c]
T=4f20dbd3
1=incs.h
2=i2c_mcu.h
3=loader.h
4=util_funcs.h
5=i2c_mcu_sub.h
6=pm.h
[incs_loader.h]
T=4ee051c8
1=jhl_defs.h
@ -225,7 +233,7 @@ T=4ee051c8
6=vreg_ctr.h
7=vreg_twl.h
[config.h]
T=4ee052f6
T=4f2108e9
[jhl_defs.h]
T=4ee051c7
[user_define.h]
@ -310,3 +318,5 @@ T=4ee051c7
T=49a3bd4e
[..\..\..\..\Program Files (x86)\NEC Electronics Tools\CC78K0R\W2.13\inc78k0r\math.h]
T=45f12258
[i2c_mcu_sub.h]
T=4f17bb6c