# FreeRTOS_Exmaples **Repository Path**: dysonnnn/FreeRTOS_Exmaples ## Basic Information - **Project Name**: FreeRTOS_Exmaples - **Description**: No description available - **Primary Language**: C - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-12-21 - **Last Updated**: 2023-12-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: freerrtos ## README # FreeRTOS Examples Welcome to the FreeRTOS example repository! These examples originally were provided in the book [Mastering the FreeRTOS Real Time Kernel - a Hands On Tutorial Guide](https://www.freertos.org/fr-content-src/uploads/2018/07/161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutorial_Guide.pdf), which you can access [here](https://www.freertos.org/Documentation/RTOS_book.html) along with the accompanying examples. New examples are added to complete tutorial and these are drived from [Hands-On-RTOS-with-Microcontrollers](https://github.com/PacktPublishing/Hands-On-RTOS-with-Microcontrollers) by Brain Amos. ## Introduction
The provided examples were initially designed to run exclusively on Windows using Visual Studio. However, I've taken the initiative to enhance their compatibility by making them functional with the GCC compiler, enabling them to be executed on Fedora Linux as well as other Linux distributions and Windows systems.
To achieve this, I've utilized the mps2-385 port of FreeRTOS and introduced the necessary adjustments to facilitate compilation using GCC. Furthermore, I've ensured that the examples can be run on the QEMU emulator
## ContributingI invite you to actively contribute to this project. Your contributions are highly valued, and pull requests are enthusiastically welcomed.
## Running Examples on Linux with GCC using the mps2-an385 PortThis section provides detailed instructions on how to run each example on a Linux environment. I've leveraged the xPack GNU Arm toolchain for compiling the code and the xPack QEMU emulator for execution.
### Requirements ---------------For simulating these examples over linux you only need toolchain and QEMU emulator.
#### ToolchainTo ensure compatibility, the following toolchain version was used:
``` arm-none-eabi-gcc --version arm-none-eabi-gcc (xPack GNU Arm Embedded GCC x86_64) 12.2.1 20221205 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE ``` You can find instructions on how to install the toolchain [here](https://xpack.github.io/dev-tools/arm-none-eabi-gcc/install/). #### QEMUThe chosen QEMU emulator version is as follows:
``` qemu-system-arm --version xPack QEMU emulator version 7.2.0 (v7.2.0-xpack) Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers ``` You can find instructions on how to install QEMU for ARM [here](https://xpack.github.io/dev-tools/qemu-arm/install/). ### Run Examples ---------------- #### Compilation Steps Follow these steps to compile the examples: 1. Navigate to the desired example's directory: `cd Examples/Example0**/GCC/` 2. Run the `make` command. #### Running the SimulatorExecute the following command to run the simulator for the example you compiled:
`qemu-system-arm "--machine" "mps2-an385" "--cpu" "cortex-m3" "--kernel" "output/RTOSDemo.out" -monitor none -nographic -serial stdio`Feel free to explore and experiment with these examples. If you encounter any issues or have improvements to suggest, please contribute to the project or submit a pull request. Your involvement is pivotal in making this repository a valuable resource for the FreeRTOS community.
## Book ExamplesIn this part, I explain about what each book example does.
### Exmpale 01Creating tasks. Running two task at the same priority level having diffrent task functions.
### Exmpale 02Using the task parameter. Running two task at the same priority level sharing the same task function.
### Exmpale 03Experimenting with priorities.
### Exmpale 04Using the Blocked state to create a delay.
### Exmpale 05Converting the example tasks to use vTaskDelayUntil().
### Exmpale 06Combining blocking and non-blocking tasks.
### Exmpale 07Defining an idle task hook function.
### Exmpale 08Changing task priorities.
### Exmpale 09Deleting tasks.
### Exmpale 10Blocking when receiving from a queue.
### Exmpale 11Blocking when sending to a queue, and sending structures on a queue.
### Exmpale 12Using a Queue Set.
### Exmpale 13Creating one-shot and auto-reload timers.
### Exmpale 14Using the callback function parameter and the software timer ID.
### Exmpale 15Resetting a software timer.
### Exmpale 16Using a binary semaphore to synchronize a task with an interrupt.
### Exmpale 17Using a counting semaphore to synchronize a task with an interrupt.
### Exmpale 18Centralized deferred interrupt processing.
### Exmpale 19Sending and receiving on a queue from within an interrupt.
### Exmpale 20Rewriting vPrintString() to use a semaphore.
### Exmpale 21Re-writing vPrintString() to use a gatekeeper task.
### Exmpale 22Experimenting with event groups.
### Exmpale 23Synchronizing tasks.
### Exmpale 24Using a task notification in place of a semaphore, method 1.
### Exmpale 25Using a task notification in place of a semaphore, method 2.
---------------- ## New ExamplesIn this part, I explain about new exmpales I add to this project. These examples are drived from Hands-On-RTOS-with-Microcontrollers by Brian Amos.
### Exmpale 026It has the same functionality of example 015. and try to keep back light on until recieved new key press within timeout.Polling method is used in the example 015 which increases cpu overhead.
In this example, we have used interrupt service routin for reading data from uart instead of polling to decrease cpu overhead.
### Exmpale 027It echos each character you send to uart0 using interrupt and queue.
### Exmpale 028Each time, it waits for 16 characters to be typed with 10 seconds timeout. It uses buffer instead of queue.
### Exmpale 029Each time, it waits for stream buffer filled with at least 10 characters with 10 seconds timeout. It shows using stream buffer which is filled with interrupt.
### Exmpale 030Using CMSIS-RTOS as a wrapper for running FreeRTOS.
### Exmpale 031Using FreeRTOS-POSIX as a wrapper for running FreeRTOS.
### Exmpale 032Using heap 1 for memory management and try to delete task created by heap.
### Exmpale 033Using heap 1 for memory management and try to delete task created statically.
### Exmpale 034Using heap 1 for memory management and try to build a queue statically.
### Exmpale 035Developing an abstract layer by using an LED interface and initilize leds to turn on and off repeatedly.
You can modify and add what implementaion you want in `ledImplementation.c` ### Exmpale 036Get data from uart and control leds based on the data. There is a python program in PythonColorSelectorUI directory which send data to the device comport. After running program you can see the result log in serial.log
This program shows abstraction and loosly coupled code. You can modify and add what implementaion you want in `pwmImplementation.c`Use this command to run a program in simulator with serial port connected to pty under linux.
`qemu-system-arm "--machine" "mps2-an385" "--cpu" "cortex-m3" "--kernel" "output/RTOSDemo.out" -monitor none -nographic -chardev pty,id=char0,logfile=serial.log,signal=off -serial chardev:char0`