mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add additional comments to SAM4E demo.
This commit is contained in:
parent
6be1ffccfb
commit
0cbd5182a3
Binary file not shown.
|
@ -103,7 +103,7 @@ struct ili93xx_opt_t g_ili93xx_display_opt;
|
|||
smc_set_pulse_timing( SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE( 4 ) | SMC_PULSE_NCS_WR_PULSE( 4 ) | SMC_PULSE_NRD_PULSE( 10 )| SMC_PULSE_NCS_RD_PULSE( 10 ) );
|
||||
smc_set_cycle_timing( SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE( 10 )| SMC_CYCLE_NRD_CYCLE( 22 ) );
|
||||
smc_set_mode( SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE );
|
||||
|
||||
|
||||
/* Initialise the LCD. */
|
||||
g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH;
|
||||
g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT;
|
||||
|
@ -116,15 +116,15 @@ struct ili93xx_opt_t g_ili93xx_display_opt;
|
|||
|
||||
/* Turn on LCD */
|
||||
ili93xx_display_on();
|
||||
|
||||
|
||||
/* Clear. */
|
||||
ili93xx_set_foreground_color( COLOR_WHITE );
|
||||
ili93xx_draw_filled_rectangle( 0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT );
|
||||
|
||||
|
||||
/* Draw logos. */
|
||||
ili93xx_set_cursor_position( 0,0 );
|
||||
gfx_draw_bmpfile( logo_atmel_bmp );
|
||||
|
||||
|
||||
/* Set foreground colour ready to write text. */
|
||||
ili93xx_set_foreground_color( COLOR_BLACK );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
@ -78,7 +78,7 @@
|
|||
#define partestNUM_LEDS ( 3UL )
|
||||
|
||||
/* The index of the pins to which the LEDs are connected. The ordering of the
|
||||
LEDs in this array is intentional and matches the order they appear on the
|
||||
LEDs in this array is intentional and matches the order they appear on the
|
||||
hardware. */
|
||||
static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO };
|
||||
|
||||
|
@ -86,13 +86,13 @@ static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO };
|
|||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
/* LEDs are initialised in the Atmel provided board initialisation
|
||||
/* LEDs are initialised in the Atmel provided board initialisation
|
||||
function. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
|
||||
{
|
||||
{
|
||||
if( uxLED < partestNUM_LEDS )
|
||||
{
|
||||
/* Turn the LED off. */
|
||||
|
@ -110,12 +110,12 @@ void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
|||
if( uxLED < partestNUM_LEDS )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
{
|
||||
ioport_toggle_pin_level( ulLED[ uxLED ] );
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
@ -185,16 +185,16 @@ each node on the network has a unique MAC address. */
|
|||
|
||||
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
|
||||
ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
|
||||
#define configIP_ADDR0 172
|
||||
#define configIP_ADDR1 25
|
||||
#define configIP_ADDR2 218
|
||||
#define configIP_ADDR0 192
|
||||
#define configIP_ADDR1 168
|
||||
#define configIP_ADDR2 0
|
||||
#define configIP_ADDR3 200
|
||||
|
||||
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to
|
||||
0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
|
||||
#define configGATEWAY_ADDR0 172
|
||||
#define configGATEWAY_ADDR1 25
|
||||
#define configGATEWAY_ADDR2 218
|
||||
#define configGATEWAY_ADDR0 192
|
||||
#define configGATEWAY_ADDR1 168
|
||||
#define configGATEWAY_ADDR2 0
|
||||
#define configGATEWAY_ADDR3 1
|
||||
|
||||
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
|
||||
|
@ -213,7 +213,7 @@ ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
|
|||
#define configNET_MASK3 0
|
||||
|
||||
/* The address of the echo server. Used when the demo is build to include the
|
||||
UDP echo tasks (when mainINCLUDE_ECHO_CLIENT_TASKS is set to 1 in
|
||||
UDP echo tasks (when mainINCLUDE_ECHO_CLIENT_TASKS is set to 1 in
|
||||
FreeRTOSConfig.h.
|
||||
http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml */
|
||||
#define configECHO_SERVER_ADDR0 192
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
* This file is part of the FreeRTOS+UDP distribution. The FreeRTOS+UDP license
|
||||
* terms are different to the FreeRTOS license terms.
|
||||
*
|
||||
* FreeRTOS+UDP uses a dual license model that allows the software to be used
|
||||
* under a standard GPL open source license, or a commercial license. The
|
||||
* standard GPL license (unlike the modified GPL license under which FreeRTOS
|
||||
* itself is distributed) requires that all software statically linked with
|
||||
* FreeRTOS+UDP is also distributed under the same GPL V2 license terms.
|
||||
* FreeRTOS+UDP uses a dual license model that allows the software to be used
|
||||
* under a standard GPL open source license, or a commercial license. The
|
||||
* standard GPL license (unlike the modified GPL license under which FreeRTOS
|
||||
* itself is distributed) requires that all software statically linked with
|
||||
* FreeRTOS+UDP is also distributed under the same GPL V2 license terms.
|
||||
* Details of both license options follow:
|
||||
*
|
||||
* - Open source licensing -
|
||||
|
@ -58,7 +58,7 @@ priority) to (configMAX_PRIORITIES - 1) (the highest priority).
|
|||
configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in
|
||||
FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
|
||||
the priority assigned to the task executing the IP stack relative to the
|
||||
priority assigned to tasks that use the IP stack.
|
||||
priority assigned to tasks that use the IP stack.
|
||||
|
||||
Note: If the application is started without the network cable plugged in then
|
||||
this should be set to the lowest priority - otherwise the Atmel ASF GMAC driver
|
||||
|
@ -120,13 +120,7 @@ ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the
|
|||
static IP address passed as a parameter to FreeRTOS_IPInit() if the
|
||||
re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
|
||||
a DHCP reply being received. */
|
||||
#ifdef _WINDOWS_
|
||||
/* The windows simulated time is not real time so the max delay is much
|
||||
shorter. */
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS )
|
||||
#else
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_RATE_MS )
|
||||
#endif /* _WINDOWS_ */
|
||||
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS )
|
||||
|
||||
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP
|
||||
stack can only send a UDP message to a remove IP address if it knowns the MAC
|
||||
|
@ -166,7 +160,8 @@ not set to 1 then only FreeRTOS_indet_addr_quick() is available. */
|
|||
/* ipconfigNUM_NETWORK_BUFFERS defines the total number of network buffer that
|
||||
are available to the IP stack. The total number of network buffers is limited
|
||||
to ensure the total amount of RAM that can be consumed by the IP stack is capped
|
||||
to a pre-determinable value. */
|
||||
to a pre-determinable value. NOTE: This constant is not used when all buffers
|
||||
are dynamically allocated and freed. */
|
||||
#define ipconfigNUM_NETWORK_BUFFERS 10
|
||||
|
||||
/* A FreeRTOS queue is used to send events from application tasks to the IP
|
||||
|
@ -242,17 +237,37 @@ Ethernet driver does all the necessary filtering in hardware then software
|
|||
filtering can be removed by using a value other than 1 or 0. */
|
||||
#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 0
|
||||
|
||||
/* If ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM is set to 1 then a UDP checksum
|
||||
will not be calculated and added to a packet before the packet is sent to the
|
||||
hardware for transmission. */
|
||||
#define ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM 0
|
||||
|
||||
/* If ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM is set to 1 then an IP checksum
|
||||
will not be calculated and added to a packet before the packet is sent to the
|
||||
hardware for transmission. */
|
||||
#define ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM 0
|
||||
|
||||
/* If ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM is set to 1 then the IP
|
||||
checksum will be ignored on incoming packets on the assumption IP packets with
|
||||
an invalid checksum are not passed to the stack. */
|
||||
#define ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM 0
|
||||
|
||||
/* If ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM is set to 1 then the UDP
|
||||
checksum will be ignored on incoming packets on the assumption the UDP packets
|
||||
with an invalid checksum are not passed to the stack. */
|
||||
#define ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM 0
|
||||
|
||||
/* Set ipconfigFREERTOS_PLUS_NABTO to 1 to support the Nabto protocol, or 0 to
|
||||
exclude support for the Nabto protocol. If ipconfigFREERTOS_PLUS_NABTO is set
|
||||
to one then the project must build the Nabto source code (or reference a
|
||||
pre-build Nabto library. */
|
||||
#define ipconfigFREERTOS_PLUS_NABTO 0
|
||||
#define ipconfigFREERTOS_PLUS_NABTO 0
|
||||
|
||||
/* Sets the size of the stack used by the Nabto service task. The Nabto event
|
||||
handler executes in the context of the Nabto service task. If the event handler
|
||||
uses a lot of stack then it is possible the value set here will need to be
|
||||
increased. It is recommended to have FreeRTOS stack overflow checking turned
|
||||
on during development (see the configCHECK_FOR_STACK_OVERFLOW in
|
||||
on during development (see the configCHECK_FOR_STACK_OVERFLOW in
|
||||
FreeRTOSConfig.h and in the documentation. */
|
||||
#define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
@ -65,11 +65,13 @@
|
|||
|
||||
/******************************************************************************
|
||||
* This project provides two demo applications. A simple blinky style project,
|
||||
* and a more comprehensive application that makes use of FreeRTOS+ add-on
|
||||
* components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this
|
||||
* file) is used to select between the two. The simply blinky demo is
|
||||
* implemented and described in main_blinky.c. The more comprehensive demo
|
||||
* application is implemented and described in main_full.c.
|
||||
* and a more comprehensive application that includes FreeRTOS+CLI, FreeRTOS+UDP
|
||||
* and FreeRTOS+FAT SL. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined
|
||||
* in this file) is used to select between the two. The simply blinky demo is
|
||||
* implemented and described in main_blinky.c. The more comprehensive demo
|
||||
* application is implemented and described in main_full.c and full user
|
||||
* instructions are provided on the following URL:
|
||||
* http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
|
||||
*
|
||||
* This file implements the code that is not demo specific, including the
|
||||
* hardware setup and FreeRTOS hook functions.
|
||||
|
@ -84,7 +86,7 @@
|
|||
#include "partest.h"
|
||||
|
||||
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
|
||||
or 0 to run the more comprehensive demo application that includes add-on
|
||||
or 0 to run the more comprehensive demo application that includes add-on
|
||||
components. */
|
||||
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
|
||||
|
||||
|
@ -111,15 +113,17 @@ int main( void )
|
|||
|
||||
/* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
|
||||
of this file. */
|
||||
#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
|
||||
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
|
||||
{
|
||||
main_blinky();
|
||||
}
|
||||
#else
|
||||
{
|
||||
/* Full user instructions are provided on the following URL:
|
||||
http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */
|
||||
main_full();
|
||||
}
|
||||
#endif
|
||||
#endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -132,7 +136,6 @@ static void prvSetupHardware( void )
|
|||
sysclk_init();
|
||||
pmc_enable_periph_clk( ID_GMAC );
|
||||
pmc_enable_periph_clk( ID_SMC );
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -163,12 +166,13 @@ void vApplicationIdleHook( void )
|
|||
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. */
|
||||
|
||||
|
||||
/* The simple blinky demo does not use the idle hook - the full demo does. */
|
||||
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
|
||||
{
|
||||
extern void vFullDemoIdleHook( void );
|
||||
|
||||
|
||||
/* Implemented in main_full.c. */
|
||||
vFullDemoIdleHook();
|
||||
}
|
||||
#endif
|
||||
|
@ -181,8 +185,8 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName
|
|||
( void ) pxTask;
|
||||
|
||||
/* 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. */
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
|
||||
called if a stack overflow is detected. */
|
||||
vAssertCalled( __LINE__, __FILE__ );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -194,12 +198,13 @@ void vApplicationTickHook( void )
|
|||
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()). */
|
||||
|
||||
|
||||
/* The simple blinky demo does not use the tick hook - the full demo does. */
|
||||
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
|
||||
{
|
||||
extern void vFullDemoTickHook( void );
|
||||
|
||||
|
||||
/* Implemented in main_full.c. */
|
||||
vFullDemoTickHook();
|
||||
}
|
||||
#endif
|
||||
|
@ -210,18 +215,18 @@ void vAssertCalled( uint32_t ulLine, const char *pcFile )
|
|||
{
|
||||
/* The following two variables are just to ensure the parameters are not
|
||||
optimised away and therefore unavailable when viewed in the debugger. */
|
||||
volatile uint32_t ulLineNumber = ulLine, ulSetNoneZeroInDebuggerToReturn = 0;
|
||||
volatile uint32_t ulLineNumber = ulLine, ulSetNonZeroInDebuggerToReturn = 0;
|
||||
volatile const char * const pcFileName = pcFile;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
while( ulSetNoneZeroInDebuggerToReturn == 0 )
|
||||
while( ulSetNonZeroInDebuggerToReturn == 0 )
|
||||
{
|
||||
/* If you want to set out of this function in the debugger to see the
|
||||
assert() location then set ulSetNoneZeroInDebuggerToReturn to a non-zero
|
||||
assert() location then set ulSetNonZeroInDebuggerToReturn to a non-zero
|
||||
value. */
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
|
||||
( void ) pcFileName;
|
||||
( void ) ulLineNumber;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
@ -65,19 +65,19 @@
|
|||
|
||||
/******************************************************************************
|
||||
* NOTE 1: This project provides two demo applications. A simple blinky style
|
||||
* project, and a more comprehensive demo application that makes use of some
|
||||
* add-on components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c
|
||||
* is used to select between the two. See the notes on using
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c. This file implements the
|
||||
* simply blinky style version.
|
||||
* project, and a more comprehensive demo application that makes use of
|
||||
* FreeRTOS_CLI, FreeRTOS+UDP and FreeRTOS+FAT SL. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
|
||||
* between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
|
||||
* in main.c. This file implements the simply blinky style version.
|
||||
*
|
||||
* NOTE 2: This file only contains the source code that is specific to the
|
||||
* basic demo. Generic functions, such FreeRTOS hook functions, and functions
|
||||
* required to configure the hardware, are defined in main.c.
|
||||
******************************************************************************
|
||||
*
|
||||
* main_blinky() creates one queue, and two tasks and one software timer. It
|
||||
* then starts the scheduler.
|
||||
* main_blinky() creates one queue, two tasks and one software timer. It then
|
||||
* starts the scheduler.
|
||||
*
|
||||
* The Queue Send Task:
|
||||
* The queue send task is implemented by the prvQueueSendTask() function in
|
||||
|
@ -116,11 +116,6 @@ will remove items as they are added, meaning the send task should always find
|
|||
the queue empty. */
|
||||
#define mainQUEUE_LENGTH ( 1 )
|
||||
|
||||
/* Values passed to the two tasks just to check the task parameter
|
||||
functionality. */
|
||||
#define mainQUEUE_SEND_PARAMETER ( 0x1111UL )
|
||||
#define mainQUEUE_RECEIVE_PARAMETER ( 0x22UL )
|
||||
|
||||
/* The period of the blinky software timer. The period is specified in ms and
|
||||
converted to ticks using the portTICK_RATE_MS constant. */
|
||||
#define mainBLINKY_TIMER_PERIOD ( 50 / portTICK_RATE_MS )
|
||||
|
@ -128,7 +123,7 @@ converted to ticks using the portTICK_RATE_MS constant. */
|
|||
/* A block time of zero simply means "don't block". */
|
||||
#define mainDONT_BLOCK ( 0 )
|
||||
|
||||
/* The LEDs toggled by the timer and queue receive task respectively. */
|
||||
/* The LEDs toggled by the timer callback and queue receive task respectively. */
|
||||
#define mainTIMER_LED 0
|
||||
#define mainTASK_LED 1
|
||||
|
||||
|
@ -154,14 +149,10 @@ void main_blinky( void );
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used by both tasks. */
|
||||
static xQueueHandle xQueue = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main_blinky( void )
|
||||
{
|
||||
xTimerHandle xTimer;
|
||||
xQueueHandle xQueue;
|
||||
|
||||
/* Create the queue. */
|
||||
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
|
||||
|
@ -173,13 +164,13 @@ xTimerHandle xTimer;
|
|||
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */
|
||||
( signed char * ) "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. */
|
||||
( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */
|
||||
( void * ) xQueue, /* Pass the queue into the task using the task parameter. */
|
||||
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */
|
||||
NULL ); /* The task handle is not required, so NULL is passed. */
|
||||
|
||||
xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL );
|
||||
xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) xQueue, mainQUEUE_SEND_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Create the blinky software timer as described at the top of this
|
||||
/* Create the blinky software timer as described at the top of this
|
||||
file. */
|
||||
xTimer = xTimerCreate( ( const signed char * ) "Blinky",/* A text name, purely to help debugging. */
|
||||
( mainBLINKY_TIMER_PERIOD ), /* The timer period. */
|
||||
|
@ -211,9 +202,10 @@ static void prvQueueSendTask( void *pvParameters )
|
|||
{
|
||||
portTickType xNextWakeTime;
|
||||
const unsigned long ulValueToSend = 100UL;
|
||||
xQueueHandle xQueue;
|
||||
|
||||
/* Check the task parameter is as expected. */
|
||||
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );
|
||||
/* The handle of the queue is passed in using the task's parameter. */
|
||||
xQueue = ( xQueueHandle ) pvParameters;
|
||||
|
||||
/* Initialise xNextWakeTime - this only needs to be done once. */
|
||||
xNextWakeTime = xTaskGetTickCount();
|
||||
|
@ -230,7 +222,7 @@ const unsigned long ulValueToSend = 100UL;
|
|||
toggle the LED. 0 is used as the block time so the sending operation
|
||||
will not block - it shouldn't need to block as the queue should always
|
||||
be empty at this point in the code. */
|
||||
xQueueSend( xQueue, &ulValueToSend, 0U );
|
||||
xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -238,9 +230,10 @@ const unsigned long ulValueToSend = 100UL;
|
|||
static void prvQueueReceiveTask( void *pvParameters )
|
||||
{
|
||||
unsigned long ulReceivedValue;
|
||||
xQueueHandle xQueue;
|
||||
|
||||
/* Check the task parameter is as expected. */
|
||||
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );
|
||||
/* The queue is passed in as the task's parameter. */
|
||||
xQueue = ( xQueueHandle ) pvParameters;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
@ -63,6 +63,52 @@
|
|||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* NOTE 1: This project provides two demo applications. A simple blinky style
|
||||
* project, and a more comprehensive test and demo application that makes use of
|
||||
* the FreeRTOS+CLI, FreeRTOS+UDP and FreeRTOS+FAT SL components. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
|
||||
* between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
|
||||
* in main.c. This file implements the comprehensive test and demo version,
|
||||
* which is fully documented on the following URL:
|
||||
* http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
|
||||
*
|
||||
* NOTE 2: This file only contains the source code that is specific to the
|
||||
* full demo. Generic functions, such FreeRTOS hook functions, and functions
|
||||
* required to configure the hardware, are defined in main.c.
|
||||
******************************************************************************
|
||||
*
|
||||
* Full user instructions are provided on the following URL:
|
||||
* http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
|
||||
*
|
||||
* main_full():
|
||||
* + Uses FreeRTOS+FAT SL to create a set of example files on a RAM disk.
|
||||
* + Displays some bitmaps on the LCD.
|
||||
* + Registers sample generic, file system related and UDP related commands
|
||||
* with FreeRTOS+CLI.
|
||||
* + Creates all the standard demo application tasks and software timers.
|
||||
* + Starts the scheduler.
|
||||
*
|
||||
* A UDP command server and optionally two UDP echo client tasks are created
|
||||
* from the network event hook after an IP address has been obtained. The IP
|
||||
* address is displayed on the LCD.
|
||||
*
|
||||
* A "check software timer" is created to provide visual feedback of the system
|
||||
* status. The timer's period is initially set to three seconds. The callback
|
||||
* function associated with the timer checks all the standard demo tasks are not
|
||||
* only still executed, but are executing without reporting any errors. If the
|
||||
* timer discovers a task has either stalled, or reported an error, then it
|
||||
* changes its own period from the initial three seconds, to just 200ms. The
|
||||
* check software timer also toggles the LED marked D4 - so if the LED toggles
|
||||
* every three seconds then no potential errors have been found, and if the LED
|
||||
* toggles every 200ms then a potential error has been found in at least one
|
||||
* task.
|
||||
*
|
||||
* Information on accessing the CLI and file system, and using the UDP echo
|
||||
* tasks is provided on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
|
||||
*
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
@ -120,14 +166,15 @@ ISR triggered task. */
|
|||
/* Misc. */
|
||||
#define mainDONT_BLOCK ( 0 )
|
||||
|
||||
/* Note: If the application is started without the network cable plugged in
|
||||
/* Note: If the application is started without the network cable plugged in
|
||||
then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to
|
||||
ensure the IP task is created at the idle priority. This is because the Atmel
|
||||
ASF GMAC driver polls the GMAC looking for a connection, and doing so will
|
||||
prevent any lower priority tasks from executing. In this demo the IP task is
|
||||
started at the idle priority, then set to configMAX_PRIORITIES - 2 in the
|
||||
ensure the IP task is created at the idle priority. This is because the Atmel
|
||||
ASF GMAC driver polls the GMAC looking for a connection, and doing so will
|
||||
prevent any lower priority tasks from executing. In this demo the IP task is
|
||||
started at the idle priority, then set to configMAX_PRIORITIES - 2 in the
|
||||
network event hook only after a connection has been established (when the event
|
||||
passed into the network event hook is eNetworkUp). */
|
||||
passed into the network event hook is eNetworkUp).
|
||||
http://www.FreeRTOS.org/udp */
|
||||
#define mainCONNECTED_IP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
|
||||
#define mainDISCONNECTED_IP_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
|
@ -136,7 +183,10 @@ passed into the network event hook is eNetworkUp). */
|
|||
#define mainUDP_CLI_PORT_NUMBER ( 5001UL )
|
||||
#define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2U )
|
||||
|
||||
/* Set to 1 to include the UDP echo client tasks. */
|
||||
/* Set to 1 to include the UDP echo client tasks in the build. The echo clients
|
||||
require the IP address of the echo server to be defined using the
|
||||
configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
|
||||
FreeRTOSConfig.h. */
|
||||
#define mainINCLUDE_ECHO_CLIENT_TASKS 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -146,23 +196,25 @@ passed into the network event hook is eNetworkUp). */
|
|||
*/
|
||||
static void prvCheckTimerCallback( xTimerHandle xTimer );
|
||||
|
||||
/*
|
||||
* Creates a set of sample files on a RAM disk.
|
||||
/*
|
||||
* Creates a set of sample files on a RAM disk. http://www.FreeRTOS.org/fat_sl
|
||||
*/
|
||||
extern void vCreateAndVerifySampleFiles( void );
|
||||
|
||||
/*
|
||||
* Register the generic commands that can be used with FreeRTOS+CLI.
|
||||
* Register sample generic commands that can be used with FreeRTOS+CLI. Type
|
||||
* 'help' in the command line to see a list of registered commands.
|
||||
* http://www.FreeRTOS.org/cli
|
||||
*/
|
||||
extern void vRegisterSampleCLICommands( void );
|
||||
|
||||
/*
|
||||
* Register the file system commands that can be used with FreeRTOS+CLI.
|
||||
* Register sample file system commands that can be used with FreeRTOS+CLI.
|
||||
*/
|
||||
extern void vRegisterFileSystemCLICommands( void );
|
||||
|
||||
/*
|
||||
* Register the UDP related commands that can be used with FreeRTOS+CLI.
|
||||
* Register sample UDP related commands that can be used with FreeRTOS+CLI.
|
||||
*/
|
||||
extern void vRegisterUDPCLICommands( void );
|
||||
|
||||
|
@ -188,11 +240,13 @@ Note each node on a network must have a unique MAC address. */
|
|||
const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int main_full( void )
|
||||
{
|
||||
xTimerHandle xTimer = NULL;
|
||||
|
||||
/* Initialise the LCD and output the bitmap. */
|
||||
/* Initialise the LCD and output a bitmap. The IP address will also be
|
||||
displayed on the LCD when it has been obtained. */
|
||||
vInitialiseLCD();
|
||||
|
||||
/* If the file system is only going to be accessed from one task then
|
||||
|
@ -200,19 +254,20 @@ xTimerHandle xTimer = NULL;
|
|||
before the RTOS scheduler is started. If the file system is going to be
|
||||
access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
|
||||
the set of sample files are created from the idle task hook function
|
||||
vApplicationIdleHook() - which is defined in this file. */
|
||||
vApplicationIdleHook(). */
|
||||
#if( F_FS_THREAD_AWARE == 0 )
|
||||
{
|
||||
/* Initialise the drive and file system, then create a few example
|
||||
files. The output from this function just goes to the stdout window,
|
||||
allowing the output to be viewed when the UDP command console is not
|
||||
connected. */
|
||||
files. The files can be viewed and accessed via the CLI. View the
|
||||
documentation page for this demo (link at the top of this file) for more
|
||||
information. */
|
||||
vCreateAndVerifySampleFiles();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Register example generic, file system related and UDP related CLI
|
||||
commands respectively. */
|
||||
/* Register example generic, file system related and UDP related CLI
|
||||
commands respectively. Type 'help' into the command console to view a list
|
||||
of registered commands. */
|
||||
vRegisterSampleCLICommands();
|
||||
vRegisterFileSystemCLICommands();
|
||||
vRegisterUDPCLICommands();
|
||||
|
@ -221,8 +276,8 @@ xTimerHandle xTimer = NULL;
|
|||
created in the network event hook when the network is connected and ready
|
||||
for use. The address values passed in here are used if ipconfigUSE_DHCP is
|
||||
set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be
|
||||
contacted. The Nabto service task is created automatically if
|
||||
ipconfigFREERTOS_PLUS_NABTO is set to 1 in FreeRTOSIPConfig.h. */
|
||||
contacted. The IP address actually used is displayed on the LCD (after DHCP
|
||||
has completed if DHCP is used). */
|
||||
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||
|
||||
/* Create all the other standard demo tasks. */
|
||||
|
@ -326,6 +381,9 @@ unsigned long ulErrorOccurred = pdFALSE;
|
|||
}
|
||||
}
|
||||
|
||||
/* Toggle the LED to give visual feedback of the system status. The rate at
|
||||
which the LED toggles will increase to mainERROR_CHECK_TIMER_PERIOD_MS if a
|
||||
suspected error has been found in any of the standard demo tasks. */
|
||||
vParTestToggleLED( mainCHECK_LED );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -348,38 +406,55 @@ char cIPAddress[ 20 ];
|
|||
passed into the network event hook is eNetworkUp). */
|
||||
if( eNetworkEvent == eNetworkUp )
|
||||
{
|
||||
/* Ensure tasks are only created once. */
|
||||
if( lTasksAlreadyCreated == pdFALSE )
|
||||
{
|
||||
/* Create the task that handles the CLI on a UDP port. The port number
|
||||
is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */
|
||||
{
|
||||
/* Create the task that handles the CLI on a UDP port. The port
|
||||
number is set using the configUDP_CLI_PORT_NUMBER setting in
|
||||
FreeRTOSConfig.h. */
|
||||
vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY );
|
||||
|
||||
|
||||
#if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 )
|
||||
{
|
||||
/* Create the UDP echo tasks. The UDP echo tasks require the IP
|
||||
address of the echo server to be defined using the
|
||||
configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
|
||||
FreeRTOSConfig.h. */
|
||||
vStartEchoClientTasks( configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Obtain the IP address, convert it to a string, then display. */
|
||||
|
||||
/* Obtain the IP address, convert it to a string, then display it on the
|
||||
LCD. */
|
||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||
FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress );
|
||||
ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
|
||||
ili93xx_draw_string( ulXCoord + ulIPAddressOffset, ulYCoord, ( uint8_t * ) cIPAddress );
|
||||
|
||||
/* Set the IP task up to the desired priority now it has connected. */
|
||||
|
||||
/* Set the priority of the IP task up to the desired priority now it has
|
||||
connected. */
|
||||
vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );
|
||||
}
|
||||
|
||||
/* NOTE: At the time of writing the Ethernet driver does not report the
|
||||
cable being unplugged - so the following if() condition will never be met.
|
||||
It is included for possible future updates to the driver. */
|
||||
if( eNetworkEvent == eNetworkDown )
|
||||
{
|
||||
/* Ensure the Atmel GMAC drivers don't hog all the CPU time as they look
|
||||
for a new connection by lowering the priority of the IP task to that of
|
||||
the Idle task. */
|
||||
vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
|
||||
|
||||
/* Disconnected - so no IP address. */
|
||||
ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vFullDemoIdleHook( void )
|
||||
{
|
||||
{
|
||||
/* If the file system is only going to be accessed from one task then
|
||||
F_FS_THREAD_AWARE can be set to 0 and the set of example files is created
|
||||
before the RTOS scheduler is started. If the file system is going to be
|
||||
|
@ -405,10 +480,10 @@ void vFullDemoIdleHook( void )
|
|||
|
||||
void vFullDemoTickHook( void )
|
||||
{
|
||||
/* Call the periodic queue overwrite from ISR demo. */
|
||||
/* Call the periodic queue overwrite from ISR test function. */
|
||||
vQueueOverwritePeriodicISRDemo();
|
||||
|
||||
/* Call the queue set ISR test function. */
|
||||
/* Call the periodic queue set ISR test function. */
|
||||
vQueueSetAccessQueueSetFromISR();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -416,7 +491,8 @@ void vFullDemoTickHook( void )
|
|||
/* Called automatically when a reply to an outgoing ping is received. */
|
||||
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )
|
||||
{
|
||||
/* This demo has nowhere to output any information so does nothing. */
|
||||
/* This demo has nowhere to output any information so does nothing, but the
|
||||
IP address resolved for the pined URL is displayed in the CLI. */
|
||||
( void ) usIdentifier;
|
||||
( void ) eStatus;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
static void printchar(char **str, int c)
|
||||
{
|
||||
extern int putchar(int c);
|
||||
|
||||
|
||||
if (str) {
|
||||
**str = c;
|
||||
++(*str);
|
||||
|
@ -185,7 +185,7 @@ static int print( char **out, const char *format, va_list args )
|
|||
int printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start( args, format );
|
||||
return print( 0, format, args );
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ int printf(const char *format, ...)
|
|||
int sprintf(char *out, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start( args, format );
|
||||
return print( &out, format, args );
|
||||
}
|
||||
|
@ -202,9 +202,9 @@ int sprintf(char *out, const char *format, ...)
|
|||
int snprintf( char *buf, unsigned int count, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
||||
( void ) count;
|
||||
|
||||
|
||||
va_start( args, format );
|
||||
return print( &buf, format, args );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue