stm32/network_wiznet5k: Fix build error with wiznet5k and lwip enabled.

Commit 4dba04a50f refactored the network code
but the combination of MICROPY_PY_WIZNET5K=5500 and MICROPY_PY_LWIP=1
broke.
This commit is contained in:
iabdalkader 2021-12-29 23:38:16 +02:00 committed by Damien George
parent 959e6f7da9
commit 8af9dbbde1
3 changed files with 10 additions and 2 deletions

View File

@ -253,7 +253,11 @@ extern const struct _mp_obj_type_t mp_network_cyw43_type;
#endif #endif
#if MICROPY_PY_WIZNET5K #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; 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) }, #define MICROPY_HW_NIC_WIZNET5K { MP_ROM_QSTR(MP_QSTR_WIZNET5K), MP_ROM_PTR(&mod_network_nic_type_wiznet5k) },
#else #else
#define MICROPY_HW_NIC_WIZNET5K #define MICROPY_HW_NIC_WIZNET5K

View File

@ -48,6 +48,10 @@
// Poll lwIP every 128ms // Poll lwIP every 128ms
#define LWIP_TICK(tick) (((tick) & ~(SYSTICK_DISPATCH_NUM_SLOTS - 1) & 0x7f) == 0) #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) { u32_t sys_now(void) {
return mp_hal_ticks_ms(); return mp_hal_ticks_ms();
} }

View File

@ -269,7 +269,7 @@ 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]); mp_hal_pin_obj_t rst = pin_find(args[2]);
// Access the existing object, if it has been constructed with the same hardware interface // 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 if (!(wiznet5k_obj.spi == spi && wiznet5k_obj.cs == cs && wiznet5k_obj.rst == rst
&& wiznet5k_obj.netif.flags != 0)) { && wiznet5k_obj.netif.flags != 0)) {
wiznet5k_deinit(); wiznet5k_deinit();
@ -277,7 +277,7 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size
} }
// Init the wiznet5k object // 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.cris_state = 0;
wiznet5k_obj.spi = spi; wiznet5k_obj.spi = spi;
wiznet5k_obj.cs = cs; wiznet5k_obj.cs = cs;