ad7172: setup_channel() fixes

This commit is contained in:
Astro 2019-09-14 02:18:47 +02:00
parent 957f92d177
commit 07dcc608bc

View File

@ -46,13 +46,14 @@ impl<SPI: Transfer<u8>, NSS: OutputPin> Adc<SPI, NSS> {
) -> Result<(), AdcError<SPI::Error>> { ) -> Result<(), AdcError<SPI::Error>> {
self.update_reg(&regs::SetupCon { index }, |data| { self.update_reg(&regs::SetupCon { index }, |data| {
data.set_bi_unipolar(false); data.set_bi_unipolar(false);
data.set_refbuf_pos(true);
data.set_refbuf_neg(true);
data.set_ainbuf_pos(true);
data.set_ainbuf_neg(true);
// TODO: which RefSource?
data.set_ref_sel(RefSource::Internal);
})?; })?;
self.update_reg(&regs::FiltCon { index }, |data| {
// 10 Hz data rate
data.set_odr(0b10011);
})?;
// let mut offset = <regs::Offset as regs::Register>::Data::empty();
// offset.set_offset(0);
// self.write_reg(&regs::Offset { index }, &mut offset);
self.update_reg(&regs::Channel { index }, |data| { self.update_reg(&regs::Channel { index }, |data| {
data.set_setup(index); data.set_setup(index);
data.set_enabled(true); data.set_enabled(true);