MultiButton: An Efficient State Machine Library Supporting 7 Button Events for Bare Metal and RTOS

MultiButton: An Efficient State Machine Library Supporting 7 Button Events for Bare Metal and RTOS

Repository Address:https://github.com/0x1abin/MultiButton An efficient and flexible multi-button state machine library that supports various button event detection. Features ✅ Multiple Button Events: Press, Release, Single Click, Double Click, Long Press Start, Long Press Hold, Repeat Press ✅ Hardware Debounce: Built-in digital filtering to eliminate button bounce ✅ State Machine Driven: Clear state transition logic with high … Read more

In-Depth Analysis of C++20 Features: Design Motivation and Application Strategies of [[no_unique_address]]

1. Introduction: The Mystery of Empty Type Space In the object model of the C++ language, an “empty class”—that is, a type that contains no non-static member variables, virtual functions, or base classes—should theoretically have zero size. However, the C++ standard states: Every complete object must have a unique address. This means that even if … Read more

The Lost Art of Structure Packing in C Language

The Lost Art of Structure Packing Eric S. Raymond <[email protected]> The Lost Art of Structure Packing Table of Contents Who Should Read This Article The Reason I Wrote This Article Alignment Requirements Padding Struct Alignment and Padding Bit Fields Struct Member Reordering Tricky Scalar Cases Readability and Cache Locality Other Packing Techniques Overriding Alignment Rules … Read more

GCC Firmware Analysis: Mastering Map Files and Memory Optimization Techniques

GCC Firmware Analysis Complete Guide: Mastering Map Files and Memory Optimization Techniques In daily embedded development, optimizing firmware size and memory usage is a crucial skill. This article will detail how to use the GCC toolchain to analyze firmware usage, helping developers accurately grasp the usage of FLASH and RAM. 1. Why is Firmware Analysis … Read more

In-Depth Analysis of Bit-Fields in C Language: From Principles to Practice for Embedded Memory Optimization

In-Depth Analysis of Bit-Fields in C Language: From Principles to Practice for Embedded Memory Optimization

In the advanced applications of the C language, especially in the field of embedded development, “memory” is often the most precious resource. When we need to handle hardware registers, binary protocols, or massive data storage, ordinary variables occupying 1 byte or 4 bytes can easily lead to resource wastage. Bit-fields (Bit-Field) act like a “space … Read more

Optimizing Microcontroller Memory Usage with Map Files

Optimizing Microcontroller Memory Usage with Map Files

The company asked me to interface a visibility detection instrument with a product from a few years ago. The mainboard uses the STM32L051C6 microcontroller to communicate with the visibility detection instrument via RS485. In theory, this should just involve implementing a serial port data reception processing logic. However, after adding the code and compiling, it … Read more

BitMagic: An Efficient C++ Bit Vector Library

BitMagic: An Efficient C++ Bit Vector Library

BitMagic: An Efficient C++ Bit Vector Library In C++ development, memory efficiency and performance optimization are crucial when handling large-scale data. BitMagic is an open-source library focused on providing efficient bit vector containers and algorithms. It employs various optimization techniques to help developers achieve better performance and lower memory usage in data-intensive applications. Bit Vector … Read more

RTOS Kernel Optimization: Achieve 0.1μs Response Time

RTOS Kernel Optimization: Achieve 0.1μs Response Time

PART.01Performance Kill: Three Major Tricks to Push RTOS Kernel to the Limit1. Interrupt Response: The “Bloody Evolution” from μs to Clock Cycles Traditional Solution: FreeRTOS default interrupt latency ≥5μs (some industrial control devices measured directly up to 8.7μs); Huawei Black Technology: L1 Cache Preloading Mechanism (measured on Hisilicon Hi1812 chip): T_{latency} = T_{int} + \lceil … Read more

Comprehensive Analysis of C++ Data Types: A Deep Guide from Memory Layout to Performance Optimization

Comprehensive Analysis of C++ Data Types: A Deep Guide from Memory Layout to Performance Optimization

C++ is an efficient system-level programming language, and its data type system is the foundation for building complex programs. 1. The Memory Essence of Basic Data Types 1. Memory Layout of Integer Family C++ provides a complete integer system from <span>short</span> to <span>long long</span>, and its memory usage follows the “increasing length” principle: #include <iostream> … Read more