tweak lwipopts.h

This commit is contained in:
2025-11-09 20:24:50 +06:00
parent a0ca17e68f
commit fd3d66e424
7 changed files with 34 additions and 44 deletions

View File

@@ -32,4 +32,6 @@
#define LWIP_RAND() ((u32_t)rand())
#include "arch/sys_arch.h"
#endif /* LWIP_ARCH_CC_H */

26
port/arch/sys_arch.c Normal file
View File

@@ -0,0 +1,26 @@
#include "sys_arch.h"
#include "ch32fun.h"
#include "lwip/sys.h"
#include "systick.h"
static unsigned long next = 1;
int rand(void) {
next = next * 1103515245 + 12345;
return (unsigned int)(next / 65536) % 32768;
}
void srand(unsigned int seed) { next = seed; }
uint32_t sys_now(void) { return millis(); }
sys_prot_t sys_arch_protect(void) {
__disable_irq();
return 1;
}
void sys_arch_unprotect(sys_prot_t pval) {
(void)pval;
__enable_irq();
}

8
port/arch/sys_arch.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef LWIP_ARCH_SYS_ARCH_H
#define LWIP_ARCH_SYS_ARCH_H
#include <stdint.h>
typedef uint32_t sys_prot_t;
#endif /* LWIP_ARCH_SYS_ARCH_H */