libpynq  (release 5EID0-2023 version 0.3.0 of 2024-04-25 09:42 )
uart.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2023 Eindhoven University of Technology
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22 #ifndef UART_H
23 #define UART_H
24 #include <stdbool.h>
25 #include <stdint.h>
26 
107 typedef enum { UART0 = 0, UART1 = 1, NUM_UARTS } uart_index_t;
108 
116 extern void uart_init(const int uart);
117 
123 extern void uart_destroy(const int uart);
124 
132 extern void uart_send(const int uart, const uint8_t data);
133 
142 extern uint8_t uart_recv(const int uart);
143 
151 extern bool uart_has_data(const int uart);
152 
160 extern bool uart_has_space(const int uart);
161 
174 extern void uart_reset_fifos(const int uart);
175 
180 #endif // UART_H
uart_recv
uint8_t uart_recv(const int uart)
Receive a byte of data from the specified UART index by waiting for the receive FIFO to have data and...
Definition: uart.c:5
uart_init
void uart_init(const int uart)
Initialize the UART specified by the index with a shared memory handle and a buffer size of 4096 byte...
Definition: uart.c:2
uart_has_space
bool uart_has_space(const int uart)
Check if the transmit FIFO for the specified UART index has space available.
Definition: uart.c:7
UART1
@ UART1
Definition: uart.h:107
NUM_UARTS
@ NUM_UARTS
Definition: uart.h:107
uart_index_t
uart_index_t
Enum of UARTs. Functions use a switch numbered from 0..NUM_UARTS-1. Alternatively,...
Definition: uart.h:107
uart_reset_fifos
void uart_reset_fifos(const int uart)
This function resets both the transmit and receive FIFOs of the UART specified by the uart parameter....
Definition: uart.c:8
uart_destroy
void uart_destroy(const int uart)
Close the shared memory handle for the specified UART index.
Definition: uart.c:3
UART0
@ UART0
Definition: uart.h:107
uart_send
void uart_send(const int uart, const uint8_t data)
Send a byte of data on the specified UART index by waiting for the transmit FIFO to have space and th...
Definition: uart.c:4
uart_has_data
bool uart_has_data(const int uart)
Check if the receive FIFO for the specified UART index has data available.
Definition: uart.c:6