2 FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
7 This file is part of the FreeRTOS distribution.
9 FreeRTOS is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License (version 2) as published by the
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
13 ***************************************************************************
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
15 >>! distribute a combined work that includes FreeRTOS without being !<<
16 >>! obliged to provide the source code for proprietary components !<<
17 >>! outside of the FreeRTOS kernel. !<<
18 ***************************************************************************
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
23 link: http://www.freertos.org/a00114.html
25 ***************************************************************************
27 * FreeRTOS provides completely free yet professionally developed, *
28 * robust, strictly quality controlled, supported, and cross *
29 * platform software that is more than just the market leader, it *
30 * is the industry's de facto standard. *
32 * Help yourself get started quickly while simultaneously helping *
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
34 * tutorial book, reference manual, or both: *
35 * http://www.FreeRTOS.org/Documentation *
37 ***************************************************************************
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
40 the FAQ page "My application does not run, what could be wrong?". Have you
41 defined configASSERT()?
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
44 embedded software for free we request you assist our global community by
45 participating in the support forum.
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
48 be as productive as possible as early as possible. Now you can receive
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50 Ltd, and the world's leading authority on the world's leading RTOS.
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
61 licenses offer ticketed support, indemnification and commercial middleware.
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64 engineered and independently SIL3 certified version for use in safety and
65 mission critical applications that require provable dependability.
71 * This is a very simply blinky style example that can be generated
72 * automatically by the Xilinx SDK.
74 * The example generates a Tx task, an Rx task, and a queue. The Tx task
75 * simply uses the queue to send a value to the Rx task every 500ms. The Rx
76 * prints out a message each time it receives the value.
78 * The demo does little in the way of hardware configuration. Separate projects
79 * are provided that include comprehensive demos which demonstrate additional
80 * hardware configuration, and additional FreeRTOS features. See the following
81 * link for more details: http://www.freertos.org/a00090.html#XILINX
84 /* FreeRTOS includes. */
89 /* Xilinx includes. */
90 #include "xil_printf.h"
91 #include "xparameters.h"
93 /*-----------------------------------------------------------*/
95 /* The Tx and Rx tasks as described at the top of this file. */
96 static void prvTxTask( void *pvParameters );
97 static void prvRxTask( void *pvParameters );
99 /*-----------------------------------------------------------*/
101 /* The queue used by the Tx and Rx tasks, as described at the top of this
103 static QueueHandle_t xQueue = NULL;
107 xil_printf( "Hello from Freertos\r\n" );
109 /* Create the two tasks. The Tx task is given a lower priority than the
110 Rx task, so the Rx task will leave the Blocked state and pre-empt the Tx
111 task as soon as the Tx task places an item in the queue. */
112 xTaskCreate( prvTxTask, /* The function that implements the task. */
113 ( const char * ) "Tx", /* Text name for the task, provided to assist debugging only. */
114 configMINIMAL_STACK_SIZE, /* The stack allocated to the task. */
115 NULL, /* The task parameter is not used, so set to NULL. */
116 tskIDLE_PRIORITY, /* The task runs at the idle priority. */
119 xTaskCreate( prvRxTask, ( const char * ) "GB", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
121 /* Create the queue used by the tasks. The Rx task has a higher priority
122 than the Tx task, so will preempt the Tx task and remove values from the
123 queue as soon as the Tx task writes to the queue - therefore the queue can
124 never have more than one item in it. */
125 xQueue = xQueueCreate( 1, /* There is only one space in the queue. */
126 sizeof( uint32_t ) ); /* Each space in the queue is large enough to hold a uint32_t. */
128 /* Check the queue was created. */
129 configASSERT( xQueue );
131 /* Start the tasks and timer running. */
132 vTaskStartScheduler();
134 /* If all is well, the scheduler will now be running, and the following line
135 will never be reached. If the following line does execute, then there was
136 insufficient FreeRTOS heap memory available for the idle and/or timer tasks
137 to be created. See the memory management section on the FreeRTOS web site
143 /*-----------------------------------------------------------*/
144 static void prvTxTask( void *pvParameters )
146 const TickType_t x500ms = pdMS_TO_TICKS( 500UL );
147 uint32_t ulValueToSend = 0;
151 /* Delay for 500ms. */
152 vTaskDelay( x500ms );
154 /* Send the next value on the queue. The queue should always be
155 empty at this point so a block time of 0 is used. */
156 xQueueSend( xQueue, /* The queue being written to. */
157 &ulValueToSend, /* The address of the data being sent. */
158 0UL ); /* The block time. */
162 /*-----------------------------------------------------------*/
163 static void prvRxTask( void *pvParameters )
165 uint32_t ulValueReceived;
169 /* Block to wait for data arriving on the queue. */
170 xQueueReceive( xQueue, /* The queue being read. */
171 &ulValueReceived, /* Data is read into this address. */
172 portMAX_DELAY ); /* Wait without a timeout for data. */
174 /* Print the received data. */
175 xil_printf( "Rx task received %u\r\n", ( unsigned int ) ulValueReceived );