Compare commits
3 Commits
4e5de7831b
...
f64e4fe2f3
Author | SHA1 | Date |
---|---|---|
Astro | f64e4fe2f3 | |
Astro | 2d2e7e80e0 | |
Astro | 2ca06e023b |
|
@ -65,8 +65,6 @@ impl<SPI: Transfer<u8>, NSS: OutputPin> Adc<SPI, NSS> {
|
||||||
data.set_enh_filt_en(true);
|
data.set_enh_filt_en(true);
|
||||||
data.set_enh_filt(PostFilter::F16SPS);
|
data.set_enh_filt(PostFilter::F16SPS);
|
||||||
data.set_order(DigitalFilterOrder::Sinc5Sinc1);
|
data.set_order(DigitalFilterOrder::Sinc5Sinc1);
|
||||||
// 10 Hz data rate
|
|
||||||
data.set_odr(0b10011);
|
|
||||||
})?;
|
})?;
|
||||||
// let mut offset = <regs::Offset as regs::Register>::Data::empty();
|
// let mut offset = <regs::Offset as regs::Register>::Data::empty();
|
||||||
// offset.set_offset(0);
|
// offset.set_offset(0);
|
||||||
|
|
|
@ -3,10 +3,10 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
branch::alt,
|
branch::alt,
|
||||||
bytes::complete::{is_a, tag, take_while1},
|
bytes::complete::{is_a, tag, take_while1},
|
||||||
character::{is_digit, complete::char},
|
character::{is_digit, complete::{char, one_of}},
|
||||||
combinator::{map, value},
|
combinator::{complete, map, value},
|
||||||
sequence::preceded,
|
sequence::preceded,
|
||||||
multi::fold_many1,
|
multi::{fold_many0, fold_many1},
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
};
|
};
|
||||||
use lexical_core as lexical;
|
use lexical_core as lexical;
|
||||||
|
@ -101,6 +101,15 @@ pub enum Command {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn end(input: &[u8]) -> IResult<&[u8], ()> {
|
||||||
|
complete(
|
||||||
|
fold_many0(
|
||||||
|
one_of("\r\n\t "),
|
||||||
|
(), |(), _| ()
|
||||||
|
)
|
||||||
|
)(input)
|
||||||
|
}
|
||||||
|
|
||||||
fn whitespace(input: &[u8]) -> IResult<&[u8], ()> {
|
fn whitespace(input: &[u8]) -> IResult<&[u8], ()> {
|
||||||
fold_many1(char(' '), (), |(), _| ())(input)
|
fold_many1(char(' '), (), |(), _| ())(input)
|
||||||
}
|
}
|
||||||
|
@ -141,11 +150,11 @@ fn report(input: &[u8]) -> IResult<&[u8], Command> {
|
||||||
|reporting| Command::Reporting(reporting))
|
|reporting| Command::Reporting(reporting))
|
||||||
),
|
),
|
||||||
// `report mode` - Show current reporting state
|
// `report mode` - Show current reporting state
|
||||||
|input| Ok((input, Command::Show(ShowCommand::Reporting)))
|
value(Command::Show(ShowCommand::Reporting), end)
|
||||||
))
|
))
|
||||||
)),
|
)),
|
||||||
// `report` - Report once
|
// `report` - Report once
|
||||||
|input| Ok((input, Command::Show(ShowCommand::Input)))
|
value(Command::Show(ShowCommand::Input), end)
|
||||||
))
|
))
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
@ -180,7 +189,7 @@ fn pwm(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
||||||
pwm_pid,
|
pwm_pid,
|
||||||
pwm_manual,
|
pwm_manual,
|
||||||
))),
|
))),
|
||||||
|input| Ok((input, Ok(Command::Show(ShowCommand::Pwm))))
|
value(Ok(Command::Show(ShowCommand::Pwm)), end)
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,15 +222,13 @@ fn pid(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
||||||
whitespace,
|
whitespace,
|
||||||
pid_parameter
|
pid_parameter
|
||||||
),
|
),
|
||||||
|input| Ok((input, Ok(Command::Show(ShowCommand::Pid))))
|
value(Ok(Command::Show(ShowCommand::Pid)), end)
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
||||||
alt((value(Ok(Command::Quit), tag("quit")),
|
alt((value(Ok(Command::Quit), tag("quit")),
|
||||||
|input| report(input).map(|(input, command)| {
|
map(report, Ok),
|
||||||
(input, Ok(command))
|
|
||||||
}),
|
|
||||||
pwm,
|
pwm,
|
||||||
pid,
|
pid,
|
||||||
))(input)
|
))(input)
|
||||||
|
|
|
@ -129,8 +129,9 @@ fn main() -> ! {
|
||||||
writeln!(stdout, "ADC id: {:04X}", id).unwrap();
|
writeln!(stdout, "ADC id: {:04X}", id).unwrap();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Ok(id) =>
|
Ok(id) => {
|
||||||
writeln!(stdout, "Corrupt ADC id: {:04X}", id).unwrap(),
|
// This always happens on the first attempt. So retry silently
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
writeln!(stdout, "AD7172: setting checksum mode").unwrap();
|
writeln!(stdout, "AD7172: setting checksum mode").unwrap();
|
||||||
|
@ -159,8 +160,9 @@ fn main() -> ! {
|
||||||
let mut pid_enabled = false;
|
let mut pid_enabled = false;
|
||||||
|
|
||||||
let mut hardware_addr = EthernetAddress(board::get_mac_address());
|
let mut hardware_addr = EthernetAddress(board::get_mac_address());
|
||||||
|
writeln!(stdout, "MAC address: {}", hardware_addr).unwrap();
|
||||||
if hardware_addr.is_multicast() {
|
if hardware_addr.is_multicast() {
|
||||||
println!("programmed MAC address is invalid, using default");
|
writeln!(stdout, "programmed MAC address is invalid, using default").unwrap();
|
||||||
hardware_addr = EthernetAddress([0x10, 0xE2, 0xD5, 0x00, 0x03, 0x00]);
|
hardware_addr = EthernetAddress([0x10, 0xE2, 0xD5, 0x00, 0x03, 0x00]);
|
||||||
}
|
}
|
||||||
let mut ip_addrs = [IpCidr::new(IpAddress::v4(192, 168, 1, 26), 24)];
|
let mut ip_addrs = [IpCidr::new(IpAddress::v4(192, 168, 1, 26), 24)];
|
||||||
|
|
Loading…
Reference in New Issue