首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > WinCE >

6410的WINCE底层GPIO设置有关问题

2012-07-28 
6410的WINCE底层GPIO设置问题各位好!我现在在做天嵌6410的GPIO设置,因为我刚接触这方面,不是很了解,希望大

6410的WINCE底层GPIO设置问题
各位好!我现在在做天嵌6410的GPIO设置,因为我刚接触这方面,不是很了解,希望大家帮个忙!我现在是直接仿照天嵌的程序设置了GPB CPC GPK口,但是发现GPB口可以实现高低电平的转换,GPC口一直是高电平,切换不了,不知道什么原因..
程序部分是这样的:
#define IO_CTL_GPIO_1_ON 0x08
#define IO_CTL_GPIO_2_ON 0x09
#define IO_CTL_GPIO_3_ON 0x0A
#define IO_CTL_GPIO_1_OFF 0x0B
#define IO_CTL_GPIO_2_OFF 0x0C
#define IO_CTL_GPIO_3_OFF 0x0D
#define IO_CTL_GPIO_4_ON 0x0E
#define IO_CTL_GPIO_4_OFF 0x0F

#define IO_CTL_GPIO_5_ON 0x18
#define IO_CTL_GPIO_5_OFF 0x19

#define IO_CTL_GPIO_11_ON 0x10
#define IO_CTL_GPIO_12_ON 0x11
#define IO_CTL_GPIO_13_ON 0x12
#define IO_CTL_GPIO_11_OFF 0x13
#define IO_CTL_GPIO_12_OFF 0x14
#define IO_CTL_GPIO_13_OFF 0x15
#define IO_CTL_GPIO_14_ON 0x16
#define IO_CTL_GPIO_14_OFF 0x17
DWORD GIO_Init(DWORD dwContext)
{

RETAILMSG(1,(TEXT("GPIO Initialize ...")));

if (!InitializeAddresses())
return (FALSE);

v_pGPIORegs->GPBCON = (v_pGPIORegs->GPBCON &~(0xF << 0)) | (1<< 0);// GPB0 == OUTPUT.LED1
v_pGPIORegs->GPBCON = (v_pGPIORegs->GPBCON &~(0xF << 4)) | (1<< 4);// GPB1 == OUTPUT.LED2
v_pGPIORegs->GPBCON = (v_pGPIORegs->GPBCON &~(0xF << 8)) | (1<< 8);// GPB2 == OUTPUT.LED3
v_pGPIORegs->GPBCON = (v_pGPIORegs->GPBCON &~(0xF << 12)) | (1<< 12);// GPB3 == OUTPUT.LED4

v_pGPIORegs->GPCCON = (v_pGPIORegs->GPCCON &~(0xF << 0)) | (1<< 0);// GPC0 == OUTPUT.LED1
v_pGPIORegs->GPCCON = (v_pGPIORegs->GPCCON &~(0xF << 4)) | (1<< 4);// GPC1 == OUTPUT.LED2
v_pGPIORegs->GPCCON = (v_pGPIORegs->GPCCON &~(0xF << 8)) | (1<< 8);// GPC2 == OUTPUT.LED3
v_pGPIORegs->GPCCON = (v_pGPIORegs->GPCCON &~(0xF << 12)) | (1<< 12);// GPC3 == OUTPUT.LED4

v_pGPIORegs->GPKCON0 = (v_pGPIORegs->GPKCON0 &~(0xF << 0)) | (1<< 0);// GPK0 == OUTPUT.LED1

v_pGPIORegs->GPBPUD = (v_pGPIORegs->GPBPUD &~(0x3<< 0));// GPB0 pull up/down disabled.
v_pGPIORegs->GPBPUD = (v_pGPIORegs->GPBPUD &~(0x3<< 2));// GPB1 pull up/down disabled.
v_pGPIORegs->GPBPUD = (v_pGPIORegs->GPBPUD &~(0x3<< 4));// GPB2 pull up/down disabled.
v_pGPIORegs->GPBPUD = (v_pGPIORegs->GPBPUD &~(0x3<< 6));// GPB3 pull up/down disabled.

v_pGPIORegs->GPCPUD = (v_pGPIORegs->GPCPUD &~(0x3<< 0));// GPC0 pull up/down disabled.
v_pGPIORegs->GPCPUD = (v_pGPIORegs->GPCPUD &~(0x3<< 2));// GPC1 pull up/down disabled.
v_pGPIORegs->GPCPUD = (v_pGPIORegs->GPCPUD &~(0x3<< 4));// GPC2 pull up/down disabled.
v_pGPIORegs->GPCPUD = (v_pGPIORegs->GPCPUD &~(0x3<< 6));// GPC3 pull up/down disabled.

v_pGPIORegs->GPKPUD = (v_pGPIORegs->GPKPUD &~(0x3<< 0));// GPK0 pull up/down disabled


mInitialized = TRUE;
RETAILMSG(1,(TEXT("OK !!!\r\n")));
return TRUE;
}

BOOL GIO_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
switch(dwCode)
{
case IO_CTL_GPIO_1_ON:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT|(0x1<<0);
break;
case IO_CTL_GPIO_2_ON:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT|(0x1<<1);
break;
case IO_CTL_GPIO_3_ON:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT|(0x1<<2);
break;
case IO_CTL_GPIO_4_ON:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT|(0x1<<3);
break;
case IO_CTL_GPIO_1_OFF:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT&~(0x1<<0);
break;
case IO_CTL_GPIO_2_OFF:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT&~(0x1<<1);


break;
case IO_CTL_GPIO_3_OFF:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT&~(0x1<<2);
break;
case IO_CTL_GPIO_4_OFF:
v_pGPIORegs->GPBDAT=v_pGPIORegs->GPBDAT&~(0x1<<3);
break;
case IO_CTL_GPIO_11_ON:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT|(0x1<<0);
break;
case IO_CTL_GPIO_12_ON:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT|(0x1<<1);
break;
case IO_CTL_GPIO_13_ON:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT|(0x1<<2);
break;
case IO_CTL_GPIO_14_ON:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT|(0x1<<3);
break;
case IO_CTL_GPIO_11_OFF:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT&~(0x1<<0);
break;
case IO_CTL_GPIO_12_OFF:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT&~(0x1<<1);
break;
case IO_CTL_GPIO_13_OFF:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT&~(0x1<<2);
break;
case IO_CTL_GPIO_14_OFF:
v_pGPIORegs->GPCDAT=v_pGPIORegs->GPCDAT&~(0x1<<3);
break;
case IO_CTL_GPIO_5_ON:
v_pGPIORegs->GPKDAT=v_pGPIORegs->GPKDAT|(0x1<<0);
break;
case IO_CTL_GPIO_5_OFF:
v_pGPIORegs->GPKDAT=v_pGPIORegs->GPKDAT&~(0x1<<0);
break;
default:
break;
}

RETAILMSG(DEBUG_GPIO,(TEXT("GPIO_Control:Ioctl code = 0x%x\r\n"), dwCode));
return TRUE;
}

谢谢大家了!!

[解决办法]
看看GPC口是否已被系统在其它地方使用了。
[解决办法]
最好用系统的API函数操作,也有可能被其他代码占用了

热点排行