]> git.sur5r.net Git - freertos/commitdiff
Continue to develop the MSP430X IAR demo project - still a work in progress.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 30 Dec 2010 14:01:21 +0000 (14:01 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 30 Dec 2010 14:01:21 +0000 (14:01 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1195 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/MSP430X_MSP430F5438_IAR/FreeRTOSConfig.h
Demo/MSP430X_MSP430F5438_IAR/RTOSDemo.ewp
Demo/MSP430X_MSP430F5438_IAR/lnk430F5438A_mod.xcl
Demo/MSP430X_MSP430F5438_IAR/main.c

index c618ab77d3c43417824059f5b53b4d9d03bb6c43..ebafb803f34aeb1ba962d789b25219237dfac8ef 100644 (file)
 \r
 #define configUSE_PREEMPTION                   1\r
 #define configUSE_IDLE_HOOK                            1\r
-#define configUSE_TICK_HOOK                            0\r
+#define configUSE_TICK_HOOK                            1\r
 #define configCPU_CLOCK_HZ                             ( 16000000UL )  \r
 #define configTICK_RATE_HZ                             ( ( portTickType ) 1000 )\r
 #define configMAX_PRIORITIES                   ( ( unsigned portBASE_TYPE ) 5 )\r
-#define configMINIMAL_STACK_SIZE               ( ( unsigned short ) 70 )\r
+#define configMINIMAL_STACK_SIZE               ( ( unsigned short ) 60 )\r
 #define configTOTAL_HEAP_SIZE                  ( ( size_t ) ( 5 * 1024 ) )\r
 #define configMAX_TASK_NAME_LEN                        ( 16 )\r
 #define configUSE_TRACE_FACILITY               0\r
index f5164b2332e32b297bbca99c3f92a389ccbc14fc..783d014d7271100a678bd1ab28521d8ecfc8fdfd 100644 (file)
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\F5XX_6XX_Core_Lib\hal_PMM.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\F5XX_6XX_Core_Lib\hal_PMM.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_adc.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_adc.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd_fonts.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_lcd_fonts.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rf.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rtc.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_rtc.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_tlv.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_tlv.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_usb.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\MSP-EXP430F5438_HAL\hal_usb.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\adcTemp.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\adcTemp.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\audio.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\audio.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\balanceBall.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\balanceBall.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\clock.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\clock.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\FFT.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\FFT.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\FFT_430.s43</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\flashUtils.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\flashUtils.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\LPM.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\LPM.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\menuSetting.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\menuSetting.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\PMM.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\PMM.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\PowerTest.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\PowerTest.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\usbTest.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\usbTest.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\UserExperience_F5438A.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\UserExperience_F5438A.h</name>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\UserExperienceGraphics.c</name>\r
+      <excluded>\r
+        <configuration>Debug</configuration>\r
+      </excluded>\r
     </file>\r
     <file>\r
       <name>$PROJ_DIR$\UserExperienceDemo\UserExperienceGraphics.h</name>\r
index 4050f1d0424b1d8003441c12c7c983395fe4b365..5c747173d70aa600733873c94eb4dbe95b4261b7 100644 (file)
 // Code\r
 //\r
 \r
--P(CODE)CODE=5C00-FF7F,10000-45BFF\r
+// *** Modified to place code in high memory and insodoing, testing the port.\r
+// Original code\r
+//-P(CODE)CODE=5C00-FF7F,10000-45BFF\r
+// Modified code\r
+-P(CODE)CODE=10000-45BFF\r
 -Z(CODE)CODE_ID\r
 \r
 // ---------------------------\r
 // Constant data\r
 //\r
 \r
--Z(CONST)DATA20_C,DATA20_ID=5C00-FF7F,10000-45BFF\r
+// *** Modified to place code in high memory and insodoing, testing the port.\r
+// Original code\r
+//-Z(CONST)DATA20_C,DATA20_ID=5C00-FF7F,10000-45BFF\r
+// Modified code\r
+-Z(CONST)DATA20_C,DATA20_ID=10000-45BFF\r
 \r
 \r
 // -------------------------------------\r
index 2b0821a355d80a25402156ed494e77a85da415a5..4bcfe27ed5a6761091032474a74c14f5bbb29e12 100644 (file)
 #include "msp430.h"\r
 #include "hal_MSP-EXP430F5438.h"\r
 \r
-/* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
-without error.  Controlled by the check task as described at the top of this\r
-file. */\r
-#define mainNO_ERROR_CYCLE_TIME                ( 5000 / portTICK_RATE_MS )\r
-\r
-/* The rate at which mainCHECK_LED will toggle when an error has been reported\r
-by at least one task.  Controlled by the check task as described at the top of\r
-this file. */\r
-#define mainERROR_CYCLE_TIME           ( 200 / portTICK_RATE_MS )\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
 cMessageID member of the message structure (defined below). */\r
@@ -82,6 +72,7 @@ of the same message and indicate what the status actually is. */
 #define mainERROR_DYNAMIC_TASKS                        ( pdPASS + 1 )\r
 #define mainERROR_COM_TEST                             ( pdPASS + 2 )\r
 #define mainERROR_GEN_QUEUE_TEST               ( pdPASS + 3 )\r
+#define mainERROR_REG_TEST                             ( pdPASS + 4 )\r
 \r
 /* The length of the queue (the number of items the queue can hold) that is used\r
 to send messages from tasks and interrupts the the LCD task. */\r
@@ -93,7 +84,6 @@ to send messages from tasks and interrupts the the LCD task. */
 \r
 extern void vRegTest1Task( void *pvParameters );\r
 extern void vRegTest2Task( void *pvParameters );\r
-static void prvCheckTask( void *pvParameters );\r
 static void prvSetupHardware( void );\r
 static void prvTerminalIOTask( void *pvParameters );\r
 static void prvButtonPollTask( void *pvParameters );\r
@@ -132,12 +122,11 @@ void main( void )
 \r
                /* Create the terminal IO and button poll tasks, as described at the top\r
                of this file. */\r
-               xTaskCreate( prvTerminalIOTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );\r
+               xTaskCreate( prvTerminalIOTask, ( signed char * ) "IO", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );\r
                xTaskCreate( prvButtonPollTask, ( signed char * ) "ButPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
                xTaskCreate( vRegTest1Task, "RegTest1", configMINIMAL_STACK_SIZE, NULL, 0, NULL );\r
                xTaskCreate( vRegTest2Task, "RegTest2", configMINIMAL_STACK_SIZE, NULL, 0, NULL );\r
-               xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
                vTaskStartScheduler();\r
        }\r
        for( ;; );\r
@@ -209,7 +198,8 @@ static char cBuffer[ 512 ];
                \r
                /* Output the message that was placed into the cBuffer array within the\r
                switch statement above. */\r
-               printf( "%s", cBuffer );\r
+               printf( "%s : %u\n", cBuffer, ( unsigned int ) xTaskGetTickCount() );\r
+               fflush( stdout );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -228,6 +218,8 @@ static void prvGenerateStatusMessage( char *pcBuffer, long lStatusValue )
                                                                                        break;\r
                case mainERROR_GEN_QUEUE_TEST   :       sprintf( pcBuffer, "Error: Gen Q test" );\r
                                                                                        break;\r
+               case mainERROR_REG_TEST                 :       sprintf( pcBuffer, "Error: Reg test" );\r
+                                                                                       break;\r
                default                                                 :       sprintf( pcBuffer, "Unknown status" );\r
                                                                                        break;\r
        }\r
@@ -245,6 +237,12 @@ xQueueMessage xMessage;
        {\r
                /* Check the button state. */\r
                ucState = ( halButtonsPressed() & BUTTON_UP );\r
+               \r
+               if( ucState != 0 )\r
+               {\r
+                       ucState = pdTRUE;\r
+               }\r
+               \r
                if( ucState != ucLastState )\r
                {\r
                        /* The state has changed, send a message to the LCD task. */\r
@@ -267,42 +265,7 @@ static void prvSetupHardware( void )
        halButtonsInit( BUTTON_ALL );\r
        halButtonsInterruptEnable( BUTTON_SELECT );\r
        LFXT_Start (XT1DRIVE_0);\r
-       Init_FLL_Settle( 25000, 488 );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvCheckTask( void *pvParameters )\r
-{\r
-volatile unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;\r
-portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;\r
-const char *pcStatusMessage = "OK";\r
-\r
-       /* Initialise xNextWakeTime - this only needs to be done once. */\r
-       xNextWakeTime = xTaskGetTickCount();\r
-\r
-       for( ;; )\r
-       {\r
-               /* Place this task in the blocked state until it is time to run again. */\r
-               vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );\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
-                       pcStatusMessage = "Error: RegTest1";\r
-               }\r
-\r
-               if( usRegTest2Counter == usLastRegTest2Counter )\r
-               {\r
-                       pcStatusMessage = "Error: RegTest2";\r
-               }\r
-\r
-               usLastRegTest1Counter = usRegTest1Counter;\r
-               usLastRegTest2Counter = usRegTest2Counter;\r
-               \r
-               printf( "%s, tick count = %u\n", pcStatusMessage, ( unsigned int ) xTaskGetTickCount() );\r
-               fflush( stdout );\r
-       }\r
+       Init_FLL_Settle( 18000, 488 );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -352,6 +315,81 @@ void vApplicationIdleHook( void )
 {\r
        __bis_SR_register( LPM3_bits + GIE );\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationTickHook( void )\r
+{\r
+static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;\r
+static unsigned long ulCounter = 0;\r
+static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS;\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+/* Define the status message that is sent to the LCD task.  By default the\r
+status is PASS. */\r
+static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };\r
+\r
+       /* This is called from within the tick interrupt and performs the 'check'\r
+       functionality as described in the comments at the top of this file.\r
+\r
+       Is it time to perform the 'check' functionality again? */\r
+       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( xAreComTestTasksStillRunning() != pdPASS )\r
+                       {\r
+                               xStatusMessage.lMessageValue = mainERROR_COM_TEST;\r
+                       }\r
+                       \r
+                       if( xAreGenericQueueTasksStillRunning() != pdPASS )\r
+                       {\r
+                               xStatusMessage.lMessageValue = mainERROR_GEN_QUEUE_TEST;\r
+                       }\r
+               #else\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.cMessageValue = mainERROR_REG_TEST;\r
+                       }\r
+       \r
+                       if( usRegTest2Counter == usLastRegTest2Counter )\r
+                       {\r
+                               xStatusMessage.cMessageValue = mainERROR_REG_TEST;\r
+                       }\r
+       \r
+                       usLastRegTest1Counter = usRegTest1Counter;\r
+                       usLastRegTest2Counter = usRegTest2Counter;\r
+               #endif\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
+               still be provided. */\r
+               xQueueSendFromISR( xLCDQueue, &xStatusMessage, &xHigherPriorityTaskWoken );\r
+               ulCounter = 0;\r
+       }\r
 \r
+       if( ( ulCounter & 0xff ) == 0 )\r
+       {\r
+               if( ( LED_PORT_OUT & LED_1 ) == 0 )\r
+               {\r
+                       LED_PORT_OUT |= LED_1;\r
+                       LED_PORT_OUT &= ~LED_2;\r
+               }\r
+               else\r
+               {\r
+                       LED_PORT_OUT &= ~LED_1;\r
+                       LED_PORT_OUT |= LED_2;\r
+               }\r
+       }\r
+}\r
 \r
 \r