8000 stmhal: Add wiznet5k module, to control WIZnet ethernet adaptor. · sparkfun/circuitpython@bcf041f · GitHub
[go: up one dir, main page]

Skip to content

Commit bcf041f

Browse files
committed
stmhal: Add wiznet5k module, to control WIZnet ethernet adaptor.
Allows to create socket objects that support TCP and UDP in server and client mode. Interface is very close to standard Python socket class, except bind and accept do not work the same (due to hardware not supporting them in the usual way). Not compiled by default. To compile this module, use: make MICROPY_PY_WIZNET5K=1
1 parent cdd40f1 commit bcf041f

File tree

7 files changed

+595
-2
lines changed

7 files changed

+595
-2
lines changed

drivers/wiznet5k/ethernet/wizchip_conf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,12 @@ void wizchip_getnetinfo(wiz_NetInfo* pnetinfo)
606606
getGAR(pnetinfo->gw);
607607
getSUBR(pnetinfo->sn);
608608
getSIPR(pnetinfo->ip);
609+
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
610+
pnetinfo->sn[0] = _SUBN_[0];
611+
pnetinfo->sn[1] = _SUBN_[1];
612+
pnetinfo->sn[2] = _SUBN_[2];
613+
pnetinfo->sn[3] = _SUBN_[3];
614+
#endif
609615
pnetinfo->dns[0]= _DNS_[0];
610616
pnetinfo->dns[1]= _DNS_[1];
611617
pnetinfo->dns[2]= _DNS_[2];

drivers/wiznet5k/internet/dns/dns.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
//#include "Ethernet/socket.h"
5656
//#include "Internet/DNS/dns.h"
57-
#include "../../Ethernet/socket.h"
57+
#include "../../ethernet/socket.h"
5858
#include "dns.h"
5959

6060
#ifdef _DNS_DEBUG_

stmhal/Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ endif
99
BUILD ?= build-$(BOARD)
1010

1111
include ../py/mkenv.mk
12+
-include mpconfigport.mk
1213

1314
# qstr definitions (must come before including py.mk)
1415
QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h
@@ -41,7 +42,7 @@ INC += -I$(FATFS_DIR)/src
4142
INC += -I$(CC3K_DIR)
4243

4344
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
44-
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
45+
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_CORTEX_M4) $(COPT)
4546
CFLAGS += -Iboards/$(BOARD)
4647

4748
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$(@:.elf=.map) --cref
@@ -196,6 +197,19 @@ SRC_CC3K = $(addprefix $(CC3K_DIR)/,\
196197
pybcc3k.c \
197198
)
198199

200+
ifeq ($(MICROPY_PY_WIZNET5K),1)
201+
WIZNET5K_DIR=drivers/wiznet5k
202+
INC += -I$(TOP)/$(WIZNET5K_DIR)
203+
CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=1
204+
SRC_MOD += modwiznet5k.c
205+
SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
206+
ethernet/w5200/w5200.c \
207+
ethernet/wizchip_conf.c \
208+
ethernet/socket.c \
209+
internet/dns/dns.c \
210+
)
211+
endif
212+
199213
OBJ =
200214
OBJ += $(PY_O)
201215
OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o))
@@ -205,6 +219,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_HAL:.c=.o))
205219
OBJ += $(addprefix $(BUILD)/, $(SRC_USBDEV:.c=.o))
206220
OBJ += $(addprefix $(BUILD)/, $(SRC_FATFS:.c=.o))
207221
OBJ += $(addprefix $(BUILD)/, $(SRC_CC3K:.c=.o))
222+
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
208223
OBJ += $(BUILD)/pins_$(BOARD).o
209224

210225
# We put ff.o and stm32f4xx_hal_sd.o into the first 16K section with the ISRs.

0 commit comments

Comments
 (0)
0