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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod common {
pub const SUBNET_MASK: u16 = 0x05;
pub const MAC: u16 = 0x09;
pub const IP: u16 = 0x0F;
pub const SOCKET_INTERRUPT_MASK: u16 = 0x0018;
pub const PHY_CONFIG: u16 = 0x2E;
pub const VERSION: u16 = 0x39;

Expand Down
8 changes: 6 additions & 2 deletions src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

| socketn::Interrupt::Timeout as u8
| socketn::Interrupt::Receive as u8,
)?;

self.socket.command(bus, socketn::Command::Open)?;
Expand All @@ -55,7 +57,9 @@ impl TcpSocket {

self.socket.set_interrupt_mask(
bus,
socketn::Interrupt::SendOk as u8 & socketn::Interrupt::Timeout as u8,
socketn::Interrupt::SendOk as u8
| socketn::Interrupt::Timeout as u8
| socketn::Interrupt::Receive as u8,
)?;

self.socket.command(bus, socketn::Command::Open)?;
Expand Down
4 changes: 3 additions & 1 deletion src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ impl UdpSocket {
self.socket.set_mode(bus, socketn::Protocol::Udp)?;
self.socket.set_interrupt_mask(
bus,
socketn::Interrupt::SendOk as u8 & socketn::Interrupt::Timeout as u8,
socketn::Interrupt::SendOk as u8
| socketn::Interrupt::Timeout as u8
| socketn::Interrupt::Receive as u8,
)?;
self.socket.command(bus, socketn::Command::Open)?;
Ok(())
Expand Down
6 changes: 6 additions & 0 deletions src/uninitialized_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ impl<SpiBus: Bus> UninitializedDevice<SpiBus> {
self.bus
.write_frame(register::COMMON, register::common::MODE, &mode)?;

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

)?;

self.set_mode(mode_options)?;
host.refresh(&mut self.bus)?;
Ok(Device::new(self.bus, host))
Expand Down