mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-13 10:15:00 +00:00
Use UART_DEBUG
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user