Skip to content

Commit 0c988ec

Browse files
Remove sub sectioning in examples and add examples list in TOC (#73)
* Remove subsection numbering from examples * Add examples list to Table of Contents * Update format of examples' heading
1 parent 2e6e605 commit 0c988ec

File tree

8 files changed

+188
-135
lines changed

8 files changed

+188
-135
lines changed

ch04.md

Lines changed: 60 additions & 42 deletions
Large diffs are not rendered by default.

ch05.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ waiting the longest.
146146

147147
Queues can be grouped into sets, allowing a task to enter the Blocked
148148
state to wait for data to become available on any of the queues in the
149-
set. Section 4.6, Receiving From Multiple Queues, demonstrates queue
149+
set. Section 5.6, Receiving From Multiple Queues, demonstrates queue
150150
sets.
151151

152152

@@ -415,7 +415,9 @@ UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue );
415415
then the queue is empty.
416416
417417
418-
### 5.3.5 Example 5.1. Blocking when receiving from a queue
418+
<a name="example5.1" title="Blocking when receiving from a queue"></a>
419+
420+
<h3><i>Example 5.1 Blocking when receiving from a queue</i></h3>
419421
420422
This example demonstrates creating a queue, sending data to the queue
421423
from multiple tasks, and receiving data from the queue. The queue is
@@ -673,7 +675,9 @@ Chapter (RB-TBD) shows how to extend this design pattern such that
673675
the controller task can reply directly to the task that queued a structure.
674676

675677

676-
### 5.4.1 Example 5.2: Blocking when sending to a queue, and sending structures on a queue
678+
<a name="example5.2" title="Blocking when sending to a queue, and sending structures on a queue"></a>
679+
680+
<h3><i>Example 5.2 Blocking when sending to a queue, and sending structures on a queue</i></h3>
677681

678682
Example 5.2 is similar to Example 5.1, but with reversed task priorities,
679683
so the receiving task has a lower priority than the sending tasks. Also,
@@ -1529,7 +1533,9 @@ QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
15291533
in the set, but the block time expired before that happened.
15301534
15311535
1532-
### 5.6.5 Example 5.3. Using a Queue Set
1536+
<a name="example5.3" title="Using a Queue Set"></a>
1537+
1538+
<h3><i>Example 5.3 Using a Queue Set</i></h3>
15331539
15341540
This example creates two sending tasks and one receiving task. The
15351541
sending tasks send data to the receiving task on two separate queues,
@@ -1726,7 +1732,7 @@ twice as often as those sent by `vSenderTask2()`.
17261732
* * *
17271733

17281734

1729-
### 5.6.6 More Realistic Queue Set Use Cases
1735+
### 5.6.5 More Realistic Queue Set Use Cases
17301736

17311737
Example 5.3 demonstrated a very simplistic case; the queue set only
17321738
contained queues, and the two queues it contained were both used to send

ch06.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ timers are created in the Dormant state.
426426
Software timers can be created before the scheduler is running, or from
427427
a task after the scheduler has been started.
428428

429-
Section 0 describes the data types and naming conventions used.
429+
[Section 2.5: Data Types and Coding Style Guide](ch02.md#25-data-types-and-coding-style-guide) describes the data types and naming conventions used.
430430

431431

432432
<a name="list6.3" title="Listing 6.3 The xTimerCreate() API function prototype"></a>
@@ -587,7 +587,9 @@ BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );
587587
specified block time expired before that happened.
588588

589589

590-
### 6.5.3 Example 6.1. Creating one-shot and auto-reload timers
590+
<a name="example6.1" title="Creating one-shot and auto-reload timers"></a>
591+
592+
<h3><i>Example 6.1 Creating one-shot and auto-reload timers</i></h3>
591593

592594
This example creates and starts a one-shot timer and an auto-reload
593595
timer—as shown in Listing 6.5.
@@ -798,7 +800,9 @@ void *pvTimerGetTimerID( const TimerHandle_t xTimer );
798800
The ID of the software timer being queried.
799801
800802
801-
### 6.6.3 Example 6.2. Using the callback function parameter and the software timer ID
803+
<a name="example6.2" title="Using the callback function parameter and the software timer ID"></a>
804+
805+
<h3><i>Example 6.2 Using the callback function parameter and the software timer ID</i></h3>
802806
803807
The same callback function can be assigned to more than one software
804808
timer. When that is done, the callback function parameter is used to
@@ -1196,7 +1200,9 @@ BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
11961200
expired before that happened.
11971201

11981202

1199-
### 6.8.2 Example 6.3. Resetting a software timer
1203+
<a name="example6.3" title="Resetting a software timer"></a>
1204+
1205+
<h3><i>Example 6.3 Resetting a software timer</i></h3>
12001206

12011207
This example simulates the behavior of the backlight on a cell phone. The backlight:
12021208

ch07.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,9 @@ BaseType_t xSemaphoreGiveFromISR( SemaphoreHandle_t xSemaphore,
628628
`xSemaphoreGiveFromISR()` will return `pdFAIL`.
629629
630630
631-
### 7.4.4 Example 7.1. Using a binary semaphore to synchronize a task with an interrupt
631+
<a name="example7.1" title="Using a binary semaphore to synchronize a task with an interrupt"></a>
632+
633+
<h3><i>Example 7.1 Using a binary semaphore to synchronize a task with an interrupt</i></h3>
632634
633635
This example uses a binary semaphore to unblock a task from an interrupt
634636
service routine, effectively synchronizing the task with the interrupt.
@@ -850,7 +852,7 @@ periodic task. Further explanation is provided in Figure 7.5.
850852
* * *
851853
852854
853-
### 7.4.5 Improving the Implementation of the Task Used in Example 7.1
855+
### 7.4.4 Improving the Implementation of the Task Used in Example 7.1
854856
855857
Example 7.1 used a binary semaphore to synchronize a task with an
856858
interrupt. The execution sequence was as follows:
@@ -1103,7 +1105,9 @@ SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount,
11031105
to the created semaphore.
11041106
11051107
1106-
### 7.5.2 Example 7.2. Using a counting semaphore to synchronize a task with an interrupt
1108+
<a name="example7.2" title="Using a counting semaphore to synchronize a task with an interrupt"></a>
1109+
1110+
<h3><i>Example 7.2 Using a counting semaphore to synchronize a task with an interrupt</i></h3>
11071111
11081112
Example 7.2 improves on the Example 7.1 implementation by using a counting
11091113
semaphore in place of the binary semaphore. `main()` is changed to include
@@ -1334,7 +1338,9 @@ void vPendableFunction( void *pvParameter1, uint32_t ulParameter2 );
13341338
command queue.
13351339
13361340
1337-
### 7.6.2 Example 7.3. Centralized deferred interrupt processing
1341+
<a name="example7.3" title="Centralized deferred interrupt processing"></a>
1342+
1343+
<h3><i>Example 7.3 Centralized deferred interrupt processing</i></h3>
13381344
13391345
Example 7.3 provides similar functionality to Example 7.1, but without
13401346
using a semaphore, and without creating a task specifically to perform
@@ -1613,8 +1619,9 @@ that are suitable for production code, include:
16131619
than the raw data) to a task. This was previously demonstrated by
16141620
Figure 5.4.
16151621

1622+
<a name="example7.4" title="Sending and receiving on a queue from within an interrupt"></a>
16161623

1617-
### 7.7.3 Example 7.4. Sending and receiving on a queue from within an interrupt
1624+
<h3><i>Example 7.4 Sending and receiving on a queue from within an interrupt</i></h3>
16181625

16191626
This example demonstrates `xQueueSendToBackFromISR()` and
16201627
`xQueueReceiveFromISR()` being used within the same interrupt. As before,

ch08.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,9 @@ SemaphoreHandle_t xSemaphoreCreateMutex( void );
531531
created mutex.
532532

533533

534-
### 8.3.2 Example 8.1. Rewriting vPrintString() to use a semaphore
534+
<a name="example8.1" title="Rewriting vPrintString() to use a semaphore"></a>
535+
536+
<h3><i>Example 8.1 Rewriting vPrintString() to use a semaphore</i></h3>
535537

536538
This example creates a new version of `vPrintString()` called
537539
`prvNewPrintString()`, then calls the new function from multiple tasks.
@@ -701,7 +703,7 @@ the random delay periods used by the tasks.
701703
* * *
702704
703705
704-
### 8.3.3 Priority Inversion
706+
### 8.3.2 Priority Inversion
705707
706708
Figure 8.3 demonstrates one of the potential pitfalls of using a mutex to
707709
provide mutual exclusion. The sequence of execution depicted shows the
@@ -727,7 +729,7 @@ systems it can often be avoided at system design time by considering
727729
how resources are accessed.
728730
729731
730-
### 8.3.4 Priority Inheritance
732+
### 8.3.3 Priority Inheritance
731733
732734
FreeRTOS mutexes and binary semaphores are very similar—the difference
733735
being that mutexes include a basic 'priority inheritance' mechanism,
@@ -758,7 +760,7 @@ tasks that are using the mutex. For that reason, mutexes must not be
758760
used from interrupt service routines.
759761
760762
761-
### 8.3.5 Deadlock (or Deadly Embrace)
763+
### 8.3.4 Deadlock (or Deadly Embrace)
762764
763765
'Deadlock' is another potential pitfall of using mutexes for mutual
764766
exclusion. Deadlock is sometimes also known by the more dramatic name
@@ -801,7 +803,7 @@ application, and so can identify and remove the areas where it could
801803
occur.
802804
803805
804-
### 8.3.6 Recursive Mutexes
806+
### 8.3.5 Recursive Mutexes
805807
806808
It is also possible for a task to deadlock with itself. This will happen
807809
if a task attempts to take the same mutex more than once, without first
@@ -912,7 +914,7 @@ void vTaskFunction( void *pvParameters )
912914
* * *
913915

914916

915-
### 8.3.7 Mutexes and Task Scheduling
917+
### 8.3.6 Mutexes and Task Scheduling
916918

917919
If two tasks of different priority use the same mutex, then the FreeRTOS
918920
scheduling policy makes the order in which the tasks will execute clear;

ch09.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,9 @@ StaticEventGroup_t ** ppxEventGroupBuffer );
530530
531531
- `pdFALSE` will be returned if the buffer was not successfully retrieved.
532532
533+
<a name="example9.1" title="Experimenting with event groups"></a>
533534
534-
### 9.3.6 Example 9.1. Experimenting with event groups
535+
<h3><i>Example 9.1 Experimenting with event groups</i></h3>
535536
536537
This example demonstrates how to:
537538
@@ -1055,7 +1056,9 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
10551056
condition.
10561057

10571058

1058-
### 9.4.2 Example 9.2. Synchronizing tasks
1059+
<a name="example9.2" title="Synchronizing tasks"></a>
1060+
1061+
<h3><i>Example 9.2 Synchronizing tasks</i></h3>
10591062

10601063
Example 9.2 uses `xEventGroupSync()` to synchronize three instances of a
10611064
single task implementation. The task parameter is used to pass into each

ch10.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ xTicksToWait );
366366
state to wait for its notification value to be greater than zero, but
367367
the specified block time expired before that happened.
368368
369-
### 10.3.5 Example 10.1. Using a task notification in place of a semaphore, method 1
369+
370+
<a name="example10.1" title="Using a task notification in place of a semaphore, method 1"></a>
371+
372+
<h3><i>Example 10.1 Using a task notification in place of a semaphore, method 1</i></h3>
370373
371374
Example 7.1 used a binary semaphore to unblock a task from within an
372375
interrupt service routine—effectively synchronizing the task with the
@@ -505,7 +508,9 @@ produced by the periodic task. Further explanation is provided in Figure 10.4.
505508
*Figure 10.4 The sequence of execution when Example 10.1 is executed*
506509
* * *
507510
508-
### 10.3.6 Example 10.2. Using a task notification in place of a semaphore, method 2
511+
<a name="example10.2" title="Using a task notification in place of a semaphore, method 2"></a>
512+
513+
<h3><i>Example 10.2 Using a task notification in place of a semaphore, method 2</i></h3>
509514
510515
In Example 10.1, the `ulTaskNotifyTake()` `xClearOnExit` parameter was set to
511516
`pdTRUE`. Example 10.1 modifies Example 10.1 slightly to demonstrate the
@@ -614,7 +619,7 @@ interrupt is generated.
614619
*Figure 10.5 The output produced when Example 10.2 is executed*
615620
* * *
616621
617-
### 10.3.7 The xTaskNotify() and xTaskNotifyFromISR() API Functions
622+
### 10.3.5 The xTaskNotify() and xTaskNotifyFromISR() API Functions
618623
619624
`xTaskNotify()` is a more capable version of `xTaskNotifyGive()` that can be
620625
used to update the receiving task's notification value in any of the
@@ -740,7 +745,7 @@ Effect on the Receiving Task's Notification Value**
740745
receiving task had a notification pending before `xTaskNotify()` was
741746
called or not.
742747

743-
### 10.3.8 The xTaskNotifyWait() API Function
748+
### 10.3.6 The xTaskNotifyWait() API Function
744749

745750
`xTaskNotifyWait()` is a more capable version of `ulTaskNotifyTake()`. It
746751
allows a task to wait, with an optional timeout, for the calling task's
@@ -844,7 +849,7 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry,
844849
held in the Blocked state to wait for its notification state to become
845850
pending, but the specified block time expired before that happened.
846851
847-
### 10.3.9 Task Notifications Used in Peripheral Device Drivers: UART Example
852+
### 10.3.7 Task Notifications Used in Peripheral Device Drivers: UART Example
848853
849854
Peripheral driver libraries provide functions that perform common
850855
operations on hardware interfaces. Examples of peripherals for which
@@ -1213,7 +1218,7 @@ void xUART_ReceiveISR( xUART *pxUARTInstance )
12131218
*Listing 10.12 Pseudo code demonstrating how a task notification can be used in a driver library receive function*
12141219
* * *
12151220

1216-
### 10.3.10 Task Notifications Used in Peripheral Device Drivers: ADC Example
1221+
### 10.3.8 Task Notifications Used in Peripheral Device Drivers: ADC Example
12171222

12181223
The previous section demonstrated how to use `vTaskNotifyGiveFromISR()` to
12191224
send a task notification from an interrupt to a task.
@@ -1324,7 +1329,7 @@ void ADC_ConversionEndISR( xADC *pxADCInstance )
13241329
*Listing 10.13 Pseudo code demonstrating how a task notification can be used to pass a value to a task*
13251330
* * *
13261331
1327-
### 10.3.11 Task Notifications Used Directly Within an Application
1332+
### 10.3.9 Task Notifications Used Directly Within an Application
13281333
13291334
This section reinforces the power of task notifications by demonstrating
13301335
their use in a hypothetical application that includes the following

0 commit comments

Comments
 (0)