Skip to content

Commit f8faf0b

Browse files
Merge pull request #20 from birkenfeld/allow-180mhz
Remove maximum limit on HCLK
2 parents 9449a26 + 437e2c7 commit f8faf0b

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main() {
4343
let p = Peripherals::take().unwrap();
4444

4545
let rcc = p.RCC.constrain();
46-
// HCLK must be between 25MHz and 168MHz to use the ethernet peripheral
46+
// HCLK must be at least 25MHz to use the ethernet peripheral
4747
let clocks = rcc.cfgr.sysclk(32.mhz()).hclk(32.mhz()).freeze();
4848

4949
let gpioa = p.GPIOA.split();

examples/ip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn main() -> ! {
6262
let mut cp = CorePeripherals::take().unwrap();
6363

6464
let rcc = p.RCC.constrain();
65-
// HCLK must be between 25MHz and 168MHz to use the ethernet peripheral
65+
// HCLK must be at least 25MHz to use the ethernet peripheral
6666
let clocks = rcc.cfgr.sysclk(32.mhz()).hclk(32.mhz()).freeze();
6767

6868
setup_systick(&mut cp.SYST);

examples/pktgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> ! {
3636
let mut cp = CorePeripherals::take().unwrap();
3737

3838
let rcc = p.RCC.constrain();
39-
// HCLK must be between 25MHz and 168MHz to use the ethernet peripheral
39+
// HCLK must be at least 25MHz to use the ethernet peripheral
4040
let clocks = rcc.cfgr.sysclk(32.mhz()).hclk(32.mhz()).freeze();
4141

4242
setup_systick(&mut cp.SYST);

src/lib.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ mod consts {
5555
pub const ETH_MACMIIAR_CR_HCLK_DIV_16: u8 = 2;
5656
/* For HCLK 35-60 MHz */
5757
pub const ETH_MACMIIAR_CR_HCLK_DIV_26: u8 = 3;
58-
/* For HCLK 150-168 MHz */
58+
/* For HCLK over 150 MHz */
5959
pub const ETH_MACMIIAR_CR_HCLK_DIV_102: u8 = 4;
6060
}
6161
use self::consts::*;
6262

63-
/// HCLK must be between 25MHz and 168MHz to use the ethernet peripheral.
63+
/// HCLK must be at least 25MHz to use the ethernet peripheral.
6464
#[derive(Debug)]
6565
pub struct WrongClock;
6666

@@ -86,10 +86,10 @@ impl<'rx, 'tx> Eth<'rx, 'tx> {
8686
///
8787
/// Make sure that the buffers reside in a memory region that is
8888
/// accessible by the peripheral. Core-Coupled Memory (CCM) is
89-
/// usually not accessible. HCLK must be between 25MHz and 168MHz for STM32F4xx
90-
/// or 25MHz to 216MHz for STM32F7xx.
89+
/// usually not accessible. HCLK must be at least 25MHz.
9190
///
92-
/// Uses an interrupt free critical section to turn on the ethernet clock for STM32F7xx.
91+
/// Uses an interrupt free critical section to turn on the ethernet clock
92+
/// for STM32F7xx.
9393
///
9494
/// Other than that, initializes and starts the Ethernet hardware
9595
/// so that you can [`send()`](#method.send) and
@@ -131,15 +131,12 @@ impl<'rx, 'tx> Eth<'rx, 'tx> {
131131

132132
fn init(&mut self, clocks: Clocks) -> Result<(), WrongClock> {
133133
let clock_range = match clocks.hclk().0 {
134-
60_000_000..=99_999_999 => ETH_MACMIIAR_CR_HCLK_DIV_42,
135-
100_000_000..=149_999_999 => ETH_MACMIIAR_CR_HCLK_DIV_62,
134+
0..=24_999_999 => return Err(WrongClock),
136135
25_000_000..=34_999_999 => ETH_MACMIIAR_CR_HCLK_DIV_16,
137136
35_000_000..=59_999_999 => ETH_MACMIIAR_CR_HCLK_DIV_26,
138-
#[cfg(feature = "stm32f4xx-hal")]
139-
150_000_000..=168_000_000 => ETH_MACMIIAR_CR_HCLK_DIV_102,
140-
#[cfg(feature = "stm32f7xx-hal")]
141-
150_000_000..=216_000_000 => ETH_MACMIIAR_CR_HCLK_DIV_102,
142-
_ => return Err(WrongClock),
137+
60_000_000..=99_999_999 => ETH_MACMIIAR_CR_HCLK_DIV_42,
138+
100_000_000..=149_999_999 => ETH_MACMIIAR_CR_HCLK_DIV_62,
139+
_ => ETH_MACMIIAR_CR_HCLK_DIV_102,
143140
};
144141
self.reset_dma_and_wait();
145142

0 commit comments

Comments
 (0)