]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/serial.c
58e3e571313eca3463927be3f25a0d7984c5943e
[freertos] / FreeRTOS / Demo / CORTEX_A9_Cyclone_V_SoC_DK / serial.c
1 /*\r
2  * FreeRTOS Kernel V10.2.1\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /*\r
29         BASIC SERIAL PORT DRIVER.\r
30 \r
31         This file just maps generic functions used by FreeRTOS example code to the\r
32         simple UART drivers provided by Altera.\r
33 */\r
34 \r
35 /* Scheduler includes. */\r
36 #include "FreeRTOS.h"\r
37 #include "task.h"\r
38 #include "queue.h"\r
39 #include "semphr.h"\r
40 \r
41 /* Demo application includes. */\r
42 #include "serial.h"\r
43 \r
44 /* Altera library includes. */\r
45 #include "uart0_support.h"\r
46 \r
47 /*-----------------------------------------------------------*/\r
48 \r
49 /*\r
50  * See the serial2.h header file.\r
51  */\r
52 xComPortHandle xSerialPortInitMinimal( uint32_t ulWantedBaud, UBaseType_t uxQueueLength )\r
53 {\r
54         /* Just call into the Altera support function, which has its own parameters,\r
55         so the parameters passed in here are not used. */\r
56         ( void ) ulWantedBaud;\r
57         ( void ) uxQueueLength;\r
58         uart0_init();\r
59 \r
60         return ( xComPortHandle ) 0;\r
61 }\r
62 /*-----------------------------------------------------------*/\r
63 \r
64 BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime )\r
65 {\r
66 BaseType_t xReturn;\r
67 \r
68         /* Just call into the Altera support function, which has its own parameters,\r
69         so the parameters passed in here are not used. */\r
70         ( void ) pxPort;\r
71         ( void ) xBlockTime;\r
72 \r
73         *pcRxedChar = uart0_getc();\r
74 \r
75         if( *pcRxedChar != -1 )\r
76         {\r
77                 xReturn = pdPASS;\r
78         }\r
79         else\r
80         {\r
81                 xReturn = pdFAIL;\r
82         }\r
83 \r
84         return xReturn;\r
85 }\r
86 /*-----------------------------------------------------------*/\r
87 \r
88 void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
89 {\r
90         /* Just call into the Altera support function, which has its own parameters,\r
91         so the parameters passed in here are not used. */\r
92         ( void ) pxPort;\r
93 \r
94         uart0_print( ( char * ) pcString );\r
95 }\r
96 /*-----------------------------------------------------------*/\r
97 \r
98 signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )\r
99 {\r
100 char cOutBytes[ 2 ];\r
101 \r
102         /* Just call into the Altera support function, which has its own parameters,\r
103         so the parameters passed in here are not used. */\r
104         ( void ) pxPort;\r
105 \r
106         cOutBytes[ 0 ] = cOutChar;\r
107         cOutBytes[ 1 ] = 0x00;\r
108         uart0_print( cOutBytes );\r
109 \r
110         return pdPASS;\r
111 }\r
112 /*-----------------------------------------------------------*/\r
113 \r
114 void vSerialClose(xComPortHandle xPort)\r
115 {\r
116         /* Not supported as not required by the demo application. */\r
117         ( void ) xPort;\r
118 }\r
119 /*-----------------------------------------------------------*/\r
120 \r