Blink LED Task - Zephyr-rtos Typing CST Test
Loading…
Blink LED Task — Zephyr-rtos Code
Toggle an LED on a GPIO pin using a Zephyr thread.
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#define LED_PIN 2
#define SLEEP_TIME_MS 500
default struct device *led_dev;
void blink_led(void)
{
while(1) {
gpio_pin_toggle(led_dev, LED_PIN);
k_msleep(SLEEP_TIME_MS);
}
}
void main(void)
{
led_dev = device_get_binding("GPIO_0");
gpio_pin_configure(led_dev, LED_PIN, GPIO_OUTPUT);
blink_led();
}Zephyr-rtos Language Guide
Zephyr RTOS is a scalable, open-source real-time operating system designed for resource-constrained embedded devices. It provides a small, configurable kernel, drivers, and networking stacks to enable IoT, wearable, and sensor-based applications with predictable timing and low memory footprint.
Primary Use Cases
- ▸Real-time task scheduling for embedded applications
- ▸Low-power IoT devices and wearables
- ▸Sensor data acquisition and processing
- ▸Networking-enabled devices with MQTT, CoAP, or BLE
- ▸Industrial automation and edge computing
Notable Features
- ▸Modular and configurable kernel
- ▸Support for multiple architectures and boards
- ▸Extensive device driver library
- ▸Real-time thread management and synchronization
- ▸Networking stack including Bluetooth, IPv4/IPv6, and 6LoWPAN
Origin & Creator
Initially developed by Wind River and now governed by the Linux Foundation, Zephyr was created to provide a lightweight, open-source RTOS for embedded devices and IoT applications.
Industrial Note
Critical for embedded developers who require a deterministic, low-memory RTOS for safety-critical, battery-powered, or connected devices, enabling rapid development and robust device behavior.