Download Allwinner Technology CO., Ltd. - linux

Transcript
Allwinner Technology CO., Ltd.
{
int ret;
user_gpio_set_t gpio_info;
__hdle
gpio_hd;
gpio_info.port = 1;
//use Port A
gpio_info.port_num = 14;
//use the 14th pin of PortA
gpio_info.mul_sel = 1;
//set to output
gpio_info.pull = 1;
//build-in resistor is pulled up
gpio_info.drv_level = 1;
//driver strength is Level 1
gpio_info.data
//output high level
= 1;
gpio_hd = OSAL_GPIO_Request(&gpio_info, 1); // request only one GPIO
if(!gpio_hd)
{
return -1;
}
ret = OSAL_GPIO_DevWRITE_ONEPIN_DATA(gpio_hd, 0, 0);
(1)
OSAL_GPIO_DevSetONEPIN_IO_STATUS(gpio_hd, 0, 0);
ret = OSAL_GPIO_DevWRITE_ONEPIN_DATA(gpio_hd, 1, 0);
(2)
return 0;
}
When requested, PA14 is set to output, high level. By calling function (1), it is set to output low
level, and then it’s set to input, making the port level unconfigurable, so when function (2) is
called to set it to high level, “-1” is returned because it is not in output status.
System Configuration and GPIO Management V1.01
Copyright © 2011 Allwinner Technology. All Rights Reserved.
April 22, 2011
45