Getting Started with USB Driver Development

TI CC1111/CC2511 USB Dongle硬件指南:从开发套件到自主设计的实战解析 在嵌入式无线通信领域,系统级芯片(SoC)通过集成微控制器与射频收发器,是实现设备小型化与低功耗的关键技术。其核心原理在于将计算与通信功能融合于单一芯片,从而简化硬件设计、降低整体功耗与成本。这项技术的价值在于为智能家居、工业传感及个人健康监测等物联网终端提供了高集成度的解决方案。深入理解其硬件参考设计,特别是官方开发套件的调试接口与射频布局,是确保产品性能与可靠性的工程实践基础。本文以TI CC1111/CC2511 USB Dongle这一经典参考设计为例,结合【在线仿真器】与【射频电路】等核心热词,详 阅读详情

转自:http://blogs.msdn.com/b/usbcoreblog/archive/2009/10/10/getting-started-with-usb-driver-development.aspx

In this article, I'm going to provide a roadmap to getting started with USB driver development.

1. Obtain and Install the latest WDK and debugging tools

To build a driver, you must install WDK which contains the resources, libraries, tools, documentation that you need to develop WDF driver. Go to WHDC web site to obtain and install latest version of WDK and debugging tools.

To debug WDM and KMDF kernel drivers, two computers are needed: One to host the debugger and another to host the driver that is being debugged. This page will tell you how to setup kernel mode debug environment.

To debug UMDF drivers, the debugger and driver can be run either on the same computer or on two separate computers. This page will tell you how to setup user mode debug environment.

2. Choose which framework to use for your driver: WinUSB, UMDF, KMDF or WDM

There are several different ways to interact with a USB device. You can either write your own driver or use Microsoft provided generic USB driver called WinUSB.

WinUSB includes the WinUSB kernel-mode driver winusb.sys, which is an integral part of WDF user-mode driver framework (UMDF) support for USB drivers, and the WinUSB user-mode dynamic link library Winusb.dll. For USB devices that are accessed by only a single application, developers can often install WinUsb.sys as their device's function driver instead of implementing a custom driver. If you manage your device with user-mode software, WinUSB will cost you less time, effort and expense devoted to driver development. Driver with WinUSB is likely to cause less system errors which improve the customer experience, is easier to manage power, brings less security threat because user mode driver can not sniff data at kernel level, and is easier and smaller to update driver package. WinUSB would be the easiest and best approach except if your driver want to do data streaming through isochronous endpoints or the functions you want to implement already have kernel-mode support in the Windows operating system (such as modem functions which is supported by TAPI or LAN functions which is supported by NDIS).

The new Windows Driver Framework provides User-Mode Driver Framework (UMDF) library for user mode driver development and Kernel-Mode Driver Framework (KMDF) library for kernel mode driver development. UMDF and KMDF implement the same conceptual driver programming model with different components, device driver interfaces (DDIs), and data structures.

If the WinUSB driver can not meet your driver requirement, try UMDF next. UMDF provides a unified model that can work across device classes and integrates tasks handling for installation, Plug and Play (PnP) and power management. It supports protocol device classes such as cameras and portable music players.

KMDF should be used only if UMDF or WinUSB don't solve your purpose. KMDF framework is a library communicating with the operating system by using WDM interfaces. It provides interfaces simpler than WDM interface and handles many operations such as Plug and Play (PnP) and power management that must be handled by WDM drivers themselves. It also provides much of the synchronization code that is required for multiprocessor environments.

There is a common misunderstanding that miniport drivers such as NDIS or AVSTREAM cannot be written using KMDF. This WinHEC presenation provides more detail on how to use KMDF in miniports. Using KMDF provided USB I/O Target interfaces to interact with your USB device from an NDIS or AVSTREAM miniport is the best way to create a simple, robust driver.

WDM driver uses a set of interfaces to communicate directly with kernel-mode Windows components such as I/O manager and the Plug and Play (PnP) manager. WDM drivers are difficult to write, complex, less robust, and should not be written unless absolutely necessary.

This page will further help you choose a driver model based on the device class.

3. Check system requirements for your driver

You can develop WinUSB and UMDF drivers for Windows XP and later versions of Windows (not including Windows Server 2003). You can develop and build KMDF drivers for Windows 2000 with Service Pack 4 and later versions of Windows. You can develop WDM drivers for any version of Windows.

4. Obtain a test device

  • In most cases, the developer for a new driver will be given a device and/or a specification for a device and told to write a driver for it. If the device is just in prototype development phase, it will be helpful to use below Device Simulation Framework (DSF) to build a simulator following the specification for development and testing purposes.
  • You can use the Device Simulation Framework (DSF) which is a part of WDK for USB Devices to test your driver (Choose install it during WDK installation). DSF only uses software to simulate USB devices, so that you do not need any special hardware. DSF has already created some sample USB Device Simulators such as HID Generic Device, Loopback Device, Audio Device and Keyboard Device. You can use them directly if you install DSF on your computer. There is an instruction to guide you to test your USB driver with a USB Device Simulator.

5. Reference samples from the WDK

  • WinUSB Samples

The most comprehensive documentation for how to use WinUSB to access a USB device is this whitepaper "How to USB WinUSB to communication with a USB Device". For sample code, refer below UMDF Fx2_Driver sample.

UMDF Driver Skeleton Sample: This sample demonstrates how to use UMDF to write a basic driver. It is a starting point for implementing a function driver.

Fx2_Driver: This sample demonstrates how to use UMDF to create a driver to perform bulk and interrupt data transfers with OSR USB Fx2 Learning Kit.

  • KMDF Samples

OSRUSBFX2: This sample is a step by step tutorial to demonstrate how to create a KMDF driver to perform bulk and interrupt data transfers to an USB device with OSR USB Fx2 Learning Kit. If you are new to KMDF driver, this sample is the best one to start with.

USBSAMP: This sample demonstrates how to perform bulk and isochronous data transfers to a generic USB device.

In the next blog post, I will describe the difference between OSRUSBFX2 and USBSAMP samples.

HIDUSBFX2: This sample demonstrates how to write a HID minidriver in which a non-HID USB device is mapped to a HID device.

Toaster -WDF Version: This sample is a rewrite of the WDM toaster driver and is great starting point for understanding KMDF. It illustrate the functionality for bus driver, function driver and filter drivers for a hypothetical bus and its devices.

  • WDM Samples

Toaster - WDM Version: This sample demonstrates how to write a bus driver, a function driver, assorted class, device and bus filter drivers, a class installer, and a device-specific co-installer for a hypothetical bus and its devices.

USBView Sample Application: This sample provides a GUI application to browse all connected controllers and USB devices on your computer. It is able to dump USB device's descriptors, query information about the devices from the registry via USB requests to the device. This is a useful tool but not a driver sample. 

We STONGLY DISCOURAGE you from using WDM Isochronous client driver sample (isousb.sys), Bulk transfer client driver sample (bulkusb.sys) and Selective suspend client driver sample (selsusp.sys) from old WDKs. These samples do not exist in the latest Windows 7 WDK installation package.


Win10下VS2015(WDK10)驱动开发环境配置 1、     概述 微软在”WDK7600“以后就不再提供独立的内核驱动开发包了,而是必须首先安装微软集成开发环境VisualStudio,然后再从微软官网下载集成的WDK开发包、或者离线安装包,但是安装后Visual Studio就集驱动程序开发,编译,安装,部署和调试于一身,使得Windows驱动程序开发会变得更容易。对于Windows 10和Visual Studio2015驱动开发W 阅读详情

相关推荐

嵌入式开发者的技术宝库:Microchip全球支持网络与MPLAB生态实战指南

在嵌入式系统开发领域,高效获取技术支持和学习资源是项目成功的关键。一个强大的技术支持生态系统,通常由系统化的知识库、集成开发工具链、活跃的开发者社区以及详尽的参考设计构成,其核心价值在于帮助开发者从概念评估、原型设计到量产部署的全生命周期中,解决芯片选型、驱动开发、系统调试等实际问题。这类生态通过提供结构化的在线课程、图形化代码配置工具以及实时技术培训,能够显著提升开发效率,降低学习曲线。例如,利用**MPLAB® Code Configurator (MCC)** 这类工具进行图形化外设配置,可以自动生成

dianwonin4433的博客 414

Developing a WDF USB Kernel Mode Driver for the OSR USB FX2

Introduction This article explains and demonstrates the steps involved in developing a kernel mode device driver using the WDF Kernel Mode Driver Foundation (KMDF). The specific USB device that is used in this article is the OSR USB-FX2 learning kit that

Tech is Online(物联网技术传播) 2260

Zephyr RTOS在XIAO RP2040上的嵌入式开发实战指南

实时操作系统(RTOS)是现代嵌入式系统开发的核心技术,它通过提供多任务调度、内存管理和设备驱动抽象等机制,解决了复杂嵌入式应用中的并发与实时性挑战。其技术价值在于能够高效管理硬件资源,提升系统可靠性和可维护性。在物联网、可穿戴设备和工业控制等应用场景中,RTOS成为连接底层硬件与上层应用的关键桥梁。本文以Zephyr RTOS为例,结合Seeed Studio XIAO RP2040开发板,深入探讨如何从环境搭建到多线程应用开发,实现从简单裸机编程到专业RTOS开发的跨越。通过具体实例,展示了如何利用Ze

weixin_30791095的博客 415

Rift Getting Started Guide

Rift Getting Started Guide入手Oculus后,不会使用的请参看用户指导手册 网址:https://product-guides.oculus.com/en-us/documentation/rift/latest/Getting Ready for RiftThe recommended Rift system specifications are:GPU (graphi

Chansonyan2014的专栏 947

LabWindows/CVI学习路径:从C语言基础到测控系统实战开发

在测试测量与自动化控制领域,上位机软件开发是连接硬件设备与数据处理的关键环节。其核心在于通过编程语言实现对硬件的高效驱动、数据采集与实时处理。C语言以其接近硬件的执行效率和直接的内存操作能力,成为该领域底层开发的经典选择。基于ANSI C的LabWindows/CVI集成开发环境,正是这一技术价值的典型体现,它将C语言的强大控制力与图形化界面开发相结合,为构建虚拟仪器和测试系统提供了高效平台。其技术价值在于平衡了开发效率与运行时性能,通过丰富的仪器驱动库和简洁的部署方式,直接满足了对硬件底层支持要求高、依赖

weixin_30613433的博客 336

mdk5-getting-started

mdk5-getting-started,简要介绍MDK5使用的文档,包括CMSIS的使用!

Windows驱动程序开发快速入门指南:从零到一的完整学习路径

Windows驱动程序开发是连接硬件与操作系统的核心技术,而微软官方的Windows Driver Kit(WDK)文档则是掌握这一技能的终极资源。对于想要快速上手的开发者来说,这份官方文档提供了从基础概念到实战项目的完整学习路径。本文将为你揭示如何高效利用这份权威资料,快速掌握Windows驱动开发的精髓。 ## 为什么选择Windows Driver Kit作为学习起点? Windows

gitblog_00657的博客 471

liquibase介绍

1、Liquibase还是Flyway Flyway和Liquibase都支持专业数据库重构和版本控制所需的所有功能,因此您将始终知道要处理的数据库模式的版本以及它是否与软件版本匹配。两种工具都集成在Maven或Gradle构建脚本中以及Spring Boot生态系统中,因此您可以完全自动化数据库重构。 Flyway使用SQL定义数据库更改,因此您可以定制SQL脚本,使其与基础数据库技术(例如Oracle或PostgreSQL)良好地配合使用。另一方面,使用Liquibase,您可以通过使用XML,YA

赶路人儿 7534

Zephyr平台ESP32S3开发环境搭建

在 Linux 系统上,该工具包还包含额外的主机工具,例如定制的 QEMU 和 OpenOCD 构建版本,这些工具用于 Zephyr 应用程序的仿真、烧录和调试。Zephyr 软件开发工具包(SDK)包含适用于 Zephyr 各支持架构的工具链,其中包括构建 Zephyr 应用程序所需的编译器、汇编器、链接器及其他程序。建议用使用Ubuntu22.04 LTE,因为LTE版本是被维护的阶段,运行update时,更新会比较顺利。完成初始化,后面的所有过程,请注意路径要对应,不要自己创建文件夹放置。

cocos_yang的博客 1492

关于Kswapd的理解(一)

关于Kswapd的理解(一) 之前跟踪了MemAvailable的计算方式,其中watermark的计算花了很多精力,在学习的过程中看到一些资料中说watermark是给swapd使用的,于是乎,研究一下看看咯 本部分主要记录两个方面: 对于kswapd这个东西,从初学者(我)的角度出发会考虑哪些内容? 跟踪kswapd 初始化结构部分; 1. KSwapd机制 上图是还没有跟踪kswapd code的时候,对自己提出的一些疑问和自身的理解,主要是如下内容: kswapd 机制用来做什么:内存不足时

And乔的博客 2732

Simulink开发项1000例实战专栏--实例52:基于Simulink开发一个超导磁储能控制系统,实现对SMES系统的精确控制和优化

需求分析超导磁储能系统(Superconducting Magnetic Energy Storage, SMES)是一种利用超导线圈储存和释放电能的高效储能技术。SMES系统具有响应速度快、能量密度高、循环寿命长等优点,广泛应用于电力系统的调峰填谷、频率调节、电压稳定以及紧急备用电源等领域。本项目将基于Simulink平台,开发一个完整的超导磁储能控制系统,实现对SMES系统的精确控制和优化。我们将详细讲解如何设计和实现该系统,并结合实际应用案例进行说明。

xiaoheshang_123的博客 241

用JavaScript打造你的超可爱机器人:Stack-chan完整入门指南

想让代码在现实世界中动起来吗?Stack-chan正是这样一个神奇的JavaScript驱动机器人项目,它基于M5Stack嵌入式平台,让你用简单的JavaScript代码就能控制一个超可爱的机器人做出表情、说话、转头等动作。无论你是编程新手、教育工作者,还是想为孩子创造有趣玩具的家长,Stack-chan都能让你轻松入门机器人开发。 ## 🚀 为什么选择Stack-chan机器人? ###

gitblog_00832的博客 695

【智能车Code review】——小S与中S道路判断

基本思想: 找到中线的左拐点和右拐点,并且计算出两点之间的空间距离。通过限制空间距离,分为中S和小S。 注意这种情况:当20行以下的中线斜率比较陡,此时可以通过人为限制设定,将第0行的中线设置为拐点。 if (flag_centre_right_point == 0 && flag_centre_left_point == 1 && parameterB >= 0.5 && centre_left_point[0] >= 33) { .

hanhan的博客 6115

嵌入式开发实战:从XMC4500评估板快速上手到项目迁移全流程解析

嵌入式系统开发中,微控制器(MCU)作为核心处理单元,其开发流程通常遵循从环境搭建到硬件调试的标准化路径。以ARM Cortex-M4内核为代表的现代MCU,通过集成浮点运算单元(FPU)和丰富外设,显著提升了工业控制、电机驱动等场景的处理能力。开发效率的提升关键在于成熟的工具链支持,例如基于Eclipse的集成开发环境(IDE)能够通过图形化配置工具自动生成初始化代码,大幅降低底层寄存器操作的门槛。硬件抽象层(HAL)和板级支持包(BSP)进一步封装了硬件差异,使得开发者能聚焦应用逻辑。在实际工程中,利用

weixin_34327761的博客 425

079、LVGL基础控件:消息框(Msgbox)

《LVGL消息框控件深度解析与避坑指南》 文章深入剖析了LVGL消息框控件的核心特性和使用技巧。消息框本质是带按钮的模态容器,而非独立窗口。作者分享了创建消息框的正确姿势、标题/内容设置方法、安全的按钮事件处理方式(避免直接调用close函数导致栈溢出),并详细介绍了模态/非模态实现、样式自定义、动态更新等实用技巧。针对常见问题如内存管理、按钮数量限制、动画效果等给出了专业建议,特别强调了消息框作为用户交互关键环节的优化重要性,建议通过异步删除、合理父对象选择等方式提升稳定性。文章包含大量实际项目经验总结,

m0_50546716的博客 158

《UDS协议从入门到精通》系列——图解0x23:通过地址读取内存

如何读取ECU中指定内存地址的数据?图解UDS 0x23服务带你快速上手!!

车载系统攻城狮 2629

BeagleV-Fire RISC-V开发板实战:从系统烧录到驱动开发与应用部署

RISC-V作为一种开源指令集架构,其核心原理在于通过模块化、可扩展的设计,为处理器提供了高度的定制自由和成本优势。这一技术价值使其在嵌入式系统、边缘计算和物联网等领域展现出巨大潜力,尤其适合需要灵活定制和低功耗的应用场景。在工程实践中,开发者常借助BeagleV-Fire这类亲民开发板进行快速原型验证。该板载平头哥玄铁C906处理器,并配备完整的Linux软件生态,支持从系统镜像烧录、交叉编译到内核驱动开发的全流程。通过GPIO、I2C等接口,开发者可以连接传感器,并利用Flask等框架构建轻量级Web服

weixin_34239169的博客 388

基于STM32L4XX、HAL库的STS40-CD1B-R3温度传感器 驱动程序设计

/ HAL库需要左移一位。// 每2秒读取一次。// 等待测量完成 - 高精度模式大约需要15ms。// 执行软复位确保传感器处于已知状态。温度测量范围:-40°C ~ +125°C。湿度测量范围:0% ~ 100% RH。// 复位后需要等待至少1ms。// 初始化STS40传感器。// 读取温湿度数据。// 转换原始数据为实际值。// 发送读取序列号命令。// 读取序列号数据。湿度精度:±1.5% RH。

zhusl6688的博客 301

Kinetis SDK驱动开发实战:从RNGA到SPI的外设驱动详解与避坑指南

在嵌入式系统开发中,外设驱动是连接硬件与应用的关键桥梁,其核心在于对微控制器内部功能模块的初始化、配置与控制。驱动的工作原理通常基于寄存器操作、中断处理和DMA(直接内存访问)等技术,旨在提升系统执行效率与可靠性。其技术价值在于通过硬件抽象层(HAL)提供标准化的API接口,实现代码的可移植性,让开发者能更专注于应用逻辑而非底层调试。在工业控制、物联网节点等应用场景中,稳定高效的驱动是保障数据采集、通信和存储的基础。本文聚焦于恩智浦Kinetis SDK v1.3驱动库,深入剖析其针对RNGA(随机数发生器

a631278993的博客 489

RISC-V CPU设计(三)---多周期CPU的设计与实现

基本情况 本多周期CPU支持RV32I指令集(fence,ecall,ebreak除外),已通过部分指令的测试,如代码有bug,欢迎指出。 模块划分 代码将CPU划分为以下几个模块: 1.控制单元:ControlUnit 用于产生控制信号,是CPU的大脑,指挥中枢。 2.分支决策单元:BranchUnit 用于决定B型指令是否发生跳转 3.立即数单元:ImmUnit 用于从指令中解析出立即数. 4.寄存器堆:RegisterFile RISC-V的32个寄存器,其中x0寄存器恒为0,不可更改。 5.指令存储

qq_40268672的博客 5550

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

STM32CubeIDE 一站式开发环境:从零安装到首个工程调试全指南

在嵌入式系统开发中,集成开发环境(IDE)是连接硬件配置与软件实现的核心工具,它通过整合编译器、调试器和图形化配置界面,大幅降低了底层开发的复杂度。STM32CubeIDE 作为意法半导体官方推出的免费 IDE,其核心原理在于将 STM32CubeMX 的图形化配置功能无缝嵌入到基于 Eclipse 的框架中,实现了从芯片选型、外设初始化到代码编写、编译下载的全流程覆盖。这一设计显著提升了开发效率,尤其适合快速原型验证和中低复杂度应用场景。对于初学者和寻求工具链统一的工程师而言,掌握 STM32CubeID

cqwmy840702的博客 302

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

CodeWarrior IDE项目管理全解析:从入门到精通8/16位MCU开发

集成开发环境(IDE)是嵌入式开发的核心工具,它通过将编辑器、编译器、链接器和调试器高度集成,极大提升了开发效率。其工作原理在于提供统一的工程管理界面,将复杂的构建流程自动化,让开发者聚焦于业务逻辑。在嵌入式领域,尤其是面对Freescale/NXP的HC08、HCS08、HC12、HCS12等经典8/16位微控制器时,一个稳定且深度适配的IDE至关重要。CodeWarrior IDE正是这样一款经典工具,它通过精细的构建目标(Build Target)配置和项目窗口(Project Window)管理,为

weixin_34221332的博客 414

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

STM32CubeC0实战:从CubeMX建工程到量产烧录的完整避坑指南

在嵌入式开发中,MCU的选型与工具链生态往往决定项目落地效率。STM32以其丰富的产品线和统一的STM32Cube开发环境,成为众多工程师的首选。其中,STM32C0系列作为入门级Cortex-M0+内核芯片,凭借极低成本、无需外部晶振的HSI48内部振荡器以及完整的HAL/LL驱动库,正在快速替代传统8位MCU。通过STM32CubeMX生成工程、使用HAL库快速开发,并合理运用低功耗模式与量产烧录方案,开发者可以高效实现小家电、传感器模块、电机控制等成本敏感型产品。本文从实际项目经验出发,梳理了从环境搭

weixin_30267785的博客 485

Jetson Orin Nano 8GB 离线大模型部署全记录:Ollama、Open WebUI、llama.cpp、vLLM、Whisper 与 Piper TTS

我按照 Seeed Studio 的“第五章:离线大模型开发”进行学习,在 Jetson Orin Nano 8GB 上依次实践了 Ollama、Open WebUI、llama.cpp、vLLM、jetson-examples、Whisper 和文本转语音。实际过程中遇到了 CPU 版 PyTorch、CUDA 版本错配、NumPy 2.x ABI、缺少。

weixin_57179621的博客 647
上一篇: AVstream 和usb driver 模型
下一篇: What's the difference between USBSAMP and OSRUSBFX2 sample?
xuke537
博客等级 码龄18年 33粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值