Skip to content
systemcoding.dev

Tag

c

362 posts

Flat illustration of a microcontroller wired to an LED and a sensor, with the C, Arm and Espressif logos.
Embedded

Implement a Fixed-Point FIR Filter in C

Write a Q15 FIR filter in portable C with a circular delay line, a 32-bit accumulator and one saturating shift at the end, with worked moving-average output.

7 min read
Flat illustration of a microcontroller wired to an LED and a sensor, with the Bluetooth, Nordic Semiconductor and Arm logos.
Embedded

Create a Custom BLE GATT Service on nRF52

Define a custom 128-bit GATT service on nRF52 with Zephyr: characteristic properties, read and write callbacks, notifications through the CCC and MTU limits.

9 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, FreeBSD and Linux logos.
Systems Programming

Process Lines Efficiently with getline

Read lines of any length in C with getline, reuse one growing buffer, strip the newline, spot read errors and handle files without a final newline.

7 min read
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, Rust and FreeBSD logos.
Systems Programming

Write Errors to stderr with perror and err

Report failures from a C tool the Unix way: perror, strerror and the err and warn family, with errno saved correctly and messages sent to stderr.

6 min read
Flat illustration of a magnifier over lines of a log, with the Linux, C and Rust logos.
Kernels

printk Log Levels and pr_* Helpers Explained

Learn the eight printk log levels, the pr_info and pr_err helpers, pr_fmt prefixes, rate limiting and the console loglevel that decides what reaches the screen.

8 min read