ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
pio_tx_rx_driver.h
Go to the documentation of this file.
1
2
3/*
4 * ether2ser - Ethernet <-> synchronous V.24 (RS-232/V.28) bridge
5 *
6 * File: src/drivers/pio_tx_rx_driver.h
7 * Purpose: PIO TX clock driver API and baudrate definitions.
8 *
9 * SPDX-License-Identifier: Apache-2.0
10 *
11 * Copyright (c) 2026 Florian <f.leuze@outlook.de>
12 */
13
14#ifndef PIO_TX_RX_DRIVER_H
15#define PIO_TX_RX_DRIVER_H
16// Related headers
17
18// Standard library headers
19#include <stdbool.h>
20#include <stdint.h>
21
22// Library Headers
23#include "hardware/pio.h"
24
25// Project Headers
26#include "drivers/gpio_driver.h"
27#include "drivers/v24_config.h"
28
29// Generated headers
30
31typedef struct
32{
34 bool rts_set;
35 PIO tx_pio;
36 uint tx_sm;
37 PIO rx_pio;
38 uint rx_sm;
41 volatile uint32_t cts_toggle_seq;
43
50void tx_clock_init(PIO pio, uint pio_sm, V24_CONFIG_T* config);
51
56bool tx_poll(void);
57
63bool tx_put(uint8_t data);
64
71void rx_clock_init(PIO pio, uint pio_sm, V24_RX_POLARITIES_T* polarities);
72
78bool rx_get(uint8_t* data);
79
85void init_v24_config(V24_CONFIG_T* config, V24_BAUDRATE_T baudrate);
86
92void reinit_v24_config(V24_CONFIG_T* config, V24_BAUDRATE_T baudrate);
93
97void led_mirror_init(void);
98
106
114
119const v24_runtime_t* get_v24_runtime(void);
120
125uint32_t tx_clock_get_cts_toggle_seq(void);
126
130void tx_clock_hard_reset(void);
131
135void rx_clock_hard_reset(void);
136
141bool rx_clock_poll_stall(void);
142
143#endif /* PIO_TX_RX_DRIVER_H */
bool tx_put(uint8_t data)
Queue one byte to the TX PIO FIFO.
void tx_clock_init(PIO pio, uint pio_sm, V24_CONFIG_T *config)
Initialize TX clock/data PIO state machine.
bool tx_poll(void)
Poll TX completion/holdoff state and manage RTS release.
bool rx_get(uint8_t *data)
Read one received byte from RX PIO FIFO.
bool rx_clock_poll_stall(void)
Poll RX FIFO stall events and update the provided event counter.
void reinit_v24_config(V24_CONFIG_T *config, V24_BAUDRATE_T baudrate)
Reinitialize V.24 runtime configuration and derived timing values.
void tx_clock_hard_reset(void)
Hard-reset TX SM state to discard queued/in-flight bytes.
const v24_runtime_t * get_v24_runtime(void)
Returns a pointer to the v24 runtime.
uint32_t tx_clock_get_cts_toggle_seq(void)
Read current CTS edge sequence counter.
void led_mirror_init(void)
Initialize optional LED activity mirror PIO program.
void rx_clock_hard_reset(void)
Disable RX Path, clear fifos, restart SMs and CLKDIV and enable again.
void rx_clock_update_settings(V24_RX_POLARITIES_T *polarities)
Apply RX runtime settings to an already configured RX PIO SM. Take note that this function relies on ...
void tx_clock_update_settings(V24_CONFIG_T *config)
Apply TX runtime settings to an already configured TX PIO SM. Take note that this function relies on ...
void rx_clock_init(PIO pio, uint pio_sm, V24_RX_POLARITIES_T *polarities)
Initialize RX clock/data PIO state machine.
void init_v24_config(V24_CONFIG_T *config, V24_BAUDRATE_T baudrate)
Initialize V.24 runtime configuration structure.
Runtime V.24 configuration and TX holdoff state.
Definition v24_config.h:87
RX/input polarity configuration.
Definition v24_config.h:65
volatile uint32_t cts_toggle_seq
uint32_t tx_rts_holdoff_us
V24_BAUDRATE_T
Supported synchronous V.24 baudrates.
Definition v24_config.h:32