mirror of
https://github.com/D-Modem/hardware.git
synced 2026-11-28 17:48:05 -08:00
As DCE the board now works out the computer's baud rate from what it
types, like a Hayes modem, so the host's speed setting doesn't have to
match the terminal's.
- PIO (autobaud.pio) times each low/high stretch on the RX pin while the
UART keeps the pin.
- src/core/autobaud.c decodes those timings at every standard rate
(110-230400) and picks the one they fit: bit length vs the shortest
stretch, edges on bit boundaries, framing/parity, then the slowest rate
whose edges score near the best.
- The characters it learned from ("AT") are decoded and passed on; the
UART switches only once the line is idle.
- Re-learns on 3 framing errors in 2 s, AUTOBAUD_RESTART, or a new peer.
- Baud mode setting (saved, settings byte 7): auto (learn as DCE, host's
as DTE), host, learn. Vendor requests 8 SET_BAUD_MODE and
9 AUTOBAUD_RESTART; GET_INFO grows to 14 bytes with flags
BAUD_LOCKED/BAUD_LEARNING and the baud mode.
- Tests: detector suite (every rate, 5 formats, jitter, rate error,
glitches, mid-character starts), 5 new core tests, and the emulator
test drives "AT\r" at 9600 and "ATI3\r" at 115200 onto GP1 with PIO
stepped per CPU cycle.
- Docs: firmware README, PROTOCOL.md, SPEC.md 5.7 and 6.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013PRsUCpxazyipPn5UGGkF8
23 lines
794 B
C
23 lines
794 B
C
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* Copyright (C) 2026 Neo-Desktop
|
|
*/
|
|
// Test waveforms: the line timings a capture would see for some characters.
|
|
#pragma once
|
|
#include <stddef.h>
|
|
#include "../src/core/hal.h"
|
|
|
|
#define WAVE_MAX 8192
|
|
typedef struct {
|
|
uint32_t n;
|
|
bool high[WAVE_MAX];
|
|
uint32_t ticks[WAVE_MAX];
|
|
} wave_t;
|
|
|
|
// Characters sent at baud * (1 + err), each edge moved by up to +-jitter of
|
|
// a bit, gap_bits of idle between characters. Starts at the first start bit;
|
|
// the run still going at the end (the final stop bit and idle) isn't included.
|
|
void wave_make(wave_t *w, uint32_t hz, uint32_t baud, double err, const uart_format_t *f,
|
|
const uint8_t *msg, size_t len, double gap_bits, double jitter);
|
|
double wave_rnd(void); // 0..1, repeatable
|