mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Add LED output to the new MicroBlaze blinky demo - still a work in progress.
This commit is contained in:
parent
ea5ec656f4
commit
9f0bf057e6
|
@ -36,20 +36,21 @@ IF EXIST FreeRTOS_Source Goto END
|
||||||
copy ..\..\..\..\Source\portable\MemMang\heap_2.c FreeRTOS_Source\portable\MemMang
|
copy ..\..\..\..\Source\portable\MemMang\heap_2.c FreeRTOS_Source\portable\MemMang
|
||||||
|
|
||||||
REM Copy the files that define the common demo tasks.
|
REM Copy the files that define the common demo tasks.
|
||||||
copy ..\Common\minimal\dynamic.c Demo_Source\Common_Demo_Files
|
copy ..\..\..\Common\minimal\dynamic.c Demo_Source\Common_Demo_Files
|
||||||
copy ..\Common\minimal\comtest.c Demo_Source\Common_Demo_Files
|
copy ..\..\..\Common\minimal\comtest.c Demo_Source\Common_Demo_Files
|
||||||
copy ..\Common\minimal\GenQTest.c Demo_Source\Common_Demo_Files
|
copy ..\..\..\Common\minimal\GenQTest.c Demo_Source\Common_Demo_Files
|
||||||
copy ..\Common\minimal\TimerDemo.c Demo_Source\Common_Demo_Files
|
copy ..\..\..\Common\minimal\TimerDemo.c Demo_Source\Common_Demo_Files
|
||||||
copy ..\Common\minimal\countsem.c Demo_Source\Common_Demo_Files
|
copy ..\..\..\Common\minimal\countsem.c Demo_Source\Common_Demo_Files
|
||||||
|
|
||||||
REM Copy the common demo file headers.
|
REM Copy the common demo file headers.
|
||||||
copy ..\Common\include\dynamic.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\dynamic.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\comtest.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\comtest.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\comtest2.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\comtest2.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\GenQTest.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\GenQTest.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\serial.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\serial.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\partest.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\partest.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\TimerDemo.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\TimerDemo.h Demo_Source\Common_Demo_Files\include
|
||||||
copy ..\Common\include\countsem.h Demo_Source\Common_Demo_Files\include
|
copy ..\..\..\Common\include\countsem.h Demo_Source\Common_Demo_Files\include
|
||||||
|
copy ..\..\..\Common\include\partest.h Demo_Source\Common_Demo_Files\include
|
||||||
|
|
||||||
: END
|
: END
|
||||||
|
|
|
@ -119,7 +119,7 @@ to exclude the API function. */
|
||||||
#define INCLUDE_vTaskDelayUntil 1
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
#define INCLUDE_vTaskDelay 1
|
#define INCLUDE_vTaskDelay 1
|
||||||
|
|
||||||
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
|
#define configASSERT( x ) if( ( x ) == 0 ) { portDISABLE_INTERRUPTS(); for( ;; ); }
|
||||||
|
|
||||||
#define configINTERRUPT_CONTROLLER_TO_USE XPAR_INTC_SINGLE_DEVICE_ID
|
#define configINTERRUPT_CONTROLLER_TO_USE XPAR_INTC_SINGLE_DEVICE_ID
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
/*
|
||||||
|
FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
||||||
|
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||||
|
* Complete, revised, and edited pdf reference manuals are also *
|
||||||
|
* available. *
|
||||||
|
* *
|
||||||
|
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||||
|
* ensuring you get running as quickly as possible and with an *
|
||||||
|
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||||
|
* the FreeRTOS project to continue with its mission of providing *
|
||||||
|
* professional grade, cross platform, de facto standard solutions *
|
||||||
|
* for microcontrollers - completely free of charge! *
|
||||||
|
* *
|
||||||
|
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||||
|
* *
|
||||||
|
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||||
|
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||||
|
distribute a combined work that includes FreeRTOS without being obliged to
|
||||||
|
provide the source code for proprietary components outside of the FreeRTOS
|
||||||
|
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or 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
|
||||||
|
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
|
||||||
|
by writing to Richard Barry, contact details for whom are available on the
|
||||||
|
FreeRTOS WEB site.
|
||||||
|
|
||||||
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------
|
||||||
|
* Simple parallel port IO routines.
|
||||||
|
*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Kernel includes. */
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
|
||||||
|
/* Demo application includes. */
|
||||||
|
#include "partest.h"
|
||||||
|
|
||||||
|
/* Library includes. */
|
||||||
|
#include "xgpio.h"
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static XGpio xOutputGPIOInstance;
|
||||||
|
static const unsigned portBASE_TYPE uxGPIOOutputChannel = 1UL;
|
||||||
|
static ucCurrentLEDState = 0U;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup the IO for the LED outputs.
|
||||||
|
*/
|
||||||
|
void vParTestInitialise( void )
|
||||||
|
{
|
||||||
|
portBASE_TYPE xStatus;
|
||||||
|
const unsigned char ucSetToOutput = 0U;
|
||||||
|
|
||||||
|
/* Initialize the GPIO. */
|
||||||
|
xStatus = XGpio_Initialize( &xOutputGPIOInstance, XPAR_LEDS_4BITS_DEVICE_ID );
|
||||||
|
if( xStatus == XST_SUCCESS )
|
||||||
|
{
|
||||||
|
/* All LEDs on this channel are going to be outputs. */
|
||||||
|
XGpio_SetDataDirection( &xOutputGPIOInstance, uxGPIOOutputChannel, ucSetToOutput );
|
||||||
|
|
||||||
|
/* Start with all LEDs off. */
|
||||||
|
ucCurrentLEDState = 0U;
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucCurrentLEDState );
|
||||||
|
}
|
||||||
|
|
||||||
|
configASSERT( ( xStatus == XST_SUCCESS ) );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;
|
||||||
|
|
||||||
|
portENTER_CRITICAL();
|
||||||
|
{
|
||||||
|
/* Which IO section does the LED being set/cleared belong to? The
|
||||||
|
4 bit or 5 bit outputs? */
|
||||||
|
if( uxLED <= partstMAX_4BIT_LED )
|
||||||
|
{
|
||||||
|
uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;
|
||||||
|
puxCurrentValue = &uxCurrentOutput4Bit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;
|
||||||
|
puxCurrentValue = &uxCurrentOutput5Bit;
|
||||||
|
uxLED -= partstMAX_4BIT_LED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup the bit mask accordingly. */
|
||||||
|
uxLED = 0x01 << uxLED;
|
||||||
|
|
||||||
|
/* Maintain the current output value. */
|
||||||
|
if( xValue )
|
||||||
|
{
|
||||||
|
*puxCurrentValue |= uxLED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*puxCurrentValue &= ~uxLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write the value to the port. */
|
||||||
|
XGpio_mSetDataReg( uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );
|
||||||
|
}
|
||||||
|
portEXIT_CRITICAL();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
unsigned portBASE_TYPE uxBaseAddress, *puxCurrentValue;
|
||||||
|
|
||||||
|
portENTER_CRITICAL();
|
||||||
|
{
|
||||||
|
/* Which IO section does the LED being toggled belong to? The
|
||||||
|
4 bit or 5 bit outputs? */
|
||||||
|
if( uxLED <= partstMAX_4BIT_LED )
|
||||||
|
{
|
||||||
|
uxBaseAddress = XPAR_LEDS_4BIT_BASEADDR;
|
||||||
|
puxCurrentValue = &uxCurrentOutput4Bit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uxBaseAddress = XPAR_LEDS_POSITIONS_BASEADDR;
|
||||||
|
puxCurrentValue = &uxCurrentOutput5Bit;
|
||||||
|
uxLED -= partstMAX_4BIT_LED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup the bit mask accordingly. */
|
||||||
|
uxLED = 0x01 << uxLED;
|
||||||
|
|
||||||
|
/* Maintain the current output value. */
|
||||||
|
if( *puxCurrentValue & uxLED )
|
||||||
|
{
|
||||||
|
*puxCurrentValue &= ~uxLED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*puxCurrentValue |= uxLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write the value to the port. */
|
||||||
|
XGpio_mSetDataReg(uxBaseAddress, partstCHANNEL_1, *puxCurrentValue );
|
||||||
|
}
|
||||||
|
portEXIT_CRITICAL();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@
|
||||||
#include "xtmrctr.h"
|
#include "xtmrctr.h"
|
||||||
#include "xil_exception.h"
|
#include "xil_exception.h"
|
||||||
#include "microblaze_exceptions_g.h"
|
#include "microblaze_exceptions_g.h"
|
||||||
|
#include "xgpio.h"
|
||||||
|
|
||||||
/* Priorities at which the tasks are created. */
|
/* Priorities at which the tasks are created. */
|
||||||
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||||
|
@ -165,14 +166,16 @@ function. */
|
||||||
static xTimerHandle xLEDTimer = NULL;
|
static xTimerHandle xLEDTimer = NULL;
|
||||||
|
|
||||||
/* Maintains the current LED output state. */
|
/* Maintains the current LED output state. */
|
||||||
static volatile unsigned long ulGPIOState = 0UL;
|
static volatile unsigned char ucGPIOState = 0U;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static XTmrCtr xTimer0Instance;
|
static XTmrCtr xTimer0Instance;
|
||||||
|
static XGpio xOutputGPIOInstance;
|
||||||
|
static const unsigned portBASE_TYPE uxGPIOOutputChannel = 1UL;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
#define JUST_TESTING
|
#define NOT_JUST_TESTING
|
||||||
#ifdef JUST_TESTING
|
#ifdef JUST_TESTING
|
||||||
volatile unsigned long ul1 = 0, ul2 = 0;
|
volatile unsigned long ul1 = 0, ul2 = 0;
|
||||||
|
|
||||||
|
@ -198,6 +201,12 @@ void main( void )
|
||||||
{
|
{
|
||||||
prvSetupHardware();
|
prvSetupHardware();
|
||||||
|
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 0 );
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 1 );
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 2 );
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, 1 << 3 );
|
||||||
|
|
||||||
|
|
||||||
xTaskCreate( vTemp1, ( signed char * ) "Test1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
|
xTaskCreate( vTemp1, ( signed char * ) "Test1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
|
||||||
xTaskCreate( vTemp2, ( signed char * ) "Test2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
|
xTaskCreate( vTemp2, ( signed char * ) "Test2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
|
||||||
|
|
||||||
|
@ -253,8 +262,8 @@ static void vLEDTimerCallback( xTimerHandle xTimer )
|
||||||
a critical section because it is accessed from multiple tasks, and the
|
a critical section because it is accessed from multiple tasks, and the
|
||||||
button interrupt - in this trivial case, for simplicity, the critical
|
button interrupt - in this trivial case, for simplicity, the critical
|
||||||
section is omitted. */
|
section is omitted. */
|
||||||
ulGPIOState |= mainTIMER_CONTROLLED_LED;
|
ucGPIOState |= mainTIMER_CONTROLLED_LED;
|
||||||
//_RB_ MSS_GPIO_set_outputs( ulGPIOState );
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -266,8 +275,8 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
/* The button was pushed, so ensure the LED is on before resetting the
|
/* The button was pushed, so ensure the LED is on before resetting the
|
||||||
LED timer. The LED timer will turn the LED off if the button is not
|
LED timer. The LED timer will turn the LED off if the button is not
|
||||||
pushed within 5000ms. */
|
pushed within 5000ms. */
|
||||||
ulGPIOState &= ~mainTIMER_CONTROLLED_LED;
|
ucGPIOState &= ~mainTIMER_CONTROLLED_LED;
|
||||||
//_RB_ MSS_GPIO_set_outputs( ulGPIOState );
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );
|
||||||
|
|
||||||
/* This interrupt safe FreeRTOS function can be called from this interrupt
|
/* This interrupt safe FreeRTOS function can be called from this interrupt
|
||||||
because the interrupt priority is below the
|
because the interrupt priority is below the
|
||||||
|
@ -330,15 +339,16 @@ unsigned long ulReceivedValue;
|
||||||
because it is accessed from multiple tasks, and the button interrupt
|
because it is accessed from multiple tasks, and the button interrupt
|
||||||
- in this trivial case, for simplicity, the critical section is
|
- in this trivial case, for simplicity, the critical section is
|
||||||
omitted. */
|
omitted. */
|
||||||
if( ( ulGPIOState & mainTASK_CONTROLLED_LED ) != 0 )
|
if( ( ucGPIOState & mainTASK_CONTROLLED_LED ) != 0 )
|
||||||
{
|
{
|
||||||
ulGPIOState &= ~mainTASK_CONTROLLED_LED;
|
ucGPIOState &= ~mainTASK_CONTROLLED_LED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ulGPIOState |= mainTASK_CONTROLLED_LED;
|
ucGPIOState |= mainTASK_CONTROLLED_LED;
|
||||||
}
|
}
|
||||||
//_RB_ MSS_GPIO_set_outputs( ulGPIOState );
|
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,6 +356,23 @@ unsigned long ulReceivedValue;
|
||||||
|
|
||||||
static void prvSetupHardware( void )
|
static void prvSetupHardware( void )
|
||||||
{
|
{
|
||||||
|
portBASE_TYPE xStatus;
|
||||||
|
const unsigned char ucSetToOutput = 0U;
|
||||||
|
|
||||||
|
/* Initialize the GPIO. */
|
||||||
|
xStatus = XGpio_Initialize( &xOutputGPIOInstance, XPAR_LEDS_4BITS_DEVICE_ID );
|
||||||
|
if( xStatus == XST_SUCCESS )
|
||||||
|
{
|
||||||
|
/* All LEDs on this channel are going to be outputs. */
|
||||||
|
XGpio_SetDataDirection( &xOutputGPIOInstance, uxGPIOOutputChannel, ucSetToOutput );
|
||||||
|
|
||||||
|
/* Start with all LEDs off. */
|
||||||
|
ucGPIOState = 0U;
|
||||||
|
XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );
|
||||||
|
}
|
||||||
|
|
||||||
|
configASSERT( ( xStatus == XST_SUCCESS ) );
|
||||||
|
|
||||||
#ifdef MICROBLAZE_EXCEPTIONS_ENABLED
|
#ifdef MICROBLAZE_EXCEPTIONS_ENABLED
|
||||||
microblaze_enable_exceptions();
|
microblaze_enable_exceptions();
|
||||||
#endif
|
#endif
|
||||||
|
@ -449,7 +476,7 @@ extern void vTickISR( void *pvUnused );
|
||||||
|
|
||||||
configASSERT( ( xStatus == pdPASS ) );
|
configASSERT( ( xStatus == pdPASS ) );
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vApplicationClearTimerInterrupt( void )
|
void vApplicationClearTimerInterrupt( void )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue