Introduction to Zephyr Part 6: How to Write a Device Driver | DigiKey
We delve into the essentials of writing a custom device driver in the Zephyr RTOS by building a simple “button” driver. You’ll learn the importance of having a driver that acts as a bridge between your hardware and the operating system, making it possible to reliably read button states across different embedded platforms. Shawn is hosting a free, hands-on webinar that walks you through the process of developing your own device driver in Zephyr. Check it out! https://event.on24.com/wcc/r/4870160/... You can find a written version of this tutorial here: https://www.digikey.com/en/maker/tuto... The GitHub repository for this course (including solutions to the challenges) can be found here: https://github.com/ShawnHymel/introdu... The MCP9808 I2C driver solution (and walkthrough) can be found here: https://github.com/ShawnHymel/worksho... We start with the core driver implementation: button.c and button.h, explaining how to initialize the GPIO pin as input and retrieve button state. We also underscore the significance of logging and error-handling to help you quickly diagnose issues in real-world embedded scenarios. You’ll see how the Devicetree macros automatically generate multiple instances of the driver for each “custom,button” node—an invaluable feature when managing multiple buttons or sensors. This section shows how each driver instance is set up with its own configuration struct, ensuring that every hardware component is correctly identified and initialized. Next, we examine the file structure for our driver, highlighting the roles of each CMakeLists.txt, Kconfig, and source file. This organized approach clarifies how Zephyr’s modular build system integrates driver code, enabling a portable and scalable setup for development teams working on diverse targets. We then demonstrate how to test the driver using an application-level file structure, with a dedicated main.c, prj.conf, and an overlay file for board-specific pin overrides. By combining these elements, you’ll see how to assemble a complete project that initializes, reads, and confirms button input behavior in a real-world development environment. Whether you’re new to embedded development or looking to refine your Zephyr RTOS skills, this guide provides a practical roadmap to building reliable device drivers. With clear file structure explanations, Devicetree insights, and testing methodology, you’ll have the confidence to expand your embedded software projects and tailor them to any hardware platform. Official Zephyr documentation: https://docs.zephyrproject.org/latest... Introduction to RTOS: • Introduction to RTOS Part 1 - What is a Re... ESP32-S3-DevKitC: https://www.digikey.com/en/products/d... Maker.io - https://www.digikey.com/en/maker DigiKey’s Blog – TheCircuit https://www.digikey.com/en/blog Connect with DigiKey on Facebook / digikey.electronics And follow us on X: https://x.com/digikey 00:00 Intro 1:05 Hardware Overview 1:21 Custom Driver C Code 25:11 Custom Driver CMake Files 28:36 Custom Driver Kconfig Files 30:46 Custom Driver Binding File 35:10 Custom Driver Module File 37:40 Demo Application 55:08 Custom Driver Instancing Demo 56:27 Challenge: MCP9808 I2C Temperature Sensor Driver 58:33 Conclusion

Introduction to Zephyr Part 7: Debugging with OpenOCD and GDB | DigiKey

The Harsh Truth about FPGAs (You Should Avoid Them?!)

Understanding the Structure of a Linux Kernel Device Driver - Sergio Prado, Toradex

Introduction to Zephyr Part 1: Getting Started - Installation and Blink | DigiKey

ESD Basics 2020 06

Introduction to Zephyr Part 4: Devicetree Tutorial | DigiKey

What is a Kernel?

Introduction to Zephyr Part 3: Kconfig Tutorial | DigiKey

ESP32-P4 First Look! This Thing is a Beast!

The Raspberry Pi Pico WAS Overrated! But that changed!

Introduction to Zephyr Part 5: Devicetree Bindings | DigiKey

COMPLETE EMBEDDED SYSTEMS Roadmap - What Arduino Won't Teach You

Why MicroPython is a Game Changer for Embedded Engineers

Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

Raspberry Pi Kernel Development | Writing a Raspberry Pi ARM GPIO Driver in C | Embedded Concepts

Linus Torvalds: AI Is Changing Linux Fast

Introduction to the Zephyr RTOS

Introduction to RTOS Part 6 - Mutex | Digi-Key Electronics

