* 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.\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 mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )\r
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )\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
+/* COM port and baud rate used by the echo task. */\r
+#define mainCOM0 ( 0 )\r
+#define mainBAUD_RATE ( 115200 )\r
+\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
\r
/* SPI2 Periph clock enable */\r
RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE );\r
-\r
- /* Initialize the SPI FLASH driver */\r
- SPI_FLASH_Init();\r
}\r
/*-----------------------------------------------------------*/\r
\r