Work in progress - checked in for backup only.

This commit is contained in:
Richard Barry 2010-06-07 15:24:50 +00:00
parent 02db572328
commit e03f239692
13 changed files with 1240 additions and 336 deletions

View file

@ -60,16 +60,13 @@
#include "task.h"
#include "partest.h"
/* Standard includes. */
#include <string.h>
/* Library includes. */
#include "stm32f10x_lib.h"
#define partstNUM_LEDs 8
#define partstMAX_OUTPUT_LED ( 4 )
#define partstFIRST_LED GPIO_Pin_6
/* Holds the current output state for each of the LEDs. */
static unsigned char ucBitStates[ partstNUM_LEDs ];
static unsigned portSHORT usOutputValue = 0;
/*-----------------------------------------------------------*/
@ -77,60 +74,64 @@ void vParTestInitialise( void )
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure PE14, PD13, PD3 and PD4 output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
/* Configure PC.06, PC.07, PC.08 and PC.09 as output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
memset( ucBitStates, 0x00, sizeof( ucBitStates ) );
GPIO_Init( GPIOC, &GPIO_InitStructure );
}
/*-----------------------------------------------------------*/
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
if( uxLED < partstNUM_LEDs )
unsigned portSHORT usBit;
vTaskSuspendAll();
{
portENTER_CRITICAL();
if( uxLED < partstMAX_OUTPUT_LED )
{
if( xValue != pdFALSE )
usBit = partstFIRST_LED << uxLED;
if( xValue == pdFALSE )
{
ucBitStates[ uxLED ] = pdTRUE;
usBit ^= ( unsigned portSHORT ) 0xffff;
usOutputValue &= usBit;
}
else
{
ucBitStates[ uxLED ] = pdFALSE;
usOutputValue |= usBit;
}
GPIO_WriteBit( GPIOB, ( GPIO_Pin_8 << uxLED ), ucBitStates[ uxLED ] );
}
portEXIT_CRITICAL();
GPIO_Write( GPIOC, usOutputValue );
}
}
xTaskResumeAll();
}
/*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
if( uxLED < partstNUM_LEDs )
unsigned portSHORT usBit;
vTaskSuspendAll();
{
portENTER_CRITICAL();
if( uxLED < partstMAX_OUTPUT_LED )
{
ucBitStates[ uxLED ] = !ucBitStates[ uxLED ];
GPIO_WriteBit( GPIOB, ( GPIO_Pin_8 << uxLED ), ucBitStates[ uxLED ] );
usBit = partstFIRST_LED << uxLED;
if( usOutputValue & usBit )
{
usOutputValue &= ~usBit;
}
else
{
usOutputValue |= usBit;
}
GPIO_Write( GPIOC, usOutputValue );
}
portEXIT_CRITICAL();
}
xTaskResumeAll();
}
/*-----------------------------------------------------------*/
portBASE_TYPE xGetLEDState( unsigned portBASE_TYPE uxLED )
{
if( uxLED < partstNUM_LEDs )
{
return ( portBASE_TYPE ) ucBitStates[ uxLED ];
}
else
{
return 0;
}
}

View file

@ -0,0 +1 @@
Only include one of the two ParTest source files in your build at any one time.