鸿 网 互 联 www.68idc.cn

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

来源:互联网 作者:佚名 时间:2015-10-26 08:24
6410的WINCE 底层 GPIO 设置 问题 各位好!我现在在做天嵌6410的GPIO 设置 ,因为我刚接触这方面,不是很了解,希望大家帮个忙!我现在是直接仿照天嵌的程序 设置 了GPB CPC GPK口,但是发现GPB口可以实现高低电平的转换,GPC口一直是高电平,切换不了,不知
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);
网友评论
<