2 * FreeRTOS Kernel V10.3.0
\r
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
29 * Manages a queue of strings that are waiting to be displayed. This is used to
\r
30 * ensure mutual exclusion of console output.
\r
32 * A task wishing to display a message will call vPrintDisplayMessage (), with a
\r
33 * pointer to the string as the parameter. The pointer is posted onto the
\r
34 * xPrintQueue queue.
\r
36 * The task spawned in main. c blocks on xPrintQueue. When a message becomes
\r
37 * available it calls pcPrintGetNextMessage () to obtain a pointer to the next
\r
38 * string, then uses the functions defined in the portable layer FileIO. c to
\r
39 * display the message.
\r
42 * Using console IO can disrupt real time performance - depending on the port.
\r
43 * Standard C IO routines are not designed for real time applications. While
\r
44 * standard IO is useful for demonstration and debugging an alternative method
\r
45 * should be used if you actually require console IO as part of your application.
\r
47 * \page PrintC print.c
\r
48 * \ingroup DemoFiles
\r
55 + Delay periods are now specified using variables and constants of
\r
56 TickType_t rather than unsigned long.
\r
61 /* Scheduler include files. */
\r
62 #include "FreeRTOS.h"
\r
65 /* Demo program include files. */
\r
68 static QueueHandle_t xPrintQueue;
\r
70 /*-----------------------------------------------------------*/
\r
72 void vPrintInitialise( void )
\r
74 const unsigned portBASE_TYPE uxQueueSize = 20;
\r
76 /* Create the queue on which errors will be reported. */
\r
77 xPrintQueue = xQueueCreate( uxQueueSize, ( unsigned portBASE_TYPE ) sizeof( char * ) );
\r
79 /*-----------------------------------------------------------*/
\r
81 void vPrintDisplayMessage( const char * const * ppcMessageToSend )
\r
84 xQueueSend( xPrintQueue, ( void * ) ppcMessageToSend, ( TickType_t ) 0 );
\r
86 /* Stop warnings. */
\r
87 ( void ) ppcMessageToSend;
\r
90 /*-----------------------------------------------------------*/
\r
92 const char *pcPrintGetNextMessage( TickType_t xPrintRate )
\r
96 if( xQueueReceive( xPrintQueue, &pcMessage, xPrintRate ) == pdPASS )
\r