extmod/modnetwork: Define network interfaces in port config files.
So this network implementation becomes more generic.
This commit is contained in:
parent
c13e25c329
commit
4dba04a50f
|
@ -44,8 +44,6 @@
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
#include "lwip/apps/mdns.h"
|
#include "lwip/apps/mdns.h"
|
||||||
#include "extmod/network_cyw43.h"
|
|
||||||
#include "drivers/cyw43/cyw43.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// \module network - network configuration
|
/// \module network - network configuration
|
||||||
|
@ -89,32 +87,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(network_route_obj, network_route);
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t mp_module_network_globals_table[] = {
|
STATIC const mp_rom_map_elem_t mp_module_network_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_network) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_network) },
|
||||||
|
|
||||||
#if defined(MICROPY_HW_ETH_MDC)
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_LAN), MP_ROM_PTR(&network_lan_type) },
|
|
||||||
#endif
|
|
||||||
#if MICROPY_PY_NETWORK_CYW43
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mp_network_cyw43_type) },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MICROPY_PY_WIZNET5K
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_WIZNET5K), MP_ROM_PTR(&mod_network_nic_type_wiznet5k) },
|
|
||||||
#endif
|
|
||||||
#if MICROPY_PY_CC3K
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_CC3K), MP_ROM_PTR(&mod_network_nic_type_cc3k) },
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_route), MP_ROM_PTR(&network_route_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_route), MP_ROM_PTR(&network_route_obj) },
|
||||||
|
|
||||||
|
// Defined per port in mpconfigport.h
|
||||||
|
MICROPY_PORT_NETWORK_INTERFACES
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
#if MICROPY_PY_NETWORK_CYW43
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_STA_IF), MP_ROM_INT(CYW43_ITF_STA)},
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_AP_IF), MP_ROM_INT(CYW43_ITF_AP)},
|
|
||||||
#else
|
|
||||||
// Station/AP mode.
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_STA_IF), MP_ROM_INT(MOD_NETWORK_STA_IF) },
|
{ MP_ROM_QSTR(MP_QSTR_STA_IF), MP_ROM_INT(MOD_NETWORK_STA_IF) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_AP_IF), MP_ROM_INT(MOD_NETWORK_AP_IF) },
|
{ MP_ROM_QSTR(MP_QSTR_AP_IF), MP_ROM_INT(MOD_NETWORK_AP_IF) },
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table);
|
||||||
|
|
|
@ -39,17 +39,9 @@
|
||||||
#define MOD_NETWORK_AP_IF (1)
|
#define MOD_NETWORK_AP_IF (1)
|
||||||
|
|
||||||
#if MICROPY_PY_LWIP
|
#if MICROPY_PY_LWIP
|
||||||
|
|
||||||
struct netif;
|
struct netif;
|
||||||
|
|
||||||
extern const mp_obj_type_t network_lan_type;
|
|
||||||
extern const mp_obj_type_t mod_network_nic_type_wiznet5k;
|
|
||||||
|
|
||||||
void mod_network_lwip_poll_wrapper(uint32_t ticks_ms);
|
void mod_network_lwip_poll_wrapper(uint32_t ticks_ms);
|
||||||
mp_obj_t mod_network_nic_ifconfig(struct netif *netif, size_t n_args, const mp_obj_t *args);
|
mp_obj_t mod_network_nic_ifconfig(struct netif *netif, size_t n_args, const mp_obj_t *args);
|
||||||
|
|
||||||
void wiznet5k_poll(void);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
struct _mod_network_socket_obj_t;
|
struct _mod_network_socket_obj_t;
|
||||||
|
@ -96,10 +88,7 @@ typedef struct _mod_network_socket_obj_t {
|
||||||
#endif
|
#endif
|
||||||
} mod_network_socket_obj_t;
|
} mod_network_socket_obj_t;
|
||||||
|
|
||||||
extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k;
|
#endif // MICROPY_PY_LWIP
|
||||||
extern const mod_network_nic_type_t mod_network_nic_type_cc3k;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void mod_network_init(void);
|
void mod_network_init(void);
|
||||||
void mod_network_deinit(void);
|
void mod_network_deinit(void);
|
||||||
|
|
|
@ -323,6 +323,34 @@ extern const struct _mp_obj_module_t mp_module_onewire;
|
||||||
#define ONEWIRE_BUILTIN_MODULE
|
#define ONEWIRE_BUILTIN_MODULE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MICROPY_HW_ETH_MDC)
|
||||||
|
extern const struct _mp_obj_type_t network_lan_type;
|
||||||
|
#define MICROPY_HW_NIC_ETH { MP_ROM_QSTR(MP_QSTR_LAN), MP_ROM_PTR(&network_lan_type) },
|
||||||
|
#else
|
||||||
|
#define MICROPY_HW_NIC_ETH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_PY_NETWORK_CYW43
|
||||||
|
extern const struct _mp_obj_type_t mp_network_cyw43_type;
|
||||||
|
#define MICROPY_HW_NIC_CYW43 { MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mp_network_cyw43_type) },
|
||||||
|
#else
|
||||||
|
#define MICROPY_HW_NIC_CYW43
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_PY_WIZNET5K
|
||||||
|
extern const struct _mod_network_nic_type_t 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
|
||||||
|
#define MICROPY_HW_NIC_WIZNET5K
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_PY_CC3K
|
||||||
|
extern const struct _mod_network_nic_type_t mod_network_nic_type_cc3k;
|
||||||
|
#define MICROPY_HW_NIC_CC3K { MP_ROM_QSTR(MP_QSTR_CC3K), MP_ROM_PTR(&mod_network_nic_type_cc3k) },
|
||||||
|
#else
|
||||||
|
#define MICROPY_HW_NIC_CC3K
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||||
MACHINE_BUILTIN_MODULE \
|
MACHINE_BUILTIN_MODULE \
|
||||||
PYB_BUILTIN_MODULE \
|
PYB_BUILTIN_MODULE \
|
||||||
|
@ -340,6 +368,12 @@ extern const struct _mp_obj_module_t mp_module_onewire;
|
||||||
PYB_BUILTIN_MODULE \
|
PYB_BUILTIN_MODULE \
|
||||||
STM_BUILTIN_MODULE \
|
STM_BUILTIN_MODULE \
|
||||||
|
|
||||||
|
#define MICROPY_PORT_NETWORK_INTERFACES \
|
||||||
|
MICROPY_HW_NIC_ETH \
|
||||||
|
MICROPY_HW_NIC_CYW43 \
|
||||||
|
MICROPY_HW_NIC_WIZNET5K \
|
||||||
|
MICROPY_HW_NIC_CC3K \
|
||||||
|
|
||||||
#define MP_STATE_PORT MP_STATE_VM
|
#define MP_STATE_PORT MP_STATE_VM
|
||||||
|
|
||||||
#if MICROPY_SSL_MBEDTLS
|
#if MICROPY_SSL_MBEDTLS
|
||||||
|
|
Loading…
Reference in New Issue