Deluge Firmware 1.3.0
Build date: 2025.04.16
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 <stdint.h>
20
21/*
22 * ================= DEBUGGING TEXT OUTPUT =================
23 *
24 * To get some debugging text output from the Deluge, ideally you’ll be using a J-link,
25 * and can then use its RTT utility. To tell the firmware build to include this text
26 * generation and outputting, go to src/drivers/All_CPUs/uart_all_cpus/uart_all_cpus.h and
27 * set ENABLE_TEXT_OUTPUT to 1. The fact that this flag is in a file labelled “uart” will seem
28 * to make no sense because RTT output has nothing to do with UART. This is because before I
29 * realised RTT was a thing, this flag would instead send the debugging text out of the MIDI DIN port,
30 * and MIDI is UART. If you’re not using a J-link and want to see the debugging text,
31 * this might be what you want to do. If so, go to src/drivers/RZA1/cpu_specific.h,
32 * and set HAVE_RTT to 0. Though this configuration hasn’t been tested for a while...
33 */
34#ifndef ENABLE_TEXT_OUTPUT
35#define ENABLE_TEXT_OUTPUT 0
36#endif
37
38struct UartItem { // Exactly 8 bytes, so can align nicely to cache line
39 uint16_t txBufferWritePos;
40 uint16_t txBufferReadPos;
41 uint16_t txBufferReadPosAfterTransfer;
42 uint8_t txSending;
43 uint8_t shouldDoConsecutiveTransferAfter; // Applies to MIDI only - for PIC, always tries to do this
44};
45
46extern struct UartItem uartItems[];
47
48extern void initUartDMA();
49uint8_t uartGetChar(int32_t item, char* readData);
50uint32_t* uartGetCharWithTiming(int32_t timingCaptureItem, char* readData);
51void uartPutCharBack(int32_t item);
52void uartInsertFakeChar(int32_t item, char data);
53void uartPrintln(char const* output);
54void uartPrint(char const* output);
55void uartPrintNumber(int32_t number);
56void uartPrintNumberSameLine(int32_t number);
57void uartPrintlnFloat(float number);
58void uartPrintFloat(float number);
59
60void uartFlushIfNotSending(int32_t item);
61int32_t uartGetTxBufferFullnessByItem(int32_t item);
62int32_t uartGetTxBufferSpace(int32_t item);
63void uartDrain(uint32_t item);
64
65extern void tx_interrupt(int32_t item);
Definition uart.h:38