add a complex demo

This commit is contained in:
Alwin Berger 2022-01-16 00:22:29 +01:00
parent cc5ba84bd8
commit 233bc518b0
4 changed files with 147 additions and 1 deletions

View File

@ -56,7 +56,7 @@ extern void vAssertCalled( void );
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 2000 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 900 ) )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_CO_ROUTINES 0

View File

@ -58,11 +58,17 @@ ifeq ($(FULL_DEMO), 1)
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/Include/
CFLAGS := -DmainCREATE_FULL_DEMO_ONLY=1
else
ifeq ($(INCREASING_DEMO), 1)
SOURCE_FILES += main_increasing.c
CFLAGS := -DmainCREATE_INCREASING_DEMO=1
else
SOURCE_FILES += main_blinky.c
CFLAGS := -DmainCREATE_SIMPLE_BLINKY_DEMO_ONLY=1
endif
endif
DEFINES := -DQEMU_SOC_MPS2 -DHEAP3

View File

@ -63,6 +63,10 @@ int main()
{
main_full();
}
#elif ( mainCREATE_INCREASING_DEMO == 1 )
{
main_increasing();
}
#else
{
#error "Invalid Selection...\nPlease Select a Demo application from the main command"

View File

@ -0,0 +1,136 @@
/*
* FreeRTOS V202111.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>
#include <stdio.h>
__attribute__((noinline)) static void trigger_Qemu_break( void )
{
puts("Trigger");
}
static void prvQueueReceiveTask( void * pvParameters );
static void prvQueueSendTask( void * pvParameters );
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainQUEUE_LENGTH ( 1 )
#define mainQUEUE_SEND_FREQUENCY_MS ( 10 / portTICK_PERIOD_MS )
/* The queue used by both tasks. */
static QueueHandle_t xQueue = NULL;
void main_increasing( void )
{
/* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned char ) );
if( xQueue != NULL )
{
/* Start the two tasks as described in the comments at the top of this
* file. */
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */
"Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */
NULL ); /* The task handle is not required, so NULL is passed. */
xTaskCreate( prvQueueSendTask,
"TX",
configMINIMAL_STACK_SIZE,
NULL,
mainQUEUE_SEND_TASK_PRIORITY,
NULL );
/* Start the tasks and timer running. */
vTaskStartScheduler();
}
/* If all is well, the scheduler will now be running, and the following
* line will never be reached. If the following line does execute, then
* there was insufficient FreeRTOS heap memory available for the Idle and/or
* timer tasks to be created. See the memory management section on the
* FreeRTOS web site for more details on the FreeRTOS heap
* http://www.freertos.org/a00111.html. */
for( ; ; )
{
}
}
volatile unsigned char FUZZ_INPUT[4096] = {33};
volatile uint32_t FUZZ_LENGTH = 32;
volatile unsigned char last_value = 32; // ascii space
static void prvQueueSendTask( void * pvParameters )
{
unsigned char ulValueToSend = 0;
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
for(int i=0; i<FUZZ_LENGTH; i++)
{
ulValueToSend = FUZZ_INPUT[i];
// printf("send: %u\n",ulValueToSend);
xQueueSend( xQueue, &ulValueToSend, portMAX_DELAY );
}
// since priority of this task is lower we only reach this after the Recieve Task is done.
trigger_Qemu_break();
}
volatile uint32_t ulRxEvents = 0;
static void prvQueueReceiveTask( void * pvParameters )
{
unsigned char ulReceivedValue = 0;
uint32_t agg = 0;
/* Remove compiler warning about unused parameter. */
( void ) pvParameters;
for( ; ; )
{
/* Wait until something arrives in the queue - this task will block
* indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
* FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
if (ulReceivedValue > last_value && ulReceivedValue < 127)
{
last_value = ulReceivedValue;
//Some computation which depends on the value recieved
int t = 0;
for (int i=1; i<ulReceivedValue; i++)
{
t+=i;
}
agg+=t;
// printf("recieved: %u, result: %u\n",ulReceivedValue,t);
}
}
}
/*-----------------------------------------------------------*/