mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-02 13:20:51 +00:00
Add MG_ARCH_FREERTOS_LWIP
This commit is contained in:
1 parent
4c0002e28a
commit
c0a8546330
6 files changed
+92
-30
No files matched your search
@@ -6,6 +6,7 @@
|
||||
#define MG_ARCH_ESP32 3
|
||||
#define MG_ARCH_ESP8266 4
|
||||
#define MG_ARCH_FREERTOS_TCP 5
|
||||
#define MG_ARCH_FREERTOS_LWIP 6
|
||||
|
||||
#if !defined(MG_ARCH)
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
@@ -43,6 +44,7 @@
|
||||
|
||||
#include "arch_esp32.h"
|
||||
#include "arch_esp8266.h"
|
||||
#include "arch_freertos_lwip.h"
|
||||
#include "arch_freertos_tcp.h"
|
||||
#include "arch_unix.h"
|
||||
#include "arch_win32.h"
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#if MG_ARCH == MG_ARCH_FREERTOS_LWIP
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
typedef long suseconds_t;
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if MG_ENABLE_FS
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
#include <lwip/sockets.h>
|
||||
|
||||
#define MG_INT64_FMT "%lld"
|
||||
#define MG_DIRSEP '/'
|
||||
|
||||
// Re-route calloc/free to the FreeRTOS's functions, don't use stdlib
|
||||
static inline void *mg_calloc(int cnt, size_t size) {
|
||||
void *p = pvPortMalloc(cnt * size);
|
||||
if (p != NULL) memset(p, 0, size);
|
||||
return p;
|
||||
}
|
||||
#define calloc(a, b) mg_calloc((a), (b))
|
||||
#define free(a) vPortFree(a)
|
||||
#define malloc(a) pvPortMalloc(a)
|
||||
|
||||
#define gmtime_r(a, b) gmtime(a)
|
||||
|
||||
#endif // MG_ARCH == MG_ARCH_FREERTOS_LWIP
|
||||
+2
-2
@@ -323,7 +323,7 @@ void mg_usleep(unsigned long usecs) {
|
||||
Sleep(usecs / 1000);
|
||||
#elif MG_ARCH == MG_ARCH_ESP8266
|
||||
ets_delay_us(usecs);
|
||||
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP
|
||||
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_FREERTOS_LWIP
|
||||
vTaskDelay(pdMS_TO_TICKS(usecs / 1000));
|
||||
#else
|
||||
usleep((useconds_t) usecs);
|
||||
@@ -337,7 +337,7 @@ unsigned long mg_millis(void) {
|
||||
return esp_timer_get_time() / 1000;
|
||||
#elif MG_ARCH == MG_ARCH_ESP8266
|
||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP
|
||||
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_FREERTOS_LWIP
|
||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
#else
|
||||
struct timespec ts;
|
||||
|
||||
Reference in new issue
Block a user