Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
uart.h
1/*
2 * Copyright © 2015-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19#include <stdbool.h>
20#include <stdint.h>
21
22/*
23 * ================= DEBUGGING TEXT OUTPUT =================
24 *
25 * To get some debugging text output from the Deluge, ideally you’ll be using a J-link,
26 * and can then use its RTT utility. To tell the firmware build to include this text
27 * generation and outputting, go to src/drivers/All_CPUs/uart_all_cpus/uart_all_cpus.h and
28 * set ENABLE_TEXT_OUTPUT to 1. The fact that this flag is in a file labelled “uart” will seem
29 * to make no sense because RTT output has nothing to do with UART. This is because before I
30 * realised RTT was a thing, this flag would instead send the debugging text out of the MIDI DIN port,
31 * and MIDI is UART. If you’re not using a J-link and want to see the debugging text,
32 * this might be what you want to do. If so, go to src/drivers/RZA1/cpu_specific.h,
33 * and set HAVE_RTT to 0. Though this configuration hasn’t been tested for a while...
34 */
35#ifndef ENABLE_TEXT_OUTPUT
36#define ENABLE_TEXT_OUTPUT 0
37#endif
38
39struct UartItem { // Exactly 8 bytes, so can align nicely to cache line
40 uint16_t txBufferWritePos;
41 uint16_t txBufferReadPos;
42 uint16_t txBufferReadPosAfterTransfer;
43 uint8_t txSending;
44 uint8_t shouldDoConsecutiveTransferAfter; // Applies to MIDI only - for PIC, always tries to do this
45};
46
47extern struct UartItem uartItems[];
48
49extern void initUartDMA();
50uint8_t uartGetChar(int32_t item, char* readData);
51// Main-loop only. PIC input is staged in order while acknowledgements are removed.
52bool uartReplacePendingByte(int32_t item, uint8_t value, uint8_t replacement);
53// PIC admission also reserves staging space for one complete DMA ring.
54uint32_t uartGetRxBufferSpace(int32_t item);
55uint32_t* uartGetCharWithTiming(int32_t timingCaptureItem, char* readData);
56void uartPutCharBack(int32_t item);
57void uartInsertFakeChar(int32_t item, char data);
58void uartPrintln(char const* output);
59void uartPrint(char const* output);
60void uartPrintNumber(int32_t number);
61void uartPrintNumberSameLine(int32_t number);
62void uartPrintlnFloat(float number);
63void uartPrintFloat(float number);
64
65void uartFlushIfNotSending(int32_t item);
66int32_t uartGetTxBufferFullnessByItem(int32_t item);
67int32_t uartGetTxBufferSpace(int32_t item);
68void uartDrain(uint32_t item);
69
70extern void tx_interrupt(int32_t item);
Definition uart.h:39