]> git.sur5r.net Git - freertos/commitdiff
Add LED output to the new MicroBlaze blinky demo - still a work in progress.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 5 Jun 2011 16:39:49 +0000 (16:39 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 5 Jun 2011 16:39:49 +0000 (16:39 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1445 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/CreateProjectDirectoryStructure.bat
Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOSConfig.h
Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/ParTest.c [new file with mode: 0644]
Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/main-blinky.c

index 62a02d304365f7830a39fcded4fa4156bfaea5ea..54c36709f758ffee3ad7e5748251338bfe988410 100644 (file)
@@ -36,20 +36,21 @@ IF EXIST FreeRTOS_Source Goto END
        copy ..\..\..\..\Source\portable\MemMang\heap_2.c FreeRTOS_Source\portable\MemMang\r
 \r
        REM Copy the files that define the common demo tasks.\r
-       copy ..\Common\minimal\dynamic.c Demo_Source\Common_Demo_Files\r
-       copy ..\Common\minimal\comtest.c Demo_Source\Common_Demo_Files\r
-       copy ..\Common\minimal\GenQTest.c Demo_Source\Common_Demo_Files\r
-       copy ..\Common\minimal\TimerDemo.c Demo_Source\Common_Demo_Files\r
-       copy ..\Common\minimal\countsem.c Demo_Source\Common_Demo_Files\r
+       copy ..\..\..\Common\minimal\dynamic.c Demo_Source\Common_Demo_Files\r
+       copy ..\..\..\Common\minimal\comtest.c Demo_Source\Common_Demo_Files\r
+       copy ..\..\..\Common\minimal\GenQTest.c Demo_Source\Common_Demo_Files\r
+       copy ..\..\..\Common\minimal\TimerDemo.c Demo_Source\Common_Demo_Files\r
+       copy ..\..\..\Common\minimal\countsem.c Demo_Source\Common_Demo_Files\r
        \r
        REM Copy the common demo file headers.\r
-       copy ..\Common\include\dynamic.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\comtest.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\comtest2.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\GenQTest.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\serial.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\partest.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\TimerDemo.h Demo_Source\Common_Demo_Files\include\r
-       copy ..\Common\include\countsem.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\dynamic.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\comtest.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\comtest2.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\GenQTest.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\serial.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\partest.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\TimerDemo.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\countsem.h Demo_Source\Common_Demo_Files\include\r
+       copy ..\..\..\Common\include\partest.h Demo_Source\Common_Demo_Files\include\r
        \r
 : END\r
index 3475e05a3bad1abca726e5cea515c1e04cbc1b2b..e247376e9a2127b379ec983049739a080c9691ac 100644 (file)
@@ -119,7 +119,7 @@ to exclude the API function. */
 #define INCLUDE_vTaskDelayUntil                        1\r
 #define INCLUDE_vTaskDelay                             1\r
 \r
-#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }    \r
+#define configASSERT( x ) if( ( x ) == 0 ) { portDISABLE_INTERRUPTS(); for( ;; ); }\r
        \r
 #define configINTERRUPT_CONTROLLER_TO_USE XPAR_INTC_SINGLE_DEVICE_ID\r
 \r
diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/ParTest.c b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/ParTest.c
new file mode 100644 (file)
index 0000000..07284b0
--- /dev/null
@@ -0,0 +1,181 @@
+/*\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+       \r
+\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 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
+    1 tab == 4 spaces!\r
+\r
+    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+    contact details.\r
+\r
+    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+    critical systems.\r
+\r
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
+*/\r
+\r
+/*-----------------------------------------------------------\r
+ * Simple parallel port IO routines.\r
+ *-----------------------------------------------------------*/\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+\r
+/* Demo application includes. */\r
+#include "partest.h"\r
+\r
+/* Library includes. */\r
+#include "xgpio.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+static XGpio xOutputGPIOInstance;\r
+static const unsigned portBASE_TYPE uxGPIOOutputChannel = 1UL;\r
+static ucCurrentLEDState = 0U;\r
+\r
+/*\r
+ * Setup the IO for the LED outputs.\r
+ */\r
+void vParTestInitialise( void )\r
+{\r
+portBASE_TYPE xStatus;\r
+const unsigned char ucSetToOutput = 0U;\r
+\r
+       /* Initialize the GPIO. */\r
+       xStatus = XGpio_Initialize( &xOutputGPIOInstance, XPAR_LEDS_4BITS_DEVICE_ID );  \r
+       if( xStatus == XST_SUCCESS )\r
+       {\r
+               /* All LEDs on this channel are going to be outputs. */\r
+               XGpio_SetDataDirection( &xOutputGPIOInstance, uxGPIOOutputChannel, ucSetToOutput );\r
+               \r
+               /* Start with all LEDs off. */\r
+               ucCurrentLEDState = 0U;\r
+               XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucCurrentLEDState );\r
+       }\r
+       \r
+       configASSERT( ( xStatus == XST_SUCCESS ) );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )\r
+{\r
+#if 0\r
+unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;\r
+\r
+       portENTER_CRITICAL();\r
+       {\r
+               /* Which IO section does the LED being set/cleared belong to?  The\r
+               4 bit or 5 bit outputs? */\r
+               if( uxLED <= partstMAX_4BIT_LED )\r
+               {\r
+                       uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;\r
+                       puxCurrentValue = &uxCurrentOutput4Bit;\r
+               }       \r
+               else\r
+               {\r
+                       uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;\r
+                       puxCurrentValue = &uxCurrentOutput5Bit;\r
+                       uxLED -= partstMAX_4BIT_LED;\r
+               }\r
+\r
+               /* Setup the bit mask accordingly. */\r
+               uxLED = 0x01 << uxLED;\r
+\r
+               /* Maintain the current output value. */\r
+               if( xValue )\r
+               {\r
+                       *puxCurrentValue |= uxLED;\r
+               }\r
+               else\r
+               {\r
+                       *puxCurrentValue &= ~uxLED;\r
+               }\r
+\r
+               /* Write the value to the port. */\r
+               XGpio_mSetDataReg( uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );\r
+       }\r
+       portEXIT_CRITICAL();\r
+#endif\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
+{\r
+#if 0\r
+unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;\r
+\r
+       portENTER_CRITICAL();\r
+       {\r
+               /* Which IO section does the LED being toggled belong to?  The\r
+               4 bit or 5 bit outputs? */\r
+               if( uxLED <= partstMAX_4BIT_LED )\r
+               {\r
+                       uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;\r
+                       puxCurrentValue = &uxCurrentOutput4Bit;\r
+               }       \r
+               else\r
+               {\r
+                       uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;\r
+                       puxCurrentValue = &uxCurrentOutput5Bit;\r
+                       uxLED -= partstMAX_4BIT_LED;\r
+               }\r
+\r
+               /* Setup the bit mask accordingly. */\r
+               uxLED = 0x01 << uxLED;\r
+\r
+               /* Maintain the current output value. */\r
+               if( *puxCurrentValue & uxLED )\r
+               {\r
+                       *puxCurrentValue &= ~uxLED;\r
+               }\r
+               else\r
+               {\r
+                       *puxCurrentValue |= uxLED;\r
+               }\r
+\r
+               /* Write the value to the port. */\r
+               XGpio_mSetDataReg(uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );\r
+       }\r
+       portEXIT_CRITICAL();\r
+#endif\r
+}\r
+\r
+\r
+\r
index 18fcc1019b8f2acc6a60cb8b77f2a8b0e73a5da0..f3f95a1c0bebe4e844f9614ac55826d6ccf10c95 100644 (file)
 #include "xtmrctr.h"\r
 #include "xil_exception.h"\r
 #include "microblaze_exceptions_g.h"\r
+#include "xgpio.h"\r
 \r
 /* Priorities at which the tasks are created. */\r
 #define mainQUEUE_RECEIVE_TASK_PRIORITY                ( tskIDLE_PRIORITY + 2 )\r
@@ -165,14 +166,16 @@ function. */
 static xTimerHandle xLEDTimer = NULL;\r
 \r
 /* Maintains the current LED output state. */\r
-static volatile unsigned long ulGPIOState = 0UL;\r
+static volatile unsigned char ucGPIOState = 0U;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 static XTmrCtr xTimer0Instance;\r
+static XGpio xOutputGPIOInstance;\r
+static const unsigned portBASE_TYPE uxGPIOOutputChannel = 1UL;\r
 \r
 /*-----------------------------------------------------------*/\r
-#define JUST_TESTING\r
+#define NOT_JUST_TESTING\r
 #ifdef JUST_TESTING\r
 volatile unsigned long ul1 = 0, ul2 = 0;\r
 \r
@@ -198,6 +201,12 @@ void main( void )
 {\r
        prvSetupHardware();\r
 \r
+       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 0 );\r
+       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 1 );\r
+       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 2 );\r
+       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 3 );\r
+\r
+\r
        xTaskCreate( vTemp1, ( signed char * ) "Test1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );\r
        xTaskCreate( vTemp2, ( signed char * ) "Test2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );\r
 \r
@@ -253,8 +262,8 @@ static void vLEDTimerCallback( xTimerHandle xTimer )
        a critical section because it is accessed from multiple tasks, and the\r
        button interrupt - in this trivial case, for simplicity, the critical\r
        section is omitted. */\r
-       ulGPIOState |= mainTIMER_CONTROLLED_LED;\r
-//_RB_ MSS_GPIO_set_outputs( ulGPIOState );\r
+       ucGPIOState |= mainTIMER_CONTROLLED_LED;\r
+       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -266,8 +275,8 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
        /* The button was pushed, so ensure the LED is on before resetting the\r
        LED timer.  The LED timer will turn the LED off if the button is not\r
        pushed within 5000ms. */\r
-       ulGPIOState &= ~mainTIMER_CONTROLLED_LED;\r
-//_RB_ MSS_GPIO_set_outputs( ulGPIOState );\r
+       ucGPIOState &= ~mainTIMER_CONTROLLED_LED;\r
+       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );\r
 \r
        /* This interrupt safe FreeRTOS function can be called from this interrupt\r
        because the interrupt priority is below the\r
@@ -330,15 +339,16 @@ unsigned long ulReceivedValue;
                        because it is accessed from multiple tasks, and the button interrupt\r
                        - in this trivial case, for simplicity, the critical section is\r
                        omitted. */\r
-                       if( ( ulGPIOState & mainTASK_CONTROLLED_LED ) != 0 )\r
+                       if( ( ucGPIOState & mainTASK_CONTROLLED_LED ) != 0 )\r
                        {\r
-                               ulGPIOState &= ~mainTASK_CONTROLLED_LED;\r
+                               ucGPIOState &= ~mainTASK_CONTROLLED_LED;\r
                        }\r
                        else\r
                        {\r
-                               ulGPIOState |= mainTASK_CONTROLLED_LED;\r
+                               ucGPIOState |= mainTASK_CONTROLLED_LED;\r
                        }\r
-//_RB_                 MSS_GPIO_set_outputs( ulGPIOState );\r
+\r
+                       XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );\r
                }\r
        }\r
 }\r
@@ -346,6 +356,23 @@ unsigned long ulReceivedValue;
 \r
 static void prvSetupHardware( void )\r
 {\r
+portBASE_TYPE xStatus;\r
+const unsigned char ucSetToOutput = 0U;\r
+\r
+       /* Initialize the GPIO. */\r
+       xStatus = XGpio_Initialize( &xOutputGPIOInstance, XPAR_LEDS_4BITS_DEVICE_ID );\r
+       if( xStatus == XST_SUCCESS )\r
+       {\r
+               /* All LEDs on this channel are going to be outputs. */\r
+               XGpio_SetDataDirection( &xOutputGPIOInstance, uxGPIOOutputChannel, ucSetToOutput );\r
+\r
+               /* Start with all LEDs off. */\r
+               ucGPIOState = 0U;\r
+               XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );\r
+       }\r
+\r
+       configASSERT( ( xStatus == XST_SUCCESS ) );\r
+\r
        #ifdef MICROBLAZE_EXCEPTIONS_ENABLED\r
                microblaze_enable_exceptions();\r
        #endif\r
@@ -449,7 +476,7 @@ extern void vTickISR( void *pvUnused );
 \r
        configASSERT( ( xStatus == pdPASS ) );\r
 }\r
-\r
+/*-----------------------------------------------------------*/\r
 \r
 void vApplicationClearTimerInterrupt( void )\r
 {\r