mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Add very basic serial CLI to the Zynq demo - needs a lot of tidy up yet!
This commit is contained in:
parent
51ea2639a9
commit
d310ac4552
|
@ -32,6 +32,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option id="xilinx.gnu.compiler.dircategory.includes.1516519458" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" valueType="includePath">
|
<option id="xilinx.gnu.compiler.dircategory.includes.1516519458" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/FreeRTOS_Source/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/FreeRTOS_Source/include}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/FreeRTOS-Plus-CLI}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Standard_Demo_Tasks/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Standard_Demo_Tasks/include}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/FreeRTOS_Source/portable/GCC/ARM_CA9}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/FreeRTOS_Source/portable/GCC/ARM_CA9}""/>
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
<linkedResources>
|
||||||
|
<link>
|
||||||
|
<name>src/FreeRTOS-Plus-CLI</name>
|
||||||
|
<type>2</type>
|
||||||
|
<locationURI>FREERTOS_ROOT/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>src/FreeRTOS_Source</name>
|
<name>src/FreeRTOS_Source</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
|
@ -34,6 +39,11 @@
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
<locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common</locationURI>
|
<locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common</locationURI>
|
||||||
</link>
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>src/UARTCommandConsole.c</name>
|
||||||
|
<type>1</type>
|
||||||
|
<locationURI>FREERTOS_ROOT/FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_CLI_Demos/UARTCommandConsole.c</locationURI>
|
||||||
|
</link>
|
||||||
</linkedResources>
|
</linkedResources>
|
||||||
<filteredResources>
|
<filteredResources>
|
||||||
<filter>
|
<filter>
|
||||||
|
|
|
@ -128,6 +128,8 @@ void vApplicationIdleHook( void );
|
||||||
void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
|
void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
|
||||||
void vApplicationTickHook( void );
|
void vApplicationTickHook( void );
|
||||||
|
|
||||||
|
XScuGic xInterruptController;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
int main( void )
|
int main( void )
|
||||||
|
@ -155,7 +157,6 @@ static void prvSetupHardware( void )
|
||||||
{
|
{
|
||||||
BaseType_t xStatus;
|
BaseType_t xStatus;
|
||||||
XScuGic_Config *pxGICConfig;
|
XScuGic_Config *pxGICConfig;
|
||||||
XScuGic xInterruptController;
|
|
||||||
|
|
||||||
/* Ensure no interrupts execute while the scheduler is in an inconsistent
|
/* Ensure no interrupts execute while the scheduler is in an inconsistent
|
||||||
state. Interrupts are automatically enabled when the scheduler is
|
state. Interrupts are automatically enabled when the scheduler is
|
||||||
|
|
|
@ -228,6 +228,11 @@ extern void vRegTest2Implementation( void );
|
||||||
extern void vRegisterSampleCLICommands( void );
|
extern void vRegisterSampleCLICommands( void );
|
||||||
extern void vRegisterFileSystemCLICommands( void );
|
extern void vRegisterFileSystemCLICommands( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The task that manages the FreeRTOS+CLI input and output.
|
||||||
|
*/
|
||||||
|
extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* The following two variables are used to communicate the status of the
|
/* The following two variables are used to communicate the status of the
|
||||||
|
@ -240,10 +245,6 @@ volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;
|
||||||
|
|
||||||
void main_full( void )
|
void main_full( void )
|
||||||
{
|
{
|
||||||
/* The baud rate setting here has no effect, hence it is set to 0 to
|
|
||||||
make that obvious. */
|
|
||||||
// xSerialPortInitMinimal( 0, mainUART_QUEUE_LENGTHS );
|
|
||||||
|
|
||||||
/* Start all the other standard demo/test tasks. The have not particular
|
/* Start all the other standard demo/test tasks. The have not particular
|
||||||
functionality, but do demonstrate how to use the FreeRTOS API and test the
|
functionality, but do demonstrate how to use the FreeRTOS API and test the
|
||||||
kernel port. */
|
kernel port. */
|
||||||
|
@ -260,7 +261,7 @@ void main_full( void )
|
||||||
|
|
||||||
/* Start the tasks that implements the command console on the UART, as
|
/* Start the tasks that implements the command console on the UART, as
|
||||||
described above. */
|
described above. */
|
||||||
// vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );
|
vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );
|
||||||
|
|
||||||
/* Register the standard CLI commands. */
|
/* Register the standard CLI commands. */
|
||||||
// vRegisterSampleCLICommands();
|
// vRegisterSampleCLICommands();
|
||||||
|
@ -294,7 +295,7 @@ void main_full( void )
|
||||||
for( ;; );
|
for( ;; );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
#error Fails when the tick hook is used
|
|
||||||
static void prvCheckTask( void *pvParameters )
|
static void prvCheckTask( void *pvParameters )
|
||||||
{
|
{
|
||||||
portTickType xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;
|
portTickType xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;
|
||||||
|
|
|
@ -1,82 +1,83 @@
|
||||||
/*
|
/*
|
||||||
FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 Real Time Engineers Ltd.
|
FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 Real Time Engineers Ltd.
|
||||||
All rights reserved
|
All rights reserved
|
||||||
|
|
||||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||||
|
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
* *
|
* *
|
||||||
* FreeRTOS provides completely free yet professionally developed, *
|
* FreeRTOS provides completely free yet professionally developed, *
|
||||||
* robust, strictly quality controlled, supported, and cross *
|
* robust, strictly quality controlled, supported, and cross *
|
||||||
* platform software that has become a de facto standard. *
|
* platform software that has become a de facto standard. *
|
||||||
* *
|
* *
|
||||||
* Help yourself get started quickly and support the FreeRTOS *
|
* Help yourself get started quickly and support the FreeRTOS *
|
||||||
* project by purchasing a FreeRTOS tutorial book, reference *
|
* project by purchasing a FreeRTOS tutorial book, reference *
|
||||||
* manual, or both from: http://www.FreeRTOS.org/Documentation *
|
* manual, or both from: http://www.FreeRTOS.org/Documentation *
|
||||||
* *
|
* *
|
||||||
* Thank you! *
|
* Thank you! *
|
||||||
* *
|
* *
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
This file is part of the FreeRTOS distribution.
|
This file is part of the FreeRTOS distribution.
|
||||||
|
|
||||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
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
|
the terms of the GNU General Public License (version 2) as published by the
|
||||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||||
|
|
||||||
>>! NOTE: The modification to the GPL is included to allow you to distribute
|
>>! NOTE: The modification to the GPL is included to allow you to distribute
|
||||||
>>! a combined work that includes FreeRTOS without being obliged to provide
|
>>! a combined work that includes FreeRTOS without being obliged to provide
|
||||||
>>! the source code for proprietary components outside of the FreeRTOS
|
>>! the source code for proprietary components outside of the FreeRTOS
|
||||||
>>! kernel.
|
>>! kernel.
|
||||||
|
|
||||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
FOR A PARTICULAR PURPOSE. Full license text is available from the following
|
FOR A PARTICULAR PURPOSE. Full license text is available from the following
|
||||||
link: http://www.freertos.org/a00114.html
|
link: http://www.freertos.org/a00114.html
|
||||||
|
|
||||||
1 tab == 4 spaces!
|
1 tab == 4 spaces!
|
||||||
|
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
* *
|
* *
|
||||||
* Having a problem? Start by reading the FAQ "My application does *
|
* Having a problem? Start by reading the FAQ "My application does *
|
||||||
* not run, what could be wrong?" *
|
* not run, what could be wrong?" *
|
||||||
* *
|
* *
|
||||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||||
* *
|
* *
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
|
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
|
||||||
license and Real Time Engineers Ltd. contact details.
|
license and Real Time Engineers Ltd. contact details.
|
||||||
|
|
||||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||||
|
|
||||||
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
|
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
|
||||||
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
|
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||||
licenses offer ticketed support, indemnification and middleware.
|
licenses offer ticketed support, indemnification and middleware.
|
||||||
|
|
||||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||||
engineered and independently SIL3 certified version for use in safety and
|
engineered and independently SIL3 certified version for use in safety and
|
||||||
mission critical applications that require provable dependability.
|
mission critical applications that require provable dependability.
|
||||||
|
|
||||||
1 tab == 4 spaces!
|
1 tab == 4 spaces!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART2.
|
BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART2.
|
||||||
|
|
||||||
***Note*** This example uses queues to send each character into an interrupt
|
***Note*** This example uses queues to send each character into an interrupt
|
||||||
service routine and out of an interrupt service routine individually. This
|
service routine and out of an interrupt service routine individually. This
|
||||||
is done to demonstrate queues being used in an interrupt, and to deliberately
|
is done to demonstrate queues being used in an interrupt, and to deliberately
|
||||||
load the system to test the FreeRTOS port. It is *NOT* meant to be an
|
load the system to test the FreeRTOS port. It is *NOT* meant to be an
|
||||||
example of an efficient implementation. An efficient implementation should
|
example of an efficient implementation. An efficient implementation should
|
||||||
use the DMA, and only use FreeRTOS API functions when enough has been
|
use the DMA, and only use FreeRTOS API functions when enough has been
|
||||||
received to warrant a task being unblocked to process the data.
|
received to warrant a task being unblocked to process the data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Scheduler includes. */
|
/* Scheduler includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "semphr.h"
|
#include "semphr.h"
|
||||||
#include "comtest2.h"
|
#include "comtest2.h"
|
||||||
|
@ -84,35 +85,104 @@
|
||||||
/* Demo application includes. */
|
/* Demo application includes. */
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
|
/* Xilinx includes. */
|
||||||
|
#include "xuartps.h"
|
||||||
|
#include "xscugic.h"
|
||||||
|
#include "xil_exception.h"
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static XUartPs xUARTInstance;
|
||||||
|
extern XScuGic xInterruptController;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvISRHandler( void *pvUnused, uint32_t ulEvent, uint32_t ulUnused2 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See the serial2.h header file.
|
* See the serial2.h header file.
|
||||||
*/
|
*/
|
||||||
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
xComPortHandle xSerialPortInitMinimal( uint32_t ulWantedBaud, UBaseType_t uxQueueLength )
|
||||||
{
|
{
|
||||||
return NULL;
|
BaseType_t xStatus;
|
||||||
|
XUartPs_Config *pxConfig;
|
||||||
|
|
||||||
|
/* Look up the UART configuration then initialise the dirver. */
|
||||||
|
pxConfig = XUartPs_LookupConfig( XPAR_XUARTPS_0_DEVICE_ID );
|
||||||
|
configASSERT( pxConfig );
|
||||||
|
|
||||||
|
xStatus = XUartPs_CfgInitialize( &xUARTInstance, pxConfig, pxConfig->BaseAddress );
|
||||||
|
configASSERT( xStatus == XST_SUCCESS );
|
||||||
|
|
||||||
|
XUartPs_SetBaudRate( &xUARTInstance, ulWantedBaud );
|
||||||
|
|
||||||
|
XUartPs_SetOperMode( &xUARTInstance, XUARTPS_OPER_MODE_NORMAL );
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )
|
BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )
|
||||||
{
|
{
|
||||||
return 0;
|
TickType_t xTimeOnEntering;
|
||||||
|
const TickType_t xDelay = 10UL / portTICK_PERIOD_MS;
|
||||||
|
BaseType_t xReturn = 0;
|
||||||
|
|
||||||
|
xTimeOnEntering = xTaskGetTickCount();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* Only wanting to receive one key press at a time. */
|
||||||
|
if( XUartPs_Recv( &xUARTInstance, pcRxedChar, sizeof( pcRxedChar ) ) != 0 )
|
||||||
|
{
|
||||||
|
xReturn = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
}
|
||||||
|
} while( ( xTaskGetTickCount() - xTimeOnEntering ) <= xBlockTime );
|
||||||
|
|
||||||
|
return xReturn;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
||||||
{
|
{
|
||||||
|
static const xTxDelay = 10UL / portTICK_PERIOD_MS;
|
||||||
|
uint32_t ulBytesSent = 0UL;
|
||||||
|
|
||||||
|
( void ) pxPort;
|
||||||
|
|
||||||
|
while( ulBytesSent < usStringLength )
|
||||||
|
{
|
||||||
|
ulBytesSent += XUartPs_Send( &xUARTInstance, pcString + ulBytesSent, usStringLength - ulBytesSent );
|
||||||
|
|
||||||
|
while( XUartPs_IsSending( &xUARTInstance ) )
|
||||||
|
{
|
||||||
|
vTaskDelay( xTxDelay );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )
|
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )
|
||||||
{
|
{
|
||||||
|
static const xTxDelay = 10UL / portTICK_PERIOD_MS;
|
||||||
|
|
||||||
|
XUartPs_Send( &xUARTInstance, &cOutChar, sizeof( cOutChar ) );
|
||||||
|
|
||||||
|
while( XUartPs_IsSending( &xUARTInstance ) )
|
||||||
|
{
|
||||||
|
vTaskDelay( xTxDelay );
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vSerialClose( xComPortHandle xPort )
|
void vSerialClose(xComPortHandle xPort)
|
||||||
{
|
{
|
||||||
/* Not supported as not required by the demo application. */
|
/* Not supported as not required by the demo application. */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue