mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 13:31:58 -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;
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
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.
|
||||||
|
@ -73,10 +73,11 @@
|
||||||
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