TwlIPL/build/libraries_sysmenu/sysmenu/ARM9/src/device.c
yoshida_teruhisa 69751c753a X3基盤でバックライト輝度の数値が4bitになったため、X2基盤でもこれに対応(ランチャーでの表示はX2でもX3でも最大15に。X2では輝度設定関数内部で2倍してPMICへ送る。)
・バックライト輝度の設定値が輝度最大値を超えていた場合、強制的に最大値まで削るように変更
 ・SDK4186以降のTwlSDK/include/twl/lcfg/common/TWLSettings.hが必要

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@669 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-02-15 01:56:53 +00:00

148 lines
5.3 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.

/*---------------------------------------------------------------------------*
Project: TwlIPL
File: SYSM_lib.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <sysmenu.h>
#include <sysmenu/mcu.h>
#include <spi.h>
#include "internal_api.h"
// define data-----------------------------------------------------------------
// extern data-----------------------------------------------------------------
// function's prototype-------------------------------------------------------
#ifdef SDK_FINALROM
u32 PM_SendUtilityCommandAsync(u32 number, u16 parameter, u16* retValue, PMCallback callback, void *arg);
u32 PM_SendUtilityCommand(u32 number, u16 parameter, u16* retValue);
u32 PMi_WriteRegister(u16 registerAddr, u16 data);
u32 PMi_WriteRegisterAsync(u16 registerAddr, u16 data, PMCallback callback, void *arg);
#endif // SDK_FINALROM
// global variable-------------------------------------------------------------
// static variable-------------------------------------------------------------
// const data------------------------------------------------------------------
// ============================================================================
//
// デバイス制御
//
// ============================================================================
// バックライト輝度調整
void SYSM_SetBackLightBrightness( u8 brightness )
{
if( brightness > LCFG_TWL_BACKLIGHT_LEVEL_MAX ) {
OS_TPrintf( "Backlight brightness over! Change brightenss forcibly : %d -> %d\n", brightness, LCFG_TWL_BACKLIGHT_LEVEL_MAX );
brightness = LCFG_TWL_BACKLIGHT_LEVEL_MAX;
}
#ifdef SDK_SUPPORT_PMIC_2
if ( SYSMi_GetMcuVersion() <= 1 )
{
( void )PMi_WriteRegister( REG_PMIC_BL_BRT_B_ADDR, (u8)(brightness * 2) );
}
else
#endif // SDK_SUPPORT_PMIC_2
{
( void )SYSM_WriteMcuRegisterAsync( MCU_REG_BL_ADDR, brightness, NULL, NULL );
}
// ( void )SYSMi_SendPXICommand( SYSM_PXI_COMM_BL_BRIGHT, brightness );
LCFG_TSD_SetBacklightBrightness( brightness );
// [TODO:] バックライト輝度は毎回セーブせずに、アプリ起動やリセット、電源OFF時に値が変わっていたらセーブするようにする。
LCFG_WriteTWLSettings();
}
// タッチパネルキャリブレーション
void SYSM_CaribrateTP( void )
{
LCFGTWLTPCalibData store;
TPCalibrateParam calibParam;
// 本体設定データからキャリブレーション情報を取得
LCFG_TSD_GetTPCalibration( &store );
// TPキャリブレーション
( void )TP_CalcCalibrateParam( &calibParam, // タッチパネル初期化
store.data.raw_x1, store.data.raw_y1, (u16)store.data.dx1, (u16)store.data.dy1,
store.data.raw_x2, store.data.raw_y2, (u16)store.data.dx2, (u16)store.data.dy2 );
TP_SetCalibrateParam( &calibParam );
OS_TPrintf("TP_calib: %4d %4d %4d %4d %4d %4d\n",
store.data.raw_x1, store.data.raw_y1, (u16)store.data.dx1, (u16)store.data.dy1,
store.data.raw_x2, store.data.raw_y2, (u16)store.data.dx2, (u16)store.data.dy2 );
}
// RTCクロック補正値をセット
void SYSMi_WriteAdjustRTC( void )
{
RTCRawAdjust raw;
raw.adjust = LCFG_THW_GetRTCAdjust();
( void )RTCi_SetRegAdjust( &raw );
}
// 起動時のRTCチェック
void SYSMi_CheckRTC( void )
{
RTCDate date;
RTCTime time;
// RTCのリセット or おかしい値を検出した場合は初回起動シーケンスへ。
( void )RTC_GetDateTime( &date, &time );
if( !SYSM_CheckRTCDate( &date ) ||
!SYSM_CheckRTCTime( &time )
#ifndef __IS_DEBUGGER_BUILD // 青デバッガではRTCの電池がないので、毎回ここにひっかかって設定データが片方クリアされてしまう。これを防ぐスイッチ。
||
SYSMi_GetWork()->flags.common.isResetRTC
#endif
) { // RTCの異常を検出したら、rtc入力フラグrtcOffsetを0にしてNVRAMに書き込み。
OS_TPrintf("\"RTC reset\" or \"Illegal RTC data\" detect!\n");
LCFG_TSD_SetFlagDateTime( FALSE );
LCFG_TSD_SetRTCOffset( 0 );
LCFG_TSD_SetRTCLastSetYear( 0 );
LCFG_WriteTWLSettings();
}
}
#ifdef SDK_FINALROM
/*---------------------------------------------------------------------------*
Name: PMi_WriteRegisterAsync
Description: send write register command to ARM7
Arguments: registerAddr : PMIC register number (0-3)
data : data written to PMIC register
callback : callback function
arg : callback argument
Returns: result of issueing command
PM_RESULT_BUSY : busy
PM_RESULT_SUCCESS : success
*---------------------------------------------------------------------------*/
u32 PMi_WriteRegisterAsync(u16 registerAddr, u16 data, PMCallback callback, void *arg)
{
return PM_SendUtilityCommandAsync(PMi_UTIL_WRITEREG, (u16)((registerAddr<<16) | (data&0xff)), NULL, callback, arg);
}
u32 PMi_WriteRegister(u16 registerAddr, u16 data)
{
return PM_SendUtilityCommand(PMi_UTIL_WRITEREG, (u16)((registerAddr<<16) | (data&0xff)), NULL);
}
#endif // SDK_FINALROM