Difference between revisions of "Embedded System Tutorial FreeRTOS"
From Embedded Systems Learning Academy
(→C++ Task) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | Socialledge is moving to two portals. | ||
+ | * The Wiki will remain here for general references about the SJ-One board, and to document student reports. | ||
+ | * The bookstack will now be used for SJSU assignments | ||
+ | |||
+ | [http://books.socialledge.com/books/embedded-drivers-real-time-operating-systems/page/freertos-tasks This article has been moved here] | ||
+ | |||
+ | <!-- | ||
+ | |||
The objective of this assignment is to show you how to create a FreeRTOS task a few different ways. The [[FreeRTOS Tutorial]] is definitely a must read before going through this lesson. | The objective of this assignment is to show you how to create a FreeRTOS task a few different ways. The [[FreeRTOS Tutorial]] is definitely a must read before going through this lesson. | ||
Line 50: | Line 58: | ||
orient_compute(uint8_t priority) : scheduler_task("compute", 2048, priority) | orient_compute(uint8_t priority) : scheduler_task("compute", 2048, priority) | ||
{ | { | ||
+ | /* We save the queue handle by using addSharedObject() */ | ||
QueueHandle_t my_queue = xQueueCreate(1, sizeof(orientation_t)); | QueueHandle_t my_queue = xQueueCreate(1, sizeof(orientation_t)); | ||
addSharedObject(shared_SensorQueueId, my_queue); | addSharedObject(shared_SensorQueueId, my_queue); | ||
Line 75: | Line 84: | ||
bool run(void *p) | bool run(void *p) | ||
{ | { | ||
+ | /* We first get the queue handle the other task added using addSharedObject() */ | ||
orientation_t orientation = invalid; | orientation_t orientation = invalid; | ||
QueueHandle_t qid = getSharedObject(shared_SensorQueueId); | QueueHandle_t qid = getSharedObject(shared_SensorQueueId); | ||
Line 106: | Line 116: | ||
This assignment is based on SJ-One board, but you can alter the requirement to fit your own hardware. | This assignment is based on SJ-One board, but you can alter the requirement to fit your own hardware. | ||
# Create a task (task1) that computes the orientation of the board. | # Create a task (task1) that computes the orientation of the board. | ||
+ | #: You can use the acceleration sensor to figure out the orientation of the board | ||
#: Send the orientation enumeration, such as "up", "down", "left", "right" to a queue every 1 second | #: Send the orientation enumeration, such as "up", "down", "left", "right" to a queue every 1 second | ||
# Create another task (task2) that waits on the queued item | # Create another task (task2) that waits on the queued item | ||
Line 114: | Line 125: | ||
#: Use the same priority for both tasks, and note down the order of the print-outs | #: Use the same priority for both tasks, and note down the order of the print-outs | ||
#: Use higher priority for the receiving task, and note down the order of the print-outs. | #: Use higher priority for the receiving task, and note down the order of the print-outs. | ||
− | # Create a terminal | + | # Create a terminal command: "orientation on" and "orientation off" |
#: If orientation is commanded on, resume the task1, otherwise suspend it | #: If orientation is commanded on, resume the task1, otherwise suspend it | ||
#: See code below on hints of how this command can get control of another task. | #: See code below on hints of how this command can get control of another task. | ||
Line 145: | Line 156: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | --> |
Latest revision as of 20:11, 25 January 2019
Socialledge is moving to two portals.
- The Wiki will remain here for general references about the SJ-One board, and to document student reports.
- The bookstack will now be used for SJSU assignments
This article has been moved here