Skip to content

Commit

Permalink
Add the first thread usage into README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
At-EC committed Feb 9, 2024
1 parent 252e0cb commit 5939b12
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 7 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.20)
project(kernal_sample
LANGUAGES C)

set(At_RTOS_PATH "../../")
set(At_RTOS_PATH "../../../")

include(${At_RTOS_PATH}/CMakeLists.txt)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$VersionFile = "atos_version.h"
$VersionPath = "../kernal/include"
$VersionPath = "../../kernal/include"
$FileContent = '/**
* Copyright (c) Riven Zheng (zhengheiot@gmail.com).
*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernal-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Build Kernal Sample CMake
shell: bash
working-directory: samples/kernal_sample
working-directory: .github/samples/kernal_sample
run: |
cmake -S . -B build
cmake --build build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger-version-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Execute Version Script
id: version
shell: powershell
working-directory: script
working-directory: .github/script
run: |
$message = powershell.exe -ExecutionPolicy bypass .\auto-version.ps1
echo "value=$message" >> "$env:GITHUB_OUTPUT"
Expand Down
89 changes: 87 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ The goal of the project is to explore and try to provide a lot useful interfaces
If this project was useful to you, give it a ⭐️ and I'll keep improving it. moreover, you can share your ideas we can together improve it. Welcome PRs!!!

<p align="center">

<img src="https://socialify.git.ci/At-EC/At-RTOS/image?description=1&descriptionEditable=At-RTOS%20is%20an%20open%20user-friendly%20real-time%20operating%20system.&font=KoHo&forks=1&issues=1&name=1&owner=1&pattern=Circuit%20Board&stargazers=1&theme=Dark" alt="At-RTOS" width="640" height="320" />

</p>

## Introduction
Expand All @@ -26,6 +24,93 @@ If this project was useful to you, give it a ⭐️ and I'll keep improving it.
* **Tiny footprint:** It's as low as 1KB ROM/few bytes of RAM.
* **Learn Once, Write Anywhere:** We don't make assumptions about the rest of your technology stack, so you can develop new features in At-RTOS without rewriting existing code.

## Kernal Structure

```shell
# At-RTOS source code tree
At-RTOS
├── arch
│ ├── arch32
│ │ └── arm
│ │ └── cmsis
│ │ └── include
│ │ └── *.h
│ ├── arch.h
│ └── CMakeLists.txt
├── clock
│ ├── include
│ │ └── clock_tick.h
│ ├── clock_systick.c
│ └── CMakeLists.txt
├── port
│ ├── include
│ │ └── port.h
│ ├── port_keil.c
│ └── CMakeLists.txt
├── include
│ ├── atos_configuration.h
│ └── CMakeLists.txt
├── kernal
│ ├── include
│ │ ├── at_rtos.h
│ │ ├── atos_version.h
│ │ └── *.h
│ ├── basic.c
│ ├── event.c
│ ├── kernal.c
│ ├── kernal_thread.c
│ ├── linker.c
│ ├── list.c
│ ├── mutex.c
│ ├── queue.c
│ ├── semaphore.c
│ ├── thread.c
│ ├── timer.c
│ ├── trace.c
│ └── CMakeLists.txt
├── kernal_idle.c
└── CMakeLists.txt
```

- **arch :** This folder was used to store all the chip architectures supported by the current At-RTOS.
- **clock :** It was implemented for At-RTOS kernal system tick to support system timers.
- **port :** It's used to support different compiler such as KEIL, IAR and GCC.
- **include :** It used to contain the At-RTOS kernal header file such as the At-RTOS user configurations.
- **kernal :** Ihis folder was implemented for the At-RTOS kernal files.

## Usage

Create Your First Thread:
```shell
# Include the At-RTOS interface's header file
#include "at_rtos.h"

# Define a thread hook to specific the stack size and prioriy of the thread
ATOS_THREAD_DEFINE(first_thread, 1024, 7); // Set the thread stack size to 1024 bytes and the schedule prioriy level to 7.

# User thread's entry function
static void first_thread_entry(void)
{
while (1)
{
AtOS.thread_sleep(1000u);
}
}

# The main routine
int main(void)
{
/* Initialize the your first thread */
os_thread_id_t first_id = thread_init(first_thread, first_thread_entry);
if (os_id_is_invalid(first_id))
{
printf("Thread %s init failed\n", first_id.pName);
}

AtOS.at_rtos_run(); // The AtOS kernal schedule starts to run.
}
```
## What's New
[v1.0.0] Welcome to At-RTOS. v1.0.0 was released now. A basic RTOS feature was implemented in the kernal system, Pls enjoy it (:
Expand Down
3 changes: 2 additions & 1 deletion kernal/include/at_rtos.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ S_ASSERT((((thread_priority) >= OS_PRIORITY_USER_THREAD_HIGHEST_LEVEL) && ((thre
* @return The value of thread unique id.
**
* demo usage:
*#include "at_rtos.h"
*
*ATOS_THREAD_DEFINE(sample_thread, 512, 5);
*
* void thread_sample_function(void)
* {
* while(1)
* {
* AtOS.thread_sleep(1000u);
* }
* }
*
* int main(void)
* {
* ATOS_PRIORITY_DEFINE(sample_pri, 5);
* os_thread_id_t sample_id = thread_init(sample_thread, thread_sample_function);
* if (os_id_is_invalid(sample_id))
* {
Expand Down

0 comments on commit 5939b12

Please sign in to comment.