ChanServ changed the topic of #rust-embedded to: Welcome to the Rust Embedded IRC channel! Bridged to #rust-embedded:matrix.org and logged at https://libera.irclog.whitequark.org/rust-embedded, code of conduct at https://www.rust-lang.org/conduct.html
_whitelogger has joined #rust-embedded
<re_irc> <@dngrs:matrix.org> if addr & 1 {
<re_irc> }
<re_irc> self.addr_a.set_low();
<re_irc> self.addr_a.set_high();
<re_irc> } else {
<re_irc> if addr & 2 {
<re_irc> self.addr_b.set_high();
<re_irc> } else {
<re_irc> self.addr_b.set_low();
<re_irc> }
<re_irc> if addr & 4 {
<re_irc> self.addr_c.set_high();
<re_irc> } else {
<re_irc> self.addr_c.set_low();
<re_irc> }
<re_irc> this kinds sucks, how can I best shorten it?
<re_irc> <@9names:matrix.org> can at least reduce each to one line
<re_irc> self.addr_a.set_state(if addr & 1 { PinState::High } else { PinState::Low});
<re_irc> <@dngrs:matrix.org> hmyeah
<re_irc> <@dngrs:matrix.org> (I also forgot the "> 0" part but oh well)
<re_irc> <@dngrs:matrix.org> unfortunately rustfmt turns it into several lines again lol (yeah I could customize it but ...)
<re_irc> <@dngrs:matrix.org> I can make a helper fn
<re_irc> <@9names:matrix.org> yeah. you can make it a little nicer with an arrays of pins, but that requires type erased pins which does not spark joy
<re_irc> <@9names:matrix.org> and, you know, dyn + box. but that also does not spark joy
<re_irc> <@dngrs:matrix.org> I'm using embassy, they're erased alright
IlPalazzo-ojiisa has quit [Read error: Connection reset by peer]
<re_irc> <@dngrs:matrix.org> but I guess it's fine enough now
<re_irc> <@9names:matrix.org> i like it
<re_irc> <@9names:matrix.org> i was about to ask about zipping another iter :D
<re_irc> <@9names:matrix.org> is it cheaper to do the <<= or just 1<<idx for a range?
<re_irc> <@jamesmunns:beeper.com> : probably about the same, depending on how large idx is
<re_irc> <@jamesmunns:beeper.com> cortex-m has a "free" shift iirc up to some number (5-6?) bits
<re_irc> <@jamesmunns:beeper.com> codegen might not work if it can't "see" that the largest shift is within that range
<re_irc> <@dngrs:matrix.org> hmyeah shifting is probably nicer
<re_irc> a job for future me
<re_irc> <@dngrs:matrix.org> first rp pio program does ... something, at least!
<re_irc> <@dngrs:matrix.org> for reasons unknown the clock pin side set is fine but the actual output pins stay low forever lol
<re_irc> well, time to bed and take another look tomorrow.
id_tam has joined #rust-embedded
crabbedhaloablut has joined #rust-embedded
emerent has quit [Ping timeout: 264 seconds]
IlPalazzo-ojiisa has joined #rust-embedded
emerent has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
dc740 has joined #rust-embedded
Foxyloxy has quit [Quit: Textual IRC Client: www.textualapp.com]
IlPalazzo-ojiisa has quit [Quit: Leaving.]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
Foxyloxy has joined #rust-embedded
IlPalazzo-ojiisa has quit [Read error: Connection reset by peer]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
<re_irc> <@firefrommoonlight:matrix.org> Launching this soon; firmware in Rust: https://www.anyleaf.org/gnss-can
IlPalazzo-ojiisa has joined #rust-embedded
<re_irc> <@jamwaffles:matrix.org> Huge shoutout to the "defmt" devs. I still can't quite believe I get basically the same log detail on a lil STM32 that I do in a full blown Linux environment. Truly impressive, and extremely useful for debugging. Thank you ❤️
<re_irc> <@firefrommoonlight:matrix.org> Thx for teh whole Knurling app tepmlate stack
<re_irc> <@firefrommoonlight:matrix.org> Those are absolutely critical to the Rust embedded experience
<re_irc> <@firefrommoonlight:matrix.org> and the PAC team (most notablly Agg)
<re_irc> <@firefrommoonlight:matrix.org> Those are critical to the Rust embedded experience
<re_irc> <@whitequark:matrix.org> "defmt" is really good
m5zs7k has quit [Ping timeout: 245 seconds]
m5zs7k has joined #rust-embedded
dc740 has quit [Remote host closed the connection]
<re_irc> <@thejpster:matrix.org> I shall pass on your thanks to Jorge and the team.
<re_irc> <@thejpster:matrix.org> I claim no credit - it predates my arrival.
crabbedhaloablut has quit []
<re_irc> <@phaseonx11:matrix.org> Hello all! Back for some help, after trying to solve this myself all week.
<re_irc> I'm exploring the possibility of writing a simple driver for a Ublox GPS receiver, the NEO-M9N.
<re_irc> So far, I've been attempting to figure out how to read data from it and its registers using i2c in a stable way and keep running into time out issues...
<re_irc> - My code doesn't run reliably. I'm probably not waiting for the device correctly, because it often takes a few resets for things to run as I expect.
<re_irc> - I might not be reading from the register correctly? All the examples use write_read, but that always times out in my case. I have to use separate read and write calls.
<re_irc> - From reading the integration manual, what I've understood is you make calls to read 0xFD and 0xFE, that gives you the amount of bytes left. Then, you keep reading 0xFF one byte at a time, until you get
<re_irc> I've made sure that the i2c bus is running at a frequency the device supports (400 kHz) and that I'm using the right port (0x42)...I've attached my code and a link to the integration guide + a snippet of it detailing i2c connectivity. https://pastebin.com/SjXjL1d1
<re_irc> <@phaseonx11:matrix.org> +a 0xFF byte as a response...which means there is no more data to read at the moment.
<re_irc> <@phaseonx11:matrix.org> * address
Guest6498 has joined #rust-embedded
Guest6498 is now known as nex8192
<re_irc> <@henrik_alser:matrix.org> Luis Roel: 👋 Does any i2c transfer at all succeed? What Error are you getting?
<re_irc> <@henrik_alser:matrix.org> Double checked all connections? And made sure SDA/SCL are not swapped etc?
<re_irc> <@jamesmunns:beeper.com> also something to note, some more complex i2c devices will have their own boot up time, which might be shorter than the MCU's boot time. So you might need to wait a few hundred ms after startup before you start talking to them
<re_irc> <@henrik_alser:matrix.org> Also some datasheets will give the address in ”pre shifted” format, so you might need to right shift it by one
<re_irc> <@like2wise:matrix.org> pull ups on the wires? how strong? what kind of wires? length?
<re_irc> <@like2wise:matrix.org> tried lower sck speeds?
<re_irc> <@like2wise:matrix.org> voltage levels?
<re_irc> <@henrik_alser:matrix.org> Do you have a scope or logic analyzer?
nex8192 has left #rust-embedded [Error from remote client]
<re_irc> <@phaseonx11:matrix.org> : Hello Henrik, thank you for your reply. Yes, it seems that I am able to transfer a few bytes...after which, it fails continously with timeout.
<re_irc> Sent init call to GPS...
<re_irc> Got low byte of bytes avail: 110010
<re_irc> Sent init call to GPS...
<re_irc> Bytes available: 11826
<re_irc> God high byte of bytes avail: 101110
<re_irc> Selected register...
<re_irc> Reading data...
<re_irc> Read a byte: 30
<re_irc> 11825 bytes left...
<re_irc> Read a byte: 30
<re_irc> 11824 bytes left...
<re_irc> Read a byte: 2C
<re_irc> 11823 bytes left...
<re_irc> Error reading byte: TimeOut...
<re_irc> Waiting...
<re_irc> Error reading byte: TimeOut...
<re_irc> Waiting...
<re_irc> Error reading byte: TimeOut...
<re_irc> Waiting...
<re_irc> Error reading byte: TimeOut...
<re_irc> Waiting...
<re_irc> Error reading byte: TimeOut...
<re_irc> Waiting...
<re_irc> Error reading byte: TimeOut...
<re_irc> Waiting...
<re_irc> <@phaseonx11:matrix.org> : Thank you for your reply James, I expected as much so I wait about 1000 ms before making that first call to the device.
<re_irc> <@phaseonx11:matrix.org> : No, unfortunately I do not. I have purchased one but it comes next week :)
<re_irc> <@phaseonx11:matrix.org> : Unfortunately, a lower speed would not work because the GPS device only functions in "fast" mode (400 kHz).
<re_irc> <@phaseonx11:matrix.org> : There is a set of pullups on the bus...I am not sure what strength. They are connected via an m2 connector.
<re_irc> I use this (https://www.sparkfun.com/products/20595) along with two function cards.
<re_irc> <@phaseonx11:matrix.org> +I cut the pullups on everything else as I was advised you should only have one set per bus...
<re_irc> <@phaseonx11:matrix.org> : Yes, I have made sure the pins are correct. I am able to comm with an SSD1306 OLED controller using the same bus...
<re_irc> <@phaseonx11:matrix.org> : I have verified I am using the correct address by running this:
<re_irc> const VALID_ADDR_RANGE: Range<u8> = 0x08..0x78;
<re_irc> if VALID_ADDR_RANGE.contains(&addr) && i2c.write(addr, &[]).is_ok() {
<re_irc> println!("{:02x}", addr)
<re_irc> for addr in 0x00_u8..0x80 {
<re_irc> }
<re_irc> }
<re_irc> I get the expected address back (0x42)
<re_irc> <@phaseonx11:matrix.org> cccccbdilnlhgvhjbjkbdlclrntbucjhdlcjldkvnlue
nex8192 has joined #rust-embedded
<re_irc> <@phaseonx11:matrix.org> : I'm not sure but I think you might be onto something...see, I use this code to print all the available device addresses (to debug):
<re_irc> const VALID_ADDR_RANGE: Range<u8> = 0x08..0x78;
<re_irc> for addr in 0x00_u8..0x80 {
<re_irc> if VALID_ADDR_RANGE.contains(&addr) && i2c.write(addr, &[]).is_ok() {
<re_irc> }
<re_irc> println!("{:x}", addr)
<re_irc> }
<re_irc> Sometimes I get back the address of the device (0x42) and sometimes I don't...
<re_irc> <@phaseonx11:matrix.org> Which leads me to believe that the module is failing to start sometimes?
<re_irc> <@henrik_alser:matrix.org> Luis Roel: Luis Roel: You can always go slower, try 100k and see what you get
duderonomy has quit [Ping timeout: 244 seconds]
<re_irc> <@phaseonx11:matrix.org> : It doesn't seem to make a difference, however, it still reads for some reason?
<re_irc> Something I've noticed:
<re_irc> I keep getting the same data back from the GPS receiver...
<re_irc> M C , 2 3 3
<re_irc> 4d 43 2c 32 33 33
<re_irc> I've tried to search and see if its some kind of error code...but I can't seem to find anything.
<re_irc> <@phaseonx11:matrix.org> (It returns same on 400kHz...)
nex8192 has left #rust-embedded [Error from remote client]
<Darius> what GPS receiver?
<re_irc> <@henrik_alser:matrix.org> Luis Roel: Hmm
<re_irc> <@henrik_alser:matrix.org> Could it be some issue with how esp32 handles clock stretching?
<re_irc> <@henrik_alser:matrix.org> So it times out while waiting
<re_irc> <@henrik_alser:matrix.org> Is the i2c timeout configurable via the hal you’re using?
<re_irc> <@henrik_alser:matrix.org> If not, you could try unsafe setting it to maximum value via the pac just to see if this is the issue