Skip to content

Commit 805c653

Browse files
galenhzpfalcon
authored andcommitted
extmod/modlwip: Initial commit of the lwip network stack module
1 parent 22cb7cd commit 805c653

4 files changed

Lines changed: 1053 additions & 0 deletions

File tree

extmod/lwip-include/arch/cc.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef __CC_H__
2+
#define __CC_H__
3+
4+
#include <stdint.h>
5+
6+
// Generate lwip's internal types from stdint
7+
8+
typedef uint8_t u8_t;
9+
typedef int8_t s8_t;
10+
typedef uint16_t u16_t;
11+
typedef int16_t s16_t;
12+
typedef uint32_t u32_t;
13+
typedef int32_t s32_t;
14+
15+
typedef u32_t mem_ptr_t;
16+
17+
#define U16_F "hu"
18+
#define S16_F "hd"
19+
#define X16_F "hx"
20+
#define U32_F "u"
21+
#define S32_F "d"
22+
#define X32_F "x"
23+
24+
#define X8_F "02x"
25+
#define SZT_F "u"
26+
27+
#define BYTE_ORDER LITTLE_ENDIAN
28+
29+
#define LWIP_CHKSUM_ALGORITHM 2
30+
31+
#include <assert.h>
32+
#define LWIP_PLATFORM_DIAG(x)
33+
#define LWIP_PLATFORM_ASSERT(x) { assert(1); }
34+
35+
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
36+
#define PACK_STRUCT_FIELD(x) x
37+
#define PACK_STRUCT_STRUCT __attribute__((packed))
38+
#define PACK_STRUCT_BEGIN
39+
#define PACK_STRUCT_END
40+
41+
#endif /* __ARCH_CC_H__ */

extmod/lwip-include/arch/perf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef __PERF_H__
2+
#define __PERF_H__
3+
4+
#define PERF_START /* null definition */
5+
#define PERF_STOP(x) /* null definition */
6+
7+
#endif /* __PERF_H__ */

extmod/lwip-include/lwipopts.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef __LWIPOPTS_H__
2+
#define __LWIPOPTS_H__
3+
4+
// We're running without an OS for this port. We don't provide any services except light protection.
5+
#define NO_SYS 1
6+
7+
#define SYS_LIGHTWEIGHT_PROT 1
8+
#include <stdint.h>
9+
typedef uint32_t sys_prot_t;
10+
11+
#define TCP_LISTEN_BACKLOG 1
12+
13+
// We'll put these into a proper ifdef once somebody implements an ethernet driver
14+
#define LWIP_ARP 0
15+
#define LWIP_ETHERNET 0
16+
17+
#define LWIP_DNS 1
18+
19+
#define LWIP_NETCONN 0
20+
#define LWIP_SOCKET 0
21+
22+
#ifdef MICROPY_PY_LWIP_SLIP
23+
#define LWIP_HAVE_SLIPIF 1
24+
#endif
25+
26+
// For now, we can simply define this as a macro for the timer code. But this function isn't
27+
// universal and other ports will need to do something else. It may be necessary to move
28+
// things like this into a port-provided header file.
29+
#define sys_now HAL_GetTick
30+
31+
#endif
32+

0 commit comments

Comments
 (0)