Эх сурвалжийг харах

initial peripheral samples package

luo jiao 7 жил өмнө
parent
commit
5d1f77d575

+ 52 - 0
.gitignore

@@ -0,0 +1,52 @@
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf

+ 202 - 0
LICENSE

@@ -0,0 +1,202 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

+ 54 - 2
README.md

@@ -1,2 +1,54 @@
-# peripheral-sample
-RT-Thread peripheral samples
+# peripheral samples package
+
+## 1、介绍
+
+这个软件包包含一些外设设备操作的例程。
+
+### 1.1 目录结构
+
+| 目录             | 例程                            |
+| ---------------- | ------------------------------- |
+| block            | 块设备的使用            |
+| can              | can 设备的使用             |
+| ethernet         | ethernet 设备的使用             |
+| i2c              | i2c 设备的使用             |
+| pin              | pin 设备的使用             |
+| pwm              | pwm 设备的使用 |
+| serial           | serial 设备的使用             |
+| spi              | spi 设备的使用             |
+| usb              | usb 设备的使用 |
+
+### 1.2 许可证
+
+peripheral samples package 遵循 Apache license v2.0 许可,详见 `LICENSE` 文件。
+
+### 1.3 依赖
+
+依赖设备管理模块提供的设备驱动。
+
+## 2、如何打开 peripheral samples package
+
+使用 peripheral samples package 需要在 RT-Thread 的包管理器中选择它,具体路径如下:
+
+```
+RT-Thread online packages
+    miscellaneous packages --->
+        samples: kernel and components samples --->
+            a peripheral_samples package for rt-thread --->
+
+```
+
+然后让 RT-Thread 的包管理器自动更新,或者使用 `pkgs --update` 命令更新包到 BSP 中。
+
+## 3、使用 peripheral samples package
+
+在打开 peripheral samples package 后,当进行 BSP 编译时,选择的软件包相关源代码会被加入到 BSP 工程中进行编译。
+
+## 4、注意事项
+
+暂无。
+
+## 5、联系方式 & 感谢
+
+* 维护:name
+* 主页:https://github.com/RT-Thread-packages/peripheral-sample.git

+ 49 - 0
SConscript

@@ -0,0 +1,49 @@
+
+from building import *
+Import('rtconfig')
+
+src   = []
+cwd   = GetCurrentDir()
+group = []
+CPPPATH = []
+
+# add kernel samples.
+if GetDepend('PERIPHERAL_SAMPLES_USING_BLOCK'):
+    src += Glob('block/*.c')
+    CPPPATH += [cwd + '/block']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_CAN'):
+    src += Glob('can/*.c')
+    CPPPATH += [cwd + '/can']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_ETHERNET'):
+    src += Glob('ethernet/*.c')
+    CPPPATH += [cwd + '/ethernet']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_I2C'):
+    src += Glob('i2c/*.c')
+    CPPPATH += [cwd + '/i2c']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_PIN'):
+    src += Glob('pin/*.c')
+    CPPPATH += [cwd + '/pin']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_PWM'):
+    src += Glob('pwm/*.c')
+    CPPPATH += [cwd + '/pwm']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_SERIAL'):
+    src += Glob('serial/*.c')
+    CPPPATH += [cwd + '/serial']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_SPI'):
+    src += Glob('spi/*.c')
+    CPPPATH += [cwd + '/spi']
+
+if GetDepend('PERIPHERAL_SAMPLES_USING_USB'):
+    src += Glob('usb/*.c')
+    CPPPATH += [cwd + '/usb']
+
+group = DefineGroup('peripheral-samples', src, depend = ['PKG_USING_PERIPHERAL_SAMPLES'], CPPPATH = CPPPATH)
+
+Return('group')

+ 0 - 0
block/README.md


+ 0 - 0
block/introduction.md


+ 0 - 0
can/README.md


+ 0 - 0
ethernet/README.md


+ 0 - 0
i2c/README.md


+ 123 - 0
i2c/i2c_sample.c

@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-15     Ernest Chen  first implementation.
+ */
+
+#include <rtthread.h>
+#include <rtdevice.h>
+
+#define AHT10_ADDR                  0x38
+#define AHT10_CALIBRATION_CMD       0xE1    /* 校准命令 */
+#define AHT10_NORMAL_CMD            0xA8    /* 一般命令 */
+#define AHT10_GET_DATA              0xAC    /* 获取数据命令 */
+#define I2C_BUS_NAME                "i2c1"  /* 传感器连接的I2C总线设备名称 */
+
+static struct rt_i2c_bus_device *i2c_bus = RT_NULL;
+static rt_uint8_t init_flag = 0;      /* 0:传感器没有初始化,1:传感器已经初始化 */
+
+/* 写 传感器寄存器 */
+static rt_err_t write_reg(struct rt_i2c_bus_device *bus, rt_uint8_t reg, rt_uint8_t *data)
+{
+    rt_uint8_t buf[3];
+
+    buf[0] = reg; //cmd
+    buf[1] = data[0];
+    buf[2] = data[1];
+
+    /* 调用I2C设备接口发送数据 */
+    if (rt_i2c_master_send(bus, AHT10_ADDR, 0, buf, 3) == 3)
+        return RT_EOK;
+    else
+        return -RT_ERROR;
+}
+
+/* 读 传感器寄存器数据 */
+static rt_err_t read_regs(struct rt_i2c_bus_device *bus, rt_uint8_t len, rt_uint8_t *buf)
+{
+    struct rt_i2c_msg msgs;
+
+    msgs.addr = AHT10_ADDR;
+    msgs.flags = RT_I2C_RD;
+    msgs.buf = buf;
+    msgs.len = len;
+
+    /* 调用I2C设备接口发送数据 */
+    if (rt_i2c_transfer(bus, &msgs, 1) == 1)
+        return RT_EOK;
+    else
+        return -RT_ERROR;
+}
+
+static void read_temp_humi(float *cur_temp,float *cur_humi)
+{
+    rt_uint8_t temp[6];
+
+    write_reg(i2c_bus, AHT10_GET_DATA, 0);      /* 发送命令 */
+    read_regs(i2c_bus, 6, temp);                /* 获取传感器数据 */
+
+    /* 湿度数据转换 */
+    *cur_humi = (temp[1] << 12 | temp[2] << 4 | (temp[3] & 0xf0) >> 4) * 100.0 / (1 << 20);
+    /* 温度数据转换 */
+    *cur_temp = ((temp[3] & 0xf) << 16 | temp[4] << 8 | temp[5]) * 200.0 / (1 << 20) - 50;
+}
+
+static void aht10_init(void)
+{
+    rt_uint8_t temp[2] = {0, 0};
+
+    /* 查找I2C总线设备,获取I2C总线设备句柄 */
+    i2c_bus = rt_i2c_bus_device_find(I2C_BUS_NAME);
+
+    if (i2c_bus == RT_NULL)
+    {
+        rt_kprintf("can't find %s device", I2C_BUS_NAME);
+    }
+    else
+    {
+        write_reg(i2c_bus, AHT10_NORMAL_CMD, temp);
+        rt_thread_delay(rt_tick_from_millisecond(600));     /* at least 300 ms */
+
+        temp[0] = 0x08;
+        temp[1] = 0x00;
+        write_reg(i2c_bus, AHT10_CALIBRATION_CMD, temp); 
+        rt_thread_delay(rt_tick_from_millisecond(600));     /* at least 300 ms */
+
+        init_flag = 1;
+    }
+}
+
+static void i2c_sample(void)
+{
+    float humidity, temperature;
+
+    humidity = 0.0;
+    temperature = 0.0;
+
+    if (0 == init_flag)
+    {
+        /* 传感器初始化 */
+        aht10_init();
+    }
+    if (1 == init_flag)
+    {
+        /* 读取温湿度数据 */
+        read_temp_humi(&temperature, &humidity);
+
+        rt_kprintf("read aht10 sensor humidity   : %d.%d %%\n", (int)humidity, (int)(humidity * 10) % 10);
+        rt_kprintf("read aht10 sensor temperature: %d.%d \n", (int)temperature, (int)(temperature * 10) % 10);
+    }
+    else
+    {
+        rt_kprintf("init sensor failed\n");
+    }
+}
+/* 导出到 msh 命令列表中 */
+MSH_CMD_EXPORT(i2c_sample, i2c device sample);
+
+
+

+ 0 - 0
pin/README.md


+ 43 - 0
pin/pin_sample.c

@@ -0,0 +1,43 @@
+#include <rtthread.h>
+#include <rtdevice.h>
+
+/* 引脚编号,通过查看drv_gpio.c确定 */
+#define BEEP_PIN        37  /* PB2 */
+#define KEY0 	        55  /* PD8 */
+#define KEY1 	        56  /* PD9 */
+
+void beep_on(void *args)
+{
+    rt_kprintf("turn on beep!\n");
+    
+    rt_pin_write(BEEP_PIN, PIN_HIGH);
+}
+
+void beep_off(void *args)
+{
+    rt_kprintf("turn off beep!\n");
+    
+    rt_pin_write(BEEP_PIN, PIN_LOW);
+}
+
+static void pin_sample(void)
+{
+    /* 按键0引脚为输入模式 */
+    rt_pin_mode(KEY0, PIN_MODE_INPUT_PULLUP);
+    /* 绑定中断,上升沿模式,回调函数名为beep_on */
+    rt_pin_attach_irq(KEY0, PIN_IRQ_MODE_FALLING, beep_on, RT_NULL);
+    /* 使能中断 */
+    rt_pin_irq_enable(KEY0, PIN_IRQ_ENABLE); 
+    
+    /* 按键1引脚为输入模式 */
+    rt_pin_mode(KEY1, PIN_MODE_INPUT_PULLUP);
+    /* 绑定中断,上升沿模式,回调函数名为beep_off */
+    rt_pin_attach_irq(KEY1, PIN_IRQ_MODE_FALLING, beep_off, RT_NULL);
+    /* 使能中断 */
+    rt_pin_irq_enable(KEY1, PIN_IRQ_ENABLE);
+    /* 蜂鸣器引脚为输出模式 */
+    rt_pin_mode(BEEP_PIN, PIN_MODE_OUTPUT);
+
+}
+/* 导出到 msh 命令列表中 */
+MSH_CMD_EXPORT(pin_sample, pin device sample);

+ 0 - 0
pwm/README.md


+ 0 - 0
serial/README.md


+ 65 - 0
serial/uart_sample.c

@@ -0,0 +1,65 @@
+#include <rtthread.h>
+
+#define UART_NAME       "uart2"
+/* 用于接收消息的信号量 */
+static struct rt_semaphore rx_sem;
+
+/* 接收数据回调函数 */
+static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
+{
+    /* 串口2接收到数据后产生中断,调用此回调函数,然后发送接收信号量 */
+    rt_sem_release(&rx_sem);
+
+    return RT_EOK;
+}
+
+static void serial_thread_entry(void* parameter)
+{
+    char ch;
+    rt_device_t serial2;
+    char str[] = "hello RT-Thread!\r\n";
+
+    /* 查找系统中的串口2设备 */
+    serial2 = rt_device_find(UART_NAME);
+    
+    if (serial2 != RT_NULL)
+    {
+        rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
+        /* 设置回调函数及打开设备 */
+        rt_device_open(serial2, RT_DEVICE_OFLAG_RDWR|RT_DEVICE_FLAG_INT_RX);
+        /* 设置回调函数 */
+        rt_device_set_rx_indicate(serial2, uart_input);
+        /* 发送字符串 */
+        rt_device_write(serial2, 0, str, (sizeof(str) - 1));
+        
+        while (1)
+        {
+            /* 从串口2读取一个字节的数据,没有读取到则等待接收信号量 */
+            while (rt_device_read(serial2, -1, &ch, 1) != 1)
+            {
+                /* 阻塞等待 接收信号量,等到信号量后再次读取数据 */
+                rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
+            }
+        /* 读取到的数据通过串口2错位输出 */
+        ch = ch + 1;
+        rt_device_write(serial2, 0, &ch, 1);
+        }
+    }
+    else
+    {
+        rt_kprintf("open uart2 failed!\n");
+    }
+}
+
+static void uart_sample(void)
+{
+    /* 创建 serial 线程 */
+    rt_thread_t thread = rt_thread_create("serial",serial_thread_entry, RT_NULL, 1024, 25, 10);
+    /* 创建成功则启动线程 */
+    if (thread!= RT_NULL)
+    {
+        rt_thread_startup(thread);
+    }
+}
+/* 导出到 msh 命令列表中 */
+MSH_CMD_EXPORT(uart_sample, uart device sample);

+ 0 - 0
spi/README.md


+ 64 - 0
spi/spi_sample.c

@@ -0,0 +1,64 @@
+/*
+ * File      : drv_qspi_flash.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2009 RT-Thread Develop Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2018-08-17     zylx         first implementation.
+ */
+
+#include <rtthread.h>
+#include <rtdevice.h>
+#include <string.h>
+
+#define SPI_DEVICE_NAME     "qspi10"
+
+static void spi_sample(int argc,char *argv[])
+{
+    struct rt_spi_device *spi_dev_w25q128;
+    rt_uint8_t w25x_read_id = 0x90;
+    rt_uint8_t id[5] = {0};
+
+    /* find qspi10 device */
+    spi_dev_w25q128 = (struct rt_spi_device *)rt_device_find(SPI_DEVICE_NAME);
+    if (!spi_dev_w25q128)
+    {
+        rt_kprintf("spi sample run failed! can't find qspi device!");
+    }
+    else
+    {
+        if ((argc >= 2) && (strcmp(argv[1], "method1") == 0))
+        {
+            rt_spi_send_then_recv(spi_dev_w25q128, &w25x_read_id, 1, id, 5);
+            rt_kprintf("use method1 read w25q128 ID is:%x%x\n", id[3], id[4]);
+        }
+        else    /* 使用 rt_spi_transfer_message()*/
+        {
+            struct rt_spi_message msg1,msg2;
+
+            msg1.send_buf   = &w25x_read_id;
+            msg1.recv_buf   = RT_NULL;
+            msg1.length     = 1;
+            msg1.cs_take    = 1;
+            msg1.cs_release = 0;
+            msg1.next       = &msg2;
+
+            msg2.send_buf   = RT_NULL;
+            msg2.recv_buf   = id;
+            msg2.length     = 5;
+            msg2.cs_take    = 0;
+            msg2.cs_release = 1;
+            msg2.next       = RT_NULL;
+            
+            rt_spi_transfer_message(spi_dev_w25q128, &msg1);
+            rt_kprintf("use method2 read w25q128 ID is:%x%x\n", id[3], id[4]);
+        }
+    }
+}
+/* 导出到 msh 命令列表中 */
+MSH_CMD_EXPORT(spi_sample, spi device sample);

+ 0 - 0
usb/README.md