MTK驱动调试相关总结 2010-12-14 Ver:1.1
1 SIM卡
2 T卡
3 FLASH
4 按键KEY
5 IO配置
6 ADC配置
7 EINT配置
8 FM驱动
9 BT驱动
10 TOUCHSCEEN驱动
11 LCM驱动
12 Sensor驱动
13 背光灯、按键灯、振动器、PWM
14 跑马灯
15 移动传感器、四方传感器
16 MP4、3GP播放
17 音量参数、EQ参数、音频功放开关
18 SMS、电话本等容量设置
19 耳机插入、拔出检查、耳机按键处理
20 充电器或USB插入、拔出检查、识别
21 RF 配置
22参考文档
附录
默认系统平台为MT6253,code版本:09B.W10.12.MP。
版本变更记录:
Andy 2010.12.10 Ver:1.0
Andy 2010-12-14 Ver:1.1
1 SIM卡
F910(MT6253)
SIM卡插槽与系统SIM卡号映射关系
drv\src\switchControl_al.c
// andy 2010.05.31 SIM卡插槽映射 __DRV_DUAL_SIM_INVERSE__
//kal_bool sim_physicalSlotChanged;
#ifdef __DRV_DUAL_SIM_INVERSE__
kal_bool sim_physicalSlotChanged = KAL_TRUE ;
#else
kal_bool sim_physicalSlotChanged = KAL_FALSE;
#endif
定制支持的SIM电压:
Customer_sim_voltage_support.c
/* For customer define ME support voltage of SIM */
/* For 1.8V Tech. ME use ME_18V_30V */
/* For 3.0V ONLY ME use ME_30V_ONLY */
/* For 1.8V ONLY ME use ME_18V_ONLY */
#define SIM_VOLTAGE_SUPPORT ME_18V_30V
sim_env SIM_GetCurrentEnv(void)
{
(SIM_VOLTAGE_SUPPORT);
return
}
MT6253的“4.3 SIM Interface”,介绍了SIM卡接口的情况。
MT6253的SIM卡接口
MT6225双卡电路
MT6225的SIM卡接口
2 T卡
F910(MT6253)
.mak
MSDC_CARD_SUPPORT_TYPE = MSDC_SD_MMC # MSDC_SD_MMC for SD/MMC card support # MSDC_MS for MS card support
# MSDC_MSPRO for MS-PRO card support
# NONE
# MT6218B, MT6217, MT6219 support MSDC
# MT6218, MT6205B, MT6208 don't support MSDC
MT6253的T卡操作有问题,其修改方法如下:
A.增加供电延时,使其在被操作之前,处于稳定状态
Pmu_custom.c :
void pmu6253_customization_init(void)
{
pmu6253_chr_current(PMU_CHR_CURRENT);
pmu6253_chofst(PMU_CHR_CURRENT_OFFSET);
//++++++++++++++++++++++++++++++++++++++++++++
;
pmu6253_vbt_sel(VBT_SEL_3_0V)
pmu6253_vbt_enable(KAL_FALSE); /* For MMC card */
{
kal_uint16 i,data; // andy 2010.06.12 __F910__ T card delay 命令超时ERR_CMD_TIMEOUT
data = 600;//1000;
while(data--)
{
for(i=0;i<5000;i++){}//
1ms每次循环5000 次
}
}
pmu6253_vbt_enable(KAL_TRUE); /* For MMC card */
{
kal_uint16 i,data; // andy 2010.06.12 __F910__ T card delay 命令超时ERR_CMD_TIMEOUT
data = 600;//1000;
while(data--)
{
1ms每次循环5000 次
for(i=0;i<5000;i++){}//
}
}
//------------------------------------------------------
……
B.增加T 卡读写失败后尝试次数
Sd_drv.c (drv\src):
#define SD_MAX_RETRY 4 // 2 andy 2010.06.18 __SD_RW_BLOCK_CH__ __F910__ T 卡读写尝试次数(SD_MAX_RETRY-1)
C.修改T卡读写函数(主要是避免个别T卡在以多个块读、写之后,会产生漏电)
static int ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer)
static int WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer)
3 FLASH
系统中定制:
A.在\tools\MemoryDeviceList\ MemoryDeviceList_Since09BW1004.xls(实际文件依据具体系统而定)中确认目标IC是否存在;
B.指定IC,并设置相应参数
Custom_memorydevice.h:
****************************************************************************
Step 1: Specify memory device type and its complete part number
Possible memory device type: NOR_RAM_MCP, LPSDRAM, NOR_LPSDRAM_MCP
****************************************************************************
*/
#define MEMORY_DEVICE_TYPE NOR_RAM_MCP
#define CS0_PART_NUMBER K5N2833ATB_AQ12000 // S71VS128RB0AHK0L0 // PF38F3040M0Y3DE // TY5701111183KC
#define CS1_PART_NUMBER K5N2833ATB_AQ12000 //S71VS128RB0AHK0L0 // PF38F3040M0Y3DE // TY5701111183KC
/*
****************************************************************************
Step 2: Specify access type for NOR_RAM_MCP; for LPSDRAM, just assign
UNDEF_ACCESS to both items (NOR_ACCESS_TYPE and RAM_ACCESS_TYPE)
Possible access types: ASYNC_ACCESS,
SYNC_ACCESS,
UNDEF_ACCESS
****************************************************************************
*/
#define FLASH_ACCESS_TYPE SYNC_ACCESS
#define RAM_ACCESS_TYPE SYNC_ACCESS
/*
****************************************************************************
Step 4: This is an optional step special for NOR-XIP configuration only.
This step configures the FS (file system) region information on NOR FLASH!
By default, FS region is located the last bank of NOR Flash.
For specific purpose, user are able to manually configure the
Step 1. Start address of FS region on NAND-flash,
Step 2. Total FS size on NAND-flash disk
Step 3. The first drive (or partition) size of FS region. if no additional drive
on NOR-flash disk, it should be 0. For more details, please refer to REMIND.
[REMIND]
========
It is special for flash disk which has two drives (or partitions), the
first leading is user drive, visible on USB disk, the second may be
system drive, and invisible from USB disk.
[VERY IMPORTANT NOTICE]
=======================
1. Disable this definition and make auto Gen pick default setting from
Memory Device Excel Database is recommend.
2. Please assign the exact integer value in terms of sectors (one sector equal
to 512 Bytes) in NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS.
MUST NOT assign as
(TOTAL_FS_SIZE - SIZE_OF_SYSTEM_DRIVE), because system will keep
some spaces for disk management.
****************************************************************************
*/
/*
PF38F3040M0Y3DE : Cluster Size 512
*/
//#define NOR_BOOTING_NOR_FS_BASE_ADDRESS 0x00E00000 // NOR_FLASH_BASE_ADDRESS 0x1c00000 //#define NOR_BOOTING_NOR_FS_SIZE 0x00200000// NOR_ALLOCATED_FAT_SPACE 0x3E0000
//#define NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS (512) // NOR_PARTITION_SECTORS ?
/*
Cluster Size 1024
*/
#define NOR_BOOTING_NOR_FS_BASE_ADDRESS 0x00E00000 // NOR_FLASH_BASE_ADDRESS 0x1c00000 #define NOR_BOOTING_NOR_FS_SIZE 0x00200000// NOR_ALLOCATED_FAT_SPACE 0x3E0000
#define NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS 1024 // NOR_PARTITION_SECTORS ?
对于系统中没有的FLASH,可参考:
\\fs\SW\项目\芯片Driver\S71VS128RB0AHK0L0_MT6253_drv.rar
F910(MT6253)
.mak中指定按键类型:
KEYPAD_TYPE = NORMAL_KEYPAD # NORMAL_KEYPAD, REDUCED_KEYPAD,QWERTY_KEYPAD andy 2010.06.04 键盘类型
按键处理任务
Kbdmain.c
kal_bool kbd_create(comptask_handler_struct **handle)
{
static const comptask_handler_struct kbd_handler_info =
{
*/
function
entry
kbd_task_main, /*
task
NULL, /* task initialization function */
NULL, /* task configuration function */
kbd_task_reset, /* task reset handler */
handler
*/
termination
task
kbd_task_end /*
};
*handle = (comptask_handler_struct *)&kbd_handler_info;
return
KAL_TRUE;
}
kal_bool PowerKey_Pressed(void) 函数用于判断开机\电源键是否按下。
PWRKEY pin 是专用引脚;
关于KEYPAD更多描述,参考基带芯片说明书的“4.4 Keypad Scanner”章节。
.mak 配置工具
DRV_CUSTOM_TOOL_SUPPORT = TRUE # TRUE or FALSE, To enable using driver customization tool for GPIO/EINT/ADC/UEM/Keypad setting. 引脚模式;内部上、下电阻;输入、输出、三态模式;变量名等。
在MT6253的说明书中:
“4.5 General Purpose Inputs/Outputs”章节详细介绍了IO口。
Gpio_drv.c:
void GPIO_init(void)
{
#ifdef __CUST_NEW__
GPIO_setting_init();
……
}
“GPIO_setting_init()”将TOOL生成的IO配置实现,即把配置值(gpio_drv.h)写入相应寄存器。
6 ADC配置
对于MT6253,ADC0—ADC2是内部强制设置,不能更改;ADC3—ADC5对应外部引脚AUX_IN0—AUX_IN2。
在MT6253的说明书,“4.10 Auxiliary ADC Unit”章节介绍了ADC的情况。
部分EINT 脚是复合的,故而,在IO设置时,注意其引脚模式设置。
F510(MT6225)
F910(MT6253),BT和FM二合一芯片
.mak 指定FM IC
FM_RADIO_CHIP = FM_RDA5870 #AR1000 # NONE, MT6189A1, MT6188A1, AR1000,FM_RDA5870 ,RDA_FM andy 2010.06.08 FM 5870 FM_RADIO_RECORD = FALSE #TRUE #TRUE/FALSE
FM_RADIO_HW_SEARCH = FALSE #TRUE # TRUE, FALSE 硬件搜索
驱动中完成八个接口:
void FMDrv_PowerOffProc(void)
void FMDrv_ChipInit()
void FMDrv_Mute(uint8 mute)
void FMDrv_SetFreq( int16 curf )
uint8 FMDrv_ValidStop(int16 freq, int8 signalvl, bool is_step_up) /* 自动搜索时,作为判定条件,再从中选择信号最强的9个台*/
uint8 FMDrv_GetSigLvl( int16 curf ) /*当满足rssi 的条件时,将信号记录,再选最强的9个频段*/
bool FMDrv_IsChipValid(void)
void FMDrv_SetV olumeLevel(uint8 level)
通常,还需指定I2C通信的IO口, 32KHZ时钟引脚及其模式:
#define RDA5868_SDA 1 //42 /// I2C data pin
#define RDA5868_SCL 2 //41 /// I2C clock pin
#define RDA5870_CRYCLK gpio_bt_32k_pin
#define RDA5870_CRYCLK_MSK 1
另,开机时建立的audio任务(MT6225)中,其会初始化FM:void L1Audio_Task(unsigned argc, void *argv)
{
……
#if (defined(FM_RADIO_ENABLE))
FMR_Init( L1Audio_GetAudioID() );
#endif
……
或者,FM任务(MT6253)中:
static void fmradio_task_main(task_entry_struct * task_entry_ptr)
{
……
#if (defined(FM_RADIO_ENABLE))
#ifdef __MTK_TARGET__
FMR_Init();
#endif
#endif
……
9 BT驱动
F510(MT6225)
驱动修改方法可参考RDA芯片的案例(\\fs\SW\项目\芯片Driver\RDA FM BT)。
更多文档:\\fs\SW\大杂烩\BT。
.mak(MT6253):
BLUETOOTH_SUPPORT = BTMTK_MT6612 # NONE, BTMTK, BTMTK_MT6601, BTMTK_MT6612
BLUETOOTH_VERSION = BT_VER_21 # NONE, BT_VER_PRE21, BT_VER_21
BTSTACK_SUPPORT = LIB # LIB, SOURCE, PARTIAL_SOURCE
BT_CONNECT_TO_UART2 = FALSE # TRUE, FALSE
# TRUE: BT module is connected to UART2
# FALSE: BT module is connected to UART3, this is general case for most projects
BT_SIM_PROFILE = FALSE # TRUE, FALSE
BT_BIP_PROFILE = TRUE # TRUE, FALSE
BT_BPP_PROFILE = TRUE # TRUE, FALSE,
BT_HIDD_PROFILE = TRUE # TRUE, FALSE
BT_HFG_PROFILE = TRUE # TRUE, FALSE
BT_FTS_PROFILE = TRUE # TRUE, FALSE
BT_FTC_PROFILE = TRUE # TRUE, FALSE
BT_OPP_PROFILE = TRUE # TRUE, FALSE
BT_DUN_PROFILE = TRUE # TRUE, FALSE
BT_SPP_SERVER = BT_SPP_SRV_NO_SCO # NONE, BT_SPP_SRV_NO_SCO or BT_SPP_SRV_WITH_SCO (default:BT_SPP_SRV_NO_SCO) # This is only used in BLUETOOTH_SUPPORT = BTMTK_MT6601
# If BLUETOOTH_SUPPORT is not BTMTK_MT6601, its value must be NONE
BT_SPP_CLIENT = NONE # NONE, BT_SPP_CLI_NO_SCO or BT_SPP_CLI_WITH_SCO (default: NONE)
# This is only used in BLUETOOTH_SUPPORT = BTMTK_MT6601
# If BLUETOOTH_SUPPORT is not BTMTK_MT6601, its value must be NONE
BT_SPP_PROFILE = TRUE # TRUE, FALSE
BT_A2DP_PROFILE = TRUE# TRUE, FALSE
BT_A VRCP_PROFILE = TRUE # TRUE, FALSE
BT_GPS_SUPPORT = FALSE # TRUE, FALSE
BT_FAX_PROFILE = TRUE # TRUE, FALSE
BT_AUDIO_VIA_SCO = TRUE # TRUE, FALSE andy 2010.10.29 F910
BT_FM_RADIO_VIA_SCO = TRUE # TRUE, FALSE andy 2010.10.29 F910
BT_PBAP_PROFILE = FALSE # TRUE or FALSE
BT_SEQ_SUPPORT = TRUE # FALSE, TRUE
WIFI_BT_SINGLE_ANTENNA_SUPPORT = FALSE # TRUE, FALSE
LGE_BT_SYSTEM_SUPPORT = FALSE # TRUE, FALSE
MERCURY_SLA VE_BT_SUPPORT = TRUE # TRUE or FALSE
CUSTOM_OPTION += __BT_RDA5868__ # RDA BT drv 对应FM: FM_RDA5870 CUSTOM_OPTION += __BT_RDA5870E__ # RDA BT DRV 对应FM: FM_RDA5870E
10 TOUCHSCEEN驱动
F910(MT6253)内建触摸屏接口
MT6225 触摸采样芯片TSC2046和EINT