iMX51 一步一个脚印 --iMX51 WINCE6.0 GPIO设置
来源:互联网 发布:sql新增字段 编辑:程序博客网 时间:2024/05/16 16:00
iMX51的功能十分强大,对于从三星平台转移过来的人说那近4千多页的看着实在是头疼,看了看实在是没办法下手,按照常规的学习方法先从IO入手,看了近一周才看出了个眉目。参考上一篇文章这才对IO设置有了一个基本的认识。下边就以PWRBUTTON为例:
#define BSP_PWRBTN_IOMUX_PIN DDK_IOMUX_PIN_EIM_A27#define BSP_PWRBTN_IOMUX_PAD DDK_IOMUX_PAD_EIM_A27#define BSP_PWRBTN_GPIO_PORT DDK_GPIO_PORT2#define BSP_PWRBTN_GPIO_PIN 21#define BSP_PWRBTN_GPIO_IRQ IRQ_GPIO2_PIN21
// Configure GPIO signal for power button events DDKIomuxSetPinMux(BSP_PWRBTN_IOMUX_PIN, DDK_IOMUX_PIN_MUXMODE_ALT1, DDK_IOMUX_PIN_SION_REGULAR); DDKIomuxSetPadConfig(BSP_PWRBTN_IOMUX_PAD, DDK_IOMUX_PAD_SLEW_NULL, DDK_IOMUX_PAD_DRIVE_NULL, DDK_IOMUX_PAD_OPENDRAIN_NULL, DDK_IOMUX_PAD_PULL_NONE, DDK_IOMUX_PAD_HYSTERESIS_ENABLE, DDK_IOMUX_PAD_INMODE_NULL, DDK_IOMUX_PAD_OUTVOLT_NULL); DDKGpioSetConfig(BSP_PWRBTN_GPIO_PORT, BSP_PWRBTN_GPIO_PIN, DDK_GPIO_DIR_IN, DDK_GPIO_INTR_HIGH_LEV); DDKGpioClearIntrPin(BSP_PWRBTN_GPIO_PORT, BSP_PWRBTN_GPIO_PIN);
板子上PWRBUTTON键是用的CPU IO口为GPIO2[21]. .
以上几个函数的原型为:
// Function: DDKIomuxSetPinMux//// Sets the IOMUX configuration for the specified IOMUX pin.//// Parameters:// pin// [in] Functional pin name used to select the IOMUX output/input// path that will be configured.//// muxmode// [in] MUX_MODE configuration.//// sion// [in] SION configuration.//// Returns:// Returns TRUE if successful, otherwise returns FALSE.////-----------------------------------------------------------------------------BOOL DDKIomuxSetPinMux(DDK_IOMUX_PIN pin, DDK_IOMUX_PIN_MUXMODE muxmode, DDK_IOMUX_PIN_SION sion){ // No need to use interlocked access since each pad has a separate register OUTREG32(&g_pIOMUX->SW_MUX_CTL[pin], (muxmode | sion)); return TRUE;}
DDKIomuxSetPinMux(BSP_PWRBTN_IOMUX_PIN, DDK_IOMUX_PIN_MUXMODE_ALT1, DDK_IOMUX_PIN_SION_REGULAR);
设置EIM_A27引脚做为GPIO使用GPIO2[21]. DDK_IOMUX_PIN_MUXMODE_ALT1对应的设置为GPIO2[21].
函数原型为:
// Function: DDKIomuxSetPadConfig//// Sets the IOMUX pad configuration for the specified IOMUX pad.//// Parameters:// pad// [in] Functional pad name used to select the pad that will be // configured.//// slew// [in] Slew rate configuration.//// drive// [in] Drive strength configuration.//// openDrain// [in] Open drain configuration.//// pull// [in] Pull-up/pull-down/keeper configuration.//// hysteresis// [in] Hysteresis configuration.//// inputMode// [in] Input mode (CMOS/DDR) configuration.//// outputVolt// [in] Output voltage configuration.//// Returns:// Returns TRUE if successful, otherwise returns FALSE.////-----------------------------------------------------------------------------BOOL DDKIomuxSetPadConfig(DDK_IOMUX_PAD pad, DDK_IOMUX_PAD_SLEW slew, DDK_IOMUX_PAD_DRIVE drive, DDK_IOMUX_PAD_OPENDRAIN openDrain, DDK_IOMUX_PAD_PULL pull, DDK_IOMUX_PAD_HYSTERESIS hysteresis, DDK_IOMUX_PAD_INMODE inputMode, DDK_IOMUX_PAD_OUTVOLT_HLVOLT outputVolt){ // No need to use interlocked access since each pad has a separate register OUTREG32(&g_pIOMUX->SW_PAD_CTL[pad], (slew | drive | openDrain | pull | hysteresis | inputMode | outputVolt)); return TRUE;}
DDKIomuxSetPadConfig(BSP_PWRBTN_IOMUX_PAD, DDK_IOMUX_PAD_SLEW_NULL, DDK_IOMUX_PAD_DRIVE_NULL, DDK_IOMUX_PAD_OPENDRAIN_NULL, DDK_IOMUX_PAD_PULL_NONE, DDK_IOMUX_PAD_HYSTERESIS_ENABLE, DDK_IOMUX_PAD_INMODE_NULL, DDK_IOMUX_PAD_OUTVOLT_NULL);
设置PAD寄存器:HYS [8]: 1, PKE[7]:0通过这2个寄存器的配置,就可以对IO进行操作了。
以下是常用的操作函数:
BOOL DDKGpioSetConfig(DDK_GPIO_PORT port, UINT32 pin, DDK_GPIO_DIR dir, DDK_GPIO_INTR intr);BOOL DDKGpioWriteData(DDK_GPIO_PORT port, UINT32 portMask, UINT32 data);BOOL DDKGpioWriteDataPin(DDK_GPIO_PORT port, UINT32 pin, UINT32 data);BOOL DDKGpioReadData(DDK_GPIO_PORT port, UINT32 portMask, UINT32 *pData);BOOL DDKGpioReadDataPin(DDK_GPIO_PORT port, UINT32 pin, UINT32 *pData);BOOL DDKGpioReadIntr(DDK_GPIO_PORT port, UINT32 portMask, UINT32 *pStatus);BOOL DDKGpioReadIntrPin(DDK_GPIO_PORT port, UINT32 pin, UINT32 *pStatus);BOOL DDKGpioClearIntrPin(DDK_GPIO_PORT port, UINT32 pin);
- iMX51 一步一个脚印 --iMX51 WINCE6.0 GPIO设置
- IMX51---GPIO
- Freescale WinCE6.0开发板IMX51初步使用
- WINCE6.0下的 IMX51 AC97驱动 简述
- Freescale WinCE6.0开发板IMX51初步使用
- IMX51 uboot中设置启动图标
- imx51制作系统盘
- Freescale iMx51开发
- imx51开发板
- Freescale iMx51开发
- IMX51, SD驱动
- IMX51,Android驱动
- Freescale iMx51开发
- IMX51启动模式
- IMX51的UUID
- iMX51的键盘布局文件
- imx51 evk 已经android跑起来了!
- IMX51系统修改wifi的mac
- java 重写类的equals方法和hashcode方法
- XSLT 教程
- SAP FI/CO 模块设置
- Git
- 如何在第三页开始设置页码
- iMX51 一步一个脚印 --iMX51 WINCE6.0 GPIO设置
- 关于修改用户,表的 tablespace_name走的一点弯路
- C#中的Object、Dynamic与var的区别
- 【人工智能】软件使用--weka如何处理大数据量
- memcached全面剖析–2.理解memcached的内存存储
- 交通灯管理系统
- 表单提交前验证
- 破解死锁几个方法
- eclipse 导入工程 叹号 红叉