mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-10-31 13:51:10 -04:00
i2c_mcu-sub.c に一部を移した(ROM不足)
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@434 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
parent
67029ac2f5
commit
9782795665
@ -137,7 +137,7 @@ task_status_immed tski_cbk_accero( )
|
||||
}
|
||||
if( (( system_status.pwr_state == ON )
|
||||
||( system_status.pwr_state == SLEEP ))
|
||||
&&( ( vreg_ctr[VREG_C_ACC_CONFIG] & VREG_BITMASK_ACC_CONF_HOSU ) != 0 ))
|
||||
&&( vreg_ctr[VREG_C_ACC_CONFIG] & VREG_BITMASK_ACC_CONF_HOSU ))
|
||||
{
|
||||
pedometer(); // •à<E280A2>”Œv
|
||||
}
|
||||
|
||||
113
trunk/i2c_mcu-sub.c
Normal file
113
trunk/i2c_mcu-sub.c
Normal file
@ -0,0 +1,113 @@
|
||||
/* ========================================================
|
||||
簡易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から不用意に割り込みが入ることがあるが、タスクが登録されて
|
||||
実際に読み出すときには書き戻した後なので何事もなかったように動くはず
|
||||
*/
|
||||
|
||||
/********************************************//**
|
||||
コーデックに 『1バイト』 ライト
|
||||
|
||||
iic_mcu_write_a_byte CODEC不具合ワークアラウンド
|
||||
***********************************************/
|
||||
i2c_err iic_mcu_write_a_byte_codec( u8 adrs, u8 dat )
|
||||
{
|
||||
u8 pm_reg_original;
|
||||
u8 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( dat != 0 ) // 書き込むのが0だったらチェックもしない
|
||||
{
|
||||
// 共有レジスタが 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 & 0x7C ) != 0x00 )
|
||||
{
|
||||
return( I2C_ERR_OK );
|
||||
}
|
||||
|
||||
// else {
|
||||
return iic_mcu_codec_write_low( CODEC_REG_PM, pm_reg_original );
|
||||
// リトライなどは無し
|
||||
}
|
||||
return( I2C_ERR_OK );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
6
trunk/i2c_mcu_sub.h
Normal file
6
trunk/i2c_mcu_sub.h
Normal 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
|
||||
@ -11,16 +11,15 @@ OpenFile4=accero.c,0,200,200,1016,818,109,227,2,0
|
||||
OpenFile5=i2c_mcu.h,0,671,375,1487,993,16,7,16,0
|
||||
OpenFile6=task_sys.c,0,225,225,1471,947,0,445,0,0
|
||||
OpenFile7=loader.c,0,250,250,1841,957,6,157,1,0
|
||||
OpenFile8=i2c_mcu.c,0,175,175,1036,939,1,453,1,0
|
||||
OpenFile9=ProjectWindow
|
||||
OpenFile8=main.c,0,402,105,1713,812,0,57,0,0
|
||||
OpenFile9=batt_params.c,0,300,300,1553,955,0,68,0,0
|
||||
OpenFile10=task_misc.c,0,141,193,1732,900,2,271,2,0
|
||||
OpenFile11=i2c_mcu.c,0,335,94,1196,858,0,22,0,0
|
||||
OpenFile12=ProjectWindow
|
||||
PrjPos=0,0,706,0,291
|
||||
OpenFile10=main.c,0,402,105,1713,812,0,57,0,0
|
||||
OpenFile11=batt_params.c,0,300,300,1553,955,0,68,0,0
|
||||
OpenFile12=OutputWindow
|
||||
OutputPos=0,419,870,220,1483
|
||||
OpenFile13=config.h,0,1009,32,1836,435,0,20,27,0
|
||||
OpenFile14=task_misc.c,0,141,193,1732,900,2,271,2,0
|
||||
OpenFile15=config.h,0,300,300,1891,1007,34,13,34,0
|
||||
OpenFile13=config.h,0,300,300,1891,1007,29,10,29,0
|
||||
OpenFile14=OutputWindow
|
||||
OutputPos=0,231,682,640,1903
|
||||
ActivePRJ=yav_mcu_bsr.prj
|
||||
[ProjectWindow]
|
||||
ProjectWindowDispType=0
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[SdbInfo]
|
||||
Ver=5
|
||||
[loader.c]
|
||||
T=4e8a69fb
|
||||
T=4f13d431
|
||||
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=4e8a69fb
|
||||
9=WDT.h
|
||||
10=magic.h
|
||||
[pm.c]
|
||||
T=4e9fab22
|
||||
T=4f13ba15
|
||||
1=incs.h
|
||||
2=adc.h
|
||||
3=led.h
|
||||
@ -25,7 +25,7 @@ T=4e9fab22
|
||||
9=vreg_twl.h
|
||||
10=i2c_mcu.h
|
||||
[i2c_ctr.c]
|
||||
T=4e8a71ec
|
||||
T=4f13d407
|
||||
1=incs.h
|
||||
2=rtc.h
|
||||
3=pedometer.h
|
||||
@ -40,27 +40,28 @@ T=4e647b08
|
||||
7=i2c_mcu.h
|
||||
8=pool.h
|
||||
[magic.c]
|
||||
T=4e9fa5d9
|
||||
T=4f13d3cb
|
||||
1=magic.h
|
||||
2=config.h
|
||||
[WDT.c]
|
||||
T=4e649146
|
||||
1=incs_loader.h
|
||||
[i2c_mcu.c]
|
||||
T=4e687586
|
||||
T=4eeed909
|
||||
1=incs_loader.h
|
||||
2=i2c_mcu.h
|
||||
3=loader.h
|
||||
4=util_funcs.h
|
||||
5=i2c_mcu_sub.h
|
||||
[i2c_twl.c]
|
||||
T=4e8a71df
|
||||
T=4f13d40f
|
||||
1=incs.h
|
||||
2=i2c_twl_defs.h
|
||||
3=i2c_twl.h
|
||||
4=vreg_twl.h
|
||||
5=WDT.h
|
||||
[led.c]
|
||||
T=4eaf9ab6
|
||||
T=4f13d418
|
||||
1=incs.h
|
||||
2=led.h
|
||||
[rtc.c]
|
||||
@ -88,7 +89,7 @@ T=4e6491f4
|
||||
4=vreg_twl.h
|
||||
5=adc.h
|
||||
[adc.c]
|
||||
T=4e6dc5ed
|
||||
T=4f13b7b7
|
||||
1=incs.h
|
||||
2=adc.h
|
||||
3=pm.h
|
||||
@ -107,7 +108,7 @@ T=4e77e344
|
||||
8=sim\simOnWin.h
|
||||
9=bsr_system.h
|
||||
[accero.c]
|
||||
T=4e687ab8
|
||||
T=4f13b810
|
||||
1=incs.h
|
||||
2=accero.h
|
||||
3=i2c_mcu.h
|
||||
@ -140,7 +141,7 @@ T=4e647e9c
|
||||
3=pm.h
|
||||
4=accero.h
|
||||
[task_misc.c]
|
||||
T=4e72a3d0
|
||||
T=4f13d472
|
||||
1=incs.h
|
||||
2=renge\renge.h
|
||||
3=pm.h
|
||||
@ -150,7 +151,7 @@ T=4e72a3d0
|
||||
7=led.h
|
||||
8=vreg_twl.h
|
||||
[task_sys.c]
|
||||
T=4e8a6ae1
|
||||
T=4f13d6f6
|
||||
1=incs.h
|
||||
2=i2c_twl.h
|
||||
3=i2c_ctr.h
|
||||
@ -175,7 +176,7 @@ T=4e6864d2
|
||||
1=config.h
|
||||
2=sim\sim_interrupt_decrare.c
|
||||
[task_status.c]
|
||||
T=4e6495df
|
||||
T=4f13bd49
|
||||
1=incs_loader.h
|
||||
2=renge\renge.h
|
||||
3=pm.h
|
||||
@ -197,7 +198,7 @@ T=4e648b74
|
||||
T=4e648ec7
|
||||
1=incs_loader.h
|
||||
[batt_params.c]
|
||||
T=4e814b22
|
||||
T=4f13b94e
|
||||
1=jhl_defs.h
|
||||
2=batt_params.h
|
||||
[voltable.c]
|
||||
@ -217,6 +218,14 @@ T=4e5223c3
|
||||
T=4e68724a
|
||||
1=incs_loader.h
|
||||
2=WDT.h
|
||||
[i2c_mcu-sub.c]
|
||||
T=4f0ba5c2
|
||||
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=4e646cef
|
||||
1=sim\simOnWin.h
|
||||
@ -234,7 +243,7 @@ T=4e559884
|
||||
T=4e5b0fa2
|
||||
1=config.h
|
||||
[config.h]
|
||||
T=4e9fab22
|
||||
T=4f13d3c9
|
||||
[jhl_defs.h]
|
||||
T=4e647343
|
||||
[user_define.h]
|
||||
@ -260,7 +269,7 @@ T=4d42202e
|
||||
[loader.h]
|
||||
T=4e646df6
|
||||
[i2c_mcu.h]
|
||||
T=4e55a31b
|
||||
T=4eeeb6a7
|
||||
[WDT.h]
|
||||
T=4c319dfc
|
||||
[..\..\..\Program Files (x86)\NEC Electronics Tools\CC78K0R\W2.13\inc78k0r\fsl.h]
|
||||
@ -322,3 +331,5 @@ T=4bf0d1e0
|
||||
T=4e409e19
|
||||
[util_funcs.h]
|
||||
T=4e687249
|
||||
[i2c_mcu_sub.h]
|
||||
T=4eeed7e6
|
||||
|
||||
Loading…
Reference in New Issue
Block a user