Continue Zynq demo - ParTest.c now working (with single LED), but still very much a work in progress.

This commit is contained in:
Richard Barry 2014-01-24 13:27:01 +00:00
parent 1e26b1875f
commit 4c9b5d88ae
6 changed files with 97 additions and 113 deletions

View file

@ -36,7 +36,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/FreeRTOS_Source/portable/GCC/ARM_CA9}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/FreeRTOS_Source/portable/GCC/ARM_CA9}&quot;"/>
</option> </option>
<option id="xilinx.gnu.compiler.misc.other.591008063" name="Other flags" superClass="xilinx.gnu.compiler.misc.other" value="-c -fmessage-length=0" valueType="string"/> <option id="xilinx.gnu.compiler.misc.other.591008063" name="Other flags" superClass="xilinx.gnu.compiler.misc.other" value="-c -fmessage-length=0 -Wextra" valueType="string"/>
<inputType id="xilinx.gnu.arm.c.compiler.input.1279195555" name="C source files" superClass="xilinx.gnu.arm.c.compiler.input"/> <inputType id="xilinx.gnu.arm.c.compiler.input.1279195555" name="C source files" superClass="xilinx.gnu.arm.c.compiler.input"/>
</tool> </tool>
<tool id="xilinx.gnu.arm.cxx.toolchain.compiler.debug.309485210" name="ARM g++ compiler" superClass="xilinx.gnu.arm.cxx.toolchain.compiler.debug"> <tool id="xilinx.gnu.arm.cxx.toolchain.compiler.debug.309485210" name="ARM g++ compiler" superClass="xilinx.gnu.arm.cxx.toolchain.compiler.debug">
@ -55,8 +55,8 @@
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lgcc,-lc,--end-group"/> <listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lgcc,-lc,--end-group"/>
</option> </option>
<option id="xilinx.gnu.c.linker.option.lscript.609053533" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" value="../src/lscript.ld" valueType="string"/> <option id="xilinx.gnu.c.linker.option.lscript.609053533" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" value="../src/lscript.ld" valueType="string"/>
<option id="xilinx.gnu.c.link.option.ldflags.1670905029" superClass="xilinx.gnu.c.link.option.ldflags" value="" valueType="string"/> <option id="xilinx.gnu.c.link.option.ldflags.1670905029" name="Linker Flags" superClass="xilinx.gnu.c.link.option.ldflags" value="" valueType="string"/>
<option id="xilinx.gnu.c.link.option.other.1460714584" superClass="xilinx.gnu.c.link.option.other" valueType="stringList"> <option id="xilinx.gnu.c.link.option.other.1460714584" name="Other options (-XLinker [option])" superClass="xilinx.gnu.c.link.option.other" valueType="stringList">
<listOptionValue builtIn="false" value="-Map=rtosdemo.map"/> <listOptionValue builtIn="false" value="-Map=rtosdemo.map"/>
</option> </option>
<inputType id="xilinx.gnu.linker.input.1414431390" superClass="xilinx.gnu.linker.input"> <inputType id="xilinx.gnu.linker.input.1414431390" superClass="xilinx.gnu.linker.input">

View file

@ -151,7 +151,7 @@ to exclude the API function. */
#define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1 #define INCLUDE_vTaskDelay 1
#define INCLUDE_eTaskGetState 1 #define INCLUDE_eTaskGetState 1
#define INCLUDE_xTimerPendFunctionCallFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1
/* This demo makes use of one or more example stats formatting functions. These /* This demo makes use of one or more example stats formatting functions. These
format the raw data provided by the uxTaskGetSystemState() function in to human format the raw data provided by the uxTaskGetSystemState() function in to human

View file

@ -71,73 +71,57 @@
#include "xscutimer.h" #include "xscutimer.h"
#include "xscugic.h" #include "xscugic.h"
#define XSCUTIMER_CLOCK_HZ XPAR_CPU_CORTEXA9_0_CPU_CLK_FREQ_HZ/2 #define XSCUTIMER_CLOCK_HZ ( XPAR_CPU_CORTEXA9_0_CPU_CLK_FREQ_HZ / 2UL )
static XScuTimer Timer; /* A9 timer counter */
/* /*
* The application must provide a function that configures a peripheral to * The application must provide a function that configures a peripheral to
* create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT() * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT()
* in FreeRTOSConfig.h to call the function. This file contains a function * in FreeRTOSConfig.h to call the function. This file contains a function
* that is suitable for use on the Renesas RZ MPU. * that is suitable for use on the Zynq SoC.
*/ */
void vConfigureTickInterrupt( void ) void vConfigureTickInterrupt( void )
{ {
static XScuGic InterruptController; /* Interrupt controller instance */ static XScuGic xInterruptController; /* Interrupt controller instance */
int Status; BaseType_t xStatus;
extern void FreeRTOS_Tick_Handler( void ); extern void FreeRTOS_Tick_Handler( void );
XScuTimer_Config *ScuConfig; XScuTimer_Config *pxTimerConfig;
XScuGic_Config *IntcConfig; XScuGic_Config *pxGICConfig;
XScuTimer xTimer;
IntcConfig = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID); /* This function is called with the IRQ interrupt disabled, and the IRQ
Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig, IntcConfig->CpuBaseAddress ); interrupt should be left disabled. It is enabled automatically when the
configASSERT( Status == XST_SUCCESS ); scheduler is started. */
/* /* Ensure XScuGic_CfgInitialize() has been called. In this demo it has
* Connect to the interrupt controller already been called from prvSetupHardware() in main(). */
*/ pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
Status = XScuGic_Connect(&InterruptController, XPAR_SCUTIMER_INTR, (Xil_ExceptionHandler) FreeRTOS_Tick_Handler, (void *)&Timer); xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
configASSERT( Status == XST_SUCCESS ); configASSERT( xStatus == XST_SUCCESS );
/* /* Install the FreeRTOS tick handler. */
* Initialize the A9Timer driver. xStatus = XScuGic_Connect(&xInterruptController, XPAR_SCUTIMER_INTR, (Xil_ExceptionHandler) FreeRTOS_Tick_Handler, (void *)&xTimer);
*/ configASSERT( xStatus == XST_SUCCESS );
ScuConfig = XScuTimer_LookupConfig(XPAR_SCUTIMER_DEVICE_ID);
Status = XScuTimer_CfgInitialize(&Timer, ScuConfig, ScuConfig->BaseAddr); /* Initialise the timer. */
pxTimerConfig = XScuTimer_LookupConfig( XPAR_SCUTIMER_DEVICE_ID );
xStatus = XScuTimer_CfgInitialize( &xTimer, pxTimerConfig, pxTimerConfig->BaseAddr );
configASSERT( xStatus == XST_SUCCESS );
configASSERT( Status == XST_SUCCESS ); /* Enable Auto reload mode. */
XScuTimer_EnableAutoReload( &xTimer );
/* /* Load the timer counter register. */
* Enable Auto reload mode. XScuTimer_LoadTimer( &xTimer, XSCUTIMER_CLOCK_HZ / configTICK_RATE_HZ );
*/
XScuTimer_EnableAutoReload(&Timer);
/* /* Start the timer counter and then wait for it to timeout a number of
* Load the timer counter register. times. */
*/ XScuTimer_Start( &xTimer );
XScuTimer_LoadTimer(&Timer, XSCUTIMER_CLOCK_HZ / configTICK_RATE_HZ);
/* /* Enable the interrupt for the xTimer in the interrupt controller. */
* Start the timer counter and then wait for it XScuGic_Enable( &xInterruptController, XPAR_SCUTIMER_INTR );
* to timeout a number of times.
*/
XScuTimer_Start(&Timer);
/* /* Enable the interrupt in the xTimer itself. */
* Enable the interrupt for the Timer in the interrupt controller XScuTimer_EnableInterrupt( &xTimer );
*/
XScuGic_Enable(&InterruptController, XPAR_SCUTIMER_INTR);
/*
* Enable the timer interrupts for timer mode.
*/
XScuTimer_EnableInterrupt(&Timer);
/*
* Do NOT enable interrupts in the ARM processor here.
* This happens when the scheduler is started.
*/
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -156,30 +140,24 @@ void vInitialiseRunTimeStats( void )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
extern XScuGic_Config XScuGic_ConfigTable[];
static const XScuGic_Config *CfgPtr = &XScuGic_ConfigTable[ XPAR_SCUGIC_SINGLE_DEVICE_ID ];
void vApplicationIRQHandler( uint32_t ulICCIAR ) void vApplicationIRQHandler( uint32_t ulICCIAR )
{ {
extern const XScuGic_Config XScuGic_ConfigTable[];
static const XScuGic_VectorTableEntry *pxVectorTable = XScuGic_ConfigTable[ XPAR_SCUGIC_SINGLE_DEVICE_ID ].HandlerTable;
uint32_t ulInterruptID; uint32_t ulInterruptID;
XScuGic_VectorTableEntry *TablePtr; const XScuGic_VectorTableEntry *pxVectorEntry;
//XScuGic_Config *CfgPtr;
//extern XScuGic_Config XScuGic_ConfigTable[];
// CfgPtr = &XScuGic_ConfigTable[ XPAR_SCUGIC_SINGLE_DEVICE_ID ];
/* Re-enable interrupts. */ /* Re-enable interrupts. */
__asm ( "cpsie i" ); __asm ( "cpsie i" );
/* The ID of the interrupt can be obtained by bitwise anding the ICCIAR value /* The ID of the interrupt is obtained by bitwise anding the ICCIAR value
with 0x3FF. */ with 0x3FF. */
ulInterruptID = ulICCIAR & 0x3FFUL; ulInterruptID = ulICCIAR & 0x3FFUL;
configASSERT( ulInterruptID < XSCUGIC_MAX_NUM_INTR_INPUTS ); configASSERT( ulInterruptID < XSCUGIC_MAX_NUM_INTR_INPUTS );
/* Call the function installed in the array of installed handler functions. */
TablePtr = &(CfgPtr->HandlerTable[ ulInterruptID ]);
TablePtr->Handler(TablePtr->CallBackRef);
// intc_func_table[ ulInterruptID ]( 0 ); /* Call the function installed in the array of installed handler functions. */
pxVectorEntry = &( pxVectorTable[ ulInterruptID ] );
pxVectorEntry->Handler( pxVectorEntry->CallBackRef );
} }

View file

@ -76,20 +76,52 @@
/* Demo includes. */ /* Demo includes. */
#include "partest.h" #include "partest.h"
/* Xilinx includes. */
#include "xgpiops.h"
#define partstNUM_LEDS ( 1 )
#define partstDIRECTION_OUTPUT ( 1 )
#define partstOUTPUT_ENABLED ( 1 )
#define partstLED_OUTPUT ( 10 )
/*-----------------------------------------------------------*/
static XGpioPs xGpio;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vParTestInitialise( void ) void vParTestInitialise( void )
{ {
XGpioPs_Config *pxConfigPtr;
BaseType_t xStatus;
/* Initialise the GPIO driver. */
pxConfigPtr = XGpioPs_LookupConfig( XPAR_XGPIOPS_0_DEVICE_ID );
xStatus = XGpioPs_CfgInitialize( &xGpio, pxConfigPtr, pxConfigPtr->BaseAddr );
configASSERT( xStatus == XST_SUCCESS );
/* Enable outputs and set low. */
XGpioPs_SetDirectionPin( &xGpio, partstLED_OUTPUT, partstDIRECTION_OUTPUT );
XGpioPs_SetOutputEnablePin( &xGpio, partstLED_OUTPUT, partstOUTPUT_ENABLED );
XGpioPs_WritePin( &xGpio, partstLED_OUTPUT, 0x0 );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) void vParTestSetLED( UBaseType_t uxLED, BaseType_t xValue )
{ {
( void ) uxLED;
XGpioPs_WritePin( &xGpio, partstLED_OUTPUT, xValue );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{ {
BaseType_t xLEDState;
( void ) uxLED;
xLEDState = XGpioPs_ReadPin( &xGpio, partstLED_OUTPUT );
XGpioPs_WritePin( &xGpio, partstLED_OUTPUT, !xLEDState );
} }

View file

@ -128,12 +128,6 @@ void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName ); void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
void vApplicationTickHook( void ); void vApplicationTickHook( void );
/*
* Creates and verifies different files on the volume, demonstrating the use of
* various different API functions.
*/
extern void vCreateAndVerifySampleFiles( void );
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
int main( void ) int main( void )
@ -159,50 +153,30 @@ int main( void )
static void prvSetupHardware( void ) static void prvSetupHardware( void )
{ {
int Status; BaseType_t xStatus;
XScuGic InterruptController; /* Interrupt controller instance */ XScuGic_Config *pxGICConfig;
extern void FreeRTOS_IRQ_Handler( void ); XScuGic xInterruptController;
extern void FreeRTOS_SWI_Handler( void );
__asm volatile ( "cpsid i" ); /* Ensure no interrupts execute while the scheduler is in an inconsistent
Xil_ExceptionInit(); state. Interrupts are automatically enabled when the scheduler is
started. */
portDISABLE_INTERRUPTS();
XScuGic_Config *IntcConfig; /* The configuration parameters of the /* Obtain the configuration of the GIC. */
interrupt controller */ pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
/*
* Initialize the interrupt controller driver
*/
IntcConfig = XScuGic_LookupConfig(XPAR_SCUGIC_SINGLE_DEVICE_ID);
configASSERT( IntcConfig );
configASSERT( IntcConfig->CpuBaseAddress == ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) );
configASSERT( IntcConfig->DistBaseAddress == configINTERRUPT_CONTROLLER_BASE_ADDRESS );
Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig, IntcConfig->CpuBaseAddress ); /* Sanity check the FreeRTOSConfig.h settings are correct for the
configASSERT( Status == XST_SUCCESS ); hardware. */
configASSERT( pxGICConfig );
configASSERT( pxGICConfig->CpuBaseAddress == ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) );
configASSERT( pxGICConfig->DistBaseAddress == configINTERRUPT_CONTROLLER_BASE_ADDRESS );
// Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_IRQ_INT, (Xil_ExceptionHandler)FreeRTOS_IRQ_Handler, &InterruptController); /* Install a default handler for each GIC interrupt. */
// Xil_ExceptionRegisterHandler( XIL_EXCEPTION_ID_SWI_INT, (Xil_ExceptionHandler)FreeRTOS_SWI_Handler, &InterruptController); xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
configASSERT( xStatus == XST_SUCCESS );
// Xil_ExceptionEnableMask( XIL_EXCEPTION_ALL ); /* Initialise the LED port. */
// Xil_ExceptionEnable(); vParTestInitialise();
/*
* Connect the interrupt controller interrupt handler to the hardware
* interrupt handling logic in the ARM processor.
*/
#if 0
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_UNDEFINED_INT,
(Xil_ExceptionHandler)FreeRTOS_ExHandler,
(void *)4);
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_PREFETCH_ABORT_INT,
(Xil_ExceptionHandler)FreeRTOS_ExHandler,
(void *)4);
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_DATA_ABORT_INT,
(Xil_ExceptionHandler)FreeRTOS_ExHandler,
(void *)8);
#endif
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View file

@ -148,7 +148,7 @@ static xQueueHandle xQueue = NULL;
void main_blinky( void ) void main_blinky( void )
{ {
/* Create the queue. */ /* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) ); xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );
if( xQueue != NULL ) if( xQueue != NULL )
{ {