--- /dev/null
+/*\r
+ FreeRTOS V8.2.0 - Copyright (C) 2015 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
+ 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
+ ***************************************************************************\r
+ >>! NOTE: The modification to the GPL is included to allow you to !<<\r
+ >>! distribute a combined work that includes FreeRTOS without being !<<\r
+ >>! obliged to provide the source code for proprietary components !<<\r
+ >>! outside of the FreeRTOS kernel. !<<\r
+ ***************************************************************************\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 on the following\r
+ link: http://www.freertos.org/a00114.html\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that is more than just the market leader, it *\r
+ * is the industry's de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly while simultaneously helping *\r
+ * to support the FreeRTOS project by purchasing a FreeRTOS *\r
+ * tutorial book, reference manual, or both: *\r
+ * http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading\r
+ the FAQ page "My application does not run, what could be wrong?". Have you\r
+ defined configASSERT()?\r
+\r
+ http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+ embedded software for free we request you assist our global community by\r
+ participating in the support forum.\r
+\r
+ http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+ be as productive as possible as early as possible. Now you can receive\r
+ FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+ Ltd, and the world's leading authority on the world's leading RTOS.\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.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+ Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+ Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and commercial 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 a UARTLite peripheral.\r
+\r
+ NOTE: This is not intended to represent an efficient driver. It is\r
+ designed to test the FreeRTOS port. Normally a UART driver would use a DMA,\r
+ or at least a circular RAM buffer rather than a queue. A task notification\r
+ can then be used to unblock any task that is waiting for a complete message\r
+ once a complete message has been buffered.\r
+*/\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "queue.h"\r
+#include "comtest_strings.h"\r
+\r
+/* Library includes. */\r
+#include "xuartlite.h"\r
+#include "xuartlite_l.h"\r
+\r
+/* Demo application includes. */\r
+#include "serial.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Functions that are installed as the handler for interrupts that are caused by\r
+Rx and Tx events respectively. */\r
+static void prvRxHandler( void *pvUnused, unsigned portBASE_TYPE uxByteCount );\r
+static void prvTxHandler( void *pvUnused, unsigned portBASE_TYPE uxByteCount );\r
+\r
+/* Structure that hold the state of the UARTLite peripheral used by this demo.\r
+This is used by the Xilinx peripheral driver API functions. */\r
+static XUartLite xUartLiteInstance;\r
+\r
+/* The queue used to hold received characters. */\r
+static QueueHandle_t xRxedChars;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )\r
+{\r
+BaseType_t xStatus;\r
+\r
+ /* The standard demo header file requires a baud rate to be passed into this\r
+ function. However, in this case the baud rate is configured when the\r
+ hardware is generated, leaving the ulWantedBaud parameter redundant. */\r
+ ( void ) ulWantedBaud;\r
+\r
+ /* Create the queue used to hold Rx characters. */\r
+ xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );\r
+\r
+ /* If the queue was created correctly, then setup the serial port\r
+ hardware. */\r
+ if( xRxedChars != NULL )\r
+ {\r
+ xStatus = XUartLite_Initialize( &xUartLiteInstance, XPAR_UARTLITE_0_DEVICE_ID );\r
+\r
+ if( xStatus == XST_SUCCESS )\r
+ {\r
+ /* Complete initialisation of the UART and its associated\r
+ interrupts. */\r
+ XUartLite_ResetFifos( &xUartLiteInstance );\r
+\r
+ /* Install the handlers that the standard Xilinx library interrupt\r
+ service routine will call when Rx and Tx events occur\r
+ respectively. */\r
+ XUartLite_SetRecvHandler( &xUartLiteInstance, ( XUartLite_Handler ) prvRxHandler, NULL );\r
+ XUartLite_SetSendHandler( &xUartLiteInstance, ( XUartLite_Handler ) prvTxHandler, NULL );\r
+\r
+ /* Install the standard Xilinx library interrupt handler itself.\r
+ *NOTE* The xPortInstallInterruptHandler() API function must be used\r
+ for this purpose. */\r
+ xStatus = xPortInstallInterruptHandler( XPAR_INTC_0_UARTLITE_0_VEC_ID, ( XInterruptHandler ) XUartLite_InterruptHandler, &xUartLiteInstance );\r
+\r
+ /* Enable the interrupt in the peripheral. */\r
+ XUartLite_EnableIntr( xUartLiteInstance.RegBaseAddress );\r
+\r
+ /* Enable the interrupt in the interrupt controller.\r
+ *NOTE* The vPortEnableInterrupt() API function must be used for this\r
+ purpose. */\r
+ vPortEnableInterrupt( XPAR_INTC_0_UARTLITE_0_VEC_ID );\r
+ }\r
+\r
+ configASSERT( xStatus == pdPASS );\r
+ }\r
+\r
+ /* This demo file only supports a single port but something must be\r
+ returned to comply with the standard demo header file. */\r
+ return ( xComPortHandle ) 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime )\r
+{\r
+portBASE_TYPE xReturn;\r
+\r
+ /* The port handle is not required as this driver only supports one port. */\r
+ ( void ) pxPort;\r
+\r
+ /* Get the next character from the receive queue. Return false if no\r
+ characters are available, or arrive before xBlockTime expires. */\r
+ if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )\r
+ {\r
+ xReturn = pdTRUE;\r
+ }\r
+ else\r
+ {\r
+ xReturn = pdFALSE;\r
+ }\r
+\r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )\r
+{\r
+ ( void ) pxPort;\r
+ ( void ) xBlockTime;\r
+\r
+ XUartLite_Send( &xUartLiteInstance, ( unsigned char * ) &cOutChar, sizeof( cOutChar ) );\r
+ return pdPASS;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
+{\r
+ ( void ) pxPort;\r
+\r
+ /* Output uxStringLength bytes starting from pcString. */\r
+ XUartLite_Send( &xUartLiteInstance, ( unsigned char * ) pcString, usStringLength );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvRxHandler( void *pvUnused, unsigned portBASE_TYPE uxByteCount )\r
+{\r
+signed char cRxedChar;\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+ ( void ) pvUnused;\r
+ ( void ) uxByteCount;\r
+\r
+ /* Place any received characters into the receive queue. */\r
+ while( XUartLite_IsReceiveEmpty( xUartLiteInstance.RegBaseAddress ) == pdFALSE )\r
+ {\r
+ cRxedChar = XUartLite_ReadReg( xUartLiteInstance.RegBaseAddress, XUL_RX_FIFO_OFFSET);\r
+ xQueueSendFromISR( xRxedChars, &cRxedChar, &xHigherPriorityTaskWoken );\r
+ }\r
+\r
+ /* If calling xQueueSendFromISR() caused a task to unblock, and the task\r
+ that unblocked has a priority equal to or greater than the task currently\r
+ in the Running state (the task that was interrupted), then\r
+ xHigherPriorityTaskWoken will have been set to pdTRUE internally within the\r
+ xQueueSendFromISR() API function. If xHigherPriorityTaskWoken is equal to\r
+ pdTRUE then a context switch should be requested to ensure that the\r
+ interrupt returns to the highest priority task that is able to run. */\r
+ portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTxHandler( void *pvUnused, unsigned portBASE_TYPE uxByteCount )\r
+{\r
+ ( void ) pvUnused;\r
+ ( void ) uxByteCount;\r
+\r
+ /* Nothing to do here. The Xilinx library function takes care of the\r
+ transmission. */\r
+ portNOP();\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r