nrf, rp: update set_config
This commit is contained in:
parent
5ad34404af
commit
d2a2734752
@ -176,7 +176,7 @@ impl<'d, T: Instance> Spim<'d, T> {
|
|||||||
let mut spim = Self { _p: spim };
|
let mut spim = Self { _p: spim };
|
||||||
|
|
||||||
// Apply runtime peripheral configuration
|
// Apply runtime peripheral configuration
|
||||||
Self::set_config(&mut spim, &config);
|
Self::set_config(&mut spim, &config).unwrap();
|
||||||
|
|
||||||
// Disable all events interrupts
|
// Disable all events interrupts
|
||||||
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
|
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
|
||||||
@ -566,7 +566,8 @@ mod eha {
|
|||||||
|
|
||||||
impl<'d, T: Instance> SetConfig for Spim<'d, T> {
|
impl<'d, T: Instance> SetConfig for Spim<'d, T> {
|
||||||
type Config = Config;
|
type Config = Config;
|
||||||
fn set_config(&mut self, config: &Self::Config) {
|
type ConfigError = ();
|
||||||
|
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> {
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
// Configure mode.
|
// Configure mode.
|
||||||
let mode = config.mode;
|
let mode = config.mode;
|
||||||
@ -604,5 +605,7 @@ impl<'d, T: Instance> SetConfig for Spim<'d, T> {
|
|||||||
// Set over-read character
|
// Set over-read character
|
||||||
let orc = config.orc;
|
let orc = config.orc;
|
||||||
r.orc.write(|w| unsafe { w.orc().bits(orc) });
|
r.orc.write(|w| unsafe { w.orc().bits(orc) });
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ impl<'d, T: Instance> Spis<'d, T> {
|
|||||||
let mut spis = Self { _p: spis };
|
let mut spis = Self { _p: spis };
|
||||||
|
|
||||||
// Apply runtime peripheral configuration
|
// Apply runtime peripheral configuration
|
||||||
Self::set_config(&mut spis, &config);
|
Self::set_config(&mut spis, &config).unwrap();
|
||||||
|
|
||||||
// Disable all events interrupts.
|
// Disable all events interrupts.
|
||||||
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
|
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
|
||||||
@ -467,7 +467,8 @@ macro_rules! impl_spis {
|
|||||||
|
|
||||||
impl<'d, T: Instance> SetConfig for Spis<'d, T> {
|
impl<'d, T: Instance> SetConfig for Spis<'d, T> {
|
||||||
type Config = Config;
|
type Config = Config;
|
||||||
fn set_config(&mut self, config: &Self::Config) {
|
type ConfigError = ();
|
||||||
|
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> {
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
// Configure mode.
|
// Configure mode.
|
||||||
let mode = config.mode;
|
let mode = config.mode;
|
||||||
@ -509,5 +510,7 @@ impl<'d, T: Instance> SetConfig for Spis<'d, T> {
|
|||||||
// Configure auto-acquire on 'transfer end' event.
|
// Configure auto-acquire on 'transfer end' event.
|
||||||
let auto_acquire = config.auto_acquire;
|
let auto_acquire = config.auto_acquire;
|
||||||
r.shorts.write(|w| w.end_acquire().bit(auto_acquire));
|
r.shorts.write(|w| w.end_acquire().bit(auto_acquire));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ impl<'d, T: Instance> Twim<'d, T> {
|
|||||||
let mut twim = Self { _p: twim };
|
let mut twim = Self { _p: twim };
|
||||||
|
|
||||||
// Apply runtime peripheral configuration
|
// Apply runtime peripheral configuration
|
||||||
Self::set_config(&mut twim, &config);
|
Self::set_config(&mut twim, &config).unwrap();
|
||||||
|
|
||||||
// Disable all events interrupts
|
// Disable all events interrupts
|
||||||
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
|
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
|
||||||
@ -890,9 +890,12 @@ mod eha {
|
|||||||
|
|
||||||
impl<'d, T: Instance> SetConfig for Twim<'d, T> {
|
impl<'d, T: Instance> SetConfig for Twim<'d, T> {
|
||||||
type Config = Config;
|
type Config = Config;
|
||||||
fn set_config(&mut self, config: &Self::Config) {
|
type ConfigError = ();
|
||||||
|
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> {
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
r.frequency
|
r.frequency
|
||||||
.write(|w| unsafe { w.frequency().bits(config.frequency as u32) });
|
.write(|w| unsafe { w.frequency().bits(config.frequency as u32) });
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,8 @@ mod eha {
|
|||||||
|
|
||||||
impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M> {
|
impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M> {
|
||||||
type Config = Config;
|
type Config = Config;
|
||||||
fn set_config(&mut self, config: &Self::Config) {
|
type ConfigError = ();
|
||||||
|
fn set_config(&mut self, config: &Self::Config) -> Result<(), ()> {
|
||||||
let p = self.inner.regs();
|
let p = self.inner.regs();
|
||||||
let (presc, postdiv) = calc_prescs(config.frequency);
|
let (presc, postdiv) = calc_prescs(config.frequency);
|
||||||
p.cpsr().write(|w| w.set_cpsdvsr(presc));
|
p.cpsr().write(|w| w.set_cpsdvsr(presc));
|
||||||
@ -607,5 +608,7 @@ impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M> {
|
|||||||
w.set_sph(config.phase == Phase::CaptureOnSecondTransition);
|
w.set_sph(config.phase == Phase::CaptureOnSecondTransition);
|
||||||
w.set_scr(postdiv);
|
w.set_scr(postdiv);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user