gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
uart.h
1
2/*
3 * MIT License
4 *
5 * Copyright (c) 2024 Joey Castillo
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26#pragma once
27
28#include <stdint.h>
29#include <stdbool.h>
30#include <stddef.h>
31
48typedef enum {
49 UART_TXPO_0 = 0,
50 UART_TXPO_2,
51 UART_TXPO_0_FLOW_CONTROL,
52 UART_TXPO_NONE = 0xff
54
56typedef enum {
57 UART_RXPO_0 = 0,
58 UART_RXPO_1,
59 UART_RXPO_2,
60 UART_RXPO_3,
61 UART_RXPO_NONE = 0xff
63
68void uart_init(uint32_t baud);
69
73void uart_enable(void);
74
79void uart_set_run_in_standby(bool run_in_standby);
80
85void uart_set_irda_mode(bool irda);
86
92void uart_write(char *data, size_t length);
93
100size_t uart_read(char *data, size_t max_length);
101
107bool uart_read_byte(char *byte);
108
112void uart_disable(void);
113
121void uart_init_instance(uint8_t sercom, uart_txpo_t txpo, uart_rxpo_t rxpo, uint32_t baud);
122
127void uart_set_run_in_standby_instance(uint8_t sercom, bool run_in_standby);
128
134void uart_set_irda_mode_instance(uint8_t sercom, bool irda);
135
140void uart_enable_instance(uint8_t sercom);
141
148void uart_write_instance(uint8_t sercom, char *data, size_t length);
149
157size_t uart_read_instance(uint8_t sercom, char *data, size_t max_length);
158
165bool uart_read_byte_instance(uint8_t sercom, char *byte);
166
171void uart_disable_instance(uint8_t sercom);
172
182void uart_irq_handler(uint8_t sercom);
183
size_t uart_read(char *data, size_t max_length)
Reads data from the UART peripheral for a board with a defined UART_SERCOM.
uart_txpo_t
UART transmit pinout options.
Definition uart.h:48
void uart_disable_instance(uint8_t sercom)
Disables a specific SERCOM UART instance.
Definition uart.c:200
void uart_irq_handler(uint8_t sercom)
UART IRQ handler.
Definition uart.c:204
bool uart_read_byte_instance(uint8_t sercom, char *byte)
Reads a single byte from a specific SERCOM UART instance.
Definition uart.c:183
uart_rxpo_t
UART receive pinout options.
Definition uart.h:56
void uart_set_irda_mode_instance(uint8_t sercom, bool irda)
Sets IRDA mode for a specific SERCOM instance.
Definition uart.c:159
void uart_set_run_in_standby_instance(uint8_t sercom, bool run_in_standby)
Enables a specific SERCOM UART instance.
Definition uart.c:155
void uart_disable(void)
Disables the UART peripheral for a board with a defined UART_SERCOM.
void uart_init_instance(uint8_t sercom, uart_txpo_t txpo, uart_rxpo_t rxpo, uint32_t baud)
initializes a specific SERCOM UART instance.
Definition uart.c:105
void uart_set_run_in_standby(bool run_in_standby)
Sets whether the UART_SERCOM should run in standby mode.
void uart_enable_instance(uint8_t sercom)
Enables a specific SERCOM UART instance.
Definition uart.c:164
void uart_init(uint32_t baud)
Initializes the UART peripheral for a board with a defined UART_SERCOM.
bool uart_read_byte(char *byte)
Reads a single byte from the UART peripheral for a board with a defined UART_SERCOM.
size_t uart_read_instance(uint8_t sercom, char *data, size_t max_length)
Reads data from a specific SERCOM UART instance.
Definition uart.c:174
void uart_write_instance(uint8_t sercom, char *data, size_t length)
Writes data to a specific SERCOM UART instance.
Definition uart.c:168
void uart_write(char *data, size_t length)
Writes data to the UART peripheral for a board with a defined UART_SERCOM.
void uart_set_irda_mode(bool irda)
Sets IRDA mode for the UART_SERCOM.
void uart_enable(void)
Enables the UART peripheral for a board with a defined UART_SERCOM.