]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/PollQ.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / RL78_E2Studio_GCC / src / Common-Demo-Tasks / PollQ.c
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/PollQ.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/PollQ.c
deleted file mode 100644 (file)
index 804ec06..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*\r
- * FreeRTOS Kernel V10.1.0\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
- * this software and associated documentation files (the "Software"), to deal in\r
- * the Software without restriction, including without limitation the rights to\r
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
- * the Software, and to permit persons to whom the Software is furnished to do so,\r
- * subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * http://www.FreeRTOS.org\r
- * http://aws.amazon.com/freertos\r
- *\r
- * 1 tab == 4 spaces!\r
- */\r
-\r
-/*\r
- * This version of PollQ. c is for use on systems that have limited stack\r
- * space and no display facilities.  The complete version can be found in\r
- * the Demo/Common/Full directory.\r
- *\r
- * Creates two tasks that communicate over a single queue.  One task acts as a\r
- * producer, the other a consumer.\r
- *\r
- * The producer loops for three iteration, posting an incrementing number onto the\r
- * queue each cycle.  It then delays for a fixed period before doing exactly the\r
- * same again.\r
- *\r
- * The consumer loops emptying the queue.  Each item removed from the queue is\r
- * checked to ensure it contains the expected value.  When the queue is empty it\r
- * blocks for a fixed period, then does the same again.\r
- *\r
- * All queue access is performed without blocking.  The consumer completely empties\r
- * the queue each time it runs so the producer should never find the queue full.\r
- *\r
- * An error is flagged if the consumer obtains an unexpected value or the producer\r
- * find the queue is full.\r
- */\r
-\r
-/*\r
-Changes from V2.0.0\r
-\r
-       + Delay periods are now specified using variables and constants of\r
-         TickType_t rather than unsigned long.\r
-*/\r
-\r
-#include <stdlib.h>\r
-\r
-/* Scheduler include files. */\r
-#include "FreeRTOS.h"\r
-#include "task.h"\r
-#include "queue.h"\r
-\r
-/* Demo program include files. */\r
-#include "PollQ.h"\r
-\r
-#define pollqSTACK_SIZE                        configMINIMAL_STACK_SIZE\r
-#define pollqQUEUE_SIZE                        ( 10 )\r
-#define pollqPRODUCER_DELAY            ( ( TickType_t ) 200 / portTICK_PERIOD_MS )\r
-#define pollqCONSUMER_DELAY            ( pollqPRODUCER_DELAY - ( TickType_t ) ( 20 / portTICK_PERIOD_MS ) )\r
-#define pollqNO_DELAY                  ( ( TickType_t ) 0 )\r
-#define pollqVALUES_TO_PRODUCE ( ( signed portBASE_TYPE ) 3 )\r
-#define pollqINITIAL_VALUE             ( ( signed portBASE_TYPE ) 0 )\r
-\r
-/* The task that posts the incrementing number onto the queue. */\r
-static portTASK_FUNCTION_PROTO( vPolledQueueProducer, pvParameters );\r
-\r
-/* The task that empties the queue. */\r
-static portTASK_FUNCTION_PROTO( vPolledQueueConsumer, pvParameters );\r
-\r
-/* Variables that are used to check that the tasks are still running with no\r
-errors. */\r
-static volatile signed portBASE_TYPE xPollingConsumerCount = pollqINITIAL_VALUE, xPollingProducerCount = pollqINITIAL_VALUE;\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void vStartPolledQueueTasks( unsigned portBASE_TYPE uxPriority )\r
-{\r
-static QueueHandle_t xPolledQueue;\r
-\r
-       /* Create the queue used by the producer and consumer. */\r
-       xPolledQueue = xQueueCreate( pollqQUEUE_SIZE, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );\r
-\r
-       /* vQueueAddToRegistry() adds the queue to the queue registry, if one is\r
-       in use.  The queue registry is provided as a means for kernel aware\r
-       debuggers to locate queues and has no purpose if a kernel aware debugger\r
-       is not being used.  The call to vQueueAddToRegistry() will be removed\r
-       by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is\r
-       defined to be less than 1. */\r
-       vQueueAddToRegistry( xPolledQueue, ( signed char * ) "Poll_Test_Queue" );\r
-\r
-       /* Spawn the producer and consumer. */\r
-       xTaskCreate( vPolledQueueConsumer, "QConsNB", pollqSTACK_SIZE, ( void * ) &xPolledQueue, uxPriority, ( TaskHandle_t * ) NULL );\r
-       xTaskCreate( vPolledQueueProducer, "QProdNB", pollqSTACK_SIZE, ( void * ) &xPolledQueue, uxPriority, ( TaskHandle_t * ) NULL );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static portTASK_FUNCTION( vPolledQueueProducer, pvParameters )\r
-{\r
-unsigned short usValue = ( unsigned short ) 0;\r
-signed portBASE_TYPE xError = pdFALSE, xLoop;\r
-\r
-       for( ;; )\r
-       {\r
-               for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ )\r
-               {\r
-                       /* Send an incrementing number on the queue without blocking. */\r
-                       if( xQueueSend( *( ( QueueHandle_t * ) pvParameters ), ( void * ) &usValue, pollqNO_DELAY ) != pdPASS )\r
-                       {\r
-                               /* We should never find the queue full so if we get here there\r
-                               has been an error. */\r
-                               xError = pdTRUE;\r
-                       }\r
-                       else\r
-                       {\r
-                               if( xError == pdFALSE )\r
-                               {\r
-                                       /* If an error has ever been recorded we stop incrementing the\r
-                                       check variable. */\r
-                                       portENTER_CRITICAL();\r
-                                               xPollingProducerCount++;\r
-                                       portEXIT_CRITICAL();\r
-                               }\r
-\r
-                               /* Update the value we are going to post next time around. */\r
-                               usValue++;\r
-                       }\r
-               }\r
-\r
-               /* Wait before we start posting again to ensure the consumer runs and\r
-               empties the queue. */\r
-               vTaskDelay( pollqPRODUCER_DELAY );\r
-       }\r
-}  /*lint !e818 Function prototype must conform to API. */\r
-/*-----------------------------------------------------------*/\r
-\r
-static portTASK_FUNCTION( vPolledQueueConsumer, pvParameters )\r
-{\r
-unsigned short usData, usExpectedValue = ( unsigned short ) 0;\r
-signed portBASE_TYPE xError = pdFALSE;\r
-\r
-       for( ;; )\r
-       {\r
-               /* Loop until the queue is empty. */\r
-               while( uxQueueMessagesWaiting( *( ( QueueHandle_t * ) pvParameters ) ) )\r
-               {\r
-                       if( xQueueReceive( *( ( QueueHandle_t * ) pvParameters ), &usData, pollqNO_DELAY ) == pdPASS )\r
-                       {\r
-                               if( usData != usExpectedValue )\r
-                               {\r
-                                       /* This is not what we expected to receive so an error has\r
-                                       occurred. */\r
-                                       xError = pdTRUE;\r
-\r
-                                       /* Catch-up to the value we received so our next expected\r
-                                       value should again be correct. */\r
-                                       usExpectedValue = usData;\r
-                               }\r
-                               else\r
-                               {\r
-                                       if( xError == pdFALSE )\r
-                                       {\r
-                                               /* Only increment the check variable if no errors have\r
-                                               occurred. */\r
-                                               portENTER_CRITICAL();\r
-                                                       xPollingConsumerCount++;\r
-                                               portEXIT_CRITICAL();\r
-                                       }\r
-                               }\r
-\r
-                               /* Next time round we would expect the number to be one higher. */\r
-                               usExpectedValue++;\r
-                       }\r
-               }\r
-\r
-               /* Now the queue is empty we block, allowing the producer to place more\r
-               items in the queue. */\r
-               vTaskDelay( pollqCONSUMER_DELAY );\r
-       }\r
-} /*lint !e818 Function prototype must conform to API. */\r
-/*-----------------------------------------------------------*/\r
-\r
-/* This is called to check that all the created tasks are still running with no errors. */\r
-portBASE_TYPE xArePollingQueuesStillRunning( void )\r
-{\r
-portBASE_TYPE xReturn;\r
-\r
-       /* Check both the consumer and producer poll count to check they have both\r
-       been changed since out last trip round.  We do not need a critical section\r
-       around the check variables as this is called from a higher priority than\r
-       the other tasks that access the same variables. */\r
-       if( ( xPollingConsumerCount == pollqINITIAL_VALUE ) ||\r
-               ( xPollingProducerCount == pollqINITIAL_VALUE )\r
-         )\r
-       {\r
-               xReturn = pdFALSE;\r
-       }\r
-       else\r
-       {\r
-               xReturn = pdTRUE;\r
-       }\r
-\r
-       /* Set the check variables back down so we know if they have been\r
-       incremented the next time around. */\r
-       xPollingConsumerCount = pollqINITIAL_VALUE;\r
-       xPollingProducerCount = pollqINITIAL_VALUE;\r
-\r
-       return xReturn;\r
-}\r