/*\r
- FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 Real Time Engineers Ltd.\r
- All rights reserved\r
-\r
- VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
-\r
- ***************************************************************************\r
- * *\r
- * FreeRTOS provides completely free yet professionally developed, *\r
- * robust, strictly quality controlled, supported, and cross *\r
- * platform software that has become a de facto standard. *\r
- * *\r
- * Help yourself get started quickly and support the FreeRTOS *\r
- * project by purchasing a FreeRTOS tutorial book, reference *\r
- * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
- * *\r
- * Thank you! *\r
- * *\r
- ***************************************************************************\r
-\r
- This file is part of the FreeRTOS distribution.\r
-\r
- FreeRTOS is free software; you can redistribute it and/or modify it under\r
- the terms of the GNU General Public License (version 2) as published by the\r
- Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
-\r
- >>! NOTE: The modification to the GPL is included to allow you to distribute\r
- >>! a combined work that includes FreeRTOS without being obliged to provide\r
- >>! the source code for proprietary components outside of the FreeRTOS\r
- >>! kernel.\r
-\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
- FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
- link: http://www.freertos.org/a00114.html\r
-\r
- 1 tab == 4 spaces!\r
-\r
- ***************************************************************************\r
- * *\r
- * Having a problem? Start by reading the FAQ "My application does *\r
- * not run, what could be wrong?" *\r
- * *\r
- * http://www.FreeRTOS.org/FAQHelp.html *\r
- * *\r
- ***************************************************************************\r
-\r
- http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
- license and Real Time Engineers Ltd. contact details.\r
-\r
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
- including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
- compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
-\r
- http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
- Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
- licenses offer ticketed support, indemnification and middleware.\r
-\r
- http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
- engineered and independently SIL3 certified version for use in safety and\r
- mission critical applications that require provable dependability.\r
-\r
- 1 tab == 4 spaces!\r
-*/\r
+ FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that has become a de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly and support the FreeRTOS *\r
+ * project by purchasing a FreeRTOS tutorial book, reference *\r
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * Thank you! *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+ >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+ >>! a combined work that includes FreeRTOS without being obliged to provide\r
+ >>! the source code for proprietary components outside of the FreeRTOS\r
+ >>! kernel.\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
+ link: http://www.freertos.org/a00114.html\r
+\r
+ 1 tab == 4 spaces!\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Having a problem? Start by reading the FAQ "My application does *\r
+ * not run, what could be wrong?" *\r
+ * *\r
+ * http://www.FreeRTOS.org/FAQHelp.html *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+ license and Real Time Engineers Ltd. contact details.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+ */\r
\r
/*\r
- BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART2.\r
-\r
- ***Note*** This example uses queues to send each character into an interrupt\r
- service routine and out of an interrupt service routine individually. This\r
- is done to demonstrate queues being used in an interrupt, and to deliberately\r
- load the system to test the FreeRTOS port. It is *NOT* meant to be an\r
- example of an efficient implementation. An efficient implementation should\r
- use the DMA, and only use FreeRTOS API functions when enough has been\r
- received to warrant a task being unblocked to process the data.\r
-*/\r
+ BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART2.\r
+\r
+ ***Note*** This example uses queues to send each character into an interrupt\r
+ service routine and out of an interrupt service routine individually. This\r
+ is done to demonstrate queues being used in an interrupt, and to deliberately\r
+ load the system to test the FreeRTOS port. It is *NOT* meant to be an\r
+ example of an efficient implementation. An efficient implementation should\r
+ use the DMA, and only use FreeRTOS API functions when enough has been\r
+ received to warrant a task being unblocked to process the data.\r
+ */\r
\r
/* Scheduler includes. */\r
#include "FreeRTOS.h"\r
+#include "task.h"\r
#include "queue.h"\r
#include "semphr.h"\r
#include "comtest2.h"\r
/* Demo application includes. */\r
#include "serial.h"\r
\r
+/* Xilinx includes. */\r
+#include "xuartps.h"\r
+#include "xscugic.h"\r
+#include "xil_exception.h"\r
+\r
/*-----------------------------------------------------------*/\r
\r
+static XUartPs xUARTInstance;\r
+extern XScuGic xInterruptController;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvISRHandler( void *pvUnused, uint32_t ulEvent, uint32_t ulUnused2 );\r
+\r
/*\r
* See the serial2.h header file.\r
*/\r
-xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )\r
+xComPortHandle xSerialPortInitMinimal( uint32_t ulWantedBaud, UBaseType_t uxQueueLength )\r
{\r
- return NULL;\r
+BaseType_t xStatus;\r
+XUartPs_Config *pxConfig;\r
+\r
+ /* Look up the UART configuration then initialise the dirver. */\r
+ pxConfig = XUartPs_LookupConfig( XPAR_XUARTPS_0_DEVICE_ID );\r
+ configASSERT( pxConfig );\r
+\r
+ xStatus = XUartPs_CfgInitialize( &xUARTInstance, pxConfig, pxConfig->BaseAddress );\r
+ configASSERT( xStatus == XST_SUCCESS );\r
+\r
+ XUartPs_SetBaudRate( &xUARTInstance, ulWantedBaud );\r
+\r
+ XUartPs_SetOperMode( &xUARTInstance, XUARTPS_OPER_MODE_NORMAL );\r
+\r
+ return 0;\r
}\r
/*-----------------------------------------------------------*/\r
\r
-signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
+BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
{\r
- return 0;\r
+TickType_t xTimeOnEntering;\r
+const TickType_t xDelay = 10UL / portTICK_PERIOD_MS;\r
+BaseType_t xReturn = 0;\r
+\r
+ xTimeOnEntering = xTaskGetTickCount();\r
+\r
+ do\r
+ {\r
+ /* Only wanting to receive one key press at a time. */\r
+ if( XUartPs_Recv( &xUARTInstance, pcRxedChar, sizeof( pcRxedChar ) ) != 0 )\r
+ {\r
+ xReturn = 1;\r
+ break;\r
+ }\r
+ else\r
+ {\r
+ vTaskDelay( xDelay );\r
+ }\r
+ } while( ( xTaskGetTickCount() - xTimeOnEntering ) <= xBlockTime );\r
+\r
+ return xReturn;\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
{\r
+static const xTxDelay = 10UL / portTICK_PERIOD_MS;\r
+uint32_t ulBytesSent = 0UL;\r
+\r
+ ( void ) pxPort;\r
+\r
+ while( ulBytesSent < usStringLength )\r
+ {\r
+ ulBytesSent += XUartPs_Send( &xUARTInstance, pcString + ulBytesSent, usStringLength - ulBytesSent );\r
+\r
+ while( XUartPs_IsSending( &xUARTInstance ) )\r
+ {\r
+ vTaskDelay( xTxDelay );\r
+ }\r
+ }\r
}\r
/*-----------------------------------------------------------*/\r
\r
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )\r
{\r
+static const xTxDelay = 10UL / portTICK_PERIOD_MS;\r
+\r
+ XUartPs_Send( &xUARTInstance, &cOutChar, sizeof( cOutChar ) );\r
+\r
+ while( XUartPs_IsSending( &xUARTInstance ) )\r
+ {\r
+ vTaskDelay( xTxDelay );\r
+ }\r
+\r
return 0;\r
}\r
/*-----------------------------------------------------------*/\r
\r
-void vSerialClose( xComPortHandle xPort )\r
+void vSerialClose(xComPortHandle xPort)\r
{\r
/* Not supported as not required by the demo application. */\r
}\r