コメント等修正

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@4 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
fujita_ryohei 2009-08-19 10:46:54 +00:00
parent 047644344a
commit 0c0ecf9023
28 changed files with 345 additions and 331 deletions

View File

@ -1,8 +1,14 @@
#pragma sfr
#include "incs_loader.h"
//=========================================================
// ウォッチドッグタイマのリスタート
// 0xACはマジック
void WDT_Restart( void ){
WDTE = 0xAC; // restart watch dog timer
WDTE = WDT_RESTART_MAGIC;
}

View File

@ -1,8 +1,18 @@
#ifndef _WDT_
#define _WDT_
#define mcu_reset WDTE = 0x5A
//=========================================================
#define WDT_RESTART_MAGIC 0xAC
//=========================================================
void WDT_Restart(void);
// 規定値以外を書くと例外でリセットがかかる
#define mcu_reset WDTE = 0x5A
#endif

View File

@ -1,10 +1,10 @@
/*****************************************************************************
/* ========================================================
 
CPUに割り込み
I2Cの競合回避などがあるので
*****************************************************************************/
======================================================== */
#pragma SFR
#pragma NOP
#pragma HALT
@ -13,6 +13,7 @@
#include "incs.h"
// ========================================================
// レジスタ名
#define ACC_REG_WHOAMI 0x0F
#define ACC_REG_CTRL1 0x20
@ -40,7 +41,8 @@
#define ACC_BITS_ALL_AXIS_ON 7
//*************************************
// ========================================================
u8 hosu_mode = 0;
/*
0: power down
@ -48,12 +50,12 @@ u8 hosu_mode = 0;
*/
/*****************************************************************************
/* ========================================================
 
I2Cが使用中だったら
*****************************************************************************/
======================================================== */
task_status_immed tsk_cbk_accero(){ // 疑似isrから登録されます
static u8 sequence;
u8* dest_adrs;
@ -103,6 +105,7 @@ task_status_immed acc_read(){
}
/*=========================================================
  
========================================================*/
@ -114,11 +117,12 @@ task_status_immed acc_write(){
}
/*****************************************************************************
/*=========================================================
 
todo
*****************************************************************************/
========================================================*/
err accero_hosu_start(){
u8 temp;
u8 err;

View File

@ -1,10 +1,8 @@
/******************************************************************************
ÎPMIC_TWL2 I2CÊ<EFBFBD>M
de JHL ¡c<EFBFBD>ŠJZ
/* ========================================================
ˇc<EFBFBD>ŠJZ
nintendo
'09 Apr
*******************************************************************************/
======================================================== */
#include "incs_loader.h"
#include "adc.h"
#include "pm.h"
@ -16,7 +14,7 @@
bit adc_updated;
/******************************************************************************
/* ========================================================
ADC設定と
@ -29,7 +27,7 @@ bit adc_updated;
8tics毎に呼ばれADCを停止します
 
******************************************************************************/
======================================================== */
task_interval tsk_adc(){
static u8 old_3ddepth;
static u8 old_sndvol;
@ -96,10 +94,10 @@ task_interval tsk_adc(){
/******************************************************************************
/* ========================================================
 
  
*******************************************************************************/
======================================================== */
/*
static u8 average( u8* dat ){
static u8 ind;
@ -153,9 +151,9 @@ __interrupt void int_adc(){
/******************************************************************************
/* ========================================================
tsk_adcと競合することを考慮していません
*******************************************************************************/
======================================================== */
u16 get_adc( u8 ch ){
u16 temp;

View File

@ -3,10 +3,17 @@
#define _debug_
#define MCU_VER_MAJOR 0;
#define MCU_VER_MINOR 1;
#define _MODEL_TEG2_
//#define _MODEL_WM0_
//define _MODEL_CTR_
#ifdef _MODEL_TEG2_
#define _PMIC_TWL_
#define _MCU_KE3_
@ -25,8 +32,5 @@
#endif
#define MCU_VER_MAJOR 0;
#define MCU_VER_MINOR 1;
#endif

View File

@ -1,8 +1,8 @@
/******************************************************************************
/* ========================================================
SoC I2C通信
de JHL ¡c<EFBFBD>ŠJZ.nintendo
ˇc<EFBFBD>ŠJZ.nintendo
'09 Apr
*******************************************************************************/
======================================================== */
#include "incs_loader.h"
// u16 tot;
@ -72,8 +72,10 @@
#endif
/*****************************************************************************
*****************************************************************************/
/* ========================================================
======================================================== */
enum{
IIC_IDLE = 0,
IIC_RCV_REG_ADRS,
@ -233,7 +235,7 @@ __interrupt void int_iic_ctr(){
/*****************************************************/
// ========================================================
void IIC_ctr_Init( void ){
IICAEN = 1;
@ -268,7 +270,8 @@ void IIC_ctr_Init( void ){
}
//****************************************************************************
// ========================================================
void IIC_ctr_Stop( void ){
IICE = 0; /* IICA disable */
IICAEN = 0;

View File

@ -1,8 +1,8 @@
/******************************************************************************
/* ========================================================
I2C使
de JHL
'09 Feb -
*******************************************************************************/
======================================================== */
#pragma sfr
#pragma di
#pragma ei
@ -12,11 +12,9 @@
#include "incs_loader.h"
#include "i2c_mcu.h"
bit iic_mcu_wo_dma;
volatile bit iic_mcu_busy;
volatile bit iic_mcu_initialized;
/*************************************/
// ========================================================
// SSR0n
#define bit_TSF0 6
// SIR0n
@ -35,7 +33,8 @@ volatile bit iic_mcu_initialized;
#define TAUS_MASK 0b0000101100001011;
/*************************************/
// ========================================================
static void iic_mcu_send_st();
static void iic_mcu_send_re_st();
static void iic_mcu_send_sp();
@ -43,7 +42,13 @@ static err iic_mcu_send_a_byte( u8 );
static err iic_mcu_call_slave( u8 slave );
/*************************************/
// ========================================================
bit iic_mcu_wo_dma;
volatile bit iic_mcu_busy;
volatile bit iic_mcu_initialized;
u8 iic_send_work[4];
u8* p_iic_send_wo_dma_dat;
u8 iic_send_wo_dma_len;
@ -53,11 +58,11 @@ u8 iic_mcu_bus_status; //
/**************************************
/* ========================================================
1
*************************************/
======================================================== */
u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ){
#ifdef _debug_
@ -104,7 +109,7 @@ u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ){
/******************************************************************************
/* ========================================================
0
1
@ -113,7 +118,7 @@ u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs ){
******************************************************************************/
======================================================== */
err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8* dest ){
//*
@ -180,14 +185,12 @@ err iic_mcu_read( u8 slave, u8 adrs, u8 len, u8* dest ){
/*****
/* ========================================================
 iic_mcu_write 
使
******************************************************************************/
======================================================== */
err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat ){
while( iic_mcu_busy ){
@ -213,7 +216,7 @@ err iic_mcu_write_a_byte( u8 SLA, u8 adrs, u8 dat ){
/******************************************************************************
/* ========================================================
adrs
*strから
@ -297,11 +300,11 @@ err iic_mcu_write( u8 slave, u8 adrs, u8 len, u8* src ){
/******************************************************************************
/* ========================================================
DMA転送終了割り込み
IIC_mcu
DMA転送が終わっただけでI2Cの転送は終わってません
******************************************************************************/
======================================================== */
__interrupt void int_dma1(){
DMAMK1 = 1;
DEN1 = 0;
@ -312,9 +315,9 @@ __interrupt void int_dma1(){
/***************************************
/* ========================================================
IIC MCUのバイト送出完了割り込み
**************************************/
======================================================== */
__interrupt void int_iic10(){
if( iic_mcu_wo_dma ){
// DMA使用せず、転送途中
@ -350,12 +353,12 @@ __interrupt void int_iic10(){
/******************************************************************************
/* ========================================================
 ACKの確認
ACK                  0
 NACK   1
******************************************************************************/
======================================================== */
static err iic_mcu_call_slave( u8 slave ){
iic_mcu_send_st();
@ -370,11 +373,10 @@ static err iic_mcu_call_slave( u8 slave ){
/**
/* ========================================================
******************************************************************************/
======================================================== */
static err iic_mcu_send_a_byte( u8 dat ){
IICIF10 = 0;
@ -391,10 +393,10 @@ static err iic_mcu_send_a_byte( u8 dat ){
/**
/* ========================================================
*******************************************************************************/
======================================================== */
static void iic_mcu_send_st(){
SO0 &= ~0x0004; // SDA
NOP();
@ -410,9 +412,9 @@ static void iic_mcu_send_st(){
/**
/* ========================================================
*******************************************************************************/
======================================================== */
static void iic_mcu_send_re_st(){
ST0 |= 0x0004;
SO0 |= 0x0400 | TAUS_MASK; // ( SDA = H ), SCL -> H
@ -430,10 +432,10 @@ static void iic_mcu_send_re_st(){
/**
/* ========================================================
*******************************************************************************/
======================================================== */
static void iic_mcu_send_sp(){
ST0 = 0x0004;
SOE0 = 0; // 受信の時はもっと前に「も」設定してる。(NACK出力)
@ -452,10 +454,10 @@ static void iic_mcu_send_sp(){
/**
/* ========================================================
(
******************************************************************************/
======================================================== */
void iic2m_bus_reset(){
/*
u8 count;
@ -477,9 +479,9 @@ void iic2m_bus_reset(){
/**
*
*****************************************************************************/
/* ========================================================
======================================================== */
void iic_mcu_start(){
I2C_PU = 1;
SAU0EN = 1;
@ -500,10 +502,10 @@ void iic_mcu_start(){
/**
*
* 使
*****************************************************************************/
/* ========================================================
使
======================================================== */
void iic_mcu_stop(){
while( iic_mcu_busy ){;} // DMA動作中はもう少し待つ
iic_mcu_send_re_st(); // SCL,SDAをLLにする

View File

@ -2,18 +2,22 @@
#define __ic2_mcu__
//*************************************
// ========================================================
#define ERR_OK 0
#define ERR_NAK 1
#define ERR_NOSLAVE 2
//*************************************
// ========================================================
extern volatile bit iic_mcu_busy;
extern bit iic_mcu_wo_dma;
extern u8 iic_mcu_bus_status;
//*************************************
// ========================================================
err iic_mcu_read( u8 SLA, u8 adrs, u8 len, u8* dest );
u8 iic_mcu_read_a_byte( u8 SLA, u8 adrs );

View File

@ -205,6 +205,7 @@ void IIC_twl_Init( void ){
}
//****************************************************************************
void IIC_twl_Stop( void ){
IICE = 0; /* IICA disable */
@ -213,7 +214,7 @@ void IIC_twl_Stop( void ){
//****************************************************************************
void IIC_twl_SlaveReceiveStart(){
IICE = 1;
LREL = 1;

View File

@ -9,10 +9,11 @@
#pragma section @@CODE ROM_CODE
//#pragma section @@CNST ROM_CNST
//=========================================================
#ifndef _incs_h_
#define _incs_h_
#include "jhl_defs.h"
#include "user_define.h"
@ -24,6 +25,9 @@
#include "i2c_mcu.h"
//=========================================================
err firm_update();
#endif

View File

@ -13,6 +13,9 @@
//#pragma section @@CNST FSL_CNST // セットしてくれない
#pragma section @@CNSTL LDR_CNSL
//=========================================================
#include "jhl_defs.h"
#include "user_define.h"
@ -26,6 +29,9 @@
#include "WDT.h"
//=========================================================
err firm_update();
err firm_restore();

View File

@ -9,7 +9,6 @@ typedef short s16;
typedef unsigned char err;
#define set_bit( cond, reg, pos ) \
{ \
if( cond ){ \

View File

@ -1,3 +1,10 @@
/* ========================================================
LED.c
======================================================== */
#pragma sfr
@ -5,7 +12,7 @@
#include "led.h"
// ****************************************************************************
// ========================================================
// TPS0
#define BIT_PRS01 4
#define BIT_PRS00 0
@ -21,31 +28,29 @@
// ****************************************************************************
// ========================================================
static task_interval led_pow_normal();
static task_interval led_pow_hotaru();
// ****************************************************************************
// ========================================================
u8 wifi_TX;
// ****************************************************************************
// ========================================================
void LED_init(){
/**
PWMのセット
 (P01:/reset2) 
     (  )
     ( )
         
         WiFi
         (32kHz out 使)
         
         
         
*/
TAU0EN = 1;
TPS0 = 1 << BIT_PRS01 | 1 << BIT_PRS00; // マスタークロックはCK01,8M/2/2^4 = 250kHz
@ -74,7 +79,7 @@ void LED_stop(){
/*******************************************************************************
/* ========================================================
// 電源LED
LED_POW_B,R 6,7
@ -96,7 +101,7 @@ enum LED_ILUM_MODE{
LED_POW_ILM_HOTARU,
LED_POW_ILM_CEOFF
};
*******************************************************************************/
======================================================== */
task_interval tsk_led_pow(){
switch( vreg_ctr[ VREG_C_LED_POW_ILUMI ] ){
@ -139,10 +144,10 @@ task_interval tsk_led_pow(){
/*******************************************************************************
/* ========================================================
 
*******************************************************************************/
======================================================== */
static task_interval led_pow_normal(){
static u8 state;
u8 dirty;
@ -192,13 +197,10 @@ static task_interval led_pow_normal(){
/*******************************************************************************
/* ========================================================
*******************************************************************************/
======================================================== */
static task_interval led_pow_hotaru(){
static u8 state;
static u8 delay;
@ -256,8 +258,9 @@ static task_interval led_pow_hotaru(){
}
/*******************************************************************************
*******************************************************************************/
/* ========================================================
======================================================== */
void set_LED_cam(){
if(( vreg_ctr[ VREG_C_CAM_LED ] & 0x01 ) != 0 ){
LED_duty_CAM = vreg_ctr[ VREG_C_LED_BRIGHT ];
@ -275,12 +278,12 @@ void set_LED_cam(){
/*******************************************************************************
/* ========================================================
// LED_Cam TO02 未
// LED_Charge 5     →PM
LED_Wifi,2 3, P24
LED_3D 4
*******************************************************************************/
======================================================== */
task_interval tsk_led_wifi(){
// WiFi LED //
static u8 remain_wifi_tx;
@ -333,10 +336,13 @@ task_interval tsk_led_wifi(){
return( 28 );
}
/*******************************************************************************
/* ========================================================
wifi_TXピン割り込み
LED点滅のフラグ操作のみ
******************************************************************************/
 LED点滅のフラグ操作のみ
  tsk_led_wifi
======================================================== */
__interrupt void intp21_RFTx(){
wifi_TX = 1;
}

View File

@ -1,4 +1,4 @@
/*============================================================================
/* ========================================================
MCU CTR BSR
2009/03/30
@ -6,7 +6,7 @@
============================================================================*/
======================================================== */
#pragma SFR
#pragma di
#pragma ei
@ -27,11 +27,7 @@
#include "magic.h"
/*============================================================================*/
/*============================================================================*/
// ========================================================
#if (FSL_DATA_BUFFER_SIZE>0)
fsl_u08 fsl_data_buffer[FSL_DATA_BUFFER_SIZE];
#endif
@ -56,7 +52,7 @@
/*============================================================================*/
// ========================================================
void FSL_Open(void);
void FSL_Close(void);
void hdwinit(void);
@ -64,7 +60,9 @@ void power_save();
extern void main_loop();
/*============================================================================*/
// ========================================================
void main(){
u16 i = 0;
@ -109,9 +107,9 @@ void main(){
/******************************************************************************
/* ========================================================
******************************************************************************/
======================================================== */
void power_save(){
if( !renge_task_interval_run_force ){
HALT();
@ -120,9 +118,9 @@ void power_save(){
/******************************************************************************
/* ========================================================
******************************************************************************/
======================================================== */
__interrupt void int_kr(){
if( system_status.pwr_state == OFF ){
// 電源onのカウント。特にすることはない
@ -131,23 +129,22 @@ __interrupt void int_kr(){
/******************************************************************************
/* ========================================================
ext dc
******************************************************************************/
======================================================== */
__interrupt void intp4(){
}
/******************************************************************************
/* ========================================================
shell close
******************************************************************************/
======================================================== */
__interrupt void intp5(){
}
/*============================================================================*/
// ========================================================
void hdwinit(void){ // スタートアップルーチンが勝手に呼びます
DI(); /* マスタ割り込み禁止 */

View File

@ -1,6 +1,6 @@
/*****************************************************************************
(touchしてね)
****************************************************************************/
#pragma section @@CNSTL MGC_LOAD AT 0x0FF6
@ -12,4 +12,3 @@ static const unsigned char MGC_HEAD[] = __TIME__;
#pragma section @@CNST MGC_TAIL AT 0x47F6
static const unsigned char MGC_TAIL[] = __TIME__;

View File

@ -1,42 +1,9 @@
/******************************************************************************
/* ========================================================
MCU CTR BSR
2008,2009 nintendo
 
()2
BP_TWL BP (The) back player back processor
======================================================== */
todo:
>1) BL用PWMはスリープに入る時にはOffにしておかないとまずいですよね
> MCUにPMIC I2C Busy
>
> SoCからのPMICへの処理依頼の書き込み終了直後に 1
> PMICへの全通信完了後に 0
> LCD Off時は50msec待っている間もずっと 1
> BL Setting Busy
>
>2) LCD Offの期間 100 msec SoCの起動に 100 msec
> LCD Offシーケンス
> 50 msec LCD Offシーケンス開始からだと合計 150 msec
> SoCからMCUにLCD Off指示
> LCD Onとした場合にOff期間があるかちゃんと計算しておいて
>
>
> Off On
> MCUにLCD On許可
>
> (NITROのスリープで苦労した時間計測もMCUがあれば楽々解決ですね)
OFFシーケンス中にモデルゲージ()
>
>LOWに引っ張ることはないことを保証できないため
*****************************************************************************/
/*
pm_irq
@ -45,7 +12,7 @@ todo:
wl_tx
dbg
*/
//*****************************************************************************
// ========================================================
#include "incs.h"
#include "WDT.h"
@ -55,7 +22,7 @@ todo:
//*****************************************************************************
// ========================================================
err to_sleep();
static void read_dipsw();
@ -64,7 +31,7 @@ unsigned char temp_teg;
extern void power_save();
//*****************************************************************************
// ========================================================
bit active;
bit sleep;
@ -79,9 +46,9 @@ system_status_ system_status;
u8 off_delay; // 電源 OFF から PWSW 等で電源オンする際、押してる時間をカウントするのに使う
/******************************************************************************
/* ========================================================
loader.c
*****************************************************************************/
======================================================== */
void main_loop( void ){
// 電池投入時の1回のみ
@ -120,7 +87,8 @@ void main_loop( void ){
/* ========================================================
======================================================== */
static void read_dipsw(){
// ソフトディップスイッチ読み込み
PU4 |= 0x03; // dip sw 0,1

View File

@ -1,10 +1,9 @@
/******************************************************************************
/* ========================================================
PMIC_TWL2 I2C通信
de JHL
nintendo
'08 Dec
*******************************************************************************/
======================================================== */
#pragma nop
#include "incs_loader.h"
@ -13,11 +12,16 @@
#include "pm.h"
// ========================================================
#define BT_GAUGE_UNLOCK_ADRS 0x3E
#define BT_BT_PARAM_ADRS 0x40
#define BT_BT_PARAM_PANA_RCOMP_ADRS 0x0C
// -1.45 ,-3.9}
// ========================================================
static const u8 BT_BT_PARAM_PANA[64] = {
0xEA, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
@ -31,17 +35,19 @@ static const u8 BT_BT_PARAM_PANA[64] = {
static const u8 BT_BT_PARAM_PANA_RCOMP_AND_PARAM[3] = { 158, 1, 4 }; // RCOMP, TempCoUp, ---Down;
// ========================================================
u16 raw_adc_temperature;
#define _TEG_
/*****************************************************************************
/* ========================================================
 
 (ERR)ERR_SUCCESS
*****************************************************************************/
======================================================== */
err PM_bt_auth(){
/*
todo
@ -53,7 +59,7 @@ err PM_bt_auth(){
/*****************************************************************************
/* ========================================================
 64ROM領域においておきたかったのだが
  DMAがROMRAM領域からしか持ってこられないので
@ -61,7 +67,7 @@ err PM_bt_auth(){
 
 
*****************************************************************************/
======================================================== */
static void BT_set_batt_vend1(){
iic_mcu_write( IIC_SLA_BT_GAUGE,
@ -138,17 +144,19 @@ STOP
}
/*****************************************************************************
/* ========================================================
PMICにリセットコマンドを送る
*****************************************************************************/
======================================================== */
err PM_reset(){
iic_mcu_start();
return( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT, 0x00 ) );
}
/*****************************************************************************
/* ========================================================
PMIC達の初期化
ICのセット
@ -156,8 +164,7 @@ err PM_reset(){
PM_BT_DET,_P
*****************************************************************************/
======================================================== */
void PM_init(){
u8 temp;
u8 result;
@ -216,11 +223,11 @@ void PM_init(){
/*****************************************************************************
/* ========================================================
raw_adc_temperatureに入っている値を
ICにセット
*****************************************************************************/
======================================================== */
err PM_bt_temp_update(){
static u8 temp_threash_hi, temp_threash_lo;
u8 temp[2];
@ -251,9 +258,9 @@ End If
/*****************************************************************************
/* ========================================================
*****************************************************************************/
======================================================== */
#ifdef _PMIC_TWL_
err PM_LCD_on(){
PM_TEG_LCD_OFF = 0;
@ -305,7 +312,7 @@ err PM_LCD_off(){
/*****************************************************************************
/* ========================================================
0
1
@ -313,11 +320,7 @@ err PM_LCD_off(){
POW_CONT1,2 TEG電源のみ
*****************************************************************************/
======================================================== */
err PM_sys_pow_on(){
#ifndef _PMIC_TWL_
u8 temp;
@ -390,9 +393,9 @@ err PM_sys_pow_on(){
/*****************************************************************************
OFFシーケンス
*****************************************************************************/
/* ========================================================
OFFシーケンス
======================================================== */
err PM_sys_pow_off(){
#ifdef _PMIC_CTR_
RSTB
@ -425,9 +428,9 @@ err PM_sys_pow_off(){
/*****************************************************************************
*****************************************************************************/
/* ========================================================
======================================================== */
err to_sleep(){
PM_LCD_off();
return 0;
@ -435,7 +438,7 @@ err to_sleep(){
/*****************************************************************************
/* ========================================================
@ -450,9 +453,7 @@ err to_sleep(){
BT_TEMP,_P tsk_ADC
PM_EXTDCは割り込みメインにするかも
*****************************************************************************/
======================================================== */
task_interval tsk_batt(){
static u8 bt_stat = 0;
static u8 charge_hys = 0; // ヒステリシスで上限下限を拡張するとき1
@ -523,9 +524,9 @@ __interrupt void intp6_PM_irq(){
}
/*****************************************************************************
/* ========================================================
PMICからの割り込みを受けてNTRPMIC互換レジスタからリード
*****************************************************************************/
======================================================== */
task_status_immed ntr_pmic_comm(){
#ifdef _CODEC_CTR_
static u8 reg_shadow;

View File

@ -6,9 +6,9 @@
#define IIC_SLA_BT_GAUGE 0x6C
/*****************************************************************************/
//=========================================================
enum BT_GAUGE_REG_ADRS{
BT_GAUGE_REG_VCELL = 0x02, // それぞれ16ビットです
BT_GAUGE_REG_VCELL = 0x02, // それぞれ16ビットのため
BT_GAUGE_REG_SOC = 0x04,
BT_GAUGE_REG_MODE = 0x06,
BT_GAUGE_REG_VERSION = 0x08,
@ -30,12 +30,9 @@ enum PMIC_REG_ADRS{
// CODEC上のPMIC互換レジスタ
#define CODEC_REG_PMCOMP 0x10
/*****************************************************************************/
extern u16 raw_adc_temperature;
/*****************************************************************************/
//=========================================================
#define PM_REG_BIT_LDSW ( 1 << 0 )
#define PM_REG_BIT_nRST1 ( 1 << 1 )
#define PM_REG_BIT_VDD 0x0F
@ -50,7 +47,12 @@ extern u16 raw_adc_temperature;
/*****************************************************************************/
//=========================================================
extern u16 raw_adc_temperature;
//=========================================================
err PM_sys_pow_on();
err PM_sys_pow_off();
err PM_LCD_on();
@ -66,7 +68,7 @@ err PM_reset();
/*****************************************************************************/
//=========================================================
// 元栓 //

View File

@ -1,24 +1,24 @@
/******************************************************************************
/* ========================================================
RTC
*******************************************************************************/
======================================================== */
#pragma sfr
#pragma inline
/*------------------------------------*/
#include "incs.h"
// ========================================================
u8 rtc_work[7];
bit rtc_lock;
bit rtc_dirty;
/******************************************************************************
/* ========================================================
*******************************************************************************/
======================================================== */
void RTC_init(void){
RTCEN = 1; // モジュールON
@ -45,20 +45,20 @@ void RTC_init(void){
/******************************************************************************
/* ========================================================
RTC
2^6/fXT1.953125 ms
*******************************************************************************/
======================================================== */
__interrupt void int_rtc_int(){
renge_flg_interval = 1;
}
/******************************************************************************
/* ========================================================
RTC
sec,min,hour,week,day,month,year
*******************************************************************************/
======================================================== */
void get_rtc(){
if( rtc_lock == 0 ){
rtc_lock = 1;
@ -72,12 +72,12 @@ void get_rtc(){
/******************************************************************************
/* ========================================================
RTC
set_rtc_close 使
RTCにセットするのはset_rtc_close()
*******************************************************************************/
======================================================== */
void set_rtc( u8 adrs, u8 data ){
if( rtc_dirty == 0 ){
rtc_dirty = 1;
@ -88,12 +88,9 @@ void set_rtc( u8 adrs, u8 data ){
/**************************************
/* ========================================================
RTCレジスタの更新
**************************************/
======================================================== */
void rtc_close_iic(){
rtc_lock = 0;
if( rtc_dirty ){

View File

@ -2,7 +2,6 @@
#define __rtc_h__
/*-------------------------------*/
void RTC_init(void);
__interrupt void int_rtc_int();
void get_rtc();
@ -10,11 +9,8 @@ void set_rtc();
void rtc_close_iic();
/*-------------------------------*/
#define RTC_32k_on() { RCLOE0 = 1; }
/*-------------------------------*/
#endif

View File

@ -1,9 +1,6 @@
/*****************************************************************************
Ž©ŚČ<EFBFBD>A<EFBFBD>v<EFBFBD>f<EFBFBD>[<EFBFBD>^
*****************************************************************************/
/* ========================================================
Ž©ŚČ<EFBFBD>A<EFBFBD>b<EFBFBD>v<EFBFBD>f<EFBFBD>[<EFBFBD>^
======================================================== */
#pragma SFR
#pragma di
#pragma ei
@ -18,6 +15,9 @@
#include "fsl_user.h"
#include "i2c_ctr.h"
// ========================================================
const u8 fsl_fx_MHz_u08 = 4;
const u8 fsl_low_voltage_u08 = 0;
@ -64,7 +64,8 @@ const u8 fsl_low_voltage_u08 = 0;
#endif
//*****************************************************************************
// ========================================================
static void FSL_Open(void);
static void FSL_Close(void);
err firm_restore();
@ -75,8 +76,8 @@ err firm_restore();
#define N_MGC_T 0x6FF6
/*****************************************************************************
*****************************************************************************/
/* ========================================================
======================================================== */
err firm_update(){
u8 flg_rcv_end;
u8 buffer_fill;
@ -226,11 +227,11 @@ firm_update_end:
/* ***************************************************************************
/* ========================================================
0x4800 - 0x7FFF ( 18 - 27) 0x2000 - 0x47FF (8 - 17)
************************************************************************** */
======================================================== */
err firm_restore(){
u8 flg_rcv_end = 0;
u8 buffer_fill;
@ -305,7 +306,7 @@ err firm_restore(){
//****************************************************************************
// ========================================================
static void FSL_Open(void)
{
/* save the configuration of the interrupt controller and set */

View File

@ -6,22 +6,22 @@
#include "incs.h"
/*****************************************************************************
/* ========================================================
WiFi
WL_TX,RX
LED_wifi
32kHz
*****************************************************************************/
======================================================== */
task_interval tsk_wifi(){
return 10;
}
/*****************************************************************************
/* ========================================================
*****************************************************************************/
======================================================== */
task_interval tsk_misc_stat(){
static u8 state_old; // ステータス変化検出→割り込み の為
@ -63,8 +63,8 @@ task_interval tsk_misc_stat(){
/*****************************************************************************
*****************************************************************************/
/* ========================================================
======================================================== */
task_interval tsk_debug(){
u8 temp;
static u8 count = 0;
@ -102,9 +102,9 @@ return 255;
#if 0
/*****************************************************************************
/* ========================================================
*****************************************************************************/
======================================================== */
task_interval tsk_hina(){
switch( system_status.pwr_state ){
case OFF:
@ -137,10 +137,10 @@ task_status_immed tsk_imm_hina( u8* arg ){
/**************************************
/* ========================================================
*************************************/
======================================================== */
task_interval tsk_soft_int(){
#ifdef _MCU_KE3_
static u8 pin;
@ -164,13 +164,13 @@ task_interval tsk_soft_int(){
/*****************************************************************************
/* ========================================================
*****************************************************************************/
======================================================== */
/*****************************************************************************
/* ========================================================
COMMANDレジスタへの書き込み
*****************************************************************************/
======================================================== */
task_status_immed do_command0(){
if( vreg_ctr[ VREG_C_COMMAND0 ] & REG_BIT_OFF_REQ ){
@ -197,9 +197,9 @@ task_status_immed do_command0(){
/*****************************************************************************
/* ========================================================
TEG2では無し
*****************************************************************************/
======================================================== */
task_status_immed do_command1(){
static u8 state = 0;
return( ERR_FINISED );
@ -207,13 +207,11 @@ task_status_immed do_command1(){
/*****************************************************************************
/* ========================================================
CPUからのスリープ要求
*****************************************************************************/
======================================================== */
__interrupt void intp0_slp(){ // SLP
}

View File

@ -16,12 +16,12 @@ u8 SW_pow_count, SW_home_count, SW_3d_count, SW_wifi_count;
bit SW_pow_mask, SW_home_mask, SW_3d_mask, SW_wifi_mask;
/*****************************************************************************
/* ========================================================
 system_status.pwr_state == OFF_TRIG
*****************************************************************************/
======================================================== */
task_interval tsk_sys(){
static u8 timeout = 0;
@ -219,11 +219,11 @@ task_interval tsk_sys(){
/*****************************************************************************
/* ========================================================
 
todo
*****************************************************************************/
======================================================== */
// 押した時間を数える。押しっぱなしでも0に戻らない
// maskが非0の時は、一度離すまで無視する
#define count_sw_n( sw, counter, mask ) \

View File

@ -1,9 +1,8 @@
/* ============================================================================
/* ========================================================
CTR MCU I2Cレジスタ
=========================================================================== */
====================================================== */
#include "incs_loader.h"
#include "vreg_ctr.h"
#include "rtc.h"
@ -11,16 +10,18 @@ CTR MCU I2C
// ********************************************************
u8 vreg_ctr[ VREG_C_ENDMARK_ ];
// ********************************************************
#define IRQ0_ngt { PM3.0 = 1; }
//*******************************************************************************
// 非ゼロの固定値の指定が必要なアドレス
// ********************************************************
// 非ゼロの初期値の指定が必要なアドレス
void vreg_ctr_init(){
vreg_ctr[ VREG_C_LED_BRIGHT ] = 0xFF;
vreg_ctr[ VREG_C_MCU_VER_MAJOR ] = MCU_VER_MAJOR;
@ -30,12 +31,11 @@ void vreg_ctr_init(){
//*******************************************************************************
// ********************************************************
// I2C仮想レジスタに書きます。
// 引数 adrs は内部アドレス
//  存在しないアドレスにアクセスした場合、何もしません。
void vreg_ctr_write( u8 adrs, u8 data ){
switch( adrs ){
case( VREG_C_COMMAND0 ):
vreg_ctr[ adrs ] = data;
@ -146,7 +146,7 @@ void vreg_ctr_write( u8 adrs, u8 data ){
//*******************************************************************************
// ********************************************************
// I2C仮想レジスタから読みます。
// 引数 adrs 外から見たときの、アドレス
// 戻り xx データ
@ -160,9 +160,9 @@ u8 vreg_ctr_read( u8 adrs ){
}
//*******************************************************************************
// ********************************************************
// I2C仮想レジスタから読まれて何かするレジスタ
//*******************************************************************************
void vreg_ctr_after_read( u8 adrs ){
// リードがトリガで何かをする↓
@ -182,7 +182,7 @@ void vreg_ctr_after_read( u8 adrs ){
}
/*-------------------------------------*/
// ********************************************************
// I2Cでロックされた物の解除
void vreg_c_iic_release(){
// クリティカルセクションとして扱わないといけないかもしれない

View File

@ -130,9 +130,8 @@ enum VREG_C{ //
VREG_C_ACC_CONFIG_HOSU,
VREG_C_ACC_CONFIG,
VREG_C_ACC_R_ADRS,
VREG_C_ACC_R_BUF,
VREG_C_ACC_W_ADRS,
VREG_C_ACC_W_BUF,
VREG_C_ACC_BUF,
VREG_C_ACC_HOSU_L,
VREG_C_ACC_HOSU_M,
@ -146,6 +145,7 @@ enum VREG_C{ //
VREG_C_ACC_ZL,
VREG_C_DIAG,
VREG_C_FREE0,
VREG_C_FREE1,
VREG_C_FREE2,

View File

@ -1,8 +1,8 @@
/* ============================================================================
/* ========================================================
TWL互換側のI2Cレジスタ
=========================================================================== */
======================================================== */
#include "incs.h"
#include "jhl_defs.h"
@ -12,9 +12,9 @@ TWL
u8 vreg_twl[ REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD +1 ];
/* ============================================================================
/* ========================================================
=========================================================================== */
======================================================== */
void vreg_twl_init(){
vreg_twl[ REG_TWL_INT_ADRS_VER_INFO ] = 0x35;
vreg_twl[ REG_TWL_INT_ADRS_POWER_SAVE ] = 0x07;
@ -25,7 +25,7 @@ void vreg_twl_init(){
}
//*******************************************************************************
// ========================================================
// I2C仮想レジスタに書きます。
// 引数 adrs は内部アドレス
//  存在しないアドレスにアクセスした場合、何もしません。
@ -50,7 +50,7 @@ void vreg_twl_write( u8 adrs, u8 data ){
//*******************************************************************************
// ========================================================
// I2C仮想レジスタから読みます。
// 引数 adrs 外から見たときの、アドレス
// 戻り xx データ
@ -66,7 +66,7 @@ u8 vreg_twl_read( u8 phy_adrs ){
//*******************************************************************************
// ========================================================
// 外部から見える虫食いアドレスを、内部の連続アドレスに読み替える
// 0xFFは存在しないアドレス。
u8 adrs_table_twl_ext2int( u8 img ){

View File

@ -2,8 +2,8 @@
#define __vreg_twl__
/*
*
*
*
*
*/
/*
*
@ -16,7 +16,7 @@
* 1: OFF
* LSB:
*/
enum REG_TWL_ADRS{ // 未定義アドレスへ書き込んだ際の動作は不定
enum REG_TWL_ADRS{ // 未定義アドレスへ書き込んだ際は無視
REG_TWL_ADRS_VER_INFO = 0x00,
REG_TWL_ADRS_PMIC_INFO,
REG_TWL_ADRS_BATT_INFO,
@ -34,7 +34,7 @@ enum REG_TWL_ADRS{ //
REG_TWL_ADRS_ADC_CALIB_STATUS,
REG_TWL_ADRS_ADC_CALIB_VALUE,
REG_TWL_ADRS_POWER_LED,
REG_TWL_ADRS_TEMP0 = 0x70, // 0x77 まで。
REG_TWL_ADRS_TEMP0 = 0x70,
REG_TWL_ADRS_TEMP1,
REG_TWL_ADRS_TEMP2,
REG_TWL_ADRS_TEMP3,
@ -49,7 +49,7 @@ enum REG_TWL_ADRS{ //
/*
*
*
*
*/
enum REG_TWL_ADRS_INT{
REG_TWL_INT_ADRS_VER_INFO = 0x00,
@ -81,8 +81,14 @@ enum REG_TWL_ADRS_INT{
REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD
};
/* ========================================================================= */
extern u8 vreg_twl[ REG_TWL_INT_ADRS_TIME_PWSW_THRESHOLD +1 ];
/* ========================================================================= */
#define is_TWL ( vregs[ REG_TWL_INT_ADRS_MODE ] & 0x01 )
#define with_NAND ( vregs[ REG_TWL_INT_ADRS_MODE ] & 0x02 )
#define volSteps32 ( vregs[ REG_TWL_INT_ADRS_MODE ] & 0x80 )
@ -98,4 +104,6 @@ void vreg_twl_write( u8 adrs, u8 data );
u8 adrs_table_twl_ext2int( u8 img );
u8 vreg_twl_read( u8 phy_adrs );
#endif

View File

@ -80,8 +80,8 @@ Kanji=SJIS
[Source]
Geometry=424, 30, 708, 979
Window=Normal
DispStart=38
CaretPos=68,0
DispStart=67
CaretPos=119,0
Mode=Normal
DispFile=
Address1=
@ -142,24 +142,24 @@ Accumulative=ON
[Source1]
Geometry=239, 23, 708, 979
Window=Normal
DispStart=81
CaretPos=82,0
DispStart=80
CaretPos=81,0
Mode=Normal
DispFile=tasks_sys.c
Accumulative=ON
[Source2]
Geometry=59, 80, 708, 979
Window=Normal
DispStart=34
CaretPos=16,0
DispStart=33
CaretPos=34,0
Mode=Normal
DispFile=adc.c
Accumulative=ON
[Assemble]
Geometry=60, 545, 600, 400
Window=Normal
DispStart=216
CaretPos=216,27
DispStart=771
CaretPos=524,27
Address1=
Address2=
Address3=