Skip to content

Instantly share code, notes, and snippets.

@barafael
Created November 28, 2020 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barafael/77c4633c8b7c6c5c0581c8ad79ce5a01 to your computer and use it in GitHub Desktop.
Save barafael/77c4633c8b7c6c5c0581c8ad79ce5a01 to your computer and use it in GitHub Desktop.
fn print_i2c_it_flags(b: &stm32f0xx_hal::stm32f0::R<u32, stm32f0xx_hal::stm32f0::Reg<u32, pac::i2c1::_ISR>>) {
rprintln!("{");
if b.txe().is_empty() {
rprintln!("TXE Transmit Data Register Empty");
}
if b.txis().is_empty() {
rprintln!("TXIS Transmit Interrupt Status");
}
if b.rxne().is_not_empty() {
rprintln!("RXNE Receive Data Register Not Empty");
}
if b.addr().is_match_() {
rprintln!("ADDR Address Match");
}
if b.nackf().is_nack() {
rprintln!("NACKF Not Acknowledge Flag");
}
if b.stopf().is_stop() {
rprintln!("STOPF Stop Event Flag")
}
if b.tc().is_complete() {
rprintln!("TC Transfer Complete");
}
if b.tcr().is_complete() {
rprintln!("TCR Transfer Complete Reload")
}
if b.berr().is_error() {
rprintln!("BERR Bus Error");
}
if b.arlo().is_lost() {
rprintln!("ARLO Arbitration Lost");
}
if b.ovr().is_overrun() {
rprintln!("OVR Overrun Error");
}
if b.pecerr().is_match_() {
rprintln!("PECERR is match");
} else {
rprintln!("PECERR is no match");
}
if b.timeout().is_timeout() {
rprintln!("TIMEOUT Timeout Flag")
}
if b.alert().is_alert() {
rprintln!("ALERT SMBus Alert Flag");
}
if b.busy().is_busy() {
rprintln!("BUSY Busy Flag");
}
if b.dir().is_read() {
rprintln!("DIR is read");
} else {
rprintln!("DIR is write");
}
rprintln!("}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment