mirror of https://github.com/m-labs/artiq.git
firmware: move wait for write completion to read()
This commit is contained in:
parent
a6ae08d8b8
commit
a04a36ee36
|
@ -22,13 +22,13 @@ fn write(addr: u16, data: u8) {
|
|||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_write(
|
||||
((addr as u32) << 16) | ((data as u32) << 8));
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
}
|
||||
}
|
||||
|
||||
fn read(addr: u16) -> u8 {
|
||||
unsafe {
|
||||
write((1 << 15) | addr, 0);
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_read() as u8
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ mod hmc830 {
|
|||
unsafe {
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_write(val << 1); // last clk cycle loads data
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,6 +87,7 @@ mod hmc830 {
|
|||
// the SPI round trip delay and stick with CPHA=0
|
||||
write((1 << 6) | addr, 0);
|
||||
unsafe {
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_read() & 0xffffff
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,6 @@ mod hmc7043 {
|
|||
unsafe {
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_write(val << 8);
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ mod imp {
|
|||
return Err(())
|
||||
}
|
||||
unsafe {
|
||||
while csr::converter_spi::idle_read() == 0 {}
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::offline_write(flags >> 0 & 1);
|
||||
csr::converter_spi::end_write(flags >> 1 & 1);
|
||||
// input (in RTIO): flags >> 2 & 1
|
||||
|
@ -38,7 +38,6 @@ mod imp {
|
|||
unsafe {
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_write(data);
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -48,6 +47,7 @@ mod imp {
|
|||
return Err(())
|
||||
}
|
||||
Ok(unsafe {
|
||||
while csr::converter_spi::writable_read() == 0 {}
|
||||
csr::converter_spi::data_read()
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue