]> git.sur5r.net Git - freertos/blobdiff - Demo/MSP430X_MSP430F5438_IAR/main.c
Add the debugger settings to the MSP430X IAR demo directory.
[freertos] / Demo / MSP430X_MSP430F5438_IAR / main.c
index 600e1f81ff0d5fc3657cd093bfccbb684660fb1c..9a922b81cb9b82cd49b208071de17aa79b7107b3 100644 (file)
@@ -65,7 +65,9 @@
 \r
 /* Standard demo includes. */\r
 #include "ParTest.h"\r
+#include "dynamic.h"\r
 #include "comtest2.h"\r
+#include "GenQTest.h"\r
 \r
 /* Codes sent within messages to the LCD task so the LCD task can interpret\r
 exactly what the message it just received was.  These are sent in the\r
@@ -88,13 +90,15 @@ to send messages from tasks and interrupts the the LCD task. */
 \r
 #define mainLCD_TASK_PRIORITY                  ( tskIDLE_PRIORITY + 1 )\r
 #define mainCOM_TEST_PRIORITY                  ( tskIDLE_PRIORITY + 2 )\r
+#define mainGENERIC_QUEUE_TEST_PRIORITY        ( tskIDLE_PRIORITY )\r
 \r
 /* The LED used by the comtest tasks. See the comtest.c file for more\r
 information.  In this case it is deliberately out of range as there are only\r
 two LEDs, and they are both already in use. */\r
-#define mainCOM_TEST_LED                       ( 3 )\r
-\r
+#define mainCOM_TEST_LED                               ( 3 )\r
 \r
+/* The baud rate used by the comtest tasks described at the top of this file. */\r
+#define mainCOM_TEST_BAUD_RATE                 ( 9600 )\r
 /*-----------------------------------------------------------*/\r
 \r
 extern void vRegTest1Task( void *pvParameters );\r
@@ -137,17 +141,21 @@ void main( void )
                vQueueAddToRegistry( xLCDQueue, "LCDQueue" );\r
 \r
                /* Create the standard demo tasks. */\r
-               vAltStartComTestTasks( mainCOM_TEST_PRIORITY, 9600, mainCOM_TEST_LED );\r
+               vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
+               vStartDynamicPriorityTasks();\r
+               vStartGenericQueueTasks( mainGENERIC_QUEUE_TEST_PRIORITY );\r
                \r
                /* Create the terminal IO and button poll tasks, as described at the top\r
                of this file. */\r
                xTaskCreate( prvTerminalIOTask, ( signed char * ) "IO", configMINIMAL_STACK_SIZE * 2, NULL, mainLCD_TASK_PRIORITY, NULL );\r
                xTaskCreate( prvButtonPollTask, ( signed char * ) "BPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
+               /* Create the register test tasks as described at the top of this file. */\r
                xTaskCreate( vRegTest1Task, "Reg1", configMINIMAL_STACK_SIZE, NULL, 0, NULL );\r
                xTaskCreate( vRegTest2Task, "Reg2", configMINIMAL_STACK_SIZE, NULL, 0, NULL );\r
                vTaskStartScheduler();\r
        }\r
+       \r
        for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -161,6 +169,8 @@ LCD.  Note this is a static variable to prevent it being allocated on the task
 stack, which is too small to hold such a variable.  The stack size is configured\r
 when the task is created. */\r
 static char cBuffer[ 512 ];\r
+unsigned char ucLine = 1;\r
+\r
 \r
        /* This function is the only function that uses printf().  If printf() is\r
        used from any other function then some sort of mutual exclusion on stdout\r
@@ -181,6 +191,13 @@ static char cBuffer[ 512 ];
                has been received. */\r
                xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY );\r
 \r
+               /* Clear the LCD if no room remains for any more text output. */\r
+               if( ucLine > 8 )\r
+               {\r
+                       halLcdClearScreen();\r
+                       ucLine = 0;\r
+               }\r
+               \r
                /* What is this message?  What does it contain? */\r
                switch( xReceivedMessage.cMessageID )\r
                {\r
@@ -201,7 +218,18 @@ static char cBuffer[ 512 ];
                                                                                                printf( "\nTask\t     Abs Time\t     %%Time\n*****************************************" );\r
                                                                                                fflush( stdout );\r
                                                                                                vTaskGetRunTimeStats( ( signed char * ) cBuffer );\r
-//                                                                                             printf( cBuffer );\r
+                                                                                               printf( cBuffer );\r
+                                                                                               fflush( stdout );\r
+                                                                                               \r
+                                                                                               /* Also print out a message to\r
+                                                                                               the LCD - in this case the\r
+                                                                                               pointer to the string to print\r
+                                                                                               is sent directly in the\r
+                                                                                               lMessageValue member of the\r
+                                                                                               message.  This just demonstrates\r
+                                                                                               a different communication\r
+                                                                                               technique. */\r
+                                                                                               sprintf( cBuffer, "%s", ( char * ) xReceivedMessage.ulMessageValue );\r
                                                                                                break;\r
                                                                                                \r
                        case mainMESSAGE_STATUS                 :       /* The tick interrupt hook\r
@@ -216,10 +244,8 @@ static char cBuffer[ 512 ];
                                                                                                break;\r
                }\r
                \r
-               /* Output the message that was placed into the cBuffer array within the\r
-               switch statement above. */\r
-               printf( "%s : %u\n", cBuffer, ( unsigned int ) xTaskGetTickCount() );\r
-               fflush( stdout );\r
+               halLcdPrintLine( cBuffer, ucLine,  OVERWRITE_TEXT );\r
+               ucLine++;\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -230,9 +256,9 @@ static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue )
        string for output onto the LCD. */\r
        switch( lStatusValue )\r
        {\r
-               case pdPASS                                             :       sprintf( pcBuffer, "Task status = PASS" );\r
+               case pdPASS                                             :       sprintf( pcBuffer, "Status = PASS" );\r
                                                                                        break;\r
-               case mainERROR_DYNAMIC_TASKS    :       sprintf( pcBuffer, "Error: Dynamic tasks" );\r
+               case mainERROR_DYNAMIC_TASKS    :       sprintf( pcBuffer, "Err: Dynamic tsks" );\r
                                                                                        break;\r
                case mainERROR_COM_TEST                 :       sprintf( pcBuffer, "Err: COM test" ); /* Error in COM test - is the Loopback connector connected? */                                                                                                            \r
                                                                                        break;\r
@@ -284,10 +310,21 @@ static void prvSetupHardware( void )
 unsigned long ulCPU_Clock_KHz = ( configCPU_CLOCK_HZ / 1000UL );\r
 \r
        halBoardInit();\r
-       halButtonsInit( BUTTON_ALL );\r
-       halButtonsInterruptEnable( BUTTON_SELECT );\r
+\r
        LFXT_Start( XT1DRIVE_0 );\r
        Init_FLL_Settle( ( unsigned short ) ulCPU_Clock_KHz, 488 );\r
+\r
+       halButtonsInit( BUTTON_ALL );\r
+       halButtonsInterruptEnable( BUTTON_SELECT );\r
+       halLcdInit();\r
+       halLcdBackLightInit();\r
+       halLcdSetBackLight( 0 );\r
+       halLcdSetContrast( 100 );\r
+       halLcdClearScreen();\r
+       \r
+       halLcdPrintLine( " www.FreeRTOS.org", 0,  OVERWRITE_TEXT );\r
+       \r
+while( ( halButtonsPressed() & BUTTON_UP ) == 0 );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -358,44 +395,38 @@ static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };
        ulCounter++;\r
        if( ulCounter >= ulCheckFrequency )\r
        {\r
-               #ifdef LEFT_OVER_FROM_CUT_AND_PASTE\r
-                       /* See if the standard demo tasks are executing as expected, changing\r
-                       the message that is sent to the LCD task from PASS to an error code if\r
-                       any tasks set reports an error. */\r
-                       if( xAreDynamicPriorityTasksStillRunning() != pdPASS )\r
-                       {\r
-                               xStatusMessage.lMessageValue = mainERROR_DYNAMIC_TASKS;\r
-                       }\r
-                       \r
-                       if( xAreGenericQueueTasksStillRunning() != pdPASS )\r
-                       {\r
-                               xStatusMessage.lMessageValue = mainERROR_GEN_QUEUE_TEST;\r
-                       }\r
-               #else\r
-                       /* See if the standard demo tasks are executing as expected, changing\r
-                       the message that is sent to the LCD task from PASS to an error code if\r
-                       any tasks set reports an error. */\r
-                       if( xAreComTestTasksStillRunning() != pdPASS )\r
-                       {\r
-                               xStatusMessage.ulMessageValue = mainERROR_COM_TEST;\r
-                       }\r
-\r
-\r
-                       /* Check the reg test tasks are still cycling.  They will stop incrementing\r
-                       their loop counters if they encounter an error. */\r
-                       if( usRegTest1Counter == usLastRegTest1Counter )\r
-                       {\r
-                               xStatusMessage.ulMessageValue = mainERROR_REG_TEST;\r
-                       }\r
-       \r
-                       if( usRegTest2Counter == usLastRegTest2Counter )\r
-                       {\r
-                               xStatusMessage.ulMessageValue = mainERROR_REG_TEST;\r
-                       }\r
-       \r
-                       usLastRegTest1Counter = usRegTest1Counter;\r
-                       usLastRegTest2Counter = usRegTest2Counter;\r
-               #endif\r
+               /* See if the standard demo tasks are executing as expected, changing\r
+               the message that is sent to the LCD task from PASS to an error code if\r
+               any tasks set reports an error. */\r
+               if( xAreComTestTasksStillRunning() != pdPASS )\r
+               {\r
+                       xStatusMessage.ulMessageValue = mainERROR_COM_TEST;\r
+               }\r
+\r
+               if( xAreDynamicPriorityTasksStillRunning() != pdPASS )\r
+               {\r
+                       xStatusMessage.ulMessageValue = mainERROR_DYNAMIC_TASKS;\r
+               }\r
+               \r
+               if( xAreGenericQueueTasksStillRunning() != pdPASS )\r
+               {\r
+                       xStatusMessage.ulMessageValue = mainERROR_GEN_QUEUE_TEST;\r
+               }                       \r
+\r
+               /* Check the reg test tasks are still cycling.  They will stop incrementing\r
+               their loop counters if they encounter an error. */\r
+               if( usRegTest1Counter == usLastRegTest1Counter )\r
+               {\r
+                       xStatusMessage.ulMessageValue = mainERROR_REG_TEST;\r
+               }\r
+\r
+               if( usRegTest2Counter == usLastRegTest2Counter )\r
+               {\r
+                       xStatusMessage.ulMessageValue = mainERROR_REG_TEST;\r
+               }\r
+\r
+               usLastRegTest1Counter = usRegTest1Counter;\r
+               usLastRegTest2Counter = usRegTest2Counter;\r
                \r
                /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not\r
                needed (a context switch is going to be performed anyway), but it must\r
@@ -424,7 +455,7 @@ static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };
 __interrupt static void prvSelectButtonInterrupt(void)\r
 {\r
 /* Define the message sent to the LCD task from this interrupt. */\r
-static const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, ( unsigned long ) "Select Interrupt!" };\r
+static const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, ( unsigned long ) "Select Interrupt" };\r
 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 \r
        /* This is the interrupt handler for the joystick select button input.\r