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

i2c.clear_irq should also clear rxie interrupts #436

Open
ostenning opened this issue Jun 22, 2023 · 0 comments
Open

i2c.clear_irq should also clear rxie interrupts #436

ostenning opened this issue Jun 22, 2023 · 0 comments

Comments

@ostenning
Copy link
Contributor

I've noticed that when attempting to clear i2c receive interrupts utilising the clear_irq function, that this is essentially a no op.
Clearing the rxie interrupt involves reading data from the rxdr register, and the clear_irq does not do this.

I would suggest having the clear_irq function return a Option, something like this:

                /// Clears interrupt flag for `event`
                pub fn clear_irq(&mut self, event: Event) -> Option<u8> {
                    self.i2c.icr.write(|w| {
                        match event {
                            Event::Stop => w.stopcf().set_bit(),
                            Event::Errors => w
                                .berrcf().set_bit()
                                .arlocf().set_bit()
                                .ovrcf().set_bit(),
                            Event::NotAcknowledge => w.nackcf().set_bit(),
                            _ => w
                        }
                    });
                    let _ = self.i2c.isr.read();
                    let _ = self.i2c.isr.read(); // Delay 2 peripheral clocks

                    if event == Event::Receive {
                        return Some(self.i2c.rxdr.read().rxdata().bits());
                    }

                    None
                }
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

No branches or pull requests

1 participant