-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driver/enc28j60: cleanup #9887
driver/enc28j60: cleanup #9887
Conversation
3a5d891
to
fc5443a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove the bank change, to me this is good to go.
if ((bank < 0) || (dev->bank == bank)) { | ||
assert(bank < 0x04); | ||
|
||
if (bank < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this semantic change split out (into another PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it separate commit
Simplify usage of params via MACROs and copy params struct instead of (re)assigning values to driver struct. Overall code cleanup.
Simplify handling of memory banks, ie. remove check if current bank is target bank and set it explicitly every time.
fc5443a
to
f35e478
Compare
ping @kaspar030, I put changes into distinct/independent commits, IMHO separate PRs is a bit overkill here. |
To me the code change looks ok. I ran a simple test with an enc28j60 shield connected to a samr21-xpro using this change: diff --git a/examples/gnrc_networking/Makefile b/examples/gnrc_networking/Makefile
index 86b7a94c14..a3250f4b42 100644
--- a/examples/gnrc_networking/Makefile
+++ b/examples/gnrc_networking/Makefile
@@ -40,6 +40,23 @@ USEMODULE += netstats_rpl
# development process:
DEVELHELP ?= 1
+ifneq (,$(filter samr21-xpro,$(BOARD)))
+ USEMODULE += enc28j60
+ GNRC_NETIF_NUMOF := 2
+
+# fallback: set SPI bus and pins to default values
+ ENC_SPI ?= SPI_DEV\(1\)
+ ENC_CS ?= GPIO_PIN\(0,18\)
+ ENC_INT ?= GPIO_PIN\(0,28\)
+ ENC_RST ?= GPIO_PIN\(0,13\)
+ # export SPI and pins
+ CFLAGS += -DENC28J60_PARAM_SPI=$(ENC_SPI)
+ CFLAGS += -DENC28J60_PARAM_CS=$(ENC_CS)
+ CFLAGS += -DENC28J60_PARAM_INT=$(ENC_INT)
+ CFLAGS += -DENC28J60_PARAM_RESET=$(ENC_RST)
+endif
+
+
# Uncomment the following 2 lines to specify static link lokal IPv6 address
# this might be useful for testing, in cases where you cannot or do not want to
# run a shell with ifconfig to get the real link lokal address.
Changing the MAC address of the device via @kaspar030 are you still around? I think your comments were addressed. Please remove your change request. |
@kaspar030 the bank change was split out into a separate commit which I think is totally fine. Not to bother you too much with this PR and to get it in the upcoming release I consider dismissing your change request tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-reviewed the PR and did basic testing that involved SPI transfers and give my ACK. @kaspar030 I'll dismiss your review now. Please give me a sign if you think something hasn't been addressed properly. I'll take care of the follow-up then.
Comments were addressed and author is not responsive anymore.
Contribution description
Some cleanup and optimisation of the ethernet driver. Safes overall 12 bytes, too.
Testing procedure
Issues/PRs references