diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-02-14 02:12:06 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-02-14 02:12:06 +0100 |
| commit | 39d06b59cd8eb6f64e5986bfaaf4e5f7d504f5c1 (patch) | |
| tree | fa49fb426a7db68550c33e7b26dfe2f720ceae15 /embassy-stm32/src | |
| parent | c8f9f1bead8aa02076ff8daec3c83c752808dbcb (diff) | |
Update stm32-data
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/i2c/v1.rs | 52 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 18 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f0.rs | 21 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f1.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f3.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f4.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f7.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/g0.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/h7.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/l0.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/l1.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/mod.rs | 27 |
12 files changed, 55 insertions, 101 deletions
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 922c1c7e8..5a9e82828 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -108,11 +108,11 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 108 | // Send a START condition | 108 | // Send a START condition |
| 109 | 109 | ||
| 110 | T::regs().cr1().modify(|reg| { | 110 | T::regs().cr1().modify(|reg| { |
| 111 | reg.set_start(i2c::vals::Start::START); | 111 | reg.set_start(true); |
| 112 | }); | 112 | }); |
| 113 | 113 | ||
| 114 | // Wait until START condition was generated | 114 | // Wait until START condition was generated |
| 115 | while self.check_and_clear_error_flags()?.sb() == i2c::vals::Sb::NOSTART {} | 115 | while !self.check_and_clear_error_flags()?.start() {} |
| 116 | 116 | ||
| 117 | // Also wait until signalled we're master and everything is waiting for us | 117 | // Also wait until signalled we're master and everything is waiting for us |
| 118 | while { | 118 | while { |
| @@ -126,13 +126,9 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 126 | T::regs().dr().write(|reg| reg.set_dr(addr << 1)); | 126 | T::regs().dr().write(|reg| reg.set_dr(addr << 1)); |
| 127 | 127 | ||
| 128 | // Wait until address was sent | 128 | // Wait until address was sent |
| 129 | while { | 129 | // Wait for the address to be acknowledged |
| 130 | // Check for any I2C errors. If a NACK occurs, the ADDR bit will never be set. | 130 | // Check for any I2C errors. If a NACK occurs, the ADDR bit will never be set. |
| 131 | let sr1 = self.check_and_clear_error_flags()?; | 131 | while !self.check_and_clear_error_flags()?.addr() {} |
| 132 | |||
| 133 | // Wait for the address to be acknowledged | ||
| 134 | !sr1.addr() | ||
| 135 | } {} | ||
| 136 | 132 | ||
| 137 | // Clear condition by reading SR2 | 133 | // Clear condition by reading SR2 |
| 138 | let _ = T::regs().sr2().read(); | 134 | let _ = T::regs().sr2().read(); |
| @@ -150,7 +146,7 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 150 | // Wait until we're ready for sending | 146 | // Wait until we're ready for sending |
| 151 | while { | 147 | while { |
| 152 | // Check for any I2C errors. If a NACK occurs, the ADDR bit will never be set. | 148 | // Check for any I2C errors. If a NACK occurs, the ADDR bit will never be set. |
| 153 | !self.check_and_clear_error_flags()?.tx_e() | 149 | !self.check_and_clear_error_flags()?.txe() |
| 154 | } {} | 150 | } {} |
| 155 | 151 | ||
| 156 | // Push out a byte of data | 152 | // Push out a byte of data |
| @@ -170,7 +166,7 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 170 | // Check for any potential error conditions. | 166 | // Check for any potential error conditions. |
| 171 | self.check_and_clear_error_flags()?; | 167 | self.check_and_clear_error_flags()?; |
| 172 | 168 | ||
| 173 | !T::regs().sr1().read().rx_ne() | 169 | !T::regs().sr1().read().rxne() |
| 174 | } {} | 170 | } {} |
| 175 | 171 | ||
| 176 | let value = T::regs().dr().read().dr(); | 172 | let value = T::regs().dr().read().dr(); |
| @@ -182,13 +178,13 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 182 | // Send a START condition and set ACK bit | 178 | // Send a START condition and set ACK bit |
| 183 | unsafe { | 179 | unsafe { |
| 184 | T::regs().cr1().modify(|reg| { | 180 | T::regs().cr1().modify(|reg| { |
| 185 | reg.set_start(i2c::vals::Start::START); | 181 | reg.set_start(true); |
| 186 | reg.set_ack(true); | 182 | reg.set_ack(true); |
| 187 | }); | 183 | }); |
| 188 | } | 184 | } |
| 189 | 185 | ||
| 190 | // Wait until START condition was generated | 186 | // Wait until START condition was generated |
| 191 | while unsafe { T::regs().sr1().read().sb() } == i2c::vals::Sb::NOSTART {} | 187 | while unsafe { !T::regs().sr1().read().start() } {} |
| 192 | 188 | ||
| 193 | // Also wait until signalled we're master and everything is waiting for us | 189 | // Also wait until signalled we're master and everything is waiting for us |
| 194 | while { | 190 | while { |
| @@ -197,24 +193,14 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 197 | } {} | 193 | } {} |
| 198 | 194 | ||
| 199 | // Set up current address, we're trying to talk to | 195 | // Set up current address, we're trying to talk to |
| 200 | unsafe { | 196 | unsafe { T::regs().dr().write(|reg| reg.set_dr((addr << 1) + 1)) } |
| 201 | T::regs().dr().write(|reg| reg.set_dr((addr << 1) + 1)); | ||
| 202 | } | ||
| 203 | 197 | ||
| 204 | // Wait until address was sent | 198 | // Wait until address was sent |
| 205 | while { | 199 | // Wait for the address to be acknowledged |
| 206 | unsafe { | 200 | while unsafe { !self.check_and_clear_error_flags()?.addr() } {} |
| 207 | let sr1 = self.check_and_clear_error_flags()?; | ||
| 208 | |||
| 209 | // Wait for the address to be acknowledged | ||
| 210 | !sr1.addr() | ||
| 211 | } | ||
| 212 | } {} | ||
| 213 | 201 | ||
| 214 | // Clear condition by reading SR2 | 202 | // Clear condition by reading SR2 |
| 215 | unsafe { | 203 | let _ = unsafe { T::regs().sr2().read() }; |
| 216 | let _ = T::regs().sr2().read(); | ||
| 217 | } | ||
| 218 | 204 | ||
| 219 | // Receive bytes into buffer | 205 | // Receive bytes into buffer |
| 220 | for c in buffer { | 206 | for c in buffer { |
| @@ -225,15 +211,15 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 225 | unsafe { | 211 | unsafe { |
| 226 | T::regs().cr1().modify(|reg| { | 212 | T::regs().cr1().modify(|reg| { |
| 227 | reg.set_ack(false); | 213 | reg.set_ack(false); |
| 228 | reg.set_stop(i2c::vals::Stop::STOP); | 214 | reg.set_stop(true); |
| 229 | }); | 215 | }) |
| 230 | } | 216 | } |
| 231 | 217 | ||
| 232 | // Receive last byte | 218 | // Receive last byte |
| 233 | *last = unsafe { self.recv_byte()? }; | 219 | *last = unsafe { self.recv_byte()? }; |
| 234 | 220 | ||
| 235 | // Wait for the STOP to be sent. | 221 | // Wait for the STOP to be sent. |
| 236 | while unsafe { T::regs().cr1().read().stop() == i2c::vals::Stop::STOP } {} | 222 | while unsafe { T::regs().cr1().read().stop() } {} |
| 237 | 223 | ||
| 238 | // Fallthrough is success | 224 | // Fallthrough is success |
| 239 | Ok(()) | 225 | Ok(()) |
| @@ -246,11 +232,9 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 246 | unsafe { | 232 | unsafe { |
| 247 | self.write_bytes(addr, bytes)?; | 233 | self.write_bytes(addr, bytes)?; |
| 248 | // Send a STOP condition | 234 | // Send a STOP condition |
| 249 | T::regs() | 235 | T::regs().cr1().modify(|reg| reg.set_stop(true)); |
| 250 | .cr1() | ||
| 251 | .modify(|reg| reg.set_stop(i2c::vals::Stop::STOP)); | ||
| 252 | // Wait for STOP condition to transmit. | 236 | // Wait for STOP condition to transmit. |
| 253 | while T::regs().cr1().read().stop() == i2c::vals::Stop::STOP {} | 237 | while T::regs().cr1().read().stop() {} |
| 254 | }; | 238 | }; |
| 255 | 239 | ||
| 256 | // Fallthrough is success | 240 | // Fallthrough is success |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 58ab771b7..493aacb6d 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -132,7 +132,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 132 | 132 | ||
| 133 | fn master_stop(&mut self) { | 133 | fn master_stop(&mut self) { |
| 134 | unsafe { | 134 | unsafe { |
| 135 | T::regs().cr2().write(|w| w.set_stop(i2c::vals::Stop::STOP)); | 135 | T::regs().cr2().write(|w| w.set_stop(true)); |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
| @@ -143,7 +143,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 143 | // Wait for any previous address sequence to end | 143 | // Wait for any previous address sequence to end |
| 144 | // automatically. This could be up to 50% of a bus | 144 | // automatically. This could be up to 50% of a bus |
| 145 | // cycle (ie. up to 0.5/freq) | 145 | // cycle (ie. up to 0.5/freq) |
| 146 | while T::regs().cr2().read().start() == i2c::vals::Start::START {} | 146 | while T::regs().cr2().read().start() {} |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | // Set START and prepare to receive bytes into | 149 | // Set START and prepare to receive bytes into |
| @@ -158,10 +158,10 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 158 | 158 | ||
| 159 | T::regs().cr2().modify(|w| { | 159 | T::regs().cr2().modify(|w| { |
| 160 | w.set_sadd((address << 1 | 0) as u16); | 160 | w.set_sadd((address << 1 | 0) as u16); |
| 161 | w.set_add10(i2c::vals::Add::BIT7); | 161 | w.set_add10(i2c::vals::Addmode::BIT7); |
| 162 | w.set_rd_wrn(i2c::vals::RdWrn::READ); | 162 | w.set_dir(i2c::vals::Dir::READ); |
| 163 | w.set_nbytes(length as u8); | 163 | w.set_nbytes(length as u8); |
| 164 | w.set_start(i2c::vals::Start::START); | 164 | w.set_start(true); |
| 165 | w.set_autoend(stop.autoend()); | 165 | w.set_autoend(stop.autoend()); |
| 166 | w.set_reload(reload); | 166 | w.set_reload(reload); |
| 167 | }); | 167 | }); |
| @@ -173,7 +173,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 173 | // Wait for any previous address sequence to end | 173 | // Wait for any previous address sequence to end |
| 174 | // automatically. This could be up to 50% of a bus | 174 | // automatically. This could be up to 50% of a bus |
| 175 | // cycle (ie. up to 0.5/freq) | 175 | // cycle (ie. up to 0.5/freq) |
| 176 | while T::regs().cr2().read().start() == i2c::vals::Start::START {} | 176 | while T::regs().cr2().read().start() {} |
| 177 | 177 | ||
| 178 | let reload = if reload { | 178 | let reload = if reload { |
| 179 | i2c::vals::Reload::NOTCOMPLETED | 179 | i2c::vals::Reload::NOTCOMPLETED |
| @@ -186,10 +186,10 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 186 | // I2C is in slave mode. | 186 | // I2C is in slave mode. |
| 187 | T::regs().cr2().modify(|w| { | 187 | T::regs().cr2().modify(|w| { |
| 188 | w.set_sadd((address << 1 | 0) as u16); | 188 | w.set_sadd((address << 1 | 0) as u16); |
| 189 | w.set_add10(i2c::vals::Add::BIT7); | 189 | w.set_add10(i2c::vals::Addmode::BIT7); |
| 190 | w.set_rd_wrn(i2c::vals::RdWrn::WRITE); | 190 | w.set_dir(i2c::vals::Dir::WRITE); |
| 191 | w.set_nbytes(length as u8); | 191 | w.set_nbytes(length as u8); |
| 192 | w.set_start(i2c::vals::Start::START); | 192 | w.set_start(true); |
| 193 | w.set_autoend(stop.autoend()); | 193 | w.set_autoend(stop.autoend()); |
| 194 | w.set_reload(reload); | 194 | w.set_reload(reload); |
| 195 | }); | 195 | }); |
diff --git a/embassy-stm32/src/rcc/f0.rs b/embassy-stm32/src/rcc/f0.rs index 1527afa05..427c958f0 100644 --- a/embassy-stm32/src/rcc/f0.rs +++ b/embassy-stm32/src/rcc/f0.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use crate::pac::rcc::vals::{Hpre, Hsebyp, Pllmul, Pllsrc, Ppre, Sw, Usbsw}; | 1 | use crate::pac::rcc::vals::{Hpre, Pllmul, Pllsrc, Ppre, Sw, Usbsw}; |
| 2 | use crate::pac::{FLASH, RCC}; | 2 | use crate::pac::{FLASH, RCC}; |
| 3 | use crate::time::Hertz; | 3 | use crate::time::Hertz; |
| 4 | 4 | ||
| @@ -16,7 +16,7 @@ pub struct Config { | |||
| 16 | pub bypass_hse: bool, | 16 | pub bypass_hse: bool, |
| 17 | pub usb_pll: bool, | 17 | pub usb_pll: bool, |
| 18 | 18 | ||
| 19 | #[cfg(rcc_f0)] | 19 | #[cfg(not(stm32f0x0))] |
| 20 | pub hsi48: bool, | 20 | pub hsi48: bool, |
| 21 | 21 | ||
| 22 | pub sys_ck: Option<Hertz>, | 22 | pub sys_ck: Option<Hertz>, |
| @@ -28,7 +28,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 28 | let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI); | 28 | let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI); |
| 29 | 29 | ||
| 30 | let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| { | 30 | let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| { |
| 31 | #[cfg(rcc_f0)] | 31 | #[cfg(not(stm32f0x0))] |
| 32 | if config.hsi48 { | 32 | if config.hsi48 { |
| 33 | return (48_000_000, true); | 33 | return (48_000_000, true); |
| 34 | } | 34 | } |
| @@ -97,10 +97,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 97 | RCC.cr().modify(|w| { | 97 | RCC.cr().modify(|w| { |
| 98 | w.set_csson(true); | 98 | w.set_csson(true); |
| 99 | w.set_hseon(true); | 99 | w.set_hseon(true); |
| 100 | 100 | w.set_hsebyp(config.bypass_hse); | |
| 101 | if config.bypass_hse { | ||
| 102 | w.set_hsebyp(Hsebyp::BYPASSED); | ||
| 103 | } | ||
| 104 | }); | 101 | }); |
| 105 | while !RCC.cr().read().hserdy() {} | 102 | while !RCC.cr().read().hserdy() {} |
| 106 | 103 | ||
| @@ -108,14 +105,12 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 108 | RCC.cfgr().modify(|w| w.set_pllsrc(Pllsrc::HSE_DIV_PREDIV)) | 105 | RCC.cfgr().modify(|w| w.set_pllsrc(Pllsrc::HSE_DIV_PREDIV)) |
| 109 | } | 106 | } |
| 110 | } | 107 | } |
| 108 | // use_hsi48 will always be false for stm32f0x0 | ||
| 109 | #[cfg(not(stm32f0x0))] | ||
| 111 | (false, true) => { | 110 | (false, true) => { |
| 112 | // use_hsi48 will always be false for rcc_f0x0 | ||
| 113 | #[cfg(rcc_f0)] | ||
| 114 | RCC.cr2().modify(|w| w.set_hsi48on(true)); | 111 | RCC.cr2().modify(|w| w.set_hsi48on(true)); |
| 115 | #[cfg(rcc_f0)] | ||
| 116 | while !RCC.cr2().read().hsi48rdy() {} | 112 | while !RCC.cr2().read().hsi48rdy() {} |
| 117 | 113 | ||
| 118 | #[cfg(rcc_f0)] | ||
| 119 | if pllmul_bits.is_some() { | 114 | if pllmul_bits.is_some() { |
| 120 | RCC.cfgr() | 115 | RCC.cfgr() |
| 121 | .modify(|w| w.set_pllsrc(Pllsrc::HSI48_DIV_PREDIV)) | 116 | .modify(|w| w.set_pllsrc(Pllsrc::HSI48_DIV_PREDIV)) |
| @@ -155,7 +150,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 155 | if config.hse.is_some() { | 150 | if config.hse.is_some() { |
| 156 | w.set_sw(Sw::HSE); | 151 | w.set_sw(Sw::HSE); |
| 157 | } else if use_hsi48 { | 152 | } else if use_hsi48 { |
| 158 | #[cfg(rcc_f0)] | 153 | #[cfg(not(stm32f0x0))] |
| 159 | w.set_sw(Sw::HSI48); | 154 | w.set_sw(Sw::HSI48); |
| 160 | } else { | 155 | } else { |
| 161 | w.set_sw(Sw::HSI) | 156 | w.set_sw(Sw::HSI) |
| @@ -169,6 +164,6 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 169 | apb2: Hertz(pclk), | 164 | apb2: Hertz(pclk), |
| 170 | apb1_tim: Hertz(pclk * timer_mul), | 165 | apb1_tim: Hertz(pclk * timer_mul), |
| 171 | apb2_tim: Hertz(pclk * timer_mul), | 166 | apb2_tim: Hertz(pclk * timer_mul), |
| 172 | ahb: Hertz(hclk), | 167 | ahb1: Hertz(hclk), |
| 173 | }); | 168 | }); |
| 174 | } | 169 | } |
diff --git a/embassy-stm32/src/rcc/f1.rs b/embassy-stm32/src/rcc/f1.rs index d44544d28..ca0883b4a 100644 --- a/embassy-stm32/src/rcc/f1.rs +++ b/embassy-stm32/src/rcc/f1.rs | |||
| @@ -173,7 +173,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 173 | apb2: Hertz(pclk2), | 173 | apb2: Hertz(pclk2), |
| 174 | apb1_tim: Hertz(pclk1 * timer_mul1), | 174 | apb1_tim: Hertz(pclk1 * timer_mul1), |
| 175 | apb2_tim: Hertz(pclk2 * timer_mul2), | 175 | apb2_tim: Hertz(pclk2 * timer_mul2), |
| 176 | ahb: Hertz(hclk), | 176 | ahb1: Hertz(hclk), |
| 177 | adc: Hertz(adcclk), | 177 | adc: Hertz(adcclk), |
| 178 | }); | 178 | }); |
| 179 | } | 179 | } |
diff --git a/embassy-stm32/src/rcc/f3.rs b/embassy-stm32/src/rcc/f3.rs index 2727a5b1c..820915312 100644 --- a/embassy-stm32/src/rcc/f3.rs +++ b/embassy-stm32/src/rcc/f3.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use crate::pac::flash::vals::Latency; | 1 | use crate::pac::flash::vals::Latency; |
| 2 | use crate::pac::rcc::vals::{Hpre, Hsebyp, Pllmul, Pllsrc, Ppre, Prediv, Sw, Usbpre}; | 2 | use crate::pac::rcc::vals::{Hpre, Pllmul, Pllsrc, Ppre, Prediv, Sw, Usbpre}; |
| 3 | use crate::pac::{FLASH, RCC}; | 3 | use crate::pac::{FLASH, RCC}; |
| 4 | use crate::rcc::{set_freqs, Clocks}; | 4 | use crate::rcc::{set_freqs, Clocks}; |
| 5 | use crate::time::Hertz; | 5 | use crate::time::Hertz; |
| @@ -106,11 +106,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 106 | // Enable HSE | 106 | // Enable HSE |
| 107 | if config.hse.is_some() { | 107 | if config.hse.is_some() { |
| 108 | RCC.cr().write(|w| { | 108 | RCC.cr().write(|w| { |
| 109 | w.set_hsebyp(if config.bypass_hse { | 109 | w.set_hsebyp(config.bypass_hse); |
| 110 | Hsebyp::BYPASSED | ||
| 111 | } else { | ||
| 112 | Hsebyp::NOTBYPASSED | ||
| 113 | }); | ||
| 114 | // We turn on clock security to switch to HSI when HSE fails | 110 | // We turn on clock security to switch to HSI when HSE fails |
| 115 | w.set_csson(true); | 111 | w.set_csson(true); |
| 116 | w.set_hseon(true); | 112 | w.set_hseon(true); |
| @@ -164,7 +160,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 164 | apb2: Hertz(pclk2), | 160 | apb2: Hertz(pclk2), |
| 165 | apb1_tim: Hertz(pclk1 * timer_mul1), | 161 | apb1_tim: Hertz(pclk1 * timer_mul1), |
| 166 | apb2_tim: Hertz(pclk2 * timer_mul2), | 162 | apb2_tim: Hertz(pclk2 * timer_mul2), |
| 167 | ahb: Hertz(hclk), | 163 | ahb1: Hertz(hclk), |
| 168 | }); | 164 | }); |
| 169 | } | 165 | } |
| 170 | 166 | ||
diff --git a/embassy-stm32/src/rcc/f4.rs b/embassy-stm32/src/rcc/f4.rs index aba8fc0ef..22a2e9ad0 100644 --- a/embassy-stm32/src/rcc/f4.rs +++ b/embassy-stm32/src/rcc/f4.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use super::sealed::RccPeripheral; | 1 | use super::sealed::RccPeripheral; |
| 2 | use crate::pac::rcc::vals::{Hpre, Hsebyp, Ppre, Sw}; | 2 | use crate::pac::rcc::vals::{Hpre, Ppre, Sw}; |
| 3 | use crate::pac::{FLASH, PWR, RCC}; | 3 | use crate::pac::{FLASH, PWR, RCC}; |
| 4 | use crate::rcc::{set_freqs, Clocks}; | 4 | use crate::rcc::{set_freqs, Clocks}; |
| 5 | use crate::time::Hertz; | 5 | use crate::time::Hertz; |
| @@ -200,7 +200,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 200 | 200 | ||
| 201 | if config.hse.is_some() { | 201 | if config.hse.is_some() { |
| 202 | RCC.cr().modify(|w| { | 202 | RCC.cr().modify(|w| { |
| 203 | w.set_hsebyp(Hsebyp(config.bypass_hse as u8)); | 203 | w.set_hsebyp(config.bypass_hse); |
| 204 | w.set_hseon(true); | 204 | w.set_hseon(true); |
| 205 | }); | 205 | }); |
| 206 | while !RCC.cr().read().hserdy() {} | 206 | while !RCC.cr().read().hserdy() {} |
diff --git a/embassy-stm32/src/rcc/f7.rs b/embassy-stm32/src/rcc/f7.rs index 1a0530296..9f2c63c16 100644 --- a/embassy-stm32/src/rcc/f7.rs +++ b/embassy-stm32/src/rcc/f7.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use super::sealed::RccPeripheral; | 1 | use super::sealed::RccPeripheral; |
| 2 | use crate::pac::pwr::vals::Vos; | 2 | use crate::pac::pwr::vals::Vos; |
| 3 | use crate::pac::rcc::vals::{Hpre, Hsebyp, Ppre, Sw}; | 3 | use crate::pac::rcc::vals::{Hpre, Ppre, Sw}; |
| 4 | use crate::pac::{FLASH, PWR, RCC}; | 4 | use crate::pac::{FLASH, PWR, RCC}; |
| 5 | use crate::rcc::{set_freqs, Clocks}; | 5 | use crate::rcc::{set_freqs, Clocks}; |
| 6 | use crate::time::Hertz; | 6 | use crate::time::Hertz; |
| @@ -213,7 +213,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 213 | 213 | ||
| 214 | if config.hse.is_some() { | 214 | if config.hse.is_some() { |
| 215 | RCC.cr().modify(|w| { | 215 | RCC.cr().modify(|w| { |
| 216 | w.set_hsebyp(Hsebyp(config.bypass_hse as u8)); | 216 | w.set_hsebyp(config.bypass_hse); |
| 217 | w.set_hseon(true); | 217 | w.set_hseon(true); |
| 218 | }); | 218 | }); |
| 219 | while !RCC.cr().read().hserdy() {} | 219 | while !RCC.cr().read().hserdy() {} |
diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs index a3a4c197f..71d44fd3c 100644 --- a/embassy-stm32/src/rcc/g0.rs +++ b/embassy-stm32/src/rcc/g0.rs | |||
| @@ -176,8 +176,8 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 176 | 176 | ||
| 177 | set_freqs(Clocks { | 177 | set_freqs(Clocks { |
| 178 | sys: sys_clk.hz(), | 178 | sys: sys_clk.hz(), |
| 179 | ahb: ahb_freq.hz(), | 179 | ahb1: ahb_freq.hz(), |
| 180 | apb: apb_freq.hz(), | 180 | apb1: apb_freq.hz(), |
| 181 | apb_tim: apb_tim_freq.hz(), | 181 | apb1_tim: apb_tim_freq.hz(), |
| 182 | }); | 182 | }); |
| 183 | } | 183 | } |
diff --git a/embassy-stm32/src/rcc/h7.rs b/embassy-stm32/src/rcc/h7.rs index 23c916365..1b2c595b3 100644 --- a/embassy-stm32/src/rcc/h7.rs +++ b/embassy-stm32/src/rcc/h7.rs | |||
| @@ -7,7 +7,7 @@ use stm32_metapac::rcc::vals::{Mco1, Mco2}; | |||
| 7 | use crate::gpio::sealed::AFType; | 7 | use crate::gpio::sealed::AFType; |
| 8 | use crate::gpio::Speed; | 8 | use crate::gpio::Speed; |
| 9 | use crate::pac::rcc::vals::Timpre; | 9 | use crate::pac::rcc::vals::Timpre; |
| 10 | use crate::pac::rcc::vals::{Ckpersel, Dppre, Hpre, Hsebyp, Hsidiv, Pllsrc, Sw}; | 10 | use crate::pac::rcc::vals::{Ckpersel, Dppre, Hpre, Hsidiv, Pllsrc, Sw}; |
| 11 | use crate::pac::{PWR, RCC, SYSCFG}; | 11 | use crate::pac::{PWR, RCC, SYSCFG}; |
| 12 | use crate::peripherals; | 12 | use crate::peripherals; |
| 13 | use crate::rcc::{set_freqs, Clocks}; | 13 | use crate::rcc::{set_freqs, Clocks}; |
| @@ -569,11 +569,7 @@ pub(crate) unsafe fn init(mut config: Config) { | |||
| 569 | // Ensure HSE is on and stable | 569 | // Ensure HSE is on and stable |
| 570 | RCC.cr().modify(|w| { | 570 | RCC.cr().modify(|w| { |
| 571 | w.set_hseon(true); | 571 | w.set_hseon(true); |
| 572 | w.set_hsebyp(if config.bypass_hse { | 572 | w.set_hsebyp(config.bypass_hse); |
| 573 | Hsebyp::BYPASSED | ||
| 574 | } else { | ||
| 575 | Hsebyp::NOTBYPASSED | ||
| 576 | }); | ||
| 577 | }); | 573 | }); |
| 578 | while !RCC.cr().read().hserdy() {} | 574 | while !RCC.cr().read().hserdy() {} |
| 579 | Some(hse) | 575 | Some(hse) |
diff --git a/embassy-stm32/src/rcc/l0.rs b/embassy-stm32/src/rcc/l0.rs index 25daeedf0..e482dcc21 100644 --- a/embassy-stm32/src/rcc/l0.rs +++ b/embassy-stm32/src/rcc/l0.rs | |||
| @@ -353,7 +353,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 353 | 353 | ||
| 354 | set_freqs(Clocks { | 354 | set_freqs(Clocks { |
| 355 | sys: sys_clk.hz(), | 355 | sys: sys_clk.hz(), |
| 356 | ahb: ahb_freq.hz(), | 356 | ahb1: ahb_freq.hz(), |
| 357 | apb1: apb1_freq.hz(), | 357 | apb1: apb1_freq.hz(), |
| 358 | apb2: apb2_freq.hz(), | 358 | apb2: apb2_freq.hz(), |
| 359 | apb1_tim: apb1_tim_freq.hz(), | 359 | apb1_tim: apb1_tim_freq.hz(), |
diff --git a/embassy-stm32/src/rcc/l1.rs b/embassy-stm32/src/rcc/l1.rs index 904e6ab5d..dfcbd4f21 100644 --- a/embassy-stm32/src/rcc/l1.rs +++ b/embassy-stm32/src/rcc/l1.rs | |||
| @@ -319,7 +319,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 319 | 319 | ||
| 320 | set_freqs(Clocks { | 320 | set_freqs(Clocks { |
| 321 | sys: sys_clk.hz(), | 321 | sys: sys_clk.hz(), |
| 322 | ahb: ahb_freq.hz(), | 322 | ahb1: ahb_freq.hz(), |
| 323 | apb1: apb1_freq.hz(), | 323 | apb1: apb1_freq.hz(), |
| 324 | apb2: apb2_freq.hz(), | 324 | apb2: apb2_freq.hz(), |
| 325 | apb1_tim: apb1_tim_freq.hz(), | 325 | apb1_tim: apb1_tim_freq.hz(), |
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 3aab01afd..5c223bc43 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | use crate::time::Hertz; | 3 | use crate::time::Hertz; |
| 4 | use core::mem::MaybeUninit; | 4 | use core::mem::MaybeUninit; |
| 5 | 5 | ||
| 6 | #[cfg_attr(any(rcc_f0, rcc_f0x0), path = "f0.rs")] | 6 | #[cfg_attr(rcc_f0, path = "f0.rs")] |
| 7 | #[cfg_attr(rcc_f1, path = "f1.rs")] | 7 | #[cfg_attr(rcc_f1, path = "f1.rs")] |
| 8 | #[cfg_attr(rcc_f3, path = "f3.rs")] | 8 | #[cfg_attr(rcc_f3, path = "f3.rs")] |
| 9 | #[cfg_attr(any(rcc_f4, rcc_f410), path = "f4.rs")] | 9 | #[cfg_attr(any(rcc_f4, rcc_f410), path = "f4.rs")] |
| @@ -24,46 +24,29 @@ pub use _version::*; | |||
| 24 | pub struct Clocks { | 24 | pub struct Clocks { |
| 25 | pub sys: Hertz, | 25 | pub sys: Hertz, |
| 26 | 26 | ||
| 27 | #[cfg(rcc_g0)] | 27 | // APB |
| 28 | pub apb: Hertz, | ||
| 29 | #[cfg(rcc_g0)] | ||
| 30 | pub apb_tim: Hertz, | ||
| 31 | |||
| 32 | #[cfg(not(rcc_g0))] | ||
| 33 | pub apb1: Hertz, | 28 | pub apb1: Hertz, |
| 34 | #[cfg(not(rcc_g0))] | ||
| 35 | pub apb1_tim: Hertz, | 29 | pub apb1_tim: Hertz, |
| 36 | |||
| 37 | #[cfg(not(rcc_g0))] | 30 | #[cfg(not(rcc_g0))] |
| 38 | pub apb2: Hertz, | 31 | pub apb2: Hertz, |
| 39 | #[cfg(not(rcc_g0))] | 32 | #[cfg(not(rcc_g0))] |
| 40 | pub apb2_tim: Hertz, | 33 | pub apb2_tim: Hertz, |
| 41 | |||
| 42 | #[cfg(any(rcc_wl5, rcc_u5))] | 34 | #[cfg(any(rcc_wl5, rcc_u5))] |
| 43 | pub apb3: Hertz, | 35 | pub apb3: Hertz, |
| 36 | #[cfg(any(rcc_h7))] | ||
| 37 | pub apb4: Hertz, | ||
| 44 | 38 | ||
| 45 | #[cfg(any(rcc_l0, rcc_l1, rcc_f0, rcc_f1, rcc_f3, rcc_f0x0, rcc_g0))] | 39 | // AHB |
| 46 | pub ahb: Hertz, | ||
| 47 | |||
| 48 | #[cfg(any( | ||
| 49 | rcc_l4, rcc_f4, rcc_f410, rcc_f7, rcc_h7, rcc_g4, rcc_u5, rcc_wb, rcc_wl5 | ||
| 50 | ))] | ||
| 51 | pub ahb1: Hertz, | 40 | pub ahb1: Hertz, |
| 52 | |||
| 53 | #[cfg(any( | 41 | #[cfg(any( |
| 54 | rcc_l4, rcc_f4, rcc_f410, rcc_f7, rcc_h7, rcc_g4, rcc_u5, rcc_wb, rcc_wl5 | 42 | rcc_l4, rcc_f4, rcc_f410, rcc_f7, rcc_h7, rcc_g4, rcc_u5, rcc_wb, rcc_wl5 |
| 55 | ))] | 43 | ))] |
| 56 | pub ahb2: Hertz, | 44 | pub ahb2: Hertz, |
| 57 | |||
| 58 | #[cfg(any(rcc_l4, rcc_f4, rcc_f410, rcc_f7, rcc_h7, rcc_u5, rcc_wb, rcc_wl5))] | 45 | #[cfg(any(rcc_l4, rcc_f4, rcc_f410, rcc_f7, rcc_h7, rcc_u5, rcc_wb, rcc_wl5))] |
| 59 | pub ahb3: Hertz, | 46 | pub ahb3: Hertz, |
| 60 | |||
| 61 | #[cfg(any(rcc_h7))] | 47 | #[cfg(any(rcc_h7))] |
| 62 | pub ahb4: Hertz, | 48 | pub ahb4: Hertz, |
| 63 | 49 | ||
| 64 | #[cfg(any(rcc_h7))] | ||
| 65 | pub apb4: Hertz, | ||
| 66 | |||
| 67 | #[cfg(any(rcc_f4, rcc_f410, rcc_f7))] | 50 | #[cfg(any(rcc_f4, rcc_f410, rcc_f7))] |
| 68 | pub pll48: Option<Hertz>, | 51 | pub pll48: Option<Hertz>, |
| 69 | 52 | ||
