60de8e71a1dac05beb93039958eef644ca5af3bc
Chip-cn-dat/ebyte-dat/ebyte-dat.md
| ... | ... | @@ -10,22 +10,22 @@ https://github.com/Edragon/ebyte |
| 10 | 10 | | ----- | ----- | ----- | ----------- | ----------------------------------------- | |
| 11 | 11 | | 1 | | P1.11 | B19 | 通用 I/O 详见官方芯片手册 | |
| 12 | 12 | | 2 | | P1.10 | A20 | 通用 I/O 低频 I/O,标准驱动 | |
| 13 | -| 3 | | P0.03 | B13 | 通用 I/O 模拟量输入 1,低频 I/O,标准驱动 | |
|
| 14 | -| 4 | | AI4 | B11 | 通用 I/O 模拟量输入 4 | |
|
| 13 | +| 3 | P0.03 | P0.03 | B13 | 通用 I/O 模拟量输入 1,低频 I/O,标准驱动 | |
|
| 14 | +| 4 | P0.28 | AI4 | B11 | 通用 I/O 模拟量输入 4 | |
|
| 15 | 15 | | 5 | | GND | - - | 单地线,连接到电源参考地 | |
| 16 | 16 | | 6 | | P1.13 | A16 | 通用 I/O 低频 I/O,标准驱动 | |
| 17 | -| 7 | | AI0 | A12 | 通用 I/O 模拟量输入 0, 低频 I/O,标准驱动 | |
|
| 18 | -| 8 | | AI5 | A10 | 通用 I/O 模拟量输入 5, 低频 I/O,标准驱动 | |
|
| 17 | +| 7 | P0.02 | AI0 | A12 | 通用 I/O 模拟量输入 0, 低频 I/O,标准驱动 | |
|
| 18 | +| 8 | P0.29 | AI5 | A10 | 通用 I/O 模拟量输入 5, 低频 I/O,标准驱动 | |
|
| 19 | 19 | | 9 | P0.31 | AI7 | A8 | 通用 I/O 模拟量输入 7, 低频 I/O,标准驱动 | |
| 20 | 20 | | 10 | P0.30 | AI6 | B9 | 通用 I/O 模拟量输入 6, 低频 I/O,标准驱动 | |
| 21 | -| 11 | | XL1 | D2 | 通用 I/O 连接 32.768 kHz 晶体 | |
|
| 21 | +| 11 | x | XL1 | D2 | 通用 I/O 连接 32.768 kHz 晶体 | |
|
| 22 | 22 | | 12 | | P0.26 | G1 | 通用 I/O 详见官方芯片手册 | |
| 23 | -| 13 | | XL2 | F2 | 通用 I/O 连接 32.768 kHz 晶体 | |
|
| 23 | +| 13 | x | XL2 | F2 | 通用 I/O 连接 32.768 kHz 晶体 | |
|
| 24 | 24 | | 14 | | P0.06 | L1 | 通用 I/O 详见官方芯片手册 | |
| 25 | -| 15 | | AI3 | K2 | 通用 I/O 模拟量输入 3 | |
|
| 25 | +| 15 | P0.25 | AI3 | K2 | 通用 I/O 模拟量输入 3 | |
|
| 26 | 26 | | 16 | | P0.08 | N1 | 通用 I/O 详见官方芯片手册 | |
| 27 | 27 | | 17 | | P1.09 | R1 | 通用 I/O 详见官方芯片手册 | |
| 28 | -| 18 | | AI2 | J1 | 通用 I/O 模拟量输入 2 | |
|
| 28 | +| 18 | P1.01 | AI2 | J1 | 通用 I/O 模拟量输入 2 | |
|
| 29 | 29 | | 19 | | VCC | - - | 电源 | |
| 30 | 30 | | 20 | | P0.12 | U1 | 通用 I/O 详见官方芯片手册 | |
| 31 | 31 | | 21 | | GND | - - | 地线,连接到电源参考地 | |
| ... | ... | @@ -33,14 +33,14 @@ https://github.com/Edragon/ebyte |
| 33 | 33 | | 23 | | VDH | VDDH - | 高压电源 | |
| 34 | 34 | | 24 | | GND | - - | 地线,连接到电源参考地 | |
| 35 | 35 | | 25 | | DCH | DCCH - | DC/DC 转换器输出 | |
| 36 | -| 26 | | RST | P0.18/RESET | 通用 I/O QSPI/CSN/外部复位 | |
|
| 36 | +| 26 | P0.18 | RST | P0.18/RESET | 通用 I/O QSPI/CSN/外部复位 | |
|
| 37 | 37 | | 27 | | VBS | VBUS - | USB 电源,5V 输入,用于 USB3.3V 稳压器 | |
| 38 | -| 28 | | P15 | AD10 | 通用 I/O 详见官方芯片手册 | |
|
| 38 | +| 28 | | P0.15 | AD10 | 通用 I/O 详见官方芯片手册 | |
|
| 39 | 39 | | 29 | | D- | D- | USB D- | |
| 40 | -| 30 | | P17 | AD12 | 通用 I/O 详见官方芯片手册 | |
|
| 40 | +| 30 | | P0.17 | AD12 | 通用 I/O 详见官方芯片手册 | |
|
| 41 | 41 | | 31 | | D+ | D+ - | USB D+ | |
| 42 | 42 | | 32 | | P0.20 | AD16 | 通用 I/O 详见官方芯片手册 | |
| 43 | -| 33 | | P0.13 | AD8 | 通用 I/O 详见官方芯片手册 | |
|
| 43 | +| 33 | P0.13 | P0.13 | AD8 | 通用 I/O 详见官方芯片手册 | |
|
| 44 | 44 | | 34 | | P0.22 | AD18 | 通用 I/O QSPI | |
| 45 | 45 | | 35 | | P0.24 | AD20 | 通用 I/O | |
| 46 | 46 | | 36 | | P1.00 | AD22 | 通用 I/O 详见官方芯片手册 | |
| ... | ... | @@ -48,6 +48,6 @@ https://github.com/Edragon/ebyte |
| 48 | 48 | | 38 | | P1.02 | P1.02 | 通用 I/O 详见官方芯片手册 | |
| 49 | 49 | | 39 | | SWC | AC24 - | 串行调试编程口时钟 | |
| 50 | 50 | | 40 | | P1.04 | U24 | 通用 I/O 低频 I/O,标准驱动 | |
| 51 | -| 41 | | NF1 | L24 | 通用 I/O NFC 输入 | |
|
| 51 | +| 41 | P0.09 | NF1 | L24 | 通用 I/O NFC 输入 | |
|
| 52 | 52 | | 42 | | P1.06 | R24 | 通用 I/O 低频 I/O,标准驱动 | |
| 53 | -| 43 | | NF2 | J24 | 通用 I/O NFC 输入 | |
|
| ... | ... | \ No newline at end of file |
| 0 | +| 43 | P0.10 | NF2 | J24 | 通用 I/O NFC 输入 | |
|
| ... | ... | \ No newline at end of file |
Chip-dat/Nordic-dat/NRF5x-dat/NRF5x-SDK-dat.md
| ... | ... | @@ -1,6 +1,25 @@ |
| 1 | 1 | |
| 2 | 2 | # NRF5x-SDK-dat.md |
| 3 | 3 | |
| 4 | + |
|
| 5 | + |
|
| 6 | + |
|
| 7 | +## programming guide |
|
| 8 | + |
|
| 9 | +1. 模块内置ARM单片机,程序下载使用J-LINK下载器 ,不能使用串口或其他任何JTAG、ISP、ICP工具。 |
|
| 10 | +2. 程序的烧录需要两部分完成,由于NORDIC官方提供的协议栈没有加载在程序中,因此在进行二次开发的时候, |
|
| 11 | + |
|
| 12 | + - 需要使用官方烧录工具 `nRFgo studio` 烧录协议栈,再用nRFgo studio烧录应用代码的hex; |
|
| 13 | + |
|
| 14 | + - 也可以先使用官方烧录工具nRFgo studio烧录协议栈,再用IAR或者KEIL下载。 |
|
| 15 | + |
|
| 16 | +官网工具下载网址 :http://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52832/ (language)/eng-GB |
|
| 17 | + |
|
| 18 | + |
|
| 19 | +- [[nRFgo-studio-dat]] |
|
| 20 | + |
|
| 21 | +- [[jlink-dat]] |
|
| 22 | + |
|
| 4 | 23 | ## software |
| 5 | 24 | |
| 6 | 25 | - nrfconnect |
SDK-dat/RTOS-dat/2024-08-28-15-15-47.png
| ... | ... | Binary files /dev/null and b/SDK-dat/RTOS-dat/2024-08-28-15-15-47.png differ |
SDK-dat/RTOS-dat/RT-Thread-dat/2025-08-28-18-00-45.png
| ... | ... | Binary files /dev/null and b/SDK-dat/RTOS-dat/RT-Thread-dat/2025-08-28-18-00-45.png differ |
SDK-dat/RTOS-dat/RT-Thread-dat/RT-Thread-dat.md
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | + |
|
| 2 | +# RT-Thread-dat |
|
| 3 | + |
|
| 4 | +- [[allwinner-dat]] |
|
| 5 | + |
|
| 6 | +https://github.com/RT-Thread/rt-thread |
|
| 7 | + |
|
| 8 | +Nano 也得到了优秀国产物联网操作系统 RT-Thread 的官方支持,有rtt相关知识或经验,我们就可以对 Nano 进行快速高效的开发; |
|
| 9 | + |
|
| 10 | +RTT官方已经给出由 uestczyh222 所维护的 Nano固件详细的编译、烧录过程,搬运至此: |
|
| 11 | + |
|
| 12 | +https://github.com/RT-Thread/rt-thread/blob/master/bsp/allwinner_tina/README.md |
|
| 13 | + |
|
| 14 | +git clone https://github.com/RT-Thread/rt-thread.git |
|
| 15 | + |
|
| 16 | + |
|
| 17 | +project - [[wch-fly-dat]] |
|
| 18 | + |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + |
|
| 24 | +## ref |
|
| 25 | + |
|
| 26 | +- [[system-dat]] |
|
| ... | ... | \ No newline at end of file |
SDK-dat/RTOS-dat/RTOS-dat.md
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | + |
|
| 2 | +# RTOS-dat |
|
| 3 | + |
|
| 4 | +- [[peripherals-dat]] |
|
| 5 | + |
|
| 6 | +- [[Zephyr-dat]] - [[SDK-dat]] - [[RTOS-dat]] |
|
| 7 | + |
|
| 8 | +## realtime system |
|
| 9 | + |
|
| 10 | +- [[freertos-dat]] - [[Zephyr-dat]] - [[MongooseOS-dat]] |
|
| 11 | + |
|
| 12 | +- [[openthread-dat]] - [[micropython-dat]] |
|
| 13 | + |
|
| 14 | +- [[RT-Thread-dat]] |
|
| 15 | + |
|
| 16 | +- [[cooperative-loop-dat]] |
|
| 17 | + |
|
| 18 | + |
|
| 19 | +## intelligent-system |
|
| 20 | + |
|
| 21 | + |
|
| 22 | + |
|
| 23 | +## AC-DC |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + |
|
| 28 | +## ref |
|
| 29 | + |
|
| 30 | +- [[tech-dat]] |
|
| ... | ... | \ No newline at end of file |
SDK-dat/RTOS-dat/Zephyr-dat/Zephyr-dat.md
| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | + |
|
| 2 | + |
|
| 3 | +# Zephyr-dat |
|
| 4 | + |
|
| 5 | +- [[git-dat]] - [[bash-dat]] - [[shell-dat]] |
|
| 6 | + |
|
| 7 | + |
|
| 8 | +## install |
|
| 9 | + |
|
| 10 | +Download the Windows SDK package for v0.17.0 from the Zephyr SDK releases page: |
|
| 11 | +https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.17.0 |
|
| 12 | + |
|
| 13 | +Pick the Windows x86_64 package, install or extract it to a permanent location such as: |
|
| 14 | + |
|
| 15 | + E:\zephyr-sdk-0.17.0 |
|
| 16 | + |
|
| 17 | +## global install |
|
| 18 | + |
|
| 19 | +In your Windows bash terminal, from the firmware folder: |
|
| 20 | + |
|
| 21 | + cd /e/git-DL/HeadTracker/firmware |
|
| 22 | + python -m pip install --upgrade pip |
|
| 23 | + python -m pip install west |
|
| 24 | + west init zephyr |
|
| 25 | + cd zephyr/zephyr |
|
| 26 | + git checkout v3.7.1 |
|
| 27 | + cd .. |
|
| 28 | + west update --narrow |
|
| 29 | + west -z "$PWD" zephyr-export |
|
| 30 | + python -m pip install -r zephyr/scripts/requirements.txt |
|
| 31 | + west blobs fetch hal_espressif |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | +## venv |
|
| 36 | + |
|
| 37 | +From your bash terminal: |
|
| 38 | + |
|
| 39 | + cd /e/git-DL/HeadTracker/firmware |
|
| 40 | + python -m venv .venv |
|
| 41 | + source .venv/Scripts/activate |
|
| 42 | + python -m pip install --upgrade pip |
|
| 43 | + pip install west |
|
| 44 | + west init zephyr |
|
| 45 | + cd zephyr/zephyr |
|
| 46 | + git checkout v3.7.1 |
|
| 47 | + cd .. |
|
| 48 | + west update --narrow |
|
| 49 | + west -z "$PWD" zephyr-export |
|
| 50 | + pip install -r zephyr/scripts/requirements.txt |
|
| 51 | + west blobs fetch hal_espressif |
|
| 52 | + |
|
| 53 | +Then install Zephyr SDK 0.17.0 for Windows into E:/git-DL/HeadTracker/firmware/zephyr-sdk. After extracting or installing it there, run its setup command from Command Prompt or PowerShell: |
|
| 54 | + |
|
| 55 | + E:\git-DL\HeadTracker\firmware\zephyr-sdk\setup.cmd -t arm-zephyr-eabi -t xtensa-espressif_esp32_zephyr-elf -t riscv64-zephyr-elf -h |
|
| 56 | + |
|
| 57 | + |
|
| 58 | +For your current bash session, set Zephyr base before building: |
|
| 59 | + |
|
| 60 | + export ZEPHYR_BASE=/e/git-DL/HeadTracker/firmware/zephyr/zephyr |
|
| 61 | + |
|
| 62 | + |
|
| 63 | +After that, build from the app directory: |
|
| 64 | + |
|
| 65 | + cd /e/git-DL/HeadTracker/firmware/src |
|
| 66 | + source ../.venv/Scripts/activate |
|
| 67 | + export ZEPHYR_BASE=/e/git-DL/HeadTracker/firmware/zephyr/zephyr |
|
| 68 | + west build -p -b dtqsys_ht |
|
| 69 | + |
|
| 70 | + |
|
| 71 | +.github\workflows\build-firmware.yml |
|
| 72 | + |
|
| 73 | + run: | |
|
| 74 | + cd /src/firmware/src |
|
| 75 | + west build -p -b dtqsys_ht |
|
| 76 | + cp ./build/zephyr/*.bin build_bins/ |
|
| ... | ... | \ No newline at end of file |
SDK-dat/RTOS-dat/cooperative-loop-dat/cooperative-loop-dat.md
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | + |
|
| 2 | +# cooperative-loop-dat |
|
| 3 | + |
|
| 4 | +``` |
|
| 5 | +void loop() { |
|
| 6 | + readELRS(); // non-blocking UART read |
|
| 7 | + updateMotors(); // update PWM |
|
| 8 | + if (millis() - lastAdc >= 1000) { |
|
| 9 | + readBattery(); |
|
| 10 | + lastAdc = millis(); |
|
| 11 | + } |
|
| 12 | + if (millis() - lastBle >= 2000) { |
|
| 13 | + updateBleAdvert(control.battery_mv); |
|
| 14 | + lastBle = millis(); |
|
| 15 | + } |
|
| 16 | +} |
|
| 17 | +``` |
|
| ... | ... | \ No newline at end of file |
SDK-dat/RTOS-dat/freertos-dat/freertos-dat.md
| ... | ... | @@ -0,0 +1,376 @@ |
| 1 | + |
|
| 2 | +# freertos-dat |
|
| 3 | + |
|
| 4 | + |
|
| 5 | +## freeRTOS debug |
|
| 6 | + |
|
| 7 | +Your sketch is written for ESP32 but you’re compiling it for ESP8266, and that’s why it’s failing. |
|
| 8 | + |
|
| 9 | +Why |
|
| 10 | + |
|
| 11 | +SemaphoreHandle_t, xSemaphoreCreateBinary(), xSemaphoreGive(), xSemaphoreTake(), and portMAX_DELAY are FreeRTOS API calls. |
|
| 12 | + |
|
| 13 | +ESP32 Arduino comes with FreeRTOS by default. |
|
| 14 | + |
|
| 15 | +ESP8266 Arduino does not use FreeRTOS — so those types and functions don’t exist unless you add a separate RTOS layer. |
|
| 16 | + |
|
| 17 | + |
|
| 18 | + |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + |
|
| 22 | +## ✅ When is it a Good Time to Use FreeRTOS? |
|
| 23 | + |
|
| 24 | +**FreeRTOS** is a real-time operating system designed for microcontrollers. It lets you split your application into multiple tasks that run seemingly in parallel. |
|
| 25 | + |
|
| 26 | +--- |
|
| 27 | + |
|
| 28 | +### 🧠 Use FreeRTOS When: |
|
| 29 | + |
|
| 30 | +#### 1. 🧵 **You Need to Run Multiple Tasks Concurrently** |
|
| 31 | +- Example: Reading sensor data, updating a display, and handling WiFi at the same time. |
|
| 32 | +- Each task can run independently using `xTaskCreate()`. |
|
| 33 | + |
|
| 34 | +#### 2. ⏱️ **You Require Real-Time Responsiveness** |
|
| 35 | +- Critical tasks (e.g., handling motor feedback or interrupts) can be given **higher priority**. |
|
| 36 | +- Guarantees **predictable response time**. |
|
| 37 | + |
|
| 38 | +#### 3. 🕓 **You Need Precise Timing or Scheduling** |
|
| 39 | +- Use `vTaskDelay()`, `xTimerCreate()`, etc., to run tasks at specific intervals. |
|
| 40 | +- Better than using `delay()` or busy-wait loops. |
|
| 41 | + |
|
| 42 | +#### 4. 📶 **You Have Asynchronous Events to Handle** |
|
| 43 | +- Great for UART, I2C, network communication, button presses, etc. |
|
| 44 | +- Use **queues**, **semaphores**, and **event groups** for clean async handling. |
|
| 45 | + |
|
| 46 | +#### 5. 🔄 **You Want to Structure a Large Project Cleanly** |
|
| 47 | +- Modular task-based design. |
|
| 48 | +- Easier to manage and debug than a giant `loop()` function. |
|
| 49 | + |
|
| 50 | +#### 6. 📦 **You're Using ESP32 or STM32 with Multiple Cores or Peripherals** |
|
| 51 | +- ESP32 has dual-core (PRO & APP cores). |
|
| 52 | +- FreeRTOS lets you **pin tasks to cores**, assign priority, and manage memory better. |
|
| 53 | + |
|
| 54 | +--- |
|
| 55 | + |
|
| 56 | +### 🧊 Not Always Necessary If: |
|
| 57 | +| Situation | Recommendation | |
|
| 58 | +|----------------------------------|---------------------------| |
|
| 59 | +| Simple blink or sensor reading | No need for FreeRTOS | |
|
| 60 | +| Single function, low resource | Use `loop()` and interrupts | |
|
| 61 | +| Ultra-low-power apps | May be better without RTOS | |
|
| 62 | + |
|
| 63 | +--- |
|
| 64 | + |
|
| 65 | +### ✅ Example: Good Use Case (ESP32 with Camera, Webserver, Sensors) |
|
| 66 | + |
|
| 67 | +- 📷 Task 1: Camera image capture |
|
| 68 | +- 🌐 Task 2: Web server and WiFi communication |
|
| 69 | +- 🌡️ Task 3: Sensor data read and logging |
|
| 70 | +- 🎯 Task 4: OTA update check |
|
| 71 | + |
|
| 72 | +All these tasks can run smoothly in parallel using FreeRTOS, each with its own stack and priority. |
|
| 73 | + |
|
| 74 | +--- |
|
| 75 | + |
|
| 76 | +### 🚀 Summary |
|
| 77 | + |
|
| 78 | +| Feature | Why FreeRTOS Helps | |
|
| 79 | +|--------------------------|-----------------------------------------| |
|
| 80 | +| Multitasking | Run multiple functions in parallel | |
|
| 81 | +| Real-time priority | Critical tasks get CPU first | |
|
| 82 | +| Precise scheduling | Timers, delays, and periodic execution | |
|
| 83 | +| Clean architecture | Organized, modular task-based design | |
|
| 84 | +| Event handling | Easy async using semaphores & queues | |
|
| 85 | + |
|
| 86 | +--- |
|
| 87 | + |
|
| 88 | +Let me know if you'd like a simple FreeRTOS project example! |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | +## Use FreeRTOS primitives: |
|
| 94 | + |
|
| 95 | +Queue: for passing sensor/audio/display data between tasks |
|
| 96 | + |
|
| 97 | +Semaphore: to lock I2C bus or protect shared resources |
|
| 98 | + |
|
| 99 | +Timer: for periodic updates (e.g., sensor every 1s) |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + |
|
| 103 | +## 🧩 Inter-Task Communication |
|
| 104 | + |
|
| 105 | +✅ 1. SSD1306 (I2C) |
|
| 106 | + |
|
| 107 | +Use Adafruit SSD1306 or u8g2 with I2C. |
|
| 108 | + |
|
| 109 | +Share I2C bus with BMP280. |
|
| 110 | + |
|
| 111 | +Protect with mutex semaphore. |
|
| 112 | + |
|
| 113 | +xSemaphoreTake(i2c_mutex, portMAX_DELAY); |
|
| 114 | +// update display |
|
| 115 | +xSemaphoreGive(i2c_mutex); |
|
| 116 | + |
|
| 117 | + |
|
| 118 | +✅ 2. BMP280 Sensor (I2C) |
|
| 119 | + |
|
| 120 | +Read temperature & pressure every 1–2 seconds. |
|
| 121 | + |
|
| 122 | +Send data to DisplayTask via queue. |
|
| 123 | + |
|
| 124 | +### Example Queues and Semaphores: |
|
| 125 | + |
|
| 126 | + QueueHandle_t sensor_data_queue; |
|
| 127 | + QueueHandle_t display_msg_queue; |
|
| 128 | + SemaphoreHandle_t i2c_mutex; |
|
| 129 | + |
|
| 130 | +### Sensor to Display Queue Message: |
|
| 131 | + |
|
| 132 | + typedef struct { |
|
| 133 | + float temperature; |
|
| 134 | + float pressure; |
|
| 135 | + } sensor_data_t |
|
| 136 | + |
|
| 137 | + |
|
| 138 | +## Pseudocode Overview |
|
| 139 | + |
|
| 140 | + void SensorTask(void *pvParams) { |
|
| 141 | + sensor_data_t data; |
|
| 142 | + while (1) { |
|
| 143 | + xSemaphoreTake(i2c_mutex, portMAX_DELAY); |
|
| 144 | + data = read_bmp280(); |
|
| 145 | + xSemaphoreGive(i2c_mutex); |
|
| 146 | + |
|
| 147 | + xQueueSend(sensor_data_queue, &data, 0); |
|
| 148 | + vTaskDelay(pdMS_TO_TICKS(1000)); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + void DisplayTask(void *pvParams) { |
|
| 153 | + sensor_data_t data; |
|
| 154 | + while (1) { |
|
| 155 | + if (xQueueReceive(sensor_data_queue, &data, portMAX_DELAY)) { |
|
| 156 | + xSemaphoreTake(i2c_mutex, portMAX_DELAY); |
|
| 157 | + update_display(data.temperature, data.pressure); |
|
| 158 | + xSemaphoreGive(i2c_mutex); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | +## cores |
|
| 166 | + |
|
| 167 | + xTaskCreatePinnedToCore(task1, "Task1", 2048, NULL, 1, NULL, 0); // Run on Core 0 |
|
| 168 | + xTaskCreatePinnedToCore(task2, "Task2", 2048, NULL, 1, NULL, 1); // Run on Core 1 |
|
| 169 | + |
|
| 170 | +Core 0: PRO_CPU (usually handles Wi-Fi, BT stack) |
|
| 171 | + |
|
| 172 | +Core 1: APP_CPU (often used for your application) |
|
| 173 | + |
|
| 174 | +## compare |
|
| 175 | + |
|
| 176 | +| Feature / RTOS | FreeRTOS | Zephyr RTOS | ThreadX (Azure RTOS) | Bare-Metal (No RTOS) | |
|
| 177 | +| ----------------------- | --------------------------------- | ---------------------------------------- | ---------------------------------- | ------------------------------ | |
|
| 178 | +| **License** | MIT (Permissive, Free) | Apache 2.0 (Permissive, Free) | Microsoft EULA (Free, but limited) | None | |
|
| 179 | +| **Footprint** | Very Small (<10 KB) | Medium (~50–100 KB) | Small (~10–20 KB) | Very Small | |
|
| 180 | +| **Real-Time** | Yes (preemptive, deterministic) | Yes (configurable RT, preemptive) | Yes (deterministic RTOS) | Depends on implementation | |
|
| 181 | +| **Ease of Use** | Simple API, easy learning curve | More complex, powerful config system | Easy API, good documentation | Full control but more effort | |
|
| 182 | +| **Hardware Support** | Very wide (ARM, RISC-V, etc.) | Very wide + device trees | Good (mainly ARM, RISC-V, x86) | Manual per-device work | |
|
| 183 | +| **Task Management** | Yes (tasks, priorities) | Yes (threads, priorities, SMP) | Yes (threads, priorities) | Manual state machine | |
|
| 184 | +| **Synchronization** | Semaphores, mutexes, queues | Semaphores, FIFOs, message queues | Semaphores, mutexes, event flags | Manual implementation | |
|
| 185 | +| **File System Support** | External (e.g., FatFs) | Native FS (e.g., LittleFS, FatFS) | With Azure FileX | Manual or third-party | |
|
| 186 | +| **Networking** | External (e.g., lwIP) | Native (TCP/IP stack, 6LoWPAN) | Azure NetX Duo (IPv4/IPv6) | External, complex to integrate | |
|
| 187 | +| **Power Management** | Basic, user-implemented | Advanced (built-in PM framework) | Good (some MCU-specific features) | Manual | |
|
| 188 | +| **Security/IoT** | AWS IoT support (via Amazon RTOS) | Secure boot, crypto, OTA, TLS | Azure IoT support, TLS, OTA | Manual, very limited | |
|
| 189 | +| **Trace & Debug** | Tools: SystemView, Tracealyzer | Zephyr logging & tracing | NetX, ThreadX tracing tools | Manual logging | |
|
| 190 | +| **Community Support** | Huge, mature ecosystem | Growing fast, backed by Linux Foundation | Good, backed by Microsoft | None (solo dev) | |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + |
|
| 195 | +## example 3 |
|
| 196 | + |
|
| 197 | +FreeRTOS Example Explanations |
|
| 198 | + |
|
| 199 | +✅ In short: |
|
| 200 | + |
|
| 201 | +- `Queue examples` → show how to pass data safely. |
|
| 202 | +- `Mutex/Notifications` → show synchronization methods. |
|
| 203 | +- `AnalogRead/Blink` → show multitasking with hardware. |
|
| 204 | +- `TaskStatus/Utilities` → show debugging and monitoring. |
|
| 205 | +- `Interrupts` → show ISR to task communication. |
|
| 206 | + |
|
| 207 | + |
|
| 208 | +### 1. AnalogRead_DigitalRead |
|
| 209 | +- Shows how to create tasks that perform **analog input** and **digital output**. |
|
| 210 | +- One task periodically reads an analog pin (ADC). |
|
| 211 | +- Another task toggles a digital pin (e.g., LED). |
|
| 212 | +- Demonstrates how multiple tasks run independently without blocking. |
|
| 213 | + |
|
| 214 | +--- |
|
| 215 | + |
|
| 216 | +### 2. ArrayQueue |
|
| 217 | +- Demonstrates using a **FreeRTOS queue** to pass an **array of data** between tasks. |
|
| 218 | +- For example: Task A fills an array → sends via queue → Task B receives and processes. |
|
| 219 | +- Useful for handling data buffers (sensor readings, UART packets). |
|
| 220 | + |
|
| 221 | +--- |
|
| 222 | + |
|
| 223 | +### 3. Assert |
|
| 224 | +- Shows how **configASSERT()** works in FreeRTOS. |
|
| 225 | +- Asserts help catch programming errors (e.g., stack overflow, bad API usage). |
|
| 226 | +- Example demonstrates failing conditions to show how assert is triggered. |
|
| 227 | + |
|
| 228 | +--- |
|
| 229 | + |
|
| 230 | +### 4. Blink_AnalogRead |
|
| 231 | +- Combines two common Arduino tasks: |
|
| 232 | + - One task **blinks an LED**. |
|
| 233 | + - Another task **reads analog input**. |
|
| 234 | +- Demonstrates that FreeRTOS allows both to run concurrently without delay() blocking. |
|
| 235 | + |
|
| 236 | +--- |
|
| 237 | + |
|
| 238 | +### 5. GoldilocksAnalogueTestSuite |
|
| 239 | +- Specific test suite for the **Goldilocks Analogue board** (Arduino-compatible with audio-grade ADC/DAC). |
|
| 240 | +- Shows how to use FreeRTOS tasks with more advanced ADC/DAC hardware. |
|
| 241 | +- Mostly relevant if you use that hardware. |
|
| 242 | + |
|
| 243 | +--- |
|
| 244 | + |
|
| 245 | +### 6. IntegerQueue |
|
| 246 | +- Demonstrates using a **queue of integers** between producer/consumer tasks. |
|
| 247 | +- Example: one task generates numbers, another task prints them. |
|
| 248 | +- Basic introduction to queues in FreeRTOS. |
|
| 249 | + |
|
| 250 | +--- |
|
| 251 | + |
|
| 252 | +### 7. Interrupts |
|
| 253 | +- Shows how FreeRTOS interacts with **hardware interrupts**. |
|
| 254 | +- Example: An ISR (interrupt service routine) gives a semaphore or sends data to a queue. |
|
| 255 | +- Demonstrates safe communication between interrupts and tasks. |
|
| 256 | + |
|
| 257 | +--- |
|
| 258 | + |
|
| 259 | +### 8. Mutex |
|
| 260 | +- Demonstrates a **mutex (mutual exclusion lock)**. |
|
| 261 | +- Ensures only one task at a time accesses a shared resource (like Serial or an I²C bus). |
|
| 262 | +- Prevents data corruption when multiple tasks try to use the same peripheral. |
|
| 263 | + |
|
| 264 | +--- |
|
| 265 | + |
|
| 266 | +### 9. Notifications |
|
| 267 | +- Shows how to use **task notifications** instead of semaphores/queues. |
|
| 268 | +- Lightweight way to signal a task from another task or from an ISR. |
|
| 269 | +- Example: ISR notifies a task when a button is pressed. |
|
| 270 | + |
|
| 271 | +--- |
|
| 272 | + |
|
| 273 | +### 10. StructArray |
|
| 274 | +- Demonstrates passing an **array of structs** between tasks. |
|
| 275 | +- Useful when you have structured data (like sensor packets). |
|
| 276 | +- Similar to ArrayQueue, but with custom struct types. |
|
| 277 | + |
|
| 278 | +--- |
|
| 279 | + |
|
| 280 | +### 11. StructQueue |
|
| 281 | +- Demonstrates using a **queue of structs**. |
|
| 282 | +- Example: Task A sends a struct `{temperature, humidity, timestamp}` to Task B. |
|
| 283 | +- More real-world than IntegerQueue because data usually comes in structs. |
|
| 284 | + |
|
| 285 | +--- |
|
| 286 | + |
|
| 287 | +### 12. TaskStatus |
|
| 288 | +- Demonstrates retrieving **task runtime statistics**. |
|
| 289 | +- Uses FreeRTOS APIs (`uxTaskGetSystemState`, `vTaskGetRunTimeStats`) to show: |
|
| 290 | + - Task names |
|
| 291 | + - CPU usage % |
|
| 292 | + - Stack high-water marks |
|
| 293 | +- Useful for debugging and optimization. |
|
| 294 | + |
|
| 295 | +--- |
|
| 296 | + |
|
| 297 | +### 13. TaskUtilities |
|
| 298 | +- Shows helper functions that make FreeRTOS task management easier. |
|
| 299 | +- Examples: delaying tasks (`vTaskDelay`), checking stack usage, suspending/resuming tasks. |
|
| 300 | +- A "toolbox" demo for common task patterns. |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + |
|
| 304 | +## example 2 |
|
| 305 | + |
|
| 306 | +queues + shared state |
|
| 307 | + |
|
| 308 | +``` |
|
| 309 | + struct ControlData { |
|
| 310 | + uint16_t throttle; |
|
| 311 | + uint16_t steering; |
|
| 312 | + uint16_t battery_mv; |
|
| 313 | + }; |
|
| 314 | + |
|
| 315 | + // Shared global (protected with mutex if multiple tasks write to it) |
|
| 316 | + volatile ControlData control; |
|
| 317 | +``` |
|
| 318 | + |
|
| 319 | +✅ Recommendation: Use FreeRTOS with 3–4 tasks (ELRS, motors, ADC, BLE) + one shared struct. It gives you the best modularity and avoids blocking. |
|
| 320 | + |
|
| 321 | +**ELRS Task (high priority)** |
|
| 322 | + |
|
| 323 | +- Reads UART (CRSF packets). |
|
| 324 | +- Parses channel values. |
|
| 325 | +- Updates control.throttle and control.steering. |
|
| 326 | + |
|
| 327 | +**Motor Control Task (medium/high priority)** |
|
| 328 | + |
|
| 329 | +- Runs periodically (e.g. every 10–20 ms). |
|
| 330 | +- Reads latest control.throttle / steering. |
|
| 331 | +- Writes PWM to motors (non-blocking). |
|
| 332 | + |
|
| 333 | +**Battery ADC Task (low priority / slow loop)** |
|
| 334 | + |
|
| 335 | +- Reads ADC every 500–1000 ms. |
|
| 336 | +- Updates control.battery_mv. |
|
| 337 | + |
|
| 338 | +**BLE Task (lowest priority)** |
|
| 339 | + |
|
| 340 | +- Takes control.battery_mv and updates BLE advertising packet. |
|
| 341 | +- Runs every 1–2 seconds. |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + |
|
| 346 | +## simple example 1 |
|
| 347 | + |
|
| 348 | + #include "FreeRTOS.h" |
|
| 349 | + #include "task.h" |
|
| 350 | + #include <stdio.h> |
|
| 351 | + |
|
| 352 | + void vTask1(void *pvParameters) { |
|
| 353 | + while (1) { |
|
| 354 | + printf("Task 1 running\n"); |
|
| 355 | + vTaskDelay(pdMS_TO_TICKS(1000)); // Delay 1000 ms |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + void vTask2(void *pvParameters) { |
|
| 360 | + while (1) { |
|
| 361 | + printf("Task 2 running\n"); |
|
| 362 | + vTaskDelay(pdMS_TO_TICKS(2000)); // Delay 2000 ms |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + int main(void) { |
|
| 367 | + xTaskCreate(vTask1, "Task1", 128, NULL, 1, NULL); |
|
| 368 | + xTaskCreate(vTask2, "Task2", 128, NULL, 1, NULL); |
|
| 369 | + |
|
| 370 | + vTaskStartScheduler(); // Start FreeRTOS |
|
| 371 | + while (1); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | +## ref |
|
| 375 | + |
|
| 376 | +- [[system-dat]] |
|
| ... | ... | \ No newline at end of file |
SDK-dat/SDK-DAT.md
| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | |
| 32 | 32 | - [[SDCC-dat]] - [[IAR-dat]] - [[MDK-ARM-dat]] - [[SDK-dat]] |
| 33 | 33 | |
| 34 | +- [[Zephyr-dat]] - [[SDK-dat]] |
|
| 34 | 35 | |
| 35 | 36 | ## VS-code |
| 36 | 37 |
SDK-dat/git-dat/git-dat.md
| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | + |
|
| 2 | + |
|
| 3 | +# git-dat |
|
| 4 | + |
|
| 5 | +## git actions |
|
| 6 | + |
SDK-dat/shell-dat/shell-dat.md
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | + |
|
| 2 | +# shell-dat |
|
| 3 | + |
|
| 4 | +## bash |
|
| 5 | + |
|
| 6 | +nano ~/.bashrc |
|
| 7 | + |
|
| 8 | +# Clash Verge Proxy Toggle |
|
| 9 | +function proxy_on() { |
|
| 10 | + export http_proxy="http://127.0.0.1:7897" |
|
| 11 | + export https_proxy="http://127.0.0.1:7897" |
|
| 12 | + export all_proxy="socks5://127.0.0.1:7897" |
|
| 13 | + export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" |
|
| 14 | + echo "Proxy environment variables set." |
|
| 15 | +} |
|
| 16 | + |
|
| 17 | +function proxy_off() { |
|
| 18 | + unset http_proxy https_proxy all_proxy no_proxy |
|
| 19 | + echo "Proxy environment variables cleared." |
|
| 20 | +} |
|
| 21 | + |
|
| 22 | +source ~/.bashrc |
|
| 23 | + |
|
| 24 | +curl -L ip.gs |
|
| 25 | + |
|
| 26 | +curl -I https://www.google.com |
|
| 27 | + |
|
| 28 | +Success: If you see HTTP/2 200 or HTTP/1.1 200 OK, your proxy is working, and the firewall is bypassed. |
|
| 29 | + |
|
| 30 | +Failure: If the terminal hangs (times out) or returns Connection refused, the proxy environment variables are not set correctly or Clash is not running. |
|
| 31 | + |
|
| 32 | +Proxy-specific error: If you get a 500 or 502 error, Clash is reachable, but your selected proxy node (server) might be down. |
|
| ... | ... | \ No newline at end of file |
Tech-dat/RTOS-dat/2024-08-28-15-15-47.png
| ... | ... | Binary files a/Tech-dat/RTOS-dat/2024-08-28-15-15-47.png and /dev/null differ |
Tech-dat/RTOS-dat/RT-Thread-dat/2025-08-28-18-00-45.png
| ... | ... | Binary files a/Tech-dat/RTOS-dat/RT-Thread-dat/2025-08-28-18-00-45.png and /dev/null differ |
Tech-dat/RTOS-dat/RT-Thread-dat/RT-Thread-dat.md
| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | - |
|
| 2 | -# RT-Thread-dat |
|
| 3 | - |
|
| 4 | -- [[allwinner-dat]] |
|
| 5 | - |
|
| 6 | -https://github.com/RT-Thread/rt-thread |
|
| 7 | - |
|
| 8 | -Nano 也得到了优秀国产物联网操作系统 RT-Thread 的官方支持,有rtt相关知识或经验,我们就可以对 Nano 进行快速高效的开发; |
|
| 9 | - |
|
| 10 | -RTT官方已经给出由 uestczyh222 所维护的 Nano固件详细的编译、烧录过程,搬运至此: |
|
| 11 | - |
|
| 12 | -https://github.com/RT-Thread/rt-thread/blob/master/bsp/allwinner_tina/README.md |
|
| 13 | - |
|
| 14 | -git clone https://github.com/RT-Thread/rt-thread.git |
|
| 15 | - |
|
| 16 | - |
|
| 17 | -project - [[wch-fly-dat]] |
|
| 18 | - |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - |
|
| 24 | -## ref |
|
| 25 | - |
|
| 26 | -- [[system-dat]] |
|
| ... | ... | \ No newline at end of file |
Tech-dat/RTOS-dat/RTOS-dat.md
| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | - |
|
| 2 | -# RTOS-dat |
|
| 3 | - |
|
| 4 | -- [[peripherals-dat]] |
|
| 5 | - |
|
| 6 | -## realtime system |
|
| 7 | - |
|
| 8 | -- [[freertos-dat]] - [[Zephyr-dat]] - [[MongooseOS-dat]] |
|
| 9 | - |
|
| 10 | -- [[openthread-dat]] - [[micropython-dat]] |
|
| 11 | - |
|
| 12 | -- [[RT-Thread-dat]] |
|
| 13 | - |
|
| 14 | -- [[cooperative-loop-dat]] |
|
| 15 | - |
|
| 16 | - |
|
| 17 | -## intelligent-system |
|
| 18 | - |
|
| 19 | - |
|
| 20 | - |
|
| 21 | -## AC-DC |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - |
|
| 26 | -## ref |
|
| 27 | - |
|
| 28 | -- [[tech-dat]] |
|
| ... | ... | \ No newline at end of file |
Tech-dat/RTOS-dat/cooperative-loop-dat/cooperative-loop-dat.md
| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | - |
|
| 2 | -# cooperative-loop-dat |
|
| 3 | - |
|
| 4 | -``` |
|
| 5 | -void loop() { |
|
| 6 | - readELRS(); // non-blocking UART read |
|
| 7 | - updateMotors(); // update PWM |
|
| 8 | - if (millis() - lastAdc >= 1000) { |
|
| 9 | - readBattery(); |
|
| 10 | - lastAdc = millis(); |
|
| 11 | - } |
|
| 12 | - if (millis() - lastBle >= 2000) { |
|
| 13 | - updateBleAdvert(control.battery_mv); |
|
| 14 | - lastBle = millis(); |
|
| 15 | - } |
|
| 16 | -} |
|
| 17 | -``` |
|
| ... | ... | \ No newline at end of file |
Tech-dat/RTOS-dat/freertos-dat/freertos-dat.md
| ... | ... | @@ -1,376 +0,0 @@ |
| 1 | - |
|
| 2 | -# freertos-dat |
|
| 3 | - |
|
| 4 | - |
|
| 5 | -## freeRTOS debug |
|
| 6 | - |
|
| 7 | -Your sketch is written for ESP32 but you’re compiling it for ESP8266, and that’s why it’s failing. |
|
| 8 | - |
|
| 9 | -Why |
|
| 10 | - |
|
| 11 | -SemaphoreHandle_t, xSemaphoreCreateBinary(), xSemaphoreGive(), xSemaphoreTake(), and portMAX_DELAY are FreeRTOS API calls. |
|
| 12 | - |
|
| 13 | -ESP32 Arduino comes with FreeRTOS by default. |
|
| 14 | - |
|
| 15 | -ESP8266 Arduino does not use FreeRTOS — so those types and functions don’t exist unless you add a separate RTOS layer. |
|
| 16 | - |
|
| 17 | - |
|
| 18 | - |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - |
|
| 22 | -## ✅ When is it a Good Time to Use FreeRTOS? |
|
| 23 | - |
|
| 24 | -**FreeRTOS** is a real-time operating system designed for microcontrollers. It lets you split your application into multiple tasks that run seemingly in parallel. |
|
| 25 | - |
|
| 26 | ---- |
|
| 27 | - |
|
| 28 | -### 🧠 Use FreeRTOS When: |
|
| 29 | - |
|
| 30 | -#### 1. 🧵 **You Need to Run Multiple Tasks Concurrently** |
|
| 31 | -- Example: Reading sensor data, updating a display, and handling WiFi at the same time. |
|
| 32 | -- Each task can run independently using `xTaskCreate()`. |
|
| 33 | - |
|
| 34 | -#### 2. ⏱️ **You Require Real-Time Responsiveness** |
|
| 35 | -- Critical tasks (e.g., handling motor feedback or interrupts) can be given **higher priority**. |
|
| 36 | -- Guarantees **predictable response time**. |
|
| 37 | - |
|
| 38 | -#### 3. 🕓 **You Need Precise Timing or Scheduling** |
|
| 39 | -- Use `vTaskDelay()`, `xTimerCreate()`, etc., to run tasks at specific intervals. |
|
| 40 | -- Better than using `delay()` or busy-wait loops. |
|
| 41 | - |
|
| 42 | -#### 4. 📶 **You Have Asynchronous Events to Handle** |
|
| 43 | -- Great for UART, I2C, network communication, button presses, etc. |
|
| 44 | -- Use **queues**, **semaphores**, and **event groups** for clean async handling. |
|
| 45 | - |
|
| 46 | -#### 5. 🔄 **You Want to Structure a Large Project Cleanly** |
|
| 47 | -- Modular task-based design. |
|
| 48 | -- Easier to manage and debug than a giant `loop()` function. |
|
| 49 | - |
|
| 50 | -#### 6. 📦 **You're Using ESP32 or STM32 with Multiple Cores or Peripherals** |
|
| 51 | -- ESP32 has dual-core (PRO & APP cores). |
|
| 52 | -- FreeRTOS lets you **pin tasks to cores**, assign priority, and manage memory better. |
|
| 53 | - |
|
| 54 | ---- |
|
| 55 | - |
|
| 56 | -### 🧊 Not Always Necessary If: |
|
| 57 | -| Situation | Recommendation | |
|
| 58 | -|----------------------------------|---------------------------| |
|
| 59 | -| Simple blink or sensor reading | No need for FreeRTOS | |
|
| 60 | -| Single function, low resource | Use `loop()` and interrupts | |
|
| 61 | -| Ultra-low-power apps | May be better without RTOS | |
|
| 62 | - |
|
| 63 | ---- |
|
| 64 | - |
|
| 65 | -### ✅ Example: Good Use Case (ESP32 with Camera, Webserver, Sensors) |
|
| 66 | - |
|
| 67 | -- 📷 Task 1: Camera image capture |
|
| 68 | -- 🌐 Task 2: Web server and WiFi communication |
|
| 69 | -- 🌡️ Task 3: Sensor data read and logging |
|
| 70 | -- 🎯 Task 4: OTA update check |
|
| 71 | - |
|
| 72 | -All these tasks can run smoothly in parallel using FreeRTOS, each with its own stack and priority. |
|
| 73 | - |
|
| 74 | ---- |
|
| 75 | - |
|
| 76 | -### 🚀 Summary |
|
| 77 | - |
|
| 78 | -| Feature | Why FreeRTOS Helps | |
|
| 79 | -|--------------------------|-----------------------------------------| |
|
| 80 | -| Multitasking | Run multiple functions in parallel | |
|
| 81 | -| Real-time priority | Critical tasks get CPU first | |
|
| 82 | -| Precise scheduling | Timers, delays, and periodic execution | |
|
| 83 | -| Clean architecture | Organized, modular task-based design | |
|
| 84 | -| Event handling | Easy async using semaphores & queues | |
|
| 85 | - |
|
| 86 | ---- |
|
| 87 | - |
|
| 88 | -Let me know if you'd like a simple FreeRTOS project example! |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | -## Use FreeRTOS primitives: |
|
| 94 | - |
|
| 95 | -Queue: for passing sensor/audio/display data between tasks |
|
| 96 | - |
|
| 97 | -Semaphore: to lock I2C bus or protect shared resources |
|
| 98 | - |
|
| 99 | -Timer: for periodic updates (e.g., sensor every 1s) |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - |
|
| 103 | -## 🧩 Inter-Task Communication |
|
| 104 | - |
|
| 105 | -✅ 1. SSD1306 (I2C) |
|
| 106 | - |
|
| 107 | -Use Adafruit SSD1306 or u8g2 with I2C. |
|
| 108 | - |
|
| 109 | -Share I2C bus with BMP280. |
|
| 110 | - |
|
| 111 | -Protect with mutex semaphore. |
|
| 112 | - |
|
| 113 | -xSemaphoreTake(i2c_mutex, portMAX_DELAY); |
|
| 114 | -// update display |
|
| 115 | -xSemaphoreGive(i2c_mutex); |
|
| 116 | - |
|
| 117 | - |
|
| 118 | -✅ 2. BMP280 Sensor (I2C) |
|
| 119 | - |
|
| 120 | -Read temperature & pressure every 1–2 seconds. |
|
| 121 | - |
|
| 122 | -Send data to DisplayTask via queue. |
|
| 123 | - |
|
| 124 | -### Example Queues and Semaphores: |
|
| 125 | - |
|
| 126 | - QueueHandle_t sensor_data_queue; |
|
| 127 | - QueueHandle_t display_msg_queue; |
|
| 128 | - SemaphoreHandle_t i2c_mutex; |
|
| 129 | - |
|
| 130 | -### Sensor to Display Queue Message: |
|
| 131 | - |
|
| 132 | - typedef struct { |
|
| 133 | - float temperature; |
|
| 134 | - float pressure; |
|
| 135 | - } sensor_data_t |
|
| 136 | - |
|
| 137 | - |
|
| 138 | -## Pseudocode Overview |
|
| 139 | - |
|
| 140 | - void SensorTask(void *pvParams) { |
|
| 141 | - sensor_data_t data; |
|
| 142 | - while (1) { |
|
| 143 | - xSemaphoreTake(i2c_mutex, portMAX_DELAY); |
|
| 144 | - data = read_bmp280(); |
|
| 145 | - xSemaphoreGive(i2c_mutex); |
|
| 146 | - |
|
| 147 | - xQueueSend(sensor_data_queue, &data, 0); |
|
| 148 | - vTaskDelay(pdMS_TO_TICKS(1000)); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - void DisplayTask(void *pvParams) { |
|
| 153 | - sensor_data_t data; |
|
| 154 | - while (1) { |
|
| 155 | - if (xQueueReceive(sensor_data_queue, &data, portMAX_DELAY)) { |
|
| 156 | - xSemaphoreTake(i2c_mutex, portMAX_DELAY); |
|
| 157 | - update_display(data.temperature, data.pressure); |
|
| 158 | - xSemaphoreGive(i2c_mutex); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | -## cores |
|
| 166 | - |
|
| 167 | - xTaskCreatePinnedToCore(task1, "Task1", 2048, NULL, 1, NULL, 0); // Run on Core 0 |
|
| 168 | - xTaskCreatePinnedToCore(task2, "Task2", 2048, NULL, 1, NULL, 1); // Run on Core 1 |
|
| 169 | - |
|
| 170 | -Core 0: PRO_CPU (usually handles Wi-Fi, BT stack) |
|
| 171 | - |
|
| 172 | -Core 1: APP_CPU (often used for your application) |
|
| 173 | - |
|
| 174 | -## compare |
|
| 175 | - |
|
| 176 | -| Feature / RTOS | FreeRTOS | Zephyr RTOS | ThreadX (Azure RTOS) | Bare-Metal (No RTOS) | |
|
| 177 | -| ----------------------- | --------------------------------- | ---------------------------------------- | ---------------------------------- | ------------------------------ | |
|
| 178 | -| **License** | MIT (Permissive, Free) | Apache 2.0 (Permissive, Free) | Microsoft EULA (Free, but limited) | None | |
|
| 179 | -| **Footprint** | Very Small (<10 KB) | Medium (~50–100 KB) | Small (~10–20 KB) | Very Small | |
|
| 180 | -| **Real-Time** | Yes (preemptive, deterministic) | Yes (configurable RT, preemptive) | Yes (deterministic RTOS) | Depends on implementation | |
|
| 181 | -| **Ease of Use** | Simple API, easy learning curve | More complex, powerful config system | Easy API, good documentation | Full control but more effort | |
|
| 182 | -| **Hardware Support** | Very wide (ARM, RISC-V, etc.) | Very wide + device trees | Good (mainly ARM, RISC-V, x86) | Manual per-device work | |
|
| 183 | -| **Task Management** | Yes (tasks, priorities) | Yes (threads, priorities, SMP) | Yes (threads, priorities) | Manual state machine | |
|
| 184 | -| **Synchronization** | Semaphores, mutexes, queues | Semaphores, FIFOs, message queues | Semaphores, mutexes, event flags | Manual implementation | |
|
| 185 | -| **File System Support** | External (e.g., FatFs) | Native FS (e.g., LittleFS, FatFS) | With Azure FileX | Manual or third-party | |
|
| 186 | -| **Networking** | External (e.g., lwIP) | Native (TCP/IP stack, 6LoWPAN) | Azure NetX Duo (IPv4/IPv6) | External, complex to integrate | |
|
| 187 | -| **Power Management** | Basic, user-implemented | Advanced (built-in PM framework) | Good (some MCU-specific features) | Manual | |
|
| 188 | -| **Security/IoT** | AWS IoT support (via Amazon RTOS) | Secure boot, crypto, OTA, TLS | Azure IoT support, TLS, OTA | Manual, very limited | |
|
| 189 | -| **Trace & Debug** | Tools: SystemView, Tracealyzer | Zephyr logging & tracing | NetX, ThreadX tracing tools | Manual logging | |
|
| 190 | -| **Community Support** | Huge, mature ecosystem | Growing fast, backed by Linux Foundation | Good, backed by Microsoft | None (solo dev) | |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - |
|
| 195 | -## example 3 |
|
| 196 | - |
|
| 197 | -FreeRTOS Example Explanations |
|
| 198 | - |
|
| 199 | -✅ In short: |
|
| 200 | - |
|
| 201 | -- `Queue examples` → show how to pass data safely. |
|
| 202 | -- `Mutex/Notifications` → show synchronization methods. |
|
| 203 | -- `AnalogRead/Blink` → show multitasking with hardware. |
|
| 204 | -- `TaskStatus/Utilities` → show debugging and monitoring. |
|
| 205 | -- `Interrupts` → show ISR to task communication. |
|
| 206 | - |
|
| 207 | - |
|
| 208 | -### 1. AnalogRead_DigitalRead |
|
| 209 | -- Shows how to create tasks that perform **analog input** and **digital output**. |
|
| 210 | -- One task periodically reads an analog pin (ADC). |
|
| 211 | -- Another task toggles a digital pin (e.g., LED). |
|
| 212 | -- Demonstrates how multiple tasks run independently without blocking. |
|
| 213 | - |
|
| 214 | ---- |
|
| 215 | - |
|
| 216 | -### 2. ArrayQueue |
|
| 217 | -- Demonstrates using a **FreeRTOS queue** to pass an **array of data** between tasks. |
|
| 218 | -- For example: Task A fills an array → sends via queue → Task B receives and processes. |
|
| 219 | -- Useful for handling data buffers (sensor readings, UART packets). |
|
| 220 | - |
|
| 221 | ---- |
|
| 222 | - |
|
| 223 | -### 3. Assert |
|
| 224 | -- Shows how **configASSERT()** works in FreeRTOS. |
|
| 225 | -- Asserts help catch programming errors (e.g., stack overflow, bad API usage). |
|
| 226 | -- Example demonstrates failing conditions to show how assert is triggered. |
|
| 227 | - |
|
| 228 | ---- |
|
| 229 | - |
|
| 230 | -### 4. Blink_AnalogRead |
|
| 231 | -- Combines two common Arduino tasks: |
|
| 232 | - - One task **blinks an LED**. |
|
| 233 | - - Another task **reads analog input**. |
|
| 234 | -- Demonstrates that FreeRTOS allows both to run concurrently without delay() blocking. |
|
| 235 | - |
|
| 236 | ---- |
|
| 237 | - |
|
| 238 | -### 5. GoldilocksAnalogueTestSuite |
|
| 239 | -- Specific test suite for the **Goldilocks Analogue board** (Arduino-compatible with audio-grade ADC/DAC). |
|
| 240 | -- Shows how to use FreeRTOS tasks with more advanced ADC/DAC hardware. |
|
| 241 | -- Mostly relevant if you use that hardware. |
|
| 242 | - |
|
| 243 | ---- |
|
| 244 | - |
|
| 245 | -### 6. IntegerQueue |
|
| 246 | -- Demonstrates using a **queue of integers** between producer/consumer tasks. |
|
| 247 | -- Example: one task generates numbers, another task prints them. |
|
| 248 | -- Basic introduction to queues in FreeRTOS. |
|
| 249 | - |
|
| 250 | ---- |
|
| 251 | - |
|
| 252 | -### 7. Interrupts |
|
| 253 | -- Shows how FreeRTOS interacts with **hardware interrupts**. |
|
| 254 | -- Example: An ISR (interrupt service routine) gives a semaphore or sends data to a queue. |
|
| 255 | -- Demonstrates safe communication between interrupts and tasks. |
|
| 256 | - |
|
| 257 | ---- |
|
| 258 | - |
|
| 259 | -### 8. Mutex |
|
| 260 | -- Demonstrates a **mutex (mutual exclusion lock)**. |
|
| 261 | -- Ensures only one task at a time accesses a shared resource (like Serial or an I²C bus). |
|
| 262 | -- Prevents data corruption when multiple tasks try to use the same peripheral. |
|
| 263 | - |
|
| 264 | ---- |
|
| 265 | - |
|
| 266 | -### 9. Notifications |
|
| 267 | -- Shows how to use **task notifications** instead of semaphores/queues. |
|
| 268 | -- Lightweight way to signal a task from another task or from an ISR. |
|
| 269 | -- Example: ISR notifies a task when a button is pressed. |
|
| 270 | - |
|
| 271 | ---- |
|
| 272 | - |
|
| 273 | -### 10. StructArray |
|
| 274 | -- Demonstrates passing an **array of structs** between tasks. |
|
| 275 | -- Useful when you have structured data (like sensor packets). |
|
| 276 | -- Similar to ArrayQueue, but with custom struct types. |
|
| 277 | - |
|
| 278 | ---- |
|
| 279 | - |
|
| 280 | -### 11. StructQueue |
|
| 281 | -- Demonstrates using a **queue of structs**. |
|
| 282 | -- Example: Task A sends a struct `{temperature, humidity, timestamp}` to Task B. |
|
| 283 | -- More real-world than IntegerQueue because data usually comes in structs. |
|
| 284 | - |
|
| 285 | ---- |
|
| 286 | - |
|
| 287 | -### 12. TaskStatus |
|
| 288 | -- Demonstrates retrieving **task runtime statistics**. |
|
| 289 | -- Uses FreeRTOS APIs (`uxTaskGetSystemState`, `vTaskGetRunTimeStats`) to show: |
|
| 290 | - - Task names |
|
| 291 | - - CPU usage % |
|
| 292 | - - Stack high-water marks |
|
| 293 | -- Useful for debugging and optimization. |
|
| 294 | - |
|
| 295 | ---- |
|
| 296 | - |
|
| 297 | -### 13. TaskUtilities |
|
| 298 | -- Shows helper functions that make FreeRTOS task management easier. |
|
| 299 | -- Examples: delaying tasks (`vTaskDelay`), checking stack usage, suspending/resuming tasks. |
|
| 300 | -- A "toolbox" demo for common task patterns. |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - |
|
| 304 | -## example 2 |
|
| 305 | - |
|
| 306 | -queues + shared state |
|
| 307 | - |
|
| 308 | -``` |
|
| 309 | - struct ControlData { |
|
| 310 | - uint16_t throttle; |
|
| 311 | - uint16_t steering; |
|
| 312 | - uint16_t battery_mv; |
|
| 313 | - }; |
|
| 314 | - |
|
| 315 | - // Shared global (protected with mutex if multiple tasks write to it) |
|
| 316 | - volatile ControlData control; |
|
| 317 | -``` |
|
| 318 | - |
|
| 319 | -✅ Recommendation: Use FreeRTOS with 3–4 tasks (ELRS, motors, ADC, BLE) + one shared struct. It gives you the best modularity and avoids blocking. |
|
| 320 | - |
|
| 321 | -**ELRS Task (high priority)** |
|
| 322 | - |
|
| 323 | -- Reads UART (CRSF packets). |
|
| 324 | -- Parses channel values. |
|
| 325 | -- Updates control.throttle and control.steering. |
|
| 326 | - |
|
| 327 | -**Motor Control Task (medium/high priority)** |
|
| 328 | - |
|
| 329 | -- Runs periodically (e.g. every 10–20 ms). |
|
| 330 | -- Reads latest control.throttle / steering. |
|
| 331 | -- Writes PWM to motors (non-blocking). |
|
| 332 | - |
|
| 333 | -**Battery ADC Task (low priority / slow loop)** |
|
| 334 | - |
|
| 335 | -- Reads ADC every 500–1000 ms. |
|
| 336 | -- Updates control.battery_mv. |
|
| 337 | - |
|
| 338 | -**BLE Task (lowest priority)** |
|
| 339 | - |
|
| 340 | -- Takes control.battery_mv and updates BLE advertising packet. |
|
| 341 | -- Runs every 1–2 seconds. |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - |
|
| 346 | -## simple example 1 |
|
| 347 | - |
|
| 348 | - #include "FreeRTOS.h" |
|
| 349 | - #include "task.h" |
|
| 350 | - #include <stdio.h> |
|
| 351 | - |
|
| 352 | - void vTask1(void *pvParameters) { |
|
| 353 | - while (1) { |
|
| 354 | - printf("Task 1 running\n"); |
|
| 355 | - vTaskDelay(pdMS_TO_TICKS(1000)); // Delay 1000 ms |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - void vTask2(void *pvParameters) { |
|
| 360 | - while (1) { |
|
| 361 | - printf("Task 2 running\n"); |
|
| 362 | - vTaskDelay(pdMS_TO_TICKS(2000)); // Delay 2000 ms |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - int main(void) { |
|
| 367 | - xTaskCreate(vTask1, "Task1", 128, NULL, 1, NULL); |
|
| 368 | - xTaskCreate(vTask2, "Task2", 128, NULL, 1, NULL); |
|
| 369 | - |
|
| 370 | - vTaskStartScheduler(); // Start FreeRTOS |
|
| 371 | - while (1); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | -## ref |
|
| 375 | - |
|
| 376 | -- [[system-dat]] |
|
| ... | ... | \ No newline at end of file |
mechanics-dat/mechanical-structure-dat/mechanical-structure-dat.md
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | - [[structure-design-dat]] - [[engineering-dat]] |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -common structure: - [[sheet-dat]] - [[frame-profile-dat]] - [[shell-dat]] |
|
| 7 | +common structure: - [[sheet-dat]] - [[frame-profile-dat]] - [[shell-case-dat/shell-dat]] |
|
| 8 | 8 | |
| 9 | 9 | - [[power-transmission-dat]] - [[bel-sys-dat]] |
| 10 | 10 |
mechanics-dat/mechanical-structure-dat/shell-case-dat/shell-case-dat.md
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | + |
|
| 2 | +# shell-case-dat |
|
| 3 | + |
|
| 4 | +- [[shell-case-dat]] - [[mechnical-structure-dat]] |
|
| 5 | + |
|
| 6 | +- [[plastic-dat]] - [[fab-sheet-metal-dat]] |
|
| 7 | + |
|
| 8 | +plastic shell thickness == 2.0 mm |
|
| 9 | + |
|
| 10 | +sheet metal thickness == 1.0 mm |
|
| 11 | + |
|
| 12 | + |
|
| 13 | + |
|
| 14 | + |
|
| 15 | +## ref |
|
| 16 | + |
mechanics-dat/mechanical-structure-dat/shell-dat/shell-dat.md
| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | - |
|
| 2 | -# shell-dat |
|
| 3 | - |
|
| 4 | -- [[shell-dat]] - [[mechnical-structure-dat]] |
|
| 5 | - |
|
| 6 | -- [[plastic-dat]] - [[fab-sheet-metal-dat]] |
|
| 7 | - |
|
| 8 | -plastic shell thickness == 2.0 mm |
|
| 9 | - |
|
| 10 | -sheet metal thickness == 1.0 mm |
|
| 11 | - |
|
| 12 | - |
|
| 13 | - |
|
| 14 | - |
|
| 15 | -## ref |
|
| 16 | - |