-
Notifications
You must be signed in to change notification settings - Fork 971
Added Ethernet example(W5500 of WIZnet product) using SPI #98
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
Conversation
|
This looks good. We'll just have to grab a module and confirm that it's working and then we'll merge it in. This will probably get allocated to an intern over the summer, as we're going to be adding a lot of example code for various breakouts. |
.gitignore
Outdated
| .DS_Store | ||
| spi/w5500_spi/mpu9250_spi.fzz | ||
| spi/w5500_spi/mpu9250_spi_bb.png |
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.
No need to add these to .gitignore, just delete them from your local directory 😃
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 deleted the .gitignore on my local.
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.
You've also (accidentally?) deleted it from this repo too, which you don't want to do.
| #include "loopback.h" | ||
|
|
||
|
|
||
| /* Example code to talk to a wiznet MEMS accelerometer and gyroscope. |
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.
Huh? 😉
spi/w5500_spi/w5500_spi.c
Outdated
| GPIO 3 (pin 5) MOSI/spi0_tx -> SDA on wiznet board | ||
| GPIO 4 (pin 6) MISO/spi0_rx-> ADO on wiznet board | ||
| GPIO 5 (pin 7) Chip select -> NCS on wiznet board | ||
| GPIO 6 (pin 9) SCK/spi0_sclk -> SCL on wiznet board |
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.
You seem to have spi0_sclk mentioned twice?
spi/w5500_spi/w5500_spi.c
Outdated
| return rx; | ||
|
|
||
| } | ||
| static void wiznet_write(uint8_t reg){ |
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.
Please fix indentation
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 fix indentation
spi/w5500_spi/loopback.c
Outdated
| #endif | ||
| setSn_IR(sn,Sn_IR_CON); | ||
| } | ||
| if((size = getSn_RX_RSR(sn)) > 0) // Don't need to check SOCKERR_BUSY because it doesn't not occur. |
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.
weird indentation
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 fixed indentation. Check the one more time, please
spi/w5500_spi/loopback.c
Outdated
| ////////////////////////////////////////////////////////////////////////////////////////////// | ||
| // Data Transaction Parts; Handle the [data receive and send] process | ||
| ////////////////////////////////////////////////////////////////////////////////////////////// | ||
| if((size = getSn_RX_RSR(sn)) > 0) // Sn_RX_RSR: Socket n Received Size Register, Receiving data length |
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.
weird indentation
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 fixed indentation. Check the one more time, please
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.
The indentation still seems a bit all over the place, but I think that might be because you're mixing tabs and spaces? 🤷
spi/w5500_spi/w5500_spi.c
Outdated
| // first, then subsequently read from the device. The register is auto incrementing | ||
| // so we don't need to keep sending the register we want, just the first. | ||
| uint8_t rx = 0, tx = 0xFF; | ||
| spi_read_blocking(SPI_PORT, &tx, &rx, 1); |
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.
weird indentation
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 fixed indentation. Check the one more time, please
spi/w5500_spi/README.adoc
Outdated
|
|
||
| [NOTE] | ||
| ====== | ||
| This is a very basic example, and it send and receive data from the WIZ850io(W5500).After you get off the communication command(S"n"_CR) on the WIZ850io, make sure the communicationcommand is clear."n" is socket number. |
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.
Missing space in "communicationcommand"
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.
Sorry, I fixed this line
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.
Is it going on? Is it stopped?
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.
See Alasdair's comment above: "This will probably get allocated to an intern over the summer, as we're going to be adding a lot of example code for various breakouts."
|
|
|
|
|
Passed to @aayushijhaveri. |
|
Just tried running the code on the W5500 board from https://dokkodai.tistory.com/198 and it looks like it is working fine. It's printing out the Mac address, IP address etc. |
aallan
left a comment
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.
Extensive changes needed.
| @@ -0,0 +1,59 @@ | |||
| = Attaching a W5500 via SPI | |||
|
|
|||
| This example code shows how to interface the Raspberry Pi Pico to the WIZ850io(W5500) board. The particular device used can be interfaced via SPI, we are using SPI, and interfacing at 3.3v. | |||
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.
Needs to mention the alternative board that we've now tested with, and any alternative arrangements needed, e.g. wiring etc?
| [NOTE] | ||
| ====== | ||
| This is a very basic example, and it send and receive data from the WIZ850io(W5500).After you get off the communication command(S"n"_CR) on the WIZ850io, make sure the communication command is clear."n" is socket number. | ||
| It is also use the polling approach in the example. |
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.
Needs reworded.
| * 3.3v (pin 36) -> VCC on IZ850io(W5500) board | ||
| * GND (pin 38) -> GND on IZ850io(W5500) board | ||
|
|
||
| The example here uses SPI port 0. Power is supplied from the 3.3V pin. |
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.
Needs reworded using standard language.
|
|
||
| [NOTE] | ||
| ====== | ||
| There are many different manufacturers who sell boards with the WIZ850io(W5500). Whilst they all appear slightly different, they all have, at least, the same 6 pins required to power and communicate. When wiring up a board that is different to the one in the diagram, ensure you connect up as described in the previous paragraph. |
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.
Repetitive wording.
| | *Item* | *Quantity* | Details | ||
| | Breadboard | 1 | generic part | ||
| | Raspberry Pi Pico | 1 | http://raspberrypi.org/ | ||
| | WIZ850io(W5500) board| 1 | https://eshop.wiznet.io/shop/module/wiz850io/ |
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.
Need to reference alternatives. It's essentially a generic part.
| //! \version 1.0.3 | ||
| //! \date 2013/10/21 | ||
| //! \par Revision history | ||
| //! <2015/02/05> Notice |
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.
This is a frozen version. Instead of inserting this static version should be use the external library directly?
| //! * Redistributions in binary form must reproduce the above copyright | ||
| //! notice, this list of conditions and the following disclaimer in the | ||
| //! documentation and/or other materials provided with the distribution. | ||
| //! * Neither the name of the <ORGANIZATION> nor the names of its |
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.
Broken version of BSD 3 clause. Needs fixing if we're including the code in the repo.
| //! \version 1.0.2 | ||
| //! \date 2013/10/21 | ||
| //! \par Revision history | ||
| //! <2015/02/05> Notice |
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'm tempted to say that we should not include this code in the example, instead provide instructions to pull it from its own repo into a preconfigred place. Including it in this fashion seems unwise.
| WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >> 8); | ||
| WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >> 0); | ||
| } | ||
| else // burst operation |
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.
Weird comments?
| //! \author MidnightCow | ||
| //! \copyright | ||
| //! | ||
| //! Copyright (c) 2013, WIZnet Co., LTD. |
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.
Same again for this file.
|
So @aayushijhaveri has picked up this PR and done some more work on it. So closing this PR in favour of #147. We'll talk about W5500 example support over there. Many thanks! |

https://youtu.be/MDdt03a3NQU