mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-08 16:11:18 +00:00
33 files changed
+64
-61
No files matched your search
@@ -120,13 +120,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/stm32/nucleo-f7" ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/stm32/nucleo-f7.*-make-" ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
run: make -C examples/stm32/nucleo-f746zg-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make -C examples/stm32/nucleo-f746zg-freertos test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
run: make -C examples/stm32/nucleo-f746zg-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make -C examples/stm32/nucleo-f746zg-freertos-tcp test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
run: make -C examples/stm32/nucleo-f746zg-freertos-tcp test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
- run: echo GO=0 >> $GITHUB_ENV ; if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-f7.*-cube-'; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: echo GO=0 >> $GITHUB_ENV ; if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-f7.*-cube-'; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
@@ -142,13 +142,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with: { fetch-depth: 2 }
|
with: { fetch-depth: 2 }
|
||||||
- run: if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/stm32/nucleo-f4" ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/stm32/nucleo-f4.*-make-" ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
run: make -C examples/stm32/nucleo-f429zi-make-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make -C examples/stm32/nucleo-f429zi-freertos test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
run: make -C examples/stm32/nucleo-f429zi-make-freertos-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}}
|
||||||
- run: echo GO=0 >> $GITHUB_ENV ; if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-f4.*-cube-'; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: echo GO=0 >> $GITHUB_ENV ; if ./test/match_changed_files.sh '^src|examples/stm32/nucleo-f4.*-cube-'; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: make -C test/cube test PROJECTS=../../examples/stm32/nucleo-f429zi-cube-baremetal-builtin VCON_API_KEY=${{secrets.VCON_API_KEY}} DEVICE=2
|
run: make -C test/cube test PROJECTS=../../examples/stm32/nucleo-f429zi-cube-baremetal-builtin VCON_API_KEY=${{secrets.VCON_API_KEY}} DEVICE=2
|
||||||
@@ -162,7 +162,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with: { fetch-depth: 3 }
|
with: { fetch-depth: 3 }
|
||||||
- run: if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/stm32/nucleo-h7" ; then echo GO=1 >> $GITHUB_ENV ; fi
|
- run: if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/stm32/nucleo-h7.*-make-" ; then echo GO=1 >> $GITHUB_ENV ; fi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi
|
run: sudo apt -y update; sudo apt -y install gcc-arm-none-eabi
|
||||||
- if: ${{ env.GO == 1 }}
|
- if: ${{ env.GO == 1 }}
|
||||||
@@ -224,10 +224,10 @@ jobs:
|
|||||||
- path: esp32/uart-bridge
|
- path: esp32/uart-bridge
|
||||||
- path: esp8266/http-client-server
|
- path: esp8266/http-client-server
|
||||||
- path: stm32/nucleo-f429zi-make-baremetal-builtin
|
- path: stm32/nucleo-f429zi-make-baremetal-builtin
|
||||||
- path: stm32/nucleo-f429zi-freertos
|
- path: stm32/nucleo-f429zi-make-freertos-builtin
|
||||||
- path: stm32/nucleo-f429zi-rndis
|
- path: stm32/nucleo-f429zi-rndis
|
||||||
- path: stm32/nucleo-f746zg-make-baremetal-builtin
|
- path: stm32/nucleo-f746zg-make-baremetal-builtin
|
||||||
- path: stm32/nucleo-f746zg-freertos
|
- path: stm32/nucleo-f746zg-make-freertos-builtin
|
||||||
- path: stm32/nucleo-f746zg-freertos-tcp
|
- path: stm32/nucleo-f746zg-freertos-tcp
|
||||||
- path: stm32/nucleo-f746zg-rndis
|
- path: stm32/nucleo-f746zg-rndis
|
||||||
- path: stm32/nucleo-h743zi-make-baremetal-builtin
|
- path: stm32/nucleo-h743zi-make-baremetal-builtin
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
# FreeRTOS Web device dashboard on NUCLEO-F429ZI
|
|
||||||
|
|
||||||
See https://mongoose.ws/tutorials/stm32/nucleo-f429zi-freertos/
|
|
||||||
@@ -33,7 +33,7 @@ static void timer_fn(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
gpio_output(LED); // Setup green LED
|
gpio_output(LED); // Setup blue LED
|
||||||
uart_init(UART_DEBUG, 115200); // Initialise debug printf
|
uart_init(UART_DEBUG, 115200); // Initialise debug printf
|
||||||
ethernet_init(); // Initialise ethernet pins
|
ethernet_init(); // Initialise ethernet pins
|
||||||
MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000));
|
MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000));
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
|
|||||||
|
# FreeRTOS Web device dashboard on NUCLEO-F429ZI
|
||||||
|
|
||||||
|
See https://mongoose.ws/tutorials/stm32/all-make-freertos-builtin/
|
||||||
+24
-1
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2022 Cesanta Software Limited
|
// Copyright (c) 2022 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
// https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
|
// https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
|
||||||
|
// https://www.st.com/resource/en/datasheet/stm32f429zi.pdf
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -11,12 +12,19 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#define BIT(x) (1UL << (x))
|
#define BIT(x) (1UL << (x))
|
||||||
#define SETBITS(R, CLEARMASK, SETMASK) (R) = ((R) & ~(CLEARMASK)) | (SETMASK)
|
#define SETBITS(R, CLEARMASK, SETMASK) (R) = ((R) & ~(CLEARMASK)) | (SETMASK)
|
||||||
#define PIN(bank, num) ((((bank) - 'A') << 8) | (num))
|
#define PIN(bank, num) ((((bank) - 'A') << 8) | (num))
|
||||||
#define PINNO(pin) (pin & 255)
|
#define PINNO(pin) (pin & 255)
|
||||||
#define PINBANK(pin) (pin >> 8)
|
#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
|
||||||
|
|
||||||
// 6.3.3: APB1 clock <= 45MHz; APB2 clock <= 90MHz
|
// 6.3.3: APB1 clock <= 45MHz; APB2 clock <= 90MHz
|
||||||
// 3.5.1, Table 11: configure flash latency (WS) in accordance to clock freq
|
// 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
|
// 33.4: The AHB clock must be at least 25 MHz when Ethernet is used
|
||||||
@@ -88,7 +96,6 @@ static inline void irq_exti_attach(uint16_t pin) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void uart_init(USART_TypeDef *uart, unsigned long baud) {
|
static inline void uart_init(USART_TypeDef *uart, unsigned long baud) {
|
||||||
// https://www.st.com/resource/en/datasheet/stm32f429zi.pdf
|
|
||||||
uint8_t af = 7; // Alternate function
|
uint8_t af = 7; // Alternate function
|
||||||
uint16_t rx = 0, tx = 0; // pins
|
uint16_t rx = 0, tx = 0; // pins
|
||||||
uint32_t freq = 0; // Bus frequency. UART1 is on APB2, rest on APB1
|
uint32_t freq = 0; // Bus frequency. UART1 is on APB2, rest on APB1
|
||||||
@@ -130,6 +137,22 @@ static inline uint32_t rng_read(void) {
|
|||||||
return RNG->DR;
|
return RNG->DR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void ethernet_init(void) {
|
||||||
|
// Initialise Ethernet. Enable MAC GPIO pins, see
|
||||||
|
// https://www.farnell.com/datasheets/2014265.pdf section 6.10
|
||||||
|
uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7),
|
||||||
|
PIN('B', 13), PIN('C', 1), PIN('C', 4),
|
||||||
|
PIN('C', 5), PIN('G', 11), PIN('G', 13)};
|
||||||
|
for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) {
|
||||||
|
gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE,
|
||||||
|
GPIO_PULL_NONE, 11); // 11 is the Ethernet function
|
||||||
|
}
|
||||||
|
NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler
|
||||||
|
SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first!
|
||||||
|
RCC->AHB1ENR |=
|
||||||
|
RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN;
|
||||||
|
}
|
||||||
|
|
||||||
#define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 39.1
|
#define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 39.1
|
||||||
|
|
||||||
// Helper macro for MAC generation
|
// Helper macro for MAC generation
|
||||||
File renamed without changes.
+1
-22
@@ -1,15 +1,10 @@
|
|||||||
// Copyright (c) 2022 Cesanta Software Limited
|
// Copyright (c) 2022-2023 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#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
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||||
@@ -27,22 +22,6 @@ static void timer_fn(void *arg) {
|
|||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ethernet_init(void) {
|
|
||||||
// Initialise Ethernet. Enable MAC GPIO pins, see
|
|
||||||
// https://www.farnell.com/datasheets/2014265.pdf section 6.10
|
|
||||||
uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7),
|
|
||||||
PIN('B', 13), PIN('C', 1), PIN('C', 4),
|
|
||||||
PIN('C', 5), PIN('G', 11), PIN('G', 13)};
|
|
||||||
for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) {
|
|
||||||
gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE,
|
|
||||||
GPIO_PULL_NONE, 11); // 11 is the Ethernet function
|
|
||||||
}
|
|
||||||
NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler
|
|
||||||
SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first!
|
|
||||||
RCC->AHB1ENR |=
|
|
||||||
RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void server(void *args) {
|
static void server(void *args) {
|
||||||
struct mg_mgr mgr; // Initialise Mongoose event manager
|
struct mg_mgr mgr; // Initialise Mongoose event manager
|
||||||
mg_mgr_init(&mgr); // and attach it to the interface
|
mg_mgr_init(&mgr); // and attach it to the interface
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,3 +0,0 @@
|
|||||||
# FreeRTOS Web device dashboard on NUCLEO-F746ZG
|
|
||||||
|
|
||||||
See https://mongoose.ws/tutorials/stm32/nucleo-f746zg-freertos/
|
|
||||||
@@ -33,7 +33,7 @@ static void timer_fn(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
gpio_output(LED); // Setup green LED
|
gpio_output(LED); // Setup blue LED
|
||||||
uart_init(UART_DEBUG, 115200); // Initialise debug printf
|
uart_init(UART_DEBUG, 115200); // Initialise debug printf
|
||||||
ethernet_init(); // Initialise ethernet pins
|
ethernet_init(); // Initialise ethernet pins
|
||||||
MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000));
|
MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000));
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
|
|||||||
|
# FreeRTOS Web device dashboard on NUCLEO-F746ZG
|
||||||
|
|
||||||
|
See https://mongoose.ws/tutorials/stm32/all-make-freertos-builtin/
|
||||||
+23
-1
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2022 Cesanta Software Limited
|
// Copyright (c) 2022 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
// https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
|
// https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
|
||||||
|
// https://www.st.com/resource/en/datasheet/stm32f746zg.pdf
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -17,6 +18,12 @@
|
|||||||
#define PINNO(pin) (pin & 255)
|
#define PINNO(pin) (pin & 255)
|
||||||
#define PINBANK(pin) (pin >> 8)
|
#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
|
/* System clock
|
||||||
5.3.3: APB1 clock <= 54MHz; APB2 clock <= 108MHz
|
5.3.3: APB1 clock <= 54MHz; APB2 clock <= 108MHz
|
||||||
3.3.2, Table 5: configure flash latency (WS) in accordance to clock freq
|
3.3.2, Table 5: configure flash latency (WS) in accordance to clock freq
|
||||||
@@ -90,7 +97,6 @@ static inline void irq_exti_attach(uint16_t pin) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void uart_init(USART_TypeDef *uart, unsigned long baud) {
|
static inline void uart_init(USART_TypeDef *uart, unsigned long baud) {
|
||||||
// https://www.st.com/resource/en/datasheet/stm32f746zg.pdf
|
|
||||||
uint8_t af = 7; // Alternate function
|
uint8_t af = 7; // Alternate function
|
||||||
uint16_t rx = 0, tx = 0; // pins
|
uint16_t rx = 0, tx = 0; // pins
|
||||||
uint32_t freq = 0; // Bus frequency. UART1 is on APB2, rest on APB1
|
uint32_t freq = 0; // Bus frequency. UART1 is on APB2, rest on APB1
|
||||||
@@ -132,6 +138,22 @@ static inline uint32_t rng_read(void) {
|
|||||||
return RNG->DR;
|
return RNG->DR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void ethernet_init(void) {
|
||||||
|
// Initialise Ethernet. Enable MAC GPIO pins, see
|
||||||
|
// https://www.farnell.com/datasheets/2014265.pdf section 6.10
|
||||||
|
uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7),
|
||||||
|
PIN('B', 13), PIN('C', 1), PIN('C', 4),
|
||||||
|
PIN('C', 5), PIN('G', 11), PIN('G', 13)};
|
||||||
|
for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) {
|
||||||
|
gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE,
|
||||||
|
GPIO_PULL_NONE, 11); // 11 is the Ethernet function
|
||||||
|
}
|
||||||
|
NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler
|
||||||
|
SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first!
|
||||||
|
RCC->AHB1ENR |=
|
||||||
|
RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN;
|
||||||
|
}
|
||||||
|
|
||||||
#define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 41.1
|
#define UUID ((uint8_t *) UID_BASE) // Unique 96-bit chip ID. TRM 41.1
|
||||||
|
|
||||||
// Helper macro for MAC generation
|
// Helper macro for MAC generation
|
||||||
File renamed without changes.
+1
-22
@@ -1,15 +1,10 @@
|
|||||||
// Copyright (c) 2022 Cesanta Software Limited
|
// Copyright (c) 2022-2023 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#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
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||||
@@ -27,22 +22,6 @@ static void timer_fn(void *arg) {
|
|||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ethernet_init(void) {
|
|
||||||
// Initialise Ethernet. Enable MAC GPIO pins, see
|
|
||||||
// https://www.farnell.com/datasheets/2014265.pdf section 6.10
|
|
||||||
uint16_t pins[] = {PIN('A', 1), PIN('A', 2), PIN('A', 7),
|
|
||||||
PIN('B', 13), PIN('C', 1), PIN('C', 4),
|
|
||||||
PIN('C', 5), PIN('G', 11), PIN('G', 13)};
|
|
||||||
for (size_t i = 0; i < sizeof(pins) / sizeof(pins[0]); i++) {
|
|
||||||
gpio_init(pins[i], GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_INSANE,
|
|
||||||
GPIO_PULL_NONE, 11); // 11 is the Ethernet function
|
|
||||||
}
|
|
||||||
NVIC_EnableIRQ(ETH_IRQn); // Setup Ethernet IRQ handler
|
|
||||||
SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL; // Use RMII. Goes first!
|
|
||||||
RCC->AHB1ENR |=
|
|
||||||
RCC_AHB1ENR_ETHMACEN | RCC_AHB1ENR_ETHMACTXEN | RCC_AHB1ENR_ETHMACRXEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void server(void *args) {
|
static void server(void *args) {
|
||||||
struct mg_mgr mgr; // Initialise Mongoose event manager
|
struct mg_mgr mgr; // Initialise Mongoose event manager
|
||||||
mg_mgr_init(&mgr); // and attach it to the interface
|
mg_mgr_init(&mgr); // and attach it to the interface
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user