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