Giao diện
Part 8: Embedded Programming Hardware
Lập trình nhúng — nơi code của bạn chạy trên vi điều khiển với tài nguyên cực kỳ hạn chế.
Embedded là gì?
┌─────────────────────────────────────────────────────────────────┐
│ EMBEDDED vs DESKTOP │
├─────────────────────────────────────────────────────────────────┤
│ │
│ DESKTOP PC EMBEDDED (MCU) │
│ ────────── ────────────── │
│ RAM: 16 GB RAM: 2 KB - 512 KB │
│ Storage: 1 TB SSD Flash: 16 KB - 2 MB │
│ CPU: 3+ GHz CPU: 16-200 MHz │
│ OS: Windows/Linux OS: None (bare-metal) │
│ Power: Wall outlet Power: Battery/Low power │
│ │
│ 💡 Embedded = Constraints Everywhere! │
│ │
└─────────────────────────────────────────────────────────────────┘1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Tại sao học Embedded C++?
Real-world Applications
┌─────────────────────────────────────────────────────────────────┐
│ EMBEDDED EVERYWHERE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 🚗 AUTOMOTIVE 🏥 MEDICAL DEVICES │
│ ───────────── ───────────────── │
│ ECU, ADAS, Infotainment Pacemakers, Monitors │
│ │
│ 📱 IoT & WEARABLES 🎮 GAME CONTROLLERS │
│ ────────────────── ─────────────────── │
│ Smartwatches, Sensors Xbox, PlayStation │
│ │
│ 🏭 INDUSTRIAL ✈️ AEROSPACE │
│ ────────────── ────────── │
│ PLCs, Robotics Drones, Satellites │
│ │
└─────────────────────────────────────────────────────────────────┘1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Embedded Programming Mindset
| Desktop Mindset | Embedded Mindset |
|---|---|
| RAM is cheap | Every byte counts |
Use new/delete freely | Avoid heap allocation |
| STL containers everywhere | Static arrays, no STL |
| Exceptions for errors | No exceptions (overhead) |
| OS handles timing | You control everything |
Module Structure
| Topic | Description |
|---|---|
| Memory Constraints | Coding cho low RAM/ROM |
| Bit Manipulation | Control hardware registers |
| volatile Keyword | Hardware mapping |
| Smart Pointers | unique_ptr vs raw |
| Interrupts | ISR basics |
Prerequisites
📋 YÊU CẦU
- ✅ C++ Basics — Variables, functions, pointers
- ✅ OOP — Classes, inheritance
- 🔸 Basic electronics (recommended)
Learning Path
Recommended Order
- 💾 Memory Constraints — Sống trong không gian nhỏ
- 🔢 Bit Manipulation — Control từng bit
- 🔒 volatile — Hardware access
- 🎯 Smart Pointers — Khi nào dùng gì
- ⚡ Interrupts — Phản hồi hardware events