W600-AliOS-Things开发教程(点灯)

通过前两篇教程我们已经搭建好了开发环境,移植了GPIO驱动,准备工作做好了就开始上板子实际测试吧。

1,创建一个我们的测试工程

填写位置,我直接用了默认

选择目标平台

我们就可得到一个新的工程,这样也就不用直接修改demo了

我使用的W600 Arduino开发板

根据原理图可以找的RGB灯的控制引脚,我们这次就控制让这个灯的蓝色进行闪烁,也就用到了PB_18引脚。

根据上一篇GPIO的介绍我们只需要以下几句简单的代码就可以实现闪烁。

#include <stdio.h>
#include "aos/hal/gpio.h"
#include "wm_gpio.h"
#include <aos/kernel.h>
#define GPIO_LED_BLUE WM_IO_PB_18
gpio_dev_t ledblue;
/**********************user code*************************/
int application_start(int argc, char *argv[])
{
    /*add your code*/
    ledblue.port = GPIO_LED_BLUE;
    ledblue.config = OUTPUT_PUSH_PULL;
    hal_gpio_init(&ledblue);
    while (1)
    {
        /*add your code*/
        printf("helloworld\r\n");
        hal_gpio_output_toggle(&ledblue);
        aos_msleep(1000);
    };
}

修改完代码后根据之前的教程编译并下载到板子里,就可以看到蓝色的灯规律的闪烁起来。

猜你喜欢

转载自blog.csdn.net/rootuseres/article/details/103630782