add trivial example
This commit is contained in:
parent
3c5043df42
commit
6831916026
@ -118,6 +118,11 @@ ifeq ($(LONGINT_DEMO), 1)
|
||||
SOURCE_FILES += main_micro_longint.c
|
||||
|
||||
CFLAGS := -DmainCREATE_LONGINT_DEMO=1
|
||||
else
|
||||
ifeq ($(MINIMAL_DEMO), 1)
|
||||
SOURCE_FILES += main_minimal.c
|
||||
|
||||
CFLAGS := -DmainCREATE_MINIMAL_DEMO=1
|
||||
else
|
||||
SOURCE_FILES += main_blinky.c
|
||||
|
||||
@ -135,6 +140,7 @@ endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(INTERRUPT_ACTIVATION), 1)
|
||||
CFLAGS += -D INTERRUPT_ACTIVATION=1
|
||||
|
@ -103,6 +103,10 @@ int main()
|
||||
{
|
||||
main_micro_longint();
|
||||
}
|
||||
#elif ( mainCREATE_MINIMAL_DEMO == 1 )
|
||||
{
|
||||
main_minimal();
|
||||
}
|
||||
#else
|
||||
|
||||
{
|
||||
|
149
FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_minimal.c
Normal file
149
FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_minimal.c
Normal file
@ -0,0 +1,149 @@
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <queue.h>
|
||||
#include <stdio.h>
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "arbitrary_loads.c"
|
||||
|
||||
__attribute__((noinline)) static void trigger_Qemu_break( void )
|
||||
{
|
||||
puts("Trigger");
|
||||
}
|
||||
|
||||
// Begin Input Stuff
|
||||
volatile unsigned char FUZZ_INPUT[4096] = {0xa,0xb,0xc,0xd,0xe,0xf};
|
||||
volatile uint32_t FUZZ_LENGTH = 32;
|
||||
volatile uint32_t FUZZ_POINTER = 0;
|
||||
// Read the Byte of Input, if the Input is exausted trigger the breakpoint instead
|
||||
static unsigned char fuzz_input_next(void) {
|
||||
// printf("Get next Input from %lx \n",FUZZ_INPUT);
|
||||
if (FUZZ_POINTER < FUZZ_LENGTH) {
|
||||
FUZZ_POINTER++;
|
||||
// printf("Input no. %d %x\n",FUZZ_POINTER-1,FUZZ_INPUT[FUZZ_POINTER-1]);
|
||||
return FUZZ_INPUT[FUZZ_POINTER-1];
|
||||
} else {
|
||||
// puts("End of Input");
|
||||
// Exausted inputs early
|
||||
trigger_Qemu_break();
|
||||
}
|
||||
}
|
||||
// End Input Stuff
|
||||
static void prvSamplerTask( void * pvParameters );
|
||||
static void prvThreadLow( void * pvParameters );
|
||||
static void prvThreadMid( void * pvParameters );
|
||||
static void prvThreadHigh( void * pvParameters );
|
||||
|
||||
#define mainLOW_PRIO ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainMID_PRIO ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainHIGH_PRIO ( tskIDLE_PRIORITY + 3 )
|
||||
|
||||
#define mainQUEUE_LENGTH ( 1 )
|
||||
#define mainQUEUE_SEND_FREQUENCY_MS ( 10 / portTICK_PERIOD_MS )
|
||||
#define voterMAXRETRIES 3
|
||||
#define WORK_SET_SIZE_POWER 1
|
||||
#define WORK_SET_SIZE 2
|
||||
|
||||
// Handles for direct messages
|
||||
static TaskHandle_t xLow = NULL;
|
||||
static TaskHandle_t xMid = NULL;
|
||||
static TaskHandle_t xHigh = NULL;
|
||||
|
||||
|
||||
#define DEBUG_PRINT(X) {puts(X);}
|
||||
// #define DEBUG_PRINT(X)
|
||||
|
||||
|
||||
void main_minimal( void )
|
||||
{
|
||||
xTaskCreate( prvThreadLow, /* The function that implements the task. */
|
||||
"Low", /* 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. */
|
||||
mainLOW_PRIO, /* The priority assigned to the task. */
|
||||
&xLow ); /* The task handle is not required, so NULL is passed. */
|
||||
|
||||
xTaskCreate( prvThreadMid, /* The function that implements the task. */
|
||||
"Mid", /* 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. */
|
||||
mainMID_PRIO, /* The priority assigned to the task. */
|
||||
&xMid ); /* The task handle is not required, so NULL is passed. */
|
||||
|
||||
xTaskCreate( prvThreadHigh, /* The function that implements the task. */
|
||||
"High", /* 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. */
|
||||
mainHIGH_PRIO, /* The priority assigned to the task. */
|
||||
&xHigh ); /* The task handle is not required, so NULL is passed. */
|
||||
|
||||
/* Start the tasks and timer running. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
}
|
||||
}
|
||||
volatile unsigned char WORK_SET[WORK_SET_SIZE] = {0};
|
||||
static int count_up(unsigned short cinput)
|
||||
{
|
||||
int t = 0;
|
||||
for (int i=1; i<cinput; i++)
|
||||
{
|
||||
t+=i;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
static unsigned short get_average( void )
|
||||
{
|
||||
// puts("Get Average");
|
||||
int tmp = 0;
|
||||
for (int i=0; i<WORK_SET_SIZE; i++)
|
||||
{tmp+=WORK_SET[i];}
|
||||
return (unsigned short)(tmp>>WORK_SET_SIZE_POWER);
|
||||
}
|
||||
|
||||
static void prvThreadLow( void * pvParameters )
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
WASTE_TIME(1000*1000000); // work for 1000 ms
|
||||
trigger_Qemu_break();
|
||||
}
|
||||
}
|
||||
static void prvThreadMid( void * pvParameters )
|
||||
{
|
||||
TickType_t xLastWakeTime = xTaskGetTickCount();
|
||||
const TickType_t xFrequency = 300 / portTICK_PERIOD_MS;
|
||||
while (1)
|
||||
{
|
||||
unsigned short value = FUZZ_INPUT[FUZZ_POINTER++];
|
||||
WASTE_TIME(1*1000000); // work for 1 ms
|
||||
// if (value=='A') {
|
||||
if ((value+100) % 11 == 3) {
|
||||
DEBUG_PRINT("L-Path");
|
||||
WASTE_TIME(10*1000000); // work for 10 ms
|
||||
xTaskNotify(xHigh, 1, eSetValueWithOverwrite);
|
||||
} else {
|
||||
DEBUG_PRINT("S-Path");
|
||||
WASTE_TIME(100*1000000); // work for 100 ms
|
||||
}
|
||||
WASTE_TIME(2*1000000); // work for 2 ms
|
||||
vTaskDelayUntil( &xLastWakeTime, xFrequency );// Wait for the next cycle.
|
||||
}
|
||||
}
|
||||
static void prvThreadHigh( void * pvParameters )
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
ulTaskNotifyTake(pdTRUE,portMAX_DELAY);
|
||||
WASTE_TIME(200*1000000); // work for 200 ms
|
||||
}
|
||||
}
|
||||
|
||||
void isr_starter( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
Loading…
x
Reference in New Issue
Block a user