[sw] Add UART disable tag (#1112)

This commit is contained in:
stnolting 2024-12-03 21:37:11 +01:00 committed by GitHub
commit 66a702d403
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View file

@ -155,6 +155,12 @@ USER_FLAGS += -Wl,--defsym,__neorv32_ram_size=8k
# Adjust maximum heap size
USER_FLAGS += -Wl,--defsym,__neorv32_heap_size=1k
# Reduce library footprint when no UART is synthesized
#USER_FLAGS += -DUART_DISABLED
# Enable link-time-optimization
#USER_FLAGS += -flto
# Additional compiler flags (append to this variable)
#USER_FLAGS += ...

View file

@ -20,6 +20,29 @@
#include <stdarg.h>
#include <ctype.h>
// Drastically reduces the footprint, when knowing that uart is not synthesized anyway.
#ifdef UART_DISABLED
int neorv32_uart_available(neorv32_uart_t *UARTx) { return 0; }
int neorv32_uart_get_rx_fifo_depth(neorv32_uart_t *UARTx) { return 0; }
int neorv32_uart_get_tx_fifo_depth(neorv32_uart_t *UARTx) { return 0; }
void neorv32_uart_setup(neorv32_uart_t *UARTx, uint32_t baudrate, uint32_t irq_mask) {}
void neorv32_uart_enable(neorv32_uart_t *UARTx) {}
void neorv32_uart_disable(neorv32_uart_t *UARTx) {}
void neorv32_uart_rtscts_enable(neorv32_uart_t *UARTx) {}
void neorv32_uart_rtscts_disable(neorv32_uart_t *UARTx) {}
void neorv32_uart_putc(neorv32_uart_t *UARTx, char c) {}
void neorv32_uart_rx_clear(neorv32_uart_t *UARTx) {}
void neorv32_uart_tx_clear(neorv32_uart_t *UARTx) {}
int neorv32_uart_tx_busy(neorv32_uart_t *UARTx) { return 0; }
char neorv32_uart_getc(neorv32_uart_t *UARTx) {return 0; }
int neorv32_uart_char_received(neorv32_uart_t *UARTx) { return 0; }
char neorv32_uart_char_received_get(neorv32_uart_t *UARTx) { return 0; }
void neorv32_uart_puts(neorv32_uart_t *UARTx, const char *s) {}
void neorv32_uart_vprintf(neorv32_uart_t *UARTx, const char *format, va_list args) {}
void neorv32_uart_printf(neorv32_uart_t *UARTx, const char *format, ...) {}
int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int echo) { return 0; }
#else
/**********************************************************************//**
* Check if UART unit was synthesized.
@ -433,3 +456,5 @@ int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int ech
return length;
}
#endif //UART_DISABLED