Microchip® Advanced Software Framework

sam/applications/sam4e_ek_demo/main.c File Reference

FreeRTOS Web/DSP Demo.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include "task_demo.h"
#include "ethernet_sam.h"
#include "status_codes.h"
#include "conf_uart_serial.h"
#include "uart_serial.h"
#include "stdio_serial.h"

Macros

#define mainDSP_TASK_PRIORITY   (tskIDLE_PRIORITY + 4)
 
#define mainDSP_TASK_STACK_SIZE   (2048)
 The stack sizes allocated to the DSP stack: (2048 * 4) = 8192 bytes. More...
 
#define mainGFX_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)
 The priorities at which various tasks will get created. More...
 
#define mainGFX_TASK_STACK_SIZE   (1048)
 The stack sizes allocated to the DSP stack: (1048 * 4) = 4096 bytes. More...
 
#define mainQTOUCH_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)
 The priorities at which various tasks will get created. More...
 
#define mainQTOUCH_TASK_STACK_SIZE   (1048)
 The stack sizes allocated to the DSP stack: (1048 * 4) = 4096 bytes. More...
 
#define mainWEBSERVER_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)
 The priorities at which various tasks will get created. More...
 
#define mainWEBSERVER_TASK_STACK_SIZE   (1048)
 The stack sizes allocated to the DSP stack: (1048 * 4) = 4096 bytes. More...
 
#define STOPWATCH_START   { cyc[0] = *DWT_CYCCNT; }
 
#define STOPWATCH_STOP   { cyc[1] = *DWT_CYCCNT; cnt = (cyc[1] - cyc[0]); }
 

Functions

static void configure_console (void)
 Configure UART console. More...
 
int main (void)
 
static void prvSetupHardware (void)
 
void vApplicationIdleHook (void)
 
void vApplicationMallocFailedHook (void)
 
void vApplicationStackOverflowHook (xTaskHandle pxTask, signed char *pcTaskName)
 
void vApplicationTickHook (void)
 This function is called by FreeRTOS each tick. More...
 

Variables

unsigned int cnt
 
volatile int cyc [2]
 
volatile unsigned int * DWT_CONTROL = (volatile unsigned int *)0xE0001000
 
volatile unsigned int * DWT_CYCCNT = (volatile unsigned int *)0xE0001004
 
volatile unsigned int * SCB_DEMCR = (volatile unsigned int *)0xE000EDFC
 

#define mainDSP_TASK_PRIORITY   (tskIDLE_PRIORITY + 4)

Referenced by main().

#define mainDSP_TASK_STACK_SIZE   (2048)

The stack sizes allocated to the DSP stack: (2048 * 4) = 8192 bytes.

Referenced by main().

#define mainGFX_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)

The priorities at which various tasks will get created.

Referenced by main().

#define mainGFX_TASK_STACK_SIZE   (1048)

The stack sizes allocated to the DSP stack: (1048 * 4) = 4096 bytes.

Referenced by main().

#define mainQTOUCH_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)

The priorities at which various tasks will get created.

Referenced by main().

#define mainQTOUCH_TASK_STACK_SIZE   (1048)

The stack sizes allocated to the DSP stack: (1048 * 4) = 4096 bytes.

Referenced by main().

#define mainWEBSERVER_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)

The priorities at which various tasks will get created.

Referenced by main().

#define mainWEBSERVER_TASK_STACK_SIZE   (1048)

The stack sizes allocated to the DSP stack: (1048 * 4) = 4096 bytes.

Referenced by main().

#define STOPWATCH_START   { cyc[0] = *DWT_CYCCNT; }
#define STOPWATCH_STOP   { cyc[1] = *DWT_CYCCNT; cnt = (cyc[1] - cyc[0]); }

static void configure_console ( void  )
static

Configure UART console.

Configure console UART.

References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().

Referenced by prvSetupHardware().

int main ( void  )

Create DSP task.

Create GFX task.

Create QTouch task.

Create WebServer task.

Start the RTOS scheduler.

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 to be created. See the memory management section on the FreeRTOS web site for more details.

References create_dsp_task(), create_gfx_task(), create_qtouch_task(), create_webserver_task(), DWT_CONTROL, DWT_CYCCNT, mainDSP_TASK_PRIORITY, mainDSP_TASK_STACK_SIZE, mainGFX_TASK_PRIORITY, mainGFX_TASK_STACK_SIZE, mainQTOUCH_TASK_PRIORITY, mainQTOUCH_TASK_STACK_SIZE, mainWEBSERVER_TASK_PRIORITY, mainWEBSERVER_TASK_STACK_SIZE, prvSetupHardware(), SCB_DEMCR, and vTaskStartScheduler().

static void prvSetupHardware ( void  )
static

Initialize the console uart

References board_init(), configure_console(), and sysclk_init().

Referenced by main().

void vApplicationIdleHook ( void  )

vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle task. It is essential that code added to this hook function never attempts to block in any way (for example, call xQueueReceive() with a block time specified, or call vTaskDelay()). If the application makes use of the vTaskDelete() API function (as this demo application does) then it is also important that vApplicationIdleHook() is permitted to return to its calling function, because it is the responsibility of the idle task to clean up memory allocated by the kernel to any task that has since been deleted.

void vApplicationMallocFailedHook ( void  )

vApplicationMallocFailedHook() will only be called if configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook function that will get called if a call to pvPortMalloc() fails. pvPortMalloc() is called internally by the kernel whenever a task, queue, timer or semaphore is created. It is also called by various parts of the demo application. If heap_1.c or heap_2.c are used, then the size of the heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used to query the size of free heap space that remains (although it does not provide information on how the remaining heap might be fragmented).

void vApplicationStackOverflowHook ( xTaskHandle  pxTask,
signed char *  pcTaskName 
)

Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called if a stack overflow is detected.

void vApplicationTickHook ( void  )

This function is called by FreeRTOS each tick.

This function will be called by each tick interrupt if configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used (those that end in FromISR()).

volatile int cyc[2]
volatile unsigned int* DWT_CONTROL = (volatile unsigned int *)0xE0001000

Referenced by main().

volatile unsigned int* DWT_CYCCNT = (volatile unsigned int *)0xE0001004

Referenced by main().

volatile unsigned int* SCB_DEMCR = (volatile unsigned int *)0xE000EDFC

Referenced by main().