8000 stm32/network_wiznet5k: Add ability to set the MAC address. · rlucia/micropython@4f936af · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f936af

Browse files
committed
stm32/network_wiznet5k: Add ability to set the MAC address.
1 parent 4410efc commit 4f936af

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ports/stm32/network_wiznet5k.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626

2727
#include <stdio.h>
28+
#include <string.h>
29+
2830
#include "py/runtime.h"
2931
#include "py/mphal.h"
3032
#include "spi.h"
@@ -398,6 +400,16 @@ STATIC mp_obj_t wiznet5k_config(size_t n_args, const mp_obj_t *args, mp_map_t *k
398400
if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
399401
mp_map_elem_t *e = &kwargs->table[i];
400402
switch (mp_obj_str_get_qstr(e->key)) {
403+
case MP_QSTR_mac: {
404+
mp_buffer_info_t buf;
405+
mp_get_buffer_raise(e->value, &buf, MP_BUFFER_READ);
406+
if (buf.len != 6) {
407+
mp_raise_ValueError(NULL);
408+
}
409+
setSHAR(buf.buf);
410+
memcpy(self->netif.hwaddr, buf.buf, 6);
411+
break;
412+
}
401413
case MP_QSTR_trace: {
402414
self->trace_flags = mp_obj_get_int(e->value);
403415
break;

0 commit comments

Comments
 (0)
0