From d76e69f9a7276caf5d900b42889dcd9e0fc0785a Mon Sep 17 00:00:00 2001 From: cpq Date: Wed, 1 Feb 2023 21:08:12 +0000 Subject: [PATCH] Use UART_DEBUG --- examples/stm32/nucleo-f746zg-baremetal/Makefile | 17 ++++++++--------- examples/stm32/nucleo-f746zg-baremetal/main.c | 3 +-- examples/stm32/nucleo-f746zg-baremetal/mcu.h | 4 ++++ .../stm32/nucleo-f746zg-baremetal/syscalls.c | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/stm32/nucleo-f746zg-baremetal/Makefile b/examples/stm32/nucleo-f746zg-baremetal/Makefile index 49b5b89e..d4c0180a 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/Makefile +++ b/examples/stm32/nucleo-f746zg-baremetal/Makefile @@ -1,16 +1,15 @@ TARGET = firmware ROOT ?= $(realpath $(CURDIR)/../../..) CFLAGS ?= -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion \ - -Wformat-truncation -fno-common -Wconversion \ - -g3 -Os -ffunction-sections -fdata-sections -I. -I$(ROOT) \ - -DMG_ARCH=MG_ARCH_NEWLIB -DMIP_DEBUG=1 -DMG_ENABLE_PACKED_FS=1 \ - -DMG_ENABLE_CUSTOM_MILLIS=1 -DxMG_ENABLE_LINES=1 -DMG_ENABLE_MIP=1 \ - -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 $(EXTRA_CFLAGS) + -Wformat-truncation -fno-common -Wconversion \ + -g3 -Os -ffunction-sections -fdata-sections -I. \ + -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 $(EXTRA_CFLAGS) LDFLAGS ?= -Tlink.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map -SOURCES = boot.c main.c syscalls.c \ - $(ROOT)/mongoose.c \ - $(ROOT)/examples/device-dashboard/packed_fs.c \ - $(ROOT)/examples/device-dashboard/net.c +SOURCES = boot.c main.c syscalls.c + +# Add Mongoose-specific flags and source files +CFLAGS += -I../../.. -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_CUSTOM_MILLIS=1 -DMG_ENABLE_MIP=1 -DMG_ENABLE_PACKED_FS=1 +SOURCES += ../../../mongoose.c ../../device-dashboard/net.c ../../device-dashboard/packed_fs.c all build example: $(TARGET).bin diff --git a/examples/stm32/nucleo-f746zg-baremetal/main.c b/examples/stm32/nucleo-f746zg-baremetal/main.c index 05b29a9e..34b49ba9 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/main.c +++ b/examples/stm32/nucleo-f746zg-baremetal/main.c @@ -37,14 +37,13 @@ void EXTI15_10_IRQHandler(void) { // External interrupt handler } int main(void) { - static struct uart *uart = UART3; // Use UART3 - its attached to debug clock_init(); // Set clock to 216MHz systick_init(SYS_FREQUENCY / 1000); // Increment s_ticks every ms gpio_output(LED1); // Setup green LED gpio_output(LED2); // Setup blue LED gpio_input(BTN1); // Set button to input irq_exti_attach(BTN1); // Attach BTN1 to exti - uart_init(uart, 115200); // It is wired to the debug port + uart_init(UART_DEBUG, 115200); // It is wired to the debug port // Initialise Ethernet. Enable MAC GPIO pins, see // https://www.farnell.com/datasheets/2014265.pdf section 6.10 diff --git a/examples/stm32/nucleo-f746zg-baremetal/mcu.h b/examples/stm32/nucleo-f746zg-baremetal/mcu.h index 6acd6417..551cd5db 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/mcu.h +++ b/examples/stm32/nucleo-f746zg-baremetal/mcu.h @@ -158,6 +158,10 @@ struct uart { #define UART2 ((struct uart *) 0x40004400) #define UART3 ((struct uart *) 0x40004800) +#ifndef UART_DEBUG +#define UART_DEBUG UART3 +#endif + static inline void uart_init(struct uart *uart, unsigned long baud) { // https://www.st.com/resource/en/datasheet/stm32f746zg.pdf uint8_t af = 7; // Alternate function diff --git a/examples/stm32/nucleo-f746zg-baremetal/syscalls.c b/examples/stm32/nucleo-f746zg-baremetal/syscalls.c index 3b16ca78..37d46dc8 100644 --- a/examples/stm32/nucleo-f746zg-baremetal/syscalls.c +++ b/examples/stm32/nucleo-f746zg-baremetal/syscalls.c @@ -53,7 +53,7 @@ int _getpid(void) { int _write(int fd, char *ptr, int len) { (void) fd, (void) ptr, (void) len; - if (fd == 1) uart_write_buf(UART3, ptr, (size_t) len); + if (fd == 1) uart_write_buf(UART_DEBUG, ptr, (size_t) len); return -1; }