Skip to content

Commit 6ce89df

Browse files
Merge #295
295: Disable ethernet MAC MMC counter interrupts r=jordens a=richardeoin Patch from quartiq/stabilizer#462 Tested that the expected registers are indeed set on a STM32H747I-DISCO > MMC_RX_INTERRUPT_MASK: 0x0C020060 MMC Rx interrupt mask register > MMC_TX_INTERRUPT_MASK: 0x0C20C000 MMC Tx interrupt mask register Closes #275 Co-authored-by: Richard Meadows <[email protected]>
2 parents 8350d5f + cddf0e0 commit 6ce89df

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/ethernet/eth.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ pub fn new<'a, const TD: usize, const RD: usize>(
428428
/// [StationManagement](super::StationManagement) trait. This can be used to
429429
/// communicate with the external PHY.
430430
///
431+
/// All the documented interrupts in the `MMC_TX_INTERRUPT_MASK` and
432+
/// `MMC_RX_INTERRUPT_MASK` registers are masked, since these cause unexpected
433+
/// interrupts after a number of days of heavy ethernet traffic. If these
434+
/// interrupts are desired, you can be unmask them in your own code after this
435+
/// method.
436+
///
431437
/// # Safety
432438
///
433439
/// `EthernetDMA` shall not be moved as it is initialised here
@@ -572,6 +578,46 @@ pub unsafe fn new_unchecked<'a, const TD: usize, const RD: usize>(
572578
w.pt().bits(0x100)
573579
});
574580
eth_mac.macrx_fcr.modify(|_, w| w);
581+
582+
// Mask away Ethernet MAC MMC RX/TX interrupts. These are statistics
583+
// counter interrupts and are enabled by default. We need to manually
584+
// disable various ethernet interrupts so they don't unintentionally
585+
// hang the device. The user is free to re-enable them later to provide
586+
// ethernet MAC-related statistics
587+
eth_mac.mmc_rx_interrupt_mask.modify(|_, w| {
588+
w.rxlpiuscim()
589+
.set_bit()
590+
.rxucgpim()
591+
.set_bit()
592+
.rxalgnerpim()
593+
.set_bit()
594+
.rxcrcerpim()
595+
.set_bit()
596+
});
597+
598+
eth_mac.mmc_tx_interrupt_mask.modify(|_, w| {
599+
w.txlpiuscim()
600+
.set_bit()
601+
.txgpktim()
602+
.set_bit()
603+
.txmcolgpim()
604+
.set_bit()
605+
.txscolgpim()
606+
.set_bit()
607+
});
608+
// TODO: The MMC_TX/RX_INTERRUPT_MASK registers incorrectly mark
609+
// LPITRCIM as read-only, so svd2rust doens't generate bindings to
610+
// modify them. Instead, as a workaround, we manually manipulate the
611+
// bits
612+
unsafe {
613+
eth_mac
614+
.mmc_tx_interrupt_mask
615+
.modify(|r, w| w.bits(r.bits() | (1 << 27)));
616+
eth_mac
617+
.mmc_rx_interrupt_mask
618+
.modify(|r, w| w.bits(r.bits() | (1 << 27)));
619+
}
620+
575621
eth_mtl.mtlrx_qomr.modify(|_, w| {
576622
w
577623
// Receive store and forward

0 commit comments

Comments
 (0)