]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/serial.c
Demo project only:
[freertos] / FreeRTOS / Demo / CORTEX_A9_Cyclone_V_SoC_DK / serial.c
diff --git a/FreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/serial.c b/FreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/serial.c
new file mode 100644 (file)
index 0000000..1384ebd
--- /dev/null
@@ -0,0 +1,158 @@
+/*\r
+ FreeRTOS V8.1.2 - 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     !<<\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
+ 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 SERIAL PORT DRIVER.\r
+\r
+       This file just maps generic functions used by FreeRTOS example code to the\r
+       simple UART drivers provided by Altera.\r
+*/\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "queue.h"\r
+#include "semphr.h"\r
+\r
+/* Demo application includes. */\r
+#include "serial.h"\r
+\r
+/* Altera library includes. */\r
+#include "uart0_support.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * See the serial2.h header file.\r
+ */\r
+xComPortHandle xSerialPortInitMinimal( uint32_t ulWantedBaud, UBaseType_t uxQueueLength )\r
+{\r
+       /* Just call into the Altera support function, which has its own parameters,\r
+       so the parameters passed in here are not used. */\r
+       ( void ) ulWantedBaud;\r
+       ( void ) uxQueueLength;\r
+       uart0_init();\r
+\r
+       return ( xComPortHandle ) 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime )\r
+{\r
+BaseType_t xReturn;\r
+\r
+       /* Just call into the Altera support function, which has its own parameters,\r
+       so the parameters passed in here are not used. */\r
+       ( void ) pxPort;\r
+       ( void ) xBlockTime;\r
+\r
+       *pcRxedChar = uart0_getc();\r
+\r
+       if( *pcRxedChar != -1 )\r
+       {\r
+               xReturn = pdPASS;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
+{\r
+       /* Just call into the Altera support function, which has its own parameters,\r
+       so the parameters passed in here are not used. */\r
+       ( void ) pxPort;\r
+\r
+       uart0_print( ( char * ) pcString );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )\r
+{\r
+char cOutBytes[ 2 ];\r
+\r
+       /* Just call into the Altera support function, which has its own parameters,\r
+       so the parameters passed in here are not used. */\r
+       ( void ) pxPort;\r
+\r
+       cOutBytes[ 0 ] = cOutChar;\r
+       cOutBytes[ 1 ] = 0x00;\r
+       uart0_print( cOutBytes );\r
+\r
+       return pdPASS;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vSerialClose(xComPortHandle xPort)\r
+{\r
+       /* Not supported as not required by the demo application. */\r
+       ( void ) xPort;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r