/*\r
- FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.\r
+ FreeRTOS V6.0.4 - Copyright (C) 2010 Real Time Engineers Ltd.\r
\r
***************************************************************************\r
* *\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
+ 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
licensing and training services.\r
*/\r
\r
+\r
#include <stdlib.h>\r
\r
/* Scheduler include files. */\r
\r
#define x7segSTACK_SIZE configMINIMAL_STACK_SIZE\r
\r
-static portTASK_FUNCTION_PROTO( vRefreshTask, pvParameters );\r
-static portTASK_FUNCTION_PROTO( vCountTask, pvParameters );\r
+static void prvRefreshTask( void *pvParameters );\r
+static void prvCountTask( void *pvParameters );\r
+\r
+/* Value to output to 7 segment display\r
+led_digits[0] is the right most digit */\r
+static signed char seg7_digits[4];\r
\r
void vStart7SegTasks( unsigned portBASE_TYPE uxPriority )\r
{\r
- xTaskCreate (vRefreshTask, ( signed char * ) "7SegRefresh", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL );\r
- xTaskCreate (vCountTask, ( signed char * ) "7SegCount", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL );\r
+ xTaskCreate( prvRefreshTask, ( signed char * ) "7SegRefresh", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL );\r
+ xTaskCreate( prvCountTask, ( signed char * ) "7SegCount", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL );\r
}\r
+/*-----------------------------------------------------------*/\r
\r
-/* Value to output to 7 segment display \r
-led_digits[0] is the right most digit */\r
-static signed char seg7_digits[4];\r
-\r
-static portTASK_FUNCTION_PROTO( vRefreshTask, pvParameters )\r
+static void prvRefreshTask( void *pvParameters )\r
{\r
/* This is table 3.3 from the Spartan-3 Starter Kit board user guide */\r
-const unsigned char bits[16] = {\r
+const unsigned char bits[ 16 ] =\r
+{\r
0x01,\r
0x4f,\r
0x12,\r
0x38\r
};\r
\r
-const unsigned char apsx[4] = {\r
+const unsigned char apsx[4] =\r
+{\r
0x06, /* 3 */\r
0x24, /* S */\r
0x18, /* P */\r
0x08 /* A */\r
};\r
- \r
+\r
portTickType xRefreshRate, xLastRefreshTime;\r
\r
/* Digit to scan */\r
\r
xRefreshRate = 2;\r
\r
- /* We need to initialise xLastRefreshTime prior to the first call to \r
+ /* We need to initialise xLastRefreshTime prior to the first call to\r
vTaskDelayUntil(). */\r
xLastRefreshTime = xTaskGetTickCount();\r
\r
for (;;)\r
{\r
- for (d = 0; d < 4; d++)\r
+ for( d = 0; d < 4; d++ )\r
{\r
- vTaskDelayUntil ( &xLastRefreshTime, xRefreshRate);\r
- \r
+ vTaskDelayUntil ( &xLastRefreshTime, xRefreshRate );\r
+\r
/* Display digit */\r
gpio->out.an = -1;\r
- if (seg7_digits[1] == 4 || seg7_digits[1] == 5) {\r
- gpio->out.digit = apsx[d];\r
- } else {\r
- gpio->out.digit = bits[seg7_digits[d]];\r
+ if( ( seg7_digits[ 1 ] == 4 ) || ( seg7_digits[ 1 ] == 5 ) )\r
+ {\r
+ gpio->out.digit = apsx[ d ];\r
+ }\r
+ else\r
+ {\r
+ gpio->out.digit = bits[ seg7_digits[ d ] ];\r
}\r
+\r
gpio->out.dp = 1;\r
gpio->out.an = ~(1 << d);\r
}\r
}\r
}\r
+/*-----------------------------------------------------------*/\r
\r
-\r
-\r
-static portTASK_FUNCTION_PROTO( vCountTask, pvParameters )\r
+static void prvCountTask( void *pvParameters )\r
{\r
portTickType xCountRate, xLastCountTime;\r
\r
-\r
/* Approximately 20HZ */\r
- xCountRate = configTICK_RATE_HZ/20;\r
+ xCountRate = configTICK_RATE_HZ / 20;\r
\r
- /* We need to initialise xLastCountTime prior to the first call to \r
+ /* We need to initialise xLastCountTime prior to the first call to\r
vTaskDelayUntil(). */\r
xLastCountTime = xTaskGetTickCount();\r
\r
for (;;)\r
{\r
- vTaskDelayUntil ( &xLastCountTime, xCountRate);\r
- \r
+ vTaskDelayUntil( &xLastCountTime, xCountRate );\r
+\r
/* Really ugly way to do BCD arithmetic.... */\r
- seg7_digits[0] -= 1;\r
- if (seg7_digits[0] < 0) {\r
- seg7_digits[0] = 9;\r
- seg7_digits[1] -= 1;\r
- if (seg7_digits[1] < 0) {\r
- seg7_digits[1] = 9;\r
- seg7_digits[2] -= 1;\r
- if (seg7_digits[2] < 0) {\r
- seg7_digits[2] = 9;\r
- seg7_digits[3] -= 1;\r
- if (seg7_digits[3] < 0) {\r
- seg7_digits[3] = 9;\r
+ seg7_digits[ 0 ] -= 1;\r
+ if( seg7_digits[ 0 ] < 0 )\r
+ {\r
+ seg7_digits[ 0 ] = 9;\r
+ seg7_digits[ 1 ] -= 1;\r
+ if( seg7_digits[ 1 ] < 0 )\r
+ {\r
+ seg7_digits[ 1 ] = 9;\r
+ seg7_digits[ 2 ] -= 1;\r
+ if( seg7_digits[ 2 ] < 0 )\r
+ {\r
+ seg7_digits[ 2 ] = 9;\r
+ seg7_digits[ 3 ] -= 1;\r
+ if( seg7_digits[ 3 ] < 0 )\r
+ {\r
+ seg7_digits[ 3 ] = 9;\r
}\r
}\r
}\r
}\r
}\r
\r
-// Local Variables:\r
-// tab-width:4\r
-// End:\r
+\r