Skip to content

Commit 69ec4b9

Browse files
committed
sdio: add low-level interrupt enable method
Adds a method to perform low-level interrupt enabling for the SDIO device peripheral.
1 parent 2f821cc commit 69ec4b9

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

esp-hal/src/sdio.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod timing;
3131

3232
pub use config::Config;
3333
pub use hinf::{AnyHinf, HinfInfo, HinfInstance};
34-
pub use interrupt::HostInterrupt;
34+
pub use interrupt::{DeviceInterrupt, HostInterrupt};
3535
pub use pins::Pins;
3636
pub use slc::{AnySlc, SlcInfo, SlcInstance};
3737
pub use slchost::{AnySlchost, SlchostInfo, SlchostInstance};
@@ -195,12 +195,12 @@ impl<'d> Sdio<'d> {
195195
self.low_level_init()?;
196196
self.low_level_enable_hs()?;
197197
self.low_level_set_timing()?;
198-
199-
Err(Error::unimplemented())
198+
self.low_level_set_timing()?;
199+
self.low_level_dev_interrupt_enable(0xffu8.into())
200200
}
201201

202202
/// Performs low-level initialization of the SDIO peripheral.
203-
fn low_level_init(&mut self) -> Result<(), Error> {
203+
pub(crate) fn low_level_init(&mut self) -> Result<(), Error> {
204204
let slc = unsafe { &*self.slc.info().register_block };
205205

206206
slc.slcconf0().modify(|_, w| {
@@ -225,7 +225,7 @@ impl<'d> Sdio<'d> {
225225
}
226226

227227
/// Sets the high-speed supported bit to be read by the host.
228-
fn low_level_enable_hs(&mut self) -> Result<(), Error> {
228+
pub(crate) fn low_level_enable_hs(&mut self) -> Result<(), Error> {
229229
let hinf = unsafe { &*self.hinf.info().register_block };
230230

231231
hinf.cfg_data1()
@@ -234,7 +234,8 @@ impl<'d> Sdio<'d> {
234234
Ok(())
235235
}
236236

237-
fn low_level_set_timing(&mut self) -> Result<(), Error> {
237+
/// Sets the communication timing.
238+
pub(crate) fn low_level_set_timing(&mut self) -> Result<(), Error> {
238239
let host = unsafe { &*self.slchost.info().register_block };
239240

240241
match self.config.timing() {
@@ -274,6 +275,27 @@ impl<'d> Sdio<'d> {
274275

275276
Ok(())
276277
}
278+
279+
/// Sets which device interrupts to enable based on the provided mask.
280+
pub(crate) fn low_level_dev_interrupt_enable(
281+
&self,
282+
mask: DeviceInterrupt,
283+
) -> Result<(), Error> {
284+
let slc = unsafe { &*self.slc.info().register_block };
285+
286+
slc.slc0int_ena().modify(|_, w| {
287+
w.sdio_slc_frhost_bit0_int_ena().variant(mask.general0());
288+
w.sdio_slc_frhost_bit1_int_ena().variant(mask.general1());
289+
w.sdio_slc_frhost_bit2_int_ena().variant(mask.general2());
290+
w.sdio_slc_frhost_bit3_int_ena().variant(mask.general3());
291+
w.sdio_slc_frhost_bit4_int_ena().variant(mask.general4());
292+
w.sdio_slc_frhost_bit5_int_ena().variant(mask.general5());
293+
w.sdio_slc_frhost_bit6_int_ena().variant(mask.general6());
294+
w.sdio_slc_frhost_bit7_int_ena().variant(mask.general7())
295+
});
296+
297+
Ok(())
298+
}
277299
}
278300

279301
/// Represents the error variants for SDIO peripherals.

0 commit comments

Comments
 (0)