MTK手机设备驱动编写介绍

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

MTKDRIVERINTRODUCTION首先需要注意两个宏定义1.__CUST_NEW__程序中有多处用该宏将代码隔开Make文件中若如下定义:DRV_CUSTOM_TOOL_SUPPORT=TRUEOption.mak文件中ifdefDRV_CUSTOM_TOOL_SUPPORTifeq($(strip$(DRV_CUSTOM_TOOL_SUPPORT)),TRUE)COM_DEFS+=__CUST_NEW__endifendif2.WIN32#ifndefWIN32………………#endif用该宏将真机与模拟器的代码分隔开一.GPIO口的初使化与使用1GPIO口的初始化方法:两种:1.工具\custom\drv\Drv_Tool\DrvGen.exe修改:\custom\drv\misc_drv\IWIT23_NEP_07A_PMJ_BB\codegen\codegen.dws2.程序中修改:Gpio_drv.cvoidGPIO_init(void)2操作1.写状态a.模式修改GPIO_ModeSetup(kal_uint16pin,kal_uint16conf_dada)b.方向修改voidGPIO_InitIO(chardirection,charport)c.置高与置低GPIO_WriteIO(chardata,charport)d.上拉与下拉的使能voidGPIO_PullenSetup(kal_uint16pin,kal_boolenable)2.读取状态a.返回模式charGPIO_ReturnMode(charport);b.返回方向charGPIO_ReturnDir(charport);c.返回电平值charGPIO_ReturnDout(charport);3.GPIO使用中需注意的问题二.中断的配置与使用1.中断个数8个EINT0,EINT1为专用中断,EINT2-7与GPIO等功能复用2.设置中断模式通过DRV_TOOL或Gpio_init(void)来初始化,也可在程序中通过GPIO_ModeSetup(kal_uint16pin,kal_uint16conf_dada)随时修改3.中断注册函数在某个TASK中注册中断,建议注册在AUX_TASK中,便于管理EINT_Registration(FLICK_EINT_NO,KAL_TRUE,flick_state,FLICK_EINT_HISR,KAL_TRUE);4.中断处理函数以FLICK及BATTERY两个中断为例:voidFLICK_EINT_HISR(void)//addedbyJeffJi071024{ilm_struct*flick_ilm;aux_id_struct*aux_id_data;if(flick_state==LEVEL_HIGH){aux_id_data=(aux_id_struct*)construct_local_para(sizeof(aux_id_struct),TD_CTRL);aux_id_data-aux_id=AUX_ID_FLICK_OFF;DRV_BuildPrimitive(flick_ilm,MOD_EINT_HISR,MOD_UEM,MSG_ID_AUX_ID,aux_id_data);}else{aux_id_data=(aux_id_struct*)construct_local_para(sizeof(aux_id_struct),TD_CTRL);aux_id_data-aux_id=AUX_ID_FLICK_ON;DRV_BuildPrimitive(flick_ilm,MOD_EINT_HISR,MOD_UEM,MSG_ID_AUX_ID,aux_id_data);}msg_send_ext_queue(flick_ilm);flick_state=!flick_state;EINT_Set_Polarity(FLICK_EINT_NO,flick_state);}voidBATTERY_EINT_HISR(void){iwit_battery_state=!iwit_battery_state;EINT_Set_Polarity(BAT_EINT_NO,iwit_battery_state);iwit_fakeChargerAct=KAL_TRUE;if(iwit_battery_state==LEVEL_HIGH)//plugout{bmt_set_chr_status(bmt_chr_out);bmt_charger_action(KAL_FALSE);}else//plugin{if(iwit_charger_present){bmt_set_chr_status(bmt_chr_in);bmt_charger_action(KAL_TRUE);}}}三.键盘配置5X6键盘Powerkey单独,第6列DEVICE_KEY_ENDKeypad_def.c配置行列矩阵Kbd_table.h定义DRIVERKEYCODEKeyBrd.c定义KeyPadMapGlobalConstants.h定义MMIKEYCODE四.LCD驱动1Lcd_sw.h1.定义写命令及写数据的函数#defineLCD_CtrlWrite_HX8306A(_data)\{\*(volatilekal_uint32*)LCD_HX8306A_CTRL_ADDR=((_data&0xFF00)2)|((_data&0xFF)1);\LCD_delay_HX8306A();\}#defineLCD_DataWrite_HX8306A(_data)\{\*(volatilekal_uint32*)LCD_HX8306A_DATA_ADDR=((_data&0xFF00)2)|((_data&0xFF)1);\LCD_delay_HX8306A();\}2.定义是否使用DMA方式#defineLCD_CMD_DMA_MODE3.若是并口屏,要定义LCD接口的位数#defineLCD_18BIT_MODE2Lcd.cvoidLCD_FunConfig(void){MainLCD=&LCD_func_ST7549T;}voidLCD_Init_ST7549T(kal_uint32bkground,void**buf_addr)voidLCD_BlockWrite_ST7549T(kal_uint16startx,kal_uint16starty,kal_uint16endx,kal_uint16endy)voidLCD_EnterSleep_ST7549T(void)voidLCD_ExitSleep_ST7549T(void)voidLCD_SetContrast_ST7549T(kal_uint8level)1串口屏voidinit_lcd_interface(void){SPI_Initialize();//modifiedbyjeffji071024}/*init_lcd_interface()*voidlcdSendSerialData(kal_uint8SerialData,kal_boolrs)#definelcdSendCmd(cmd)lcdSendSerialData(cmd,0)#definelcdSendData(data)lcdSendSerialData(data,1)2并口屏:voidinit_lcd_interface(void){kal_uint32i;REG_LCD_ROI_CTRL=0;CLEAR_LCD_CTRL_RESET_PIN;#if(defined(MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6223)||defined(MT6223P))SET_LCD_PARALLEL_CE2WR_SETUP_TIME((kal_uint32)2);SET_LCD_PARALLEL_CE2WR_HOLD_TIME(2);SET_LCD_PARALLEL_CE2RD_SETUP_TIME(2);SET_LCD_PARALLEL_WRITE_WAIT_STATE(3);SET_LCD_PARALLEL_READ_LATENCY_TIME(31);SET_LCD_ROI_CTRL_CMD_LATENCY(3#if(defined(MT6226)||defined(MT6226M)||defined(MT6227)||defined(MT6223)||defined(MT6223P))#if(defined(LCD_16BIT_MODE))SET_LCD_PARALLEL_16BIT_DATA_BUS;//ywm++20060518#elif(defined(LCD_18BIT_MODE))GPIO_ModeSetup(55,1);*((volatileunsignedshort*)0x801201B0)|=0x4000;*((volatileunsignedshort*)0x801201D0)|=0x0001;SET_LCD_PARALLEL_18BIT_DATA_BUS;#elif(defined(LCD_8BIT_MODE))SET_LCD_PARALLEL_8BIT_DATA_BUS;#endif#endif#if(defined(MT6219))DISABLE_LCD_PARALLEL_SYNC;#endif#endifSET_LCD_CTRL_RESET_PIN;Delayms(100);}/*init_lcd_interface()*/五.音效优化1.Speaker2.Receiver3.Micphone模式:normal;handfree;headsetNvram_default_audio.c值的范围0-255Audcoeff.cFIR需使用音频测试仪器测出的参数,一般都是normal模式下的参数;handfree模式下的参数要依靠经验和尝试来确定。constunsignedshortDG_DL_Speech=0x1000;constunsignedshortDG_Microphone=0x1400;以上两个变量为Receiver及Microphone的数字增益,值可以在0x1000至0x2000之间调整,但一般情况下不需调整。使用默认值,而只调整Nvram_default_audio.c当中的模拟增益值的大小即可audcoeff_default.h#defineDEFAULT_SPEECH_LOUDSPK_MODE_PARA\{\128,224,5128,0,374,0,400,0\}第一个参数范围值0至1024,值越大,回声抑制越弱;值越小,回声抑制越强。该值可以用于改善音频的回声及断续。其它值不建议修改._Apply_Mic_Setting对MIC的设置,注意MIC的单端及差分设置void_apply_mic_setting_c63216(kal_int16a_lowest){if(afe.mic_src==L1SP_LNA_1){/*HeadsetMode*/*AFE_VAC_CON0|=0x0480;/*Switchinputsourcetoheadsetmicrophone*/*AFE_VAC_CON1|=0x0040;/*Swi

1 / 29
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功