关闭

GPIO操作

284人阅读 评论(0) 收藏 举报
分类:
GPIOZ_0   GPIONUM 14    green
GPIOZ_1   GPIONUM 15    blue
GPIOAO_14   GPIONUM 135   red










可以手动调试申请一个pin:
echo GPIO_NUM > /sys/class/gpio/export
成功以后
在sys/class/gpio 创建目录 gpioGPIO_NUM
cd /sys/class/gpio/gpioGPIO_NUM
ls:
active_low
direction
edge
power
subsystem
uevent
value


向 direction 写
1 high 输出高电平
2 low 低电平
3 in 输入 




36,37:


echo 36 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio36/direction






red:


echo 135 > /sys/class/gpio/export
cd /sys/class/gpio/gpio135/
echo out > direction //输出.


 //操作步骤:设置GPIO节点 gpio14, gpio15, gpio135


echo 14 > /sys/class/gpio/export
echo 15 > /sys/class/gpio/export
echo 135 > /sys/class/gpio/export




=====================================================
cd /sys/class/gpio/gpio14
root@OomiStreamer:/sys/class/gpio/gpio14 # ls
active_low
direction
power
subsystem
uevent
value
====================================================================
echo low > /sys/class/gpio/gpio14/direction   //绿色
echo high > /sys/class/gpio/gpio14/direction  //关闭绿色


echo low > /sys/class/gpio/gpio15/direction  //蓝色
echo high > /sys/class/gpio/gpio15/direction  //关闭蓝色


echo low > /sys/class/gpio/gpio135/direction //红色
echo high > /sys/class/gpio/gpio135/direction //关闭红色






=================================================
蓝色+红色=粉色
echo high > /sys/class/gpio/gpio14/direction && echo low > /sys/class/gpio/gpio15/direction && echo low > /sys/class/gpio/gpio135/direction
蓝色+绿色=青色
echo low > /sys/class/gpio/gpio14/direction && echo low > /sys/class/gpio/gpio15/direction && echo high > /sys/class/gpio/gpio135/direction
红色+绿色=黄色
echo low > /sys/class/gpio/gpio14/direction && echo high > /sys/class/gpio/gpio15/direction && echo low > /sys/class/gpio/gpio135/direction


红绿蓝=白色
echo low > /sys/class/gpio/gpio14/direction && echo low > /sys/class/gpio/gpio15/direction && echo low > /sys/class/gpio/gpio135/direction


关闭红绿蓝
echo high > /sys/class/gpio/gpio14/direction && echo high > /sys/class/gpio/gpio15/direction && echo high > /sys/class/gpio/gpio135/direction








//测试:


GPIODV_27:  92
echo 92 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio92/direction  //亮
echo low > /sys/class/gpio/gpio92/direction


GPIOY_6: 101
echo 101 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio101/direction
echo low > /sys/class/gpio/gpio101/direction




GPIOX_18: 130
echo 130 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio130/direction
echo low > /sys/class/gpio/gpio130/direction






GPIOX_19 : 131
echo 131 > /sys/class/gpio/export
echo high > /sys/class/gpio/gpio131/direction
echo low > /sys/class/gpio/gpio131/direction
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:144913次
    • 积分:2423
    • 等级:
    • 排名:第15401名
    • 原创:88篇
    • 转载:82篇
    • 译文:2篇
    • 评论:20条
    最新评论