ctr_mcu/trunk/pm.h
fujita_ryohei 972a9bcd16 電源シーケンス 液晶電源周りのウェイト変更
tuneボタン廃止
検出スイッチ廃止でコードも削除

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@15 013db118-44a6-b54f-8bf7-843cb86687b1
2009-10-28 13:36:49 +00:00

138 lines
4.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __PM__
#define __PM__
#define IIC_SLA_PMIC 0x84
#define IIC_SLA_BT_GAUGE 0x6C
//=========================================================
enum BT_GAUGE_REG_ADRS
{
BT_GAUGE_REG_VCELL = 0x02, // それぞれ16ビットのため
BT_GAUGE_REG_SOC = 0x04,
BT_GAUGE_REG_MODE = 0x06,
BT_GAUGE_REG_VERSION = 0x08,
BT_GAUGE_REG_OCV = 0x0E,
BT_GAUGE_REG_RCOMP = 0x0C,
BT_GAUGE_REG_LOCK = 0x3E,
BT_GAUGE_REG_BT_PARAM = 0x40,
BT_GAUGE_REG_COMMAND = 0xFE
};
enum PMIC_REG_ADRS
{
PM_REG_ADRS_VER = 0x00, // verinfo など
PM_REG_ADRS_VDD_SYS, // システムが使用する電源
PM_REG_ADRS_VDD_LCD, // 液晶電源
PM_REG_ADRS_CONT, // /RESET1, LoadSwitch
PM_REG_ADRS_BL, // バックライト on/off
PM_REG_ADRS_POW_SAVE, // 省電力設定
PM_REG_ADRS_POW_DAC1,
PM_REG_ADRS_POW_DAC2
};
// CODEC上のPMIC互換レジスタ
#define CODEC_REG_PMCOMP 0x10
//=========================================================
#define PM_REG_BIT_LDSW ( 1 << 0 )
#define PM_REG_BIT_nRST1 ( 1 << 1 )
#define PM_REG_BIT_VDD 0x0F
#define PM_REG_BIT_VDD50A ( 1 << 4 )
#define PM_REG_BIT_VDDLCD 0x07
#define PM_REG_BIT_LCD_ANALOG ( 0x03 << 3 )
#define DELAY_PM_TW_PWUP 16
#define DELAY_PM_TSS_50B_AND_VCOM ( 5 + 17 )
#define DELAY_PM_5V_TO_VCOM 17
#define DELAY_PM_VCOM_TO_BL ( 17 + 5 )
#define DELAY_PM_LCD_OFF ( 50 + 1 )
//=========================================================
extern u8 raw_adc_temperature;
//=========================================================
err PM_sys_pow_on( );
err PM_sys_pow_off( );
err PM_LCD_on( );
err PM_bt_auth( );
task_status_immed PM_bt_temp_update( );
void PM_init( );
err PM_LCD_vcom_set( );
task_status_immed tski_vcom_set( );
err PM_BL_on( );
err PM_BL_off( );
task_status_immed tski_PM_BL_on( );
task_status_immed tski_PM_BL_off( );
task_status_immed tski_PM_LCD_on( );
task_status_immed tski_PM_LCD_off( );
//  これを呼ぶ前に、現在温度を教えておく必要があります。
#define PM_get_batt_left() ( iic_mcu_read_a_byte( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_SOC ) )
#define PM_reset() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT, 0x00 ) )
//=========================================================
// 元栓 //
#define PM_LDSW_on() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT, PM_REG_BIT_LDSW ))
#define PM_LDSW_off() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT, 0 ))
// システム電源 //
#define PM_VDD_on() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_SYS, PM_REG_BIT_VDD ))
#define PM_VDD50A_on() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_SYS, ( PM_REG_BIT_VDD | PM_REG_BIT_VDD50A )))
#define PM_VDD_off() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_SYS, 0 ))
#define PM_off() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_SYS, 0 ))
#ifdef _model_CTR_
#define PM_VDD_ecoMode() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_SAVE, 0x47 ))
#define PM_VDD_normMode() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_SAVE, 0x00 ))
#else
#define PM_VDD_ecoMode() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_SAVE, 0x00 | 0x40 ))
#define PM_VDD_normMode() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_SAVE, 0x00 | 0x03 ))
#endif
// ↑本番チップ待ちPMICバグ
// ほか //
#ifdef _PMIC_TWL_
#define PM_reset_neg() { PM0.0 = 1; PU0.0 = 1; }
#define PM_reset_ast() { P0.0 = 0; PM0.0 = 0; }
#define PM_chk_LDSW() ( 1 )
#else
#define PM_reset_neg() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT, ( PM_REG_BIT_LDSW | PM_REG_BIT_nRST1 )))
#define PM_reset_ast() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT, ( PM_REG_BIT_LDSW )))
#define PM_chk_LDSW() ( iic_mcu_read_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_CONT ) & PM_REG_BIT_LDSW )
#endif
// 液晶系電源 //
#define PM_VDDLCD_on() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_LCD, PM_REG_BIT_VDDLCD ))
#define PM_TCOM_VCS_on() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_LCD, ( PM_REG_BIT_VDDLCD | PM_REG_BIT_LCD_ANALOG )))
#define PM_TCOM_VCS_off() PM_VDDLCD_on()
#define PM_VDDLCD_off() ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_VDD_LCD, 0 ) )
#define PM_set_BL( dat ) ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_BL, dat ) )
#define PM_set_pow_save( dat ) ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_SAVE, dat ) )
#define PM_set_adc1( dat ) ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_DAC1, dat ) )
#define PM_set_adc2( dat ) ( iic_mcu_write_a_byte( IIC_SLA_PMIC, PM_REG_ADRS_POW_DAC2, dat ) )
#endif // __PM__