MTK手机设备驱动编写介绍.ppt
《MTK手机设备驱动编写介绍.ppt》由会员分享,可在线阅读,更多相关《MTK手机设备驱动编写介绍.ppt(29页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
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(
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MTK 手机 设备 驱动 编写 介绍
限制150内