Skip to content

Commit

Permalink
stm32/network_wiznet5k: Fix build error with wiznet5k and lwip enabled.
Browse files Browse the repository at this point in the history
Commit 4dba04a refactored the network code
but the combination of MICROPY_PY_WIZNET5K=5500 and MICROPY_PY_LWIP=1
broke.
  • Loading branch information
iabdalkader authored and dpgeorge committed Dec 30, 2021
1 parent 959e6f7 commit 8af9dbb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ports/stm32/mpconfigport.h
Expand Up @@ -253,7 +253,11 @@ extern const struct _mp_obj_type_t mp_network_cyw43_type;
#endif

#if MICROPY_PY_WIZNET5K
#if MICROPY_PY_LWIP
extern const struct _mp_obj_type_t mod_network_nic_type_wiznet5k;
#else
extern const struct _mod_network_nic_type_t mod_network_nic_type_wiznet5k;
#endif
#define MICROPY_HW_NIC_WIZNET5K { MP_ROM_QSTR(MP_QSTR_WIZNET5K), MP_ROM_PTR(&mod_network_nic_type_wiznet5k) },
#else
#define MICROPY_HW_NIC_WIZNET5K
Expand Down
4 changes: 4 additions & 0 deletions ports/stm32/mpnetworkport.c
Expand Up @@ -48,6 +48,10 @@
// Poll lwIP every 128ms
#define LWIP_TICK(tick) (((tick) & ~(SYSTICK_DISPATCH_NUM_SLOTS - 1) & 0x7f) == 0)

#if MICROPY_PY_WIZNET5K
void wiznet5k_poll(void);
#endif

u32_t sys_now(void) {
return mp_hal_ticks_ms();
}
Expand Down
4 changes: 2 additions & 2 deletions ports/stm32/network_wiznet5k.c
Expand Up @@ -269,15 +269,15 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size
mp_hal_pin_obj_t rst = pin_find(args[2]);

// Access the existing object, if it has been constructed with the same hardware interface
if (wiznet5k_obj.base.type == &mod_network_nic_type_wiznet5k) {
if (wiznet5k_obj.base.type == (mp_obj_type_t *)&mod_network_nic_type_wiznet5k) {
if (!(wiznet5k_obj.spi == spi && wiznet5k_obj.cs == cs && wiznet5k_obj.rst == rst
&& wiznet5k_obj.netif.flags != 0)) {
wiznet5k_deinit();
}
}

// Init the wiznet5k object
wiznet5k_obj.base.type = &mod_network_nic_type_wiznet5k;
wiznet5k_obj.base.type = (mp_obj_type_t *)&mod_network_nic_type_wiznet5k;
wiznet5k_obj.cris_state = 0;
wiznet5k_obj.spi = spi;
wiznet5k_obj.cs = cs;
Expand Down

0 comments on commit 8af9dbb

Please sign in to comment.