Skip to content
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

Enable hardware interrupts #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Wassasin
Copy link
Contributor

I noticed no hardware interrupts being triggered on pin INTn. Fixed by:

  • fixing the mask construction for the sockets from a bitwise AND & to bitwise OR |.
  • enabling hardware interrupts for all sockets.

I am unsure whether enabling the hardware interrupts in the device initialization is the best location to do so, or whether it is better to fetch the current mask when using a specific socket and enabling interrupts only for the new socket.

@elpiel
Copy link
Contributor

elpiel commented Feb 12, 2023

Hello @Wassasin, thank you for this fix. I was wondering if you could give a quick overview of how this interrupt could be used?
I know it's Wake on LAN but is it setting the pin HIGH and how can I test if your fix actually works?

@Wassasin
Copy link
Contributor Author

It has been a while since opening this PR, so please check anything I write here yourself.

This pull request only fixes the interrupt related to already opened sockets. WOL is a mechanism implemented by the W5500 separately as part of the Mode Register, and works without opening any socket for any WOL packet received on any UDP port. Check the datasheet for when the W5500 asserts the intn-pin. You would only have to create a new PR that:

  • Sets the WOL symbol (bit 5) of the Mode Register (0x0000).
  • Enable the Magic Packet Interrupt (bit 4) in the Interrupt Mask Register (0x0016).
  • Check the interrupt pin yourself.
  • Check the Magic Packet symbol (bit 4) in the Interrupt Register (0x0015).
  • Write a 1 to the Magic Packet symbol (bit 4) in the Interrupt Register (0x0015) to clear it.

@@ -37,7 +37,9 @@ impl TcpSocket {

self.socket.set_interrupt_mask(
bus,
socketn::Interrupt::SendOk as u8 & socketn::Interrupt::Timeout as u8,
socketn::Interrupt::SendOk as u8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like interrupts should be configured when creating the socket. We don't want to blindly enable them for everything in my opinion

self.bus.write_frame(
register::COMMON,
register::common::SOCKET_INTERRUPT_MASK,
&[0xFF],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get this as configurable data. People may have cases where they do not want the INTn line changing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants