Minor formatting and name changes only.

pull/4/head
Richard Barry 15 years ago
parent a93c8d6659
commit b492b7eb89

@ -1,5 +1,5 @@
/* /*
FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd. FreeRTOS V6.0.4 - Copyright (C) 2010 Real Time Engineers Ltd.
*************************************************************************** ***************************************************************************
* * * *
@ -33,9 +33,9 @@
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details. You should have received a copy of the GNU General Public more details. You should have received a copy of the GNU General Public
License and the FreeRTOS license exception along with FreeRTOS; if not it License and the FreeRTOS license exception along with FreeRTOS; if not it
can be viewed here: http://www.freertos.org/a00114.html and also obtained can be viewed here: http://www.freertos.org/a00114.html and also obtained
by writing to Richard Barry, contact details for whom are available on the by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site. FreeRTOS WEB site.
@ -51,6 +51,7 @@
licensing and training services. licensing and training services.
*/ */
#include <stdlib.h> #include <stdlib.h>
/* Scheduler include files. */ /* Scheduler include files. */
@ -63,23 +64,25 @@
#define x7segSTACK_SIZE configMINIMAL_STACK_SIZE #define x7segSTACK_SIZE configMINIMAL_STACK_SIZE
static portTASK_FUNCTION_PROTO( vRefreshTask, pvParameters ); static void prvRefreshTask( void *pvParameters );
static portTASK_FUNCTION_PROTO( vCountTask, pvParameters ); static void prvCountTask( void *pvParameters );
/* Value to output to 7 segment display
led_digits[0] is the right most digit */
static signed char seg7_digits[4];
void vStart7SegTasks( unsigned portBASE_TYPE uxPriority ) void vStart7SegTasks( unsigned portBASE_TYPE uxPriority )
{ {
xTaskCreate (vRefreshTask, ( signed char * ) "7SegRefresh", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL ); xTaskCreate( prvRefreshTask, ( signed char * ) "7SegRefresh", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL );
xTaskCreate (vCountTask, ( signed char * ) "7SegCount", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL ); xTaskCreate( prvCountTask, ( signed char * ) "7SegCount", x7segSTACK_SIZE, NULL, uxPriority, ( xTaskHandle *) NULL );
} }
/*-----------------------------------------------------------*/
/* Value to output to 7 segment display static void prvRefreshTask( void *pvParameters )
led_digits[0] is the right most digit */
static signed char seg7_digits[4];
static portTASK_FUNCTION_PROTO( vRefreshTask, pvParameters )
{ {
/* This is table 3.3 from the Spartan-3 Starter Kit board user guide */ /* This is table 3.3 from the Spartan-3 Starter Kit board user guide */
const unsigned char bits[16] = { const unsigned char bits[ 16 ] =
{
0x01, 0x01,
0x4f, 0x4f,
0x12, 0x12,
@ -98,13 +101,14 @@ const unsigned char bits[16] = {
0x38 0x38
}; };
const unsigned char apsx[4] = { const unsigned char apsx[4] =
{
0x06, /* 3 */ 0x06, /* 3 */
0x24, /* S */ 0x24, /* S */
0x18, /* P */ 0x18, /* P */
0x08 /* A */ 0x08 /* A */
}; };
portTickType xRefreshRate, xLastRefreshTime; portTickType xRefreshRate, xLastRefreshTime;
/* Digit to scan */ /* Digit to scan */
@ -112,60 +116,66 @@ static int d = 0;
xRefreshRate = 2; xRefreshRate = 2;
/* We need to initialise xLastRefreshTime prior to the first call to /* We need to initialise xLastRefreshTime prior to the first call to
vTaskDelayUntil(). */ vTaskDelayUntil(). */
xLastRefreshTime = xTaskGetTickCount(); xLastRefreshTime = xTaskGetTickCount();
for (;;) for (;;)
{ {
for (d = 0; d < 4; d++) for( d = 0; d < 4; d++ )
{ {
vTaskDelayUntil ( &xLastRefreshTime, xRefreshRate); vTaskDelayUntil ( &xLastRefreshTime, xRefreshRate );
/* Display digit */ /* Display digit */
gpio->out.an = -1; gpio->out.an = -1;
if (seg7_digits[1] == 4 || seg7_digits[1] == 5) { if( ( seg7_digits[ 1 ] == 4 ) || ( seg7_digits[ 1 ] == 5 ) )
gpio->out.digit = apsx[d]; {
} else { gpio->out.digit = apsx[ d ];
gpio->out.digit = bits[seg7_digits[d]]; }
else
{
gpio->out.digit = bits[ seg7_digits[ d ] ];
} }
gpio->out.dp = 1; gpio->out.dp = 1;
gpio->out.an = ~(1 << d); gpio->out.an = ~(1 << d);
} }
} }
} }
/*-----------------------------------------------------------*/
static void prvCountTask( void *pvParameters )
static portTASK_FUNCTION_PROTO( vCountTask, pvParameters )
{ {
portTickType xCountRate, xLastCountTime; portTickType xCountRate, xLastCountTime;
/* Approximately 20HZ */ /* Approximately 20HZ */
xCountRate = configTICK_RATE_HZ/20; xCountRate = configTICK_RATE_HZ / 20;
/* We need to initialise xLastCountTime prior to the first call to /* We need to initialise xLastCountTime prior to the first call to
vTaskDelayUntil(). */ vTaskDelayUntil(). */
xLastCountTime = xTaskGetTickCount(); xLastCountTime = xTaskGetTickCount();
for (;;) for (;;)
{ {
vTaskDelayUntil ( &xLastCountTime, xCountRate); vTaskDelayUntil( &xLastCountTime, xCountRate );
/* Really ugly way to do BCD arithmetic.... */ /* Really ugly way to do BCD arithmetic.... */
seg7_digits[0] -= 1; seg7_digits[ 0 ] -= 1;
if (seg7_digits[0] < 0) { if( seg7_digits[ 0 ] < 0 )
seg7_digits[0] = 9; {
seg7_digits[1] -= 1; seg7_digits[ 0 ] = 9;
if (seg7_digits[1] < 0) { seg7_digits[ 1 ] -= 1;
seg7_digits[1] = 9; if( seg7_digits[ 1 ] < 0 )
seg7_digits[2] -= 1; {
if (seg7_digits[2] < 0) { seg7_digits[ 1 ] = 9;
seg7_digits[2] = 9; seg7_digits[ 2 ] -= 1;
seg7_digits[3] -= 1; if( seg7_digits[ 2 ] < 0 )
if (seg7_digits[3] < 0) { {
seg7_digits[3] = 9; seg7_digits[ 2 ] = 9;
seg7_digits[ 3 ] -= 1;
if( seg7_digits[ 3 ] < 0 )
{
seg7_digits[ 3 ] = 9;
} }
} }
} }
@ -173,6 +183,4 @@ portTickType xCountRate, xLastCountTime;
} }
} }
// Local Variables:
// tab-width:4
// End:

@ -68,7 +68,7 @@
#include "serial.h" #include "serial.h"
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#define COM_BLOCK_RETRYTIME 10 #define comBLOCK_RETRY_TIME 10
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vUARTInterruptHandlerTxWrapper(void) __attribute((naked)); void vUARTInterruptHandlerTxWrapper(void) __attribute((naked));
@ -132,7 +132,7 @@ void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString
for( i = 0; i < usStringLength; i++ ) for( i = 0; i < usStringLength; i++ )
{ {
/* Block until character has been transmitted. */ /* Block until character has been transmitted. */
while( xSerialPutChar( pxPort, *pChNext, COM_BLOCK_RETRYTIME ) != pdTRUE ); pChNext++; while( xSerialPutChar( pxPort, *pChNext, comBLOCK_RETRY_TIME ) != pdTRUE ); pChNext++;
} }
} }

Loading…
Cancel
Save