代码拉取完成,页面将自动刷新
A_A _
o'' )_____// [MOS-STM32]
`_/ MOS ) Mini RTOS on Cortex-M
(_(_/--(_/ MOS <=> Mini-RTOS
- Board: NUCLEO-144 F429ZI
- MCU: STM32F429ZIT6 (256KB SRAM, 2MB FLASH)
.
├── vendor // Hardware Abstraction Layer(SPL/HAL/LL/...)
└── src
├── drivers // Hardware Driver Portable Interface
│ ├── stm32f4xx // STM32F4xx On-Chip Peripherals(USART, I2C, SPI, ...)
│ └── device // Other components(LED, LCD, ...)
│
├── mos
│ ├── config.h // System Configuration
│ ├── arch // Arch-related
│ │ └── cpu.hpp // asm for init/context_switch
│ │
│ ├── kernel // Kernel(Arch-independent)
│ │ ├── macro.hpp // Kernel Constant Macros
│ │ ├── type.hpp // Basic Types
│ │ ├── concepts.hpp // Type Constraints(Optional)
│ │ ├── data_type.hpp // Basic Data Structures
│ │ ├── alloc.hpp // Static/Dynamic Allocator
│ │ ├── global.hpp // Kernel Globals
│ │ ├── printf.h/.c // Thread-safe printf (by mpaland)
│ │ ├── task.hpp // Task control
│ │ ├── sync.hpp // Sync primitives
│ │ ├── scheduler.hpp // Scheduler and Policy
│ │ ├── ipc.hpp // Inter-Process Communication
│ │ └── utils.hpp // Utils
│ │
│ ├── kernel.hpp // Import Kernel Modules
│ └── shell.hpp // Simple Shell
│
├── user
│ ├── gui // GUI-related
│ │ ├── GuiLite.h // GuiLite Framework
│ │ └── UICode.cpp // User Interface
│ │
│ ├── global.hpp // User Globals
│ ├── bsp.hpp // Board Support Package
│ ├── app.hpp // User Applications
│ └── test.hpp // Test
│
├── main.cpp // Entry main()
└── stm32f4xx_it.cpp // Interrput SubRoutine(Partly)
Shell Test
Mutex Test
LCD Driver & GUI Demo
Concurrent Task Period & Time Sequence
Async Executor
// MOS Kernel & Shell
#include "mos/kernel.hpp"
#include "mos/shell.hpp"
// HAL and Device
#include "drivers/stm32f4xx/hal.hpp"
#include "drivers/device/led.hpp"
namespace MOS::User::Global
{
using namespace HAL::STM32F4xx;
using namespace Driver::Device;
using namespace DataType;
// Shell I/O UART and Buffer
auto& stdio = STM32F4xx::convert(USARTx);
DataType::SyncRxBuf_t<16> io_buf;
// LED red, green, blue
Device::LED_t leds[] = {...};
}
namespace MOS::User::BSP
{
using namespace Driver;
using namespace Global;
void LED_Config()
{
for (auto& led: leds) {
led.init();
}
}
void USART_Config()
{
// Simplified
stdio.init(9600-8-1-N)
.rx_config(PXa) // RX -> PXa
.tx_config(PYb) // TX -> PYb
.it_enable(RXNE) // Enable RXNE interrupt
.enable();
}
...
}
namespace MOS::User::App
{
Sync::Barrier_t bar {2};
void LED_1(Device::LED_t leds[])
{
bar.wait();
for (auto _: Range(0, 20)) {
leds[1].toggle(); // green
Task::delay(250_ms);
}
kprintf("L1 exits...\n");
}
void LED_0(Device::LED_t leds[])
{
Task::create(
LED_1,
leds,
Task::current()->get_pri(),
"L1"
);
bar.wait();
while (true) {
leds[0].toggle(); // red
Task::delay(500_ms);
}
}
}
int main()
{
using namespace MOS;
using namespace Kernel;
using namespace User;
using namespace User::Global;
BSP::config(); // Init hardware and clocks
Task::create( // Create Calendar with RTC
App::Calendar, nullptr, 0, "Calendar"
);
Task::create( // Create Shell with io_buf
Shell::launch, &io_buf, 1, "Shell"
);
/* User Tasks */
Task::create(App::LED_0, &leds, 2, "L0");
...
/* Test examples */
Test::MutexTest();
Test::MsgQueueTest();
...
// Start scheduling, never return
Scheduler::launch();
}
A_A _ Version @ x.x.x(...)
o'' )_____// Build @ TIME, DATE
`_/ MOS ) Chip @ MCU, ARCH
(_(_/--(_/ 2023-2024 Copyright by Eplankton
Tid Name Priority Status Stack%
-----------------------------------------
#0 idle 15 READY 10%
#1 Shell 1 BLOCKED 21%
#2 L0 2 RUNNING 9%
-----------------------------------------
📦 v0.1
✅ Done
- Basic Scheduler and Task control, memory management
📌 Plan
- Timers,
RoundRobin
- Inter-process communication
IPC
, pipes, message queues- Sync, semaphore, mutex, lock
- Porting simple shells
- Mutable page size, memory allocator
SPI
driver andLVGL
library- Port to other platform like
ESP32-C3(RISC-V)
📦 v0.2
✅ Done
Sync::{Sema_t, Lock_t, Mutex_t<T>, CondVar_t, Barrier_t}
, whereMutex_t
adopts Priority Ceiling ProtocolScheduler::Policy::PreemptPri
, under same priority ->RoundRobin
Task::terminate
will be implicitly called when task exitsShell::{Command, CmdCall, launch}
HAL::STM32F4xx::SPI_t
andDriver::ST7735S_t
, supportGuiLite
Kernel::Global::os_ticks
andTask::delay
for blocking delay- Refactor the project into
{kernel, arch, drivers}
- Support
GCC
andSTM32CubeMX HAL
HAL::STM32F4xx::RTC_t
,CmdCall::date_cmd
andApp::Calendar
idle
usesKernel::Global::zombie_list
to recycle inactive pages- Three basic page allocator policies,
Page_t::Policy::{POOL, DYNAMIC, STATIC}
📦 v0.3
✅ Done
Tids
fromBitMap_t
IPC::MsgQueue_t
, Message QueueTask::create
allows genericfn
signature asvoid fn(auto argv)
with type check- Add
ESP32C3
asWiFi
Module- Add
Driver::Device::SD_t
driver withSPI
mode- Add
FatFs
as File System- Add
Shell::usr_cmds
,User Register Service- [Experimental] Atomic Type in
<stdatomic.h>
- [Experimental]
Utils::IntrGuard_t
, Nested Interrupt Lock Guard
📌 Plan
IPC::pipe/channel
- Soft/Hardware Timers
FPU
support- Performance Benchmark
DMA_t
DriverResult<T, E>, Option<T>
- [Experimental] Add
POSIX
support- [Experimental] Async Stackless Coroutine
Async::{Future_t, async/await}
- [Experimental] Basic Formal Verification on
Scheduler
- [Experimental] More real-time scheduling algorithms
Wake up, Neo...
The Matrix has you...
Follow the white rabbit.
Knock, knock, Neo.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。