MTK手机设备驱动编写介绍.ppt

上传人:wuy****n92 文档编号:70800335 上传时间:2023-01-28 格式:PPT 页数:29 大小:258.50KB
返回 下载 相关 举报
MTK手机设备驱动编写介绍.ppt_第1页
第1页 / 共29页
MTK手机设备驱动编写介绍.ppt_第2页
第2页 / 共29页
点击查看更多>>
资源描述

《MTK手机设备驱动编写介绍.ppt》由会员分享,可在线阅读,更多相关《MTK手机设备驱动编写介绍.ppt(29页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、首先需要注意两个宏定义1._CUST_NEW_CUST_NEW_程序中有多处用该宏将代码隔开Make文件中若如下定义:DRV_CUSTOM_TOOL_SUPPORT =TRUE Option.mak文件中ifdef DRV_CUSTOM_TOOL_SUPPORT ifeq($(strip$(DRV_CUSTOM_TOOL_SUPPORT),TRUE)COM_DEFS +=_CUST_NEW_ endifendif2.WIN32 WIN32#ifndef WIN32#endif用该宏将真机与模拟器的代码分隔开 GPIO口的初始化方法:两种:1.工具customdrvDrv_ToolDrvGen.

2、exe 修改:customdrvmisc_drvIWIT23_NEP_07A_PMJ_BBcodegencodegen.dws 2.程序中修改:Gpio_drv.c void GPIO_init(void)操作 1.写状态 a.模式修改 GPIO_ModeSetup(kal_uint16 pin,kal_uint16 conf_dada)b.方向修改 void GPIO_InitIO(char direction,char port)c.置高与置低 GPIO_WriteIO(char data,char port)d.上拉与下拉的使能void GPIO_PullenSetup(kal_uint

3、16 pin,kal_bool enable)2.读取状态 a.返回模式char GPIO_ReturnMode(char port);b.返回方向char GPIO_ReturnDir(char port);c.返回电平值char GPIO_ReturnDout(char port);3.GPIO使用中需注意的问题.中断个数 8个EINT0,EINT1为专用中断,EINT2-7 与GPIO等功能复用.设置中断模式通过DRV_TOOL或Gpio_init(void)来初始化,也可在程序中通过GPIO_ModeSetup(kal_uint16 pin,kal_uint16 conf_dada)随

4、时修改.中断注册函数 在某个TASK中注册中断,建议注册在AUX_TASK中,便于管理 EINT_Registration(FLICK_EINT_NO,KAL_TRUE,flick_state,FLICK_EINT_HISR,KAL_TRUE);.中断处理函数以FLICK及BATTERY两个中断为例:void FLICK_EINT_HISR(void)/added by Jeff Ji 071024 ilm_struct *flick_ilm;aux_id_struct *aux_id_data;if(flick_state=LEVEL_HIGH)aux_id_data=(aux_id_str

5、uct*)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_Build

6、Primitive(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);void BATTERY_EINT_HISR(void)iwit_battery_state=!iwit_battery_state;EINT_Set_Polarity(BAT_EINT_NO,iwit_battery_state);iwit_fakeCharg

7、erAct=KAL_TRUE;if(iwit_battery_state=LEVEL_HIGH)/plug out bmt_set_chr_status(bmt_chr_out);bmt_charger_action(KAL_FALSE);else/plug in if(iwit_charger_present)bmt_set_chr_status(bmt_chr_in);bmt_charger_action(KAL_TRUE);5X6键盘Powerkey单独,第6列 DEVICE_KEY_ENDKeypad_def.c 配置行列矩阵Kbd_table.h 定义 DRIVER KEY CODE

8、KeyBrd.c 定义KeyPadMap GlobalConstants.h 定义MMI KEY CODE 四.LCD驱动 Lcd_sw.h 1.定义写命令及写数据的函数#define LCD_CtrlWrite_HX8306A(_data)*(volatile kal_uint32*)LCD_HX8306A_CTRL_ADDR=(_data&0 xFF00)2)|(_data&0 xFF)1);LCD_delay_HX8306A();#define LCD_DataWrite_HX8306A(_data)*(volatile kal_uint32*)LCD_HX8306A_DATA_ADDR

9、=(_data&0 xFF00)2)|(_data&0 xFF)1);LCD_delay_HX8306A();2.定义是否使用DMA方式#define LCD_CMD_DMA_MODE 3.若是并口屏,要定义LCD接口的位数#define LCD_18BIT_MODE Lcd.c void LCD_FunConfig(void)MainLCD=&LCD_func_ST7549T;void LCD_Init_ST7549T(kal_uint32 bkground,void*buf_addr)void LCD_BlockWrite_ST7549T(kal_uint16 startx,kal_uin

10、t16 starty,kal_uint16 endx,kal_uint16 endy)void LCD_EnterSleep_ST7549T(void)void LCD_ExitSleep_ST7549T(void)void LCD_SetContrast_ST7549T(kal_uint8 level)串口屏void init_lcd_interface(void)SPI_Initialize();/modified by jeff ji 071024/*init_lcd_interface()*void lcdSendSerialData(kal_uint8 SerialData,kal_

11、bool rs)#define lcdSendCmd(cmd)lcdSendSerialData(cmd,0)#define lcdSendData(data)lcdSendSerialData(data,1)并口屏:void init_lcd_interface(void)kal_uint32 i;REG_LCD_ROI_CTRL=0;CLEAR_LCD_CTRL_RESET_PIN;#if(defined(MT6219)|defined(MT6226)|defined(MT6226M)|defined(MT6227)|defined(MT6223)|defined(MT6223P)SET_

12、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(

13、MT6223P)#if(defined(LCD_16BIT_MODE)SET_LCD_PARALLEL_16BIT_DATA_BUS;/ywm+20060518#elif(defined(LCD_18BIT_MODE)GPIO_ModeSetup(55,1);*(volatile unsigned short*)0 x801201B0)|=0 x4000;*(volatile unsigned short*)0 x801201D0)|=0 x0001;SET_LCD_PARALLEL_18BIT_DATA_BUS;#elif(defined(LCD_8BIT_MODE)SET_LCD_PARA

14、LLEL_8BIT_DATA_BUS;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;headset Nvram_default_audio.c值的范围 0-255Audcoeff.c FIR 需使用音频测试仪器测出的参数,一般都

15、是normal模式下的参数;handfree模式下的参数要依靠经验和尝试来确定。const unsigned short DG_DL_Speech =0 x1000;const unsigned short DG_Microphone =0 x1400;以上两个变量为Receiver及Microphone的数字增益,值可以在0 x1000至0 x2000之间调整,但一般情况下不需调整。使用默认值,而只调整Nvram_default_audio.c当中的模拟增益值的大小即可audcoeff_default.h#define DEFAULT_SPEECH_LOUDSPK_MODE_PARA 128

16、128,224,5128,0,374,0,400,0 第一个参数范围值0至1024,值越大,回声抑制越弱;值越小,回声抑制越强。该值可以用于改善音频的回声及断续。其它值不建议修改._Apply_Mic_Setting对MIC的设置,注意MIC的单端及差分设置void _apply_mic_setting_c63216(kal_int16 a_lowest)if(afe.mic_src=L1SP_LNA_1)/*Headset Mode*/*AFE_VAC_CON0|=0 x0480;*AFE_VAC_CON0|=0 x0480;/*Switch input source to headset

17、microphone*/*AFE_VAC_CON1|=0 x0040;/*Switch on resister string*/else /*Normal Mode*/*AFE_VAC_CON0&=0 x0480;/*Switch input source to normal microphone*/*AFE_VAC_CON1&=0 x0040;/*Switch off resister string*/1.工具配置2.系数设置 Chr_parameter.cconst kal_uint16 adc_volt_factorADC_MAX_CHANNEL 100,100,50,250,50,50

18、,/*NC*/50/*NC*/,50为一倍3.ADC测量 Auxmain.c 七.Touch panel 1.MAKE文件中如下配置TOUCH_PANEL_SUPPORT =MT63012.Touch_panel_spi.h#define SPI_DIN_PIN gpio_tp_spi_din_pin /*GPO*/#define SPI_CLK_PIN gpio_tp_spi_clk_pin/*GPO*/#define SPI_DOUT_PIN gpio_tp_spi_dout_pin/*GPI*/#define SPI_CS_PIN gpio_tp_spi_cs_pin/*GPO*/#de

19、fine SPI_BUSY_PIN gpio_tp_spi_busy_pin/*GPI*/3.Touch_panel_custom.h#define TOUCH_PANEL_COORD_X_START 0#define TOUCH_PANEL_COORD_X_END 239#define TOUCH_PANEL_COORD_Y_START 0#define TOUCH_PANEL_COORD_Y_END 319 八.USB 1.MAKE文件中_CHARGER_USB_DETECT_WIHT_ONE_EINT_ _USB_ENABLE_ USB_IN_NORMAL_MODE_SUPPORT=TR

20、UE2.ADC配置,工具配置 ADC_CHR_USB3.Chr_parameter.cconst kal_uint16 adc_volt_factorADC_MAX_CHANNEL 100,100,50,250,50,50,/*NC*/50/*NC*/,九.UART 串口初始化 Uart.c中,void UART_HWInit(UART_PORT port)UARTDCBStruct UART_DefaultConfig=UART_BAUD_115200,/*baud;*/len_8,/*dataBits;*/sb_1,/*stopBits;*/pa_none,/*parity;*/fc_no

21、ne,/*no flow control*/0 x11,/*xonChar;*/0 x13,/*xoffChar;*/KAL_FALSE ;关于AT模式串口及Trace模式串口的设置(NVRAM)Nvram_common_config.cstatic kal_uint8 const NVRAM_EF_PORT_SETTING_DEFAULT=#if defined(_ONLY_ONE_UART_)0 x63,0 x00,/*TST uses uart_port2(value is 1)*/0 x00,0 x00,/*APP uses uart_port1*/#else 0 x010 x01,0

22、 x00,/*TST uses uart_port2(value is 1)*/0 x000 x00,0 x00,/*APP uses uart_port1*/#endif#if defined(EMPTY_MMI)0 x00,0 x10,0 x0E,0 x00,/*tst default baud rate base=921600=0 x000E1000*/#else 0 x00,0 xC2,0 x01,0 x00,/*tst default baud rate base=115200=0 x0001C200*/#endif#if defined(_GPRS_MODE_)0 x00,0 xC

23、2,0 x01,0 x00,/*ps default baud rate base=115200=0 x0001C200*/#else 0 x00,0 xC2,0 x01,0 x00,/*ps default baud rate base=57600=0 x0000E100*/#endif 0 x00,/*High SpeedSIM*/0 x00,/*SWDBG*/0 x03,0 x63,/*uart power setting,plus 1-byte padding*/0 x00,0 x00,0 x00,0 x00 /*CTI baud rate*/;1.充电器检测 EINT 配置2.充电开

24、始与停止 bmt_charge_start();bmt_charge_end();3.充电电流控制Pmu.cpmu_chr_cur_level pmu_ret_chr_current(void)4.电池电量等级 kal_uint32 const NVRAM_EF_CUST_HW_LEVEL_TBL_DEFAULT=5.chr_parameter.c1.FactoryModeSrc.cconst testlet TestsMAX_AUTO_TEST_ITEMS 2.Nvram_common_config.cstatic kal_uint8 const NVRAM_EF_AUTOTEST_DEFA

25、ULTNVRAM_EF_AUTOTEST_SIZE WDT的使用调试时使用,在出现死循环情况时.void WDT_Enable(kal_bool en)将该函数默认为Disable.但当RAM CRUSH掉后,无效.void DRV_RESET(void)LCD,键盘背光及马达控制Uem_gpio.ckal_bool custom_cfg_gpio_set_level(kal_uint8 gpio_dev_type,kal_uint8 gpio_dev_level)3.工程模式*#3646633#4.META工具的使用5.总的初始化函数Init.c 中void Application_Initialize(void*first_available_memory)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁