From 5e3ad2fb19d482092fa6d17068b32fd65e43a75f Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Wed, 2 Aug 2023 11:59:46 -0300 Subject: [PATCH] standardize example names --- .../Makefile | 0 .../README.md | 3 +++ .../hal.h | 21 +++++++++++++++++++ .../link.ld | 0 .../main.c | 11 +--------- .../mongoose.c | 0 .../mongoose.h | 0 .../netif/ethernet.h | 0 .../syscalls.c | 0 .../sysinit.c | 0 .../tusb_config.h | 0 .../usb_descriptors.c | 0 examples/stm32/nucleo-f429zi-rndis/README.md | 3 --- .../Makefile | 0 .../README.md | 3 +++ .../hal.h | 18 ++++++++++++++++ .../link.ld | 0 .../main.c | 13 +----------- .../mongoose.c | 0 .../mongoose.h | 0 .../netif/ethernet.h | 0 .../syscalls.c | 0 .../sysinit.c | 0 .../tusb_config.h | 0 .../usb_descriptors.c | 0 examples/stm32/nucleo-f746zg-rndis/README.md | 3 --- 26 files changed, 47 insertions(+), 28 deletions(-) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/Makefile (100%) create mode 100644 examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/README.md rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/hal.h (85%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/link.ld (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/main.c (84%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/mongoose.c (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/mongoose.h (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/netif/ethernet.h (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/syscalls.c (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/sysinit.c (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/tusb_config.h (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f429zi-make-baremetal-builtin-rndis}/usb_descriptors.c (100%) delete mode 100644 examples/stm32/nucleo-f429zi-rndis/README.md rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/Makefile (100%) create mode 100644 examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/README.md rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/hal.h (87%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/link.ld (100%) rename examples/stm32/{nucleo-f429zi-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/main.c (80%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/mongoose.c (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/mongoose.h (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/netif/ethernet.h (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/syscalls.c (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/sysinit.c (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/tusb_config.h (100%) rename examples/stm32/{nucleo-f746zg-rndis => nucleo-f746zg-make-baremetal-builtin-rndis}/usb_descriptors.c (100%) delete mode 100644 examples/stm32/nucleo-f746zg-rndis/README.md diff --git a/examples/stm32/nucleo-f429zi-rndis/Makefile b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/Makefile similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/Makefile rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/Makefile diff --git a/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/README.md b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/README.md new file mode 100644 index 00000000000..5eefc3b7f9a --- /dev/null +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/README.md @@ -0,0 +1,3 @@ +# RNDIS Web device dashboard on NUCLEO-F429ZI + +See https://mongoose.ws/tutorials/stm32/all-make-baremetal-builtin-rndis/ diff --git a/examples/stm32/nucleo-f429zi-rndis/hal.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/hal.h similarity index 85% rename from examples/stm32/nucleo-f429zi-rndis/hal.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/hal.h index 1c3849d3b76..9d3377667d0 100644 --- a/examples/stm32/nucleo-f429zi-rndis/hal.h +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/hal.h @@ -17,6 +17,13 @@ #define PINNO(pin) (pin & 255) #define PINBANK(pin) (pin >> 8) +#define LED1 PIN('B', 0) // On-board LED pin (green) +#define LED2 PIN('B', 7) // On-board LED pin (blue) +#define LED3 PIN('B', 14) // On-board LED pin (red) + +#define LED LED2 // Use blue LED for blinking + +// System clock // 6.3.3: APB1 clock <= 45MHz; APB2 clock <= 90MHz // 3.5.1, Table 11: configure flash latency (WS) in accordance to clock freq // 33.4: The AHB clock must be at least 25 MHz when Ethernet is used @@ -121,6 +128,20 @@ static inline uint8_t uart_read_byte(USART_TypeDef *uart) { return (uint8_t) (uart->DR & 255); } +static inline void usb_init() { + gpio_init(PIN('A', 11), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, + GPIO_PULL_NONE, 10); // D+ + gpio_init(PIN('A', 12), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, + GPIO_PULL_NONE, 10); // D- + gpio_init(PIN('A', 9), GPIO_MODE_INPUT, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, + GPIO_PULL_NONE, 0); // VBUS + gpio_init(PIN('A', 10), GPIO_MODE_AF, GPIO_OTYPE_OPEN_DRAIN, GPIO_SPEED_HIGH, + GPIO_PULL_UP, 10); // ID + RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; // Enable USB FS clock + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; // VBUS sensing disable + USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; // VBUS sensing enable +} + static inline void rng_init(void) { RCC->AHB2ENR |= RCC_AHB2ENR_RNGEN; RNG->CR |= RNG_CR_RNGEN; diff --git a/examples/stm32/nucleo-f429zi-rndis/link.ld b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/link.ld similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/link.ld rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/link.ld diff --git a/examples/stm32/nucleo-f746zg-rndis/main.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/main.c similarity index 84% rename from examples/stm32/nucleo-f746zg-rndis/main.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/main.c index 6bf7ff83705..228c90e393b 100644 --- a/examples/stm32/nucleo-f746zg-rndis/main.c +++ b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/main.c @@ -5,7 +5,6 @@ #include "mongoose.h" #include "tusb.h" -#define LED PIN('B', 7) // On-board LED pin (blue) static struct mg_tcpip_if *s_ifp; const uint8_t tud_network_mac_address[6] = {2, 2, 0x84, 0x6A, 0x96, 0}; @@ -101,15 +100,7 @@ int main(void) { mg_http_listen(&mgr, "tcp://0.0.0.0:80", fn, &mgr); MG_INFO(("Init USB ...")); - gpio_init(PIN('A', 11), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, - GPIO_PULL_NONE, 10); // D+ - gpio_init(PIN('A', 12), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, - GPIO_PULL_NONE, 10); // D- - gpio_init(PIN('A', 9), GPIO_MODE_INPUT, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, - GPIO_PULL_NONE, 0); // VBUS - gpio_init(PIN('A', 10), GPIO_MODE_AF, GPIO_OTYPE_OPEN_DRAIN, GPIO_SPEED_HIGH, - GPIO_PULL_UP, 10); // ID - RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; // Enable USB FS clock + usb_init(); tusb_init(); MG_INFO(("Init done, starting main loop ...")); diff --git a/examples/stm32/nucleo-f429zi-rndis/mongoose.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/mongoose.c similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/mongoose.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/mongoose.c diff --git a/examples/stm32/nucleo-f429zi-rndis/mongoose.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/mongoose.h similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/mongoose.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/mongoose.h diff --git a/examples/stm32/nucleo-f429zi-rndis/netif/ethernet.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/netif/ethernet.h similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/netif/ethernet.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/netif/ethernet.h diff --git a/examples/stm32/nucleo-f429zi-rndis/syscalls.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/syscalls.c similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/syscalls.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/syscalls.c diff --git a/examples/stm32/nucleo-f429zi-rndis/sysinit.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/sysinit.c similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/sysinit.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/sysinit.c diff --git a/examples/stm32/nucleo-f429zi-rndis/tusb_config.h b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/tusb_config.h similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/tusb_config.h rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/tusb_config.h diff --git a/examples/stm32/nucleo-f429zi-rndis/usb_descriptors.c b/examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/usb_descriptors.c similarity index 100% rename from examples/stm32/nucleo-f429zi-rndis/usb_descriptors.c rename to examples/stm32/nucleo-f429zi-make-baremetal-builtin-rndis/usb_descriptors.c diff --git a/examples/stm32/nucleo-f429zi-rndis/README.md b/examples/stm32/nucleo-f429zi-rndis/README.md deleted file mode 100644 index 495d307f661..00000000000 --- a/examples/stm32/nucleo-f429zi-rndis/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# RNDIS Web device dashboard on NUCLEO-F429ZI - -See https://mongoose.ws/tutorials/stm32/nucleo-f429zi-rndis/ diff --git a/examples/stm32/nucleo-f746zg-rndis/Makefile b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/Makefile similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/Makefile rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/Makefile diff --git a/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/README.md b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/README.md new file mode 100644 index 00000000000..9096bcdd37a --- /dev/null +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/README.md @@ -0,0 +1,3 @@ +# RNDIS Web device dashboard on NUCLEO-F746ZG + +See https://mongoose.ws/tutorials/stm32/all-make-baremetal-builtin-rndis/ diff --git a/examples/stm32/nucleo-f746zg-rndis/hal.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/hal.h similarity index 87% rename from examples/stm32/nucleo-f746zg-rndis/hal.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/hal.h index 36a1b71cf05..1c311dcff26 100644 --- a/examples/stm32/nucleo-f746zg-rndis/hal.h +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/hal.h @@ -17,6 +17,12 @@ #define PINNO(pin) (pin & 255) #define PINBANK(pin) (pin >> 8) +#define LED1 PIN('B', 0) // On-board LED pin (green) +#define LED2 PIN('B', 7) // On-board LED pin (blue) +#define LED3 PIN('B', 14) // On-board LED pin (red) + +#define LED LED2 // Use blue LED for blinking + /* System clock 5.3.3: APB1 clock <= 54MHz; APB2 clock <= 108MHz 3.3.2, Table 5: configure flash latency (WS) in accordance to clock freq @@ -123,6 +129,18 @@ static inline uint8_t uart_read_byte(USART_TypeDef *uart) { return (uint8_t) (uart->RDR & 255); } +static inline void usb_init(void) { + gpio_init(PIN('A', 11), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, + GPIO_PULL_NONE, 10); // D+ + gpio_init(PIN('A', 12), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, + GPIO_PULL_NONE, 10); // D- + gpio_init(PIN('A', 9), GPIO_MODE_INPUT, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, + GPIO_PULL_NONE, 0); // VBUS + gpio_init(PIN('A', 10), GPIO_MODE_AF, GPIO_OTYPE_OPEN_DRAIN, GPIO_SPEED_HIGH, + GPIO_PULL_UP, 10); // ID + RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; // Enable USB FS clock +} + static inline void rng_init(void) { RCC->AHB2ENR |= RCC_AHB2ENR_RNGEN; RNG->CR |= RNG_CR_RNGEN; diff --git a/examples/stm32/nucleo-f746zg-rndis/link.ld b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/link.ld similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/link.ld rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/link.ld diff --git a/examples/stm32/nucleo-f429zi-rndis/main.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/main.c similarity index 80% rename from examples/stm32/nucleo-f429zi-rndis/main.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/main.c index b4bbe32e75e..228c90e393b 100644 --- a/examples/stm32/nucleo-f429zi-rndis/main.c +++ b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/main.c @@ -5,7 +5,6 @@ #include "mongoose.h" #include "tusb.h" -#define LED PIN('B', 7) // On-board LED pin (blue) static struct mg_tcpip_if *s_ifp; const uint8_t tud_network_mac_address[6] = {2, 2, 0x84, 0x6A, 0x96, 0}; @@ -101,17 +100,7 @@ int main(void) { mg_http_listen(&mgr, "tcp://0.0.0.0:80", fn, &mgr); MG_INFO(("Init USB ...")); - gpio_init(PIN('A', 11), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, - GPIO_PULL_NONE, 10); // D+ - gpio_init(PIN('A', 12), GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, - GPIO_PULL_NONE, 10); // D- - gpio_init(PIN('A', 9), GPIO_MODE_INPUT, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, - GPIO_PULL_NONE, 0); // VBUS - gpio_init(PIN('A', 10), GPIO_MODE_AF, GPIO_OTYPE_OPEN_DRAIN, GPIO_SPEED_HIGH, - GPIO_PULL_UP, 10); // ID - RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; // Enable USB FS clock - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS; // VBUS sensing disable - USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN; // VBUS sensing enable + usb_init(); tusb_init(); MG_INFO(("Init done, starting main loop ...")); diff --git a/examples/stm32/nucleo-f746zg-rndis/mongoose.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/mongoose.c similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/mongoose.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/mongoose.c diff --git a/examples/stm32/nucleo-f746zg-rndis/mongoose.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/mongoose.h similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/mongoose.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/mongoose.h diff --git a/examples/stm32/nucleo-f746zg-rndis/netif/ethernet.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/netif/ethernet.h similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/netif/ethernet.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/netif/ethernet.h diff --git a/examples/stm32/nucleo-f746zg-rndis/syscalls.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/syscalls.c similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/syscalls.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/syscalls.c diff --git a/examples/stm32/nucleo-f746zg-rndis/sysinit.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/sysinit.c similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/sysinit.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/sysinit.c diff --git a/examples/stm32/nucleo-f746zg-rndis/tusb_config.h b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/tusb_config.h similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/tusb_config.h rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/tusb_config.h diff --git a/examples/stm32/nucleo-f746zg-rndis/usb_descriptors.c b/examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/usb_descriptors.c similarity index 100% rename from examples/stm32/nucleo-f746zg-rndis/usb_descriptors.c rename to examples/stm32/nucleo-f746zg-make-baremetal-builtin-rndis/usb_descriptors.c diff --git a/examples/stm32/nucleo-f746zg-rndis/README.md b/examples/stm32/nucleo-f746zg-rndis/README.md deleted file mode 100644 index bef64f437c5..00000000000 --- a/examples/stm32/nucleo-f746zg-rndis/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# RNDIS Web device dashboard on NUCLEO-F746ZG - -See https://mongoose.ws/tutorials/stm32/nucleo-f746zg-rndis/