Skip to content

Commit bd9c1ad

Browse files
committed
stmhal: Make CC3K object static, so it's only registered once as NIC.
1 parent 8b77e3d commit bd9c1ad

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

stmhal/modnwcc3k.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ typedef struct _cc3k_obj_t {
421421
mp_obj_base_t base;
422422
} cc3k_obj_t;
423423

424+
STATIC const cc3k_obj_t cc3k_obj = {{(mp_obj_type_t*)&mod_network_nic_type_cc3k}};
425+
424426
// \classmethod \constructor(spi, pin_cs, pin_en, pin_irq)
425427
// Initialise the CC3000 using the given SPI bus and pins and return a CC3K object.
426428
//
@@ -458,13 +460,10 @@ STATIC mp_obj_t cc3k_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw
458460
HCI_EVNT_WLAN_ASYNC_PING_REPORT|
459461
HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE);
460462

461-
cc3k_obj_t *cc3k = m_new_obj(cc3k_obj_t);
462-
cc3k->base.type = (mp_obj_type_t*)&mod_network_nic_type_cc3k;
463-
464463
// register with network module
465-
mod_network_register_nic(cc3k);
464+
mod_network_register_nic((mp_obj_t)&cc3k_obj);
466465

467-
return cc3k;
466+
return (mp_obj_t)&cc3k_obj;
468467
}
469468

470469
// method connect(ssid, key=None, *, security=WPA2, bssid=None)

0 commit comments

Comments
 (0)