mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-15 18:09:15 +08:00
43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
|
// Copyright (c) 2024 Cesanta Software Limited
|
||
|
// All rights reserved
|
||
|
|
||
|
#include "hal.h"
|
||
|
#include "mongoose.h"
|
||
|
#include "net.h"
|
||
|
|
||
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||
|
|
||
|
static void server(void *args) {
|
||
|
struct mg_mgr mgr; // Initialise Mongoose event manager
|
||
|
mg_mgr_init(&mgr); // and attach it to the interface
|
||
|
mg_log_set(MG_LL_DEBUG); // Set log level
|
||
|
|
||
|
MG_INFO(("Initialising application..."));
|
||
|
web_init(&mgr);
|
||
|
|
||
|
MG_INFO(("Starting event loop"));
|
||
|
for (;;) mg_mgr_poll(&mgr, 1); // Infinite event loop
|
||
|
(void) args;
|
||
|
}
|
||
|
|
||
|
static void blinker(void *args) {
|
||
|
gpio_output(LED1);
|
||
|
for (;;) {
|
||
|
gpio_toggle(LED1);
|
||
|
vTaskDelay(pdMS_TO_TICKS(BLINK_PERIOD_MS));
|
||
|
}
|
||
|
(void) args;
|
||
|
}
|
||
|
|
||
|
int main(void) {
|
||
|
|
||
|
hal_init(); // Cross-platform hardware init
|
||
|
|
||
|
// Start tasks. NOTE: stack sizes are in 32-bit words
|
||
|
xTaskCreate(blinker, "blinker", 128, ":)", configMAX_PRIORITIES - 1, NULL);
|
||
|
xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL);
|
||
|
|
||
|
vTaskStartScheduler(); // This blocks
|
||
|
return 0;
|
||
|
}
|