/*\r
- FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd.\r
+ FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+ \r
\r
***************************************************************************\r
- * *\r
- * If you are: *\r
- * *\r
- * + New to FreeRTOS, *\r
- * + Wanting to learn FreeRTOS or multitasking in general quickly *\r
- * + Looking for basic training, *\r
- * + Wanting to improve your FreeRTOS skills and productivity *\r
- * *\r
- * then take a look at the FreeRTOS eBook *\r
- * *\r
- * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *\r
- * http://www.FreeRTOS.org/Documentation *\r
- * *\r
- * A pdf reference manual is also available. Both are usually delivered *\r
- * to your inbox within 20 minutes to two hours when purchased between 8am *\r
- * and 8pm GMT (although please allow up to 24 hours in case of *\r
- * exceptional circumstances). Thank you for your support! *\r
- * *\r
+ * *\r
+ * FreeRTOS tutorial books are available in pdf and paperback. *\r
+ * Complete, revised, and edited pdf reference manuals are also *\r
+ * available. *\r
+ * *\r
+ * Purchasing FreeRTOS documentation will not only help you, by *\r
+ * ensuring you get running as quickly as possible and with an *\r
+ * in-depth knowledge of how to use FreeRTOS, it will also help *\r
+ * the FreeRTOS project to continue with its mission of providing *\r
+ * professional grade, cross platform, de facto standard solutions *\r
+ * for microcontrollers - completely free of charge! *\r
+ * *\r
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *\r
+ * *\r
+ * Thank you for using FreeRTOS, and thank you for your support! *\r
+ * *\r
***************************************************************************\r
\r
+\r
This file is part of the FreeRTOS distribution.\r
\r
FreeRTOS is free software; you can redistribute it and/or modify it under\r
the terms of the GNU General Public License (version 2) as published by the\r
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
- ***NOTE*** The exception to the GPL is included to allow you to distribute\r
- a combined work that includes FreeRTOS without being obliged to provide the\r
- source code for proprietary components outside of the FreeRTOS kernel.\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- more details. You should have received a copy of the GNU General Public \r
- License and the FreeRTOS license exception along with FreeRTOS; if not it \r
- can be viewed here: http://www.freertos.org/a00114.html and also obtained \r
+ >>>NOTE<<< The modification to the GPL is included to allow you to\r
+ distribute a combined work that includes FreeRTOS without being obliged to\r
+ provide the source code for proprietary components outside of the FreeRTOS\r
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
+ more details. You should have received a copy of the GNU General Public\r
+ License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
by writing to Richard Barry, contact details for whom are available on the\r
FreeRTOS WEB site.\r
\r
* In addition to the standard demo tasks, the following tasks and tests are\r
* defined and/or created within this file:\r
*\r
- * "Check" task - This only executes every five seconds but has the highest\r
+ * "Check" task - This only executes every five seconds but has the highest\r
* priority so is guaranteed to get processor time. Its main function is to \r
* check that all the standard demo tasks are still operational. The check task\r
- * will toggle LED 7 (PB15) every five seconds so long as no errors have been\r
+ * will toggle LED 3 (PB11) every five seconds so long as no errors have been\r
* detected. The toggle rate will increase to half a second if an error has \r
* been found in any task.\r
*\r
+ * "Echo" task - This is a very basic task that simply echoes any characters \r
+ * received on COM0 (USART1). This can be tested by transmitting a text file\r
+ * from a dumb terminal to the STM32 USART then observing or capturing the text\r
+ * that is echoed back. Missing characters will be all the more obvious if the \r
+ * file contains a simple repeating string of fixed width.\r
+ *\r
+ * Currently this demo does not include interrupt nesting examples. High \r
+ * frequency timer and simpler nesting examples can be found in most Cortex-M3\r
+ * demo applications.\r
+ *\r
+ * The functions used to initialise, set and clear LED outputs are normally \r
+ * defined in partest.c. This demo includes two partest files, one that is \r
+ * configured for use with the Keil MCBSTM32 evaluation board (called \r
+ * ParTest_MCBSTM32.c) and one that is configured for use with the official\r
+ * ST Eval board (called ParTest_ST_Eval.c). One one of these files should be\r
+ * included in the build at any one time, as appropriate for the hardware \r
+ * actually being used.\r
*/\r
\r
/* Standard includes. */\r
-#include <stdio.h>\r
+#include <string.h>\r
\r
/* Scheduler includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
#include "queue.h"\r
-#include "semphr.h"\r
\r
/* Library includes. */\r
#include "stm32f10x_it.h"\r
-#include "stm32f10x_tim.h"\r
\r
/* Demo app includes. */\r
#include "BlockQ.h"\r
#include "QPeek.h"\r
#include "recmutex.h"\r
\r
+/* Driver includes. */\r
+#include "STM32_USART.h"\r
+\r
\r
/* The time between cycles of the 'check' task - which depends on whether the\r
check task has detected an error or not. */\r
#define mainCHECK_DELAY_ERROR ( ( portTickType ) 500 / portTICK_RATE_MS )\r
\r
/* The LED controlled by the 'check' task. */\r
-#define mainCHECK_LED ( 7 )\r
+#define mainCHECK_LED ( 3 )\r
\r
/* Task priorities. */\r
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )\r
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
-#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )\r
+#define mainECHO_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )\r
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )\r
\r
-/* The WEB server has a larger stack as it utilises stack hungry string\r
-handling library calls. */\r
-#define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 )\r
-\r
-/* The length of the queue used to send messages to the LCD task. */\r
-#define mainQUEUE_SIZE ( 3 )\r
-\r
-/* The period of the system clock in nano seconds. This is used to calculate\r
-the jitter time in nano seconds. */\r
-#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )\r
+/* COM port and baud rate used by the echo task. */\r
+#define mainCOM0 ( 0 )\r
+#define mainBAUD_RATE ( 115200 )\r
\r
/*-----------------------------------------------------------*/\r
\r
/* The 'check' task as described at the top of this file. */\r
static void prvCheckTask( void *pvParameters );\r
\r
+/* A simple task that echoes all the characters that are received on COM0 \r
+(USART1). */\r
+static void prvUSARTEchoTask( void *pvParameters );\r
+\r
/*-----------------------------------------------------------*/\r
\r
int main( void )\r
vStartQueuePeekTasks();\r
vStartRecursiveMutexTasks();\r
\r
- /* Create the 'check' task, which is defined within this file. */\r
+ /* Create the 'echo' task, which is also defined within this file. */\r
+ xTaskCreate( prvUSARTEchoTask, ( signed char * ) "Echo", configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );\r
+\r
+ /* Create the 'check' task, which is also defined within this file. */\r
xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
\r
/* Start the scheduler. */\r
}\r
/*-----------------------------------------------------------*/\r
\r
+/* Described at the top of this file. */\r
static void prvCheckTask( void *pvParameters )\r
{\r
portTickType xLastExecutionTime;\r
}\r
/*-----------------------------------------------------------*/\r
\r
+/* Described at the top of this file. */\r
+static void prvUSARTEchoTask( void *pvParameters )\r
+{\r
+signed char cChar;\r
+\r
+/* String declared static to ensure it does not end up on the stack, no matter\r
+what the optimisation level. */\r
+static const char *pcLongishString = \r
+"ABBA was a Swedish pop music group formed in Stockholm in 1972, consisting of Anni-Frid Frida Lyngstad, "\r
+"Björn Ulvaeus, Benny Andersson and Agnetha Fältskog. Throughout the band's existence, Fältskog and Ulvaeus "\r
+"were a married couple, as were Lyngstad and Andersson - although both couples later divorced. They became one "\r
+"of the most commercially successful acts in the history of popular music, and they topped the charts worldwide "\r
+"from 1972 to 1983. ABBA gained international popularity employing catchy song hooks, simple lyrics, sound "\r
+"effects (reverb, phasing) and a Wall of Sound achieved by overdubbing the female singers' voices in multiple "\r
+"harmonies. As their popularity grew, they were sought after to tour Europe, Australia, and North America, drawing "\r
+"crowds of ardent fans, notably in Australia. Touring became a contentious issue, being particularly cumbersome for "\r
+"Fältskog, but they continued to release studio albums to widespread commercial success. At the height of their "\r
+"popularity, however, both relationships began suffering strain that led ultimately to the collapse of first the "\r
+"Ulvaeus-Fältskog marriage (in 1979) and then of the Andersson-Lyngstad marriage in 1981. In the late 1970s and early "\r
+"1980s these relationship changes began manifesting in the group's music, as they produced more thoughtful, "\r
+"introspective lyrics with different compositions.";\r
+\r
+ /* Just to avoid compiler warnings. */\r
+ ( void ) pvParameters;\r
+\r
+ /* Initialise COM0, which is USART1 according to the STM32 libraries. */\r
+ lCOMPortInit( mainCOM0, mainBAUD_RATE );\r
+\r
+ /* Try sending out a string all in one go, as a very basic test of the\r
+ lSerialPutString() function. */\r
+ lSerialPutString( mainCOM0, pcLongishString, strlen( pcLongishString ) );\r
+\r
+ for( ;; )\r
+ {\r
+ /* Block to wait for a character to be received on COM0. */\r
+ xSerialGetChar( mainCOM0, &cChar, portMAX_DELAY );\r
+\r
+ /* Write the received character back to COM0. */\r
+ xSerialPutChar( mainCOM0, cChar, 0 );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
static void prvSetupHardware( void )\r
{\r
/* RCC system reset(for debug purpose). */\r
RCC_DeInit (); \r
\r
/* Enable HSE. */\r
- RCC_HSEConfig (RCC_HSE_ON); \r
+ RCC_HSEConfig( RCC_HSE_ON ); \r
\r
/* Wait till HSE is ready. */\r
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);\r
\r
/* HCLK = SYSCLK. */\r
- RCC_HCLKConfig (RCC_SYSCLK_Div1); \r
+ RCC_HCLKConfig( RCC_SYSCLK_Div1 ); \r
\r
/* PCLK2 = HCLK. */\r
- RCC_PCLK2Config (RCC_HCLK_Div1); \r
+ RCC_PCLK2Config( RCC_HCLK_Div1 ); \r
\r
/* PCLK1 = HCLK/2. */\r
- RCC_PCLK1Config (RCC_HCLK_Div2); \r
+ RCC_PCLK1Config( RCC_HCLK_Div2 ); \r
\r
/* ADCCLK = PCLK2/4. */\r
- RCC_ADCCLKConfig (RCC_PCLK2_Div4); \r
+ RCC_ADCCLKConfig( RCC_PCLK2_Div4 ); \r
\r
/* Flash 2 wait state. */\r
*( volatile unsigned long * )0x40022000 = 0x01; \r
\r
/* PLLCLK = 8MHz * 9 = 72 MHz */\r
- RCC_PLLConfig (RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);\r
+ RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_9 );\r
\r
/* Enable PLL. */\r
- RCC_PLLCmd (ENABLE); \r
+ RCC_PLLCmd( ENABLE );\r
\r
/* Wait till PLL is ready. */\r
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);\r
\r
/* Initialise the IO used for the LED outputs. */\r
vParTestInitialise();\r
+\r
+ /* SPI2 Periph clock enable */\r
+ RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE );\r
}\r
/*-----------------------------------------------------------*/\r
\r