Skip to content

Commit

Permalink
Merge impl blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Aug 27, 2024
1 parent 752cb31 commit 65de070
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions esp-hal/src/rsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,6 @@ pub struct Rsa<'d, DM: crate::Mode> {
phantom: PhantomData<DM>,
}

impl<'d, DM: crate::Mode> Rsa<'d, DM> {
fn internal_set_interrupt_handler(&mut self, handler: InterruptHandler) {
unsafe {
crate::interrupt::bind_interrupt(crate::peripherals::Interrupt::RSA, handler.handler());
crate::interrupt::enable(crate::peripherals::Interrupt::RSA, handler.priority())
.unwrap();
}
}

fn wait_for_idle(&self) {
while !self.is_idle() {}
self.clear_interrupt();
}

fn read_results<const N: usize>(&self, outbuf: &mut [u32; N]) {
self.wait_for_idle();
self.read_out(outbuf);
}
}

impl<'d> Rsa<'d, crate::Blocking> {
/// Create a new instance in [crate::Blocking] mode.
///
Expand Down Expand Up @@ -150,6 +130,24 @@ impl<'d, DM: crate::Mode> Rsa<'d, DM> {
);
}
}

fn internal_set_interrupt_handler(&mut self, handler: InterruptHandler) {
unsafe {
crate::interrupt::bind_interrupt(crate::peripherals::Interrupt::RSA, handler.handler());
crate::interrupt::enable(crate::peripherals::Interrupt::RSA, handler.priority())
.unwrap();
}
}

fn wait_for_idle(&self) {
while !self.is_idle() {}
self.clear_interrupt();
}

fn read_results<const N: usize>(&self, outbuf: &mut [u32; N]) {
self.wait_for_idle();
self.read_out(outbuf);
}
}

/// Defines the input size of an RSA operation.
Expand Down

0 comments on commit 65de070

Please sign in to comment.