Zephyr初识_psoc4_gpio

1.设备树引入:
zephyr不同于常用的RTOS,pin脚定义部分需要配合dts,config,yaml等文件结合实现但是有着超强的可移植性。
pin脚定义如下

test0: testpin { 
	compatible = "gpio-outputs"; 

	testpin: testpin0 { 

	gpios = <&gpio_prt3 GPIO_ACTIVE_HIGH>; 

	label = "my label"; 
	}; 
}; 

2.yaml的引入:
我的理解是yaml相当于dts和c文件沟通的桥梁,每新建一个模块的dts需要实施更新对应的yaml


description: |
  This allows you to control a gpio pin

compatible: "gpio-outputs"

child-binding:
    description: |
      GPIO output child node
    properties:
       gpios:
          type: phandle-array
          required: true
          description: |
            pin function
       label:
          required: false
          type: string
          description: |
            gpio function.

3.main.c

#define MYPIN DT_NODELABEL(testpin) 

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(gpiopin,gpiotest);
gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); 
while(1)
{
//灯闪烁
	gpio_pin_toggle_dt(&led); 
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Sumerking

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值