本帖最后由 Anshadow 于 2019-6-25 22:34 编辑

## 一、前期准备
硬件准备:
* 1.w600开发板
* 2.一根microusb线

软件准备:
* 1.MDK软件
* 2.RT-Thread的env工具
* 3.RT-Thread的代码包
* 4.串口下载工具

## 二、学习过程
### (一)编译程序与下载
* 1.在RT-Thread的代码包中的BSP目录下找到w60x的文件夹,进入w60x的文件夹里面,在该目录下打开env工具,在env工具的命令行下输入:
```
pkgs --update
```
执行该命令会在该目录下产生packages文件夹,里面包括一些必要的文件,在编译前一定要先执行上述的操作。
* 2.在env工具的命令行中输入编译生成新的工程或者添加其他配置的命令,在此处不执行操作,直接打开原有的项目工程。
* 3.通过mdk5 打开项目工程,进行编译。
* 4.编译生成的文件在项目工程目录下的Bin文件夹中。
* 通过串口下载工具,下载.FLS文件。

### (二)点亮LED灯
* 1. GPIO说明: 板载的5个LED灯的GPIO对应如下表:

| GPIO | PIN | LED|
|------|-----|----|
| PB_14| 19  | 01 |
| PB_15| 20  | 02 |
| PB_16| 21  | 03 |
| PB_17| 22  | 04 |
| PB_18| 23  | 05 |
* 2. 点亮LED的代码说明: 使用PIN设备的框架,设置pin口,设置为输出模式,设置高低电平。
    直接上代码:

   

    ```
    /* 定义LED 的pin脚  */
    #define LED1_PIN        (19)
    int basic_led_blink(int argc ,char *argv[])
    {
        unsigned int count = 1;
        
        /* 设置LED 为输出模式 */
        rt_pin_mode(LED_PIN,PIN_MODE_OUTPUT);
        
        while (count > 0)
        {
            /* LED 亮 */
            rt_pin_write(LED1_PIN, PIN_LOW);
            rt_kprintf("led on, count: %d\n", count);
            rt_thread_mdelay(500);
   
            /* LED 灭  */
            rt_pin_write(LED1_PIN, PIN_HIGH);
            rt_kprintf("led off\n");
            rt_thread_mdelay(500);
   
            count++;
        }
   
        return 0;
   
    }
   
    MSH_CMD_EXPORT(basic_led_blink,Blink Led);
    ```

### 跑马灯示例

```
#include <rtthread.h>
#include <rtdevice.h>


#define DBG_SECTION_NAME  "LED"
#define DBG_LEVEL         DBG_LOG
#include <rtdbg.h>

/* 定义LED 的pin脚  */
#define LED1_PIN        (19)
#define LED2_PIN        (20)
#define LED3_PIN        (21)
#define LED4_PIN        (22)
#define LED5_PIN        (23)
int basic_led_blink(int argc ,char *argv[])
{
    unsigned int count = 1;
    int i = 0;

    /* 设置LED 为输出模式 */
    for (i = 19;i <= 23;i++)
    {
        rt_pin_mode(i, PIN_MODE_OUTPUT);
    }

    while (count > 0)
    {
        for(i = 19;i <= 23;i++)
        {
            /* LED 亮 */
        rt_pin_write(i, PIN_LOW);
        rt_kprintf("led i=%d on , count: %d\n", i,count);
        rt_thread_mdelay(500);

        /* LED 灭  */
        rt_pin_write(i, PIN_HIGH);
        rt_kprintf("led i= %d off,count = %d \n",i,count);
        rt_thread_mdelay(500);

        }
        count++;

        if(count >=200)
        {
            count = 0;
        }
    }

    return 0;

}

MSH_CMD_EXPORT(basic_led_blink,Blink Led);
```


刚入门W600的学习,对于W600的强大性能还有很多diy的想法.....
正在学习论坛发帖,期待有更多的干货和大伙分享.