Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
4410efc1
Commit
4410efc1
authored
5 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stm32/network_wiznet5k: Add ability to trace Ethernet TX and RX frames.
Via: nic.config(trace=2|4)
parent
69cb24a2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ports/stm32/network_wiznet5k.c
+28
-1
28 additions, 1 deletion
ports/stm32/network_wiznet5k.c
with
28 additions
and
1 deletion
ports/stm32/network_wiznet5k.c
+
28
−
1
View file @
4410efc1
...
...
@@ -32,12 +32,16 @@
#if MICROPY_PY_WIZNET5K && MICROPY_PY_LWIP
#include
"lib/netutils/netutils.h"
#include
"drivers/wiznet5k/ethernet/socket.h"
#include
"lwip/err.h"
#include
"lwip/dns.h"
#include
"lwip/dhcp.h"
#include
"netif/etharp.h"
#define TRACE_ETH_TX (0x0002)
#define TRACE_ETH_RX (0x0004)
/*******************************************************************************/
// Wiznet5k Ethernet driver in MACRAW mode
...
...
@@ -48,6 +52,7 @@ typedef struct _wiznet5k_obj_t {
mp_hal_pin_obj_t
cs
;
mp_hal_pin_obj_t
rst
;
uint8_t
eth_frame
[
1514
];
uint32_t
trace_flags
;
struct
netif
netif
;
struct
dhcp
dhcp_struct
;
}
wiznet5k_obj_t
;
...
...
@@ -176,6 +181,9 @@ STATIC uint16_t wiznet5k_recv_ethernet(wiznet5k_obj_t *self) {
STATIC
err_t
wiznet5k_netif_output
(
struct
netif
*
netif
,
struct
pbuf
*
p
)
{
wiznet5k_obj_t
*
self
=
netif
->
state
;
pbuf_copy_partial
(
p
,
self
->
eth_frame
,
p
->
tot_len
,
0
);
if
(
self
->
trace_flags
&
TRACE_ETH_TX
)
{
netutils_ethernet_trace
(
MP_PYTHON_PRINTER
,
p
->
tot_len
,
self
->
eth_frame
,
NETUTILS_TRACE_IS_TX
|
NETUTILS_TRACE_NEWLINE
);
}
wiznet5k_send_ethernet
(
self
,
p
->
tot_len
,
self
->
eth_frame
);
return
ERR_OK
;
}
...
...
@@ -223,6 +231,9 @@ STATIC void wiznet5k_lwip_poll(void *self_in, struct netif *netif) {
wiznet5k_obj_t
*
self
=
self_in
;
uint16_t
len
;
while
((
len
=
wiznet5k_recv_ethernet
(
self
))
>
0
)
{
if
(
self
->
trace_flags
&
TRACE_ETH_RX
)
{
netutils_ethernet_trace
(
MP_PYTHON_PRINTER
,
len
,
self
->
eth_frame
,
NETUTILS_TRACE_NEWLINE
);
}
struct
pbuf
*
p
=
pbuf_alloc
(
PBUF_RAW
,
len
,
PBUF_POOL
);
if
(
p
!=
NULL
)
{
pbuf_take
(
p
,
self
->
eth_frame
,
len
);
...
...
@@ -260,6 +271,7 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size
wiznet5k_obj
.
spi
=
spi
;
wiznet5k_obj
.
cs
=
cs
;
wiznet5k_obj
.
rst
=
rst
;
wiznet5k_obj
.
trace_flags
=
0
;
// Return wiznet5k object
return
MP_OBJ_FROM_PTR
(
&
wiznet5k_obj
);
...
...
@@ -381,7 +393,22 @@ STATIC mp_obj_t wiznet5k_config(size_t n_args, const mp_obj_t *args, mp_map_t *k
if
(
n_args
!=
1
)
{
mp_raise_TypeError
(
"can't specify pos and kw args"
);
}
mp_raise_ValueError
(
"unknown config param"
);
for
(
size_t
i
=
0
;
i
<
kwargs
->
alloc
;
++
i
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
kwargs
,
i
))
{
mp_map_elem_t
*
e
=
&
kwargs
->
table
[
i
];
switch
(
mp_obj_str_get_qstr
(
e
->
key
))
{
case
MP_QSTR_trace
:
{
self
->
trace_flags
=
mp_obj_get_int
(
e
->
value
);
break
;
}
default:
mp_raise_ValueError
(
"unknown config param"
);
}
}
}
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
wiznet5k_config_obj
,
1
,
wiznet5k_config
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment