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
<re_irc> <yruama_lairba> yep, ADC and DAC are very close, and each time Dma transfert is half or full, i spawn a process task that process the half where ADC and DAC are not writing
<re_irc> <yruama_lairba> but if the process take too long, a collision can happen with ADC writting and DAC reading
<re_irc> <firefrommoonlight> Clever
<re_irc> <firefrommoonlight> Same thing with the 2x double-buffer approach
<re_irc> <firefrommoonlight> If the computation takes longer than it takes to fill half of the buffer, the sound get screwed up
<re_irc> <firefrommoonlight> In my use case, would happen if I got too greedy with the filters
<re_irc> <yruama_lairba> on thing i didn't tryed to use yet is a DMA feature allowing to swap half words. when using DMA with a 32bts long i2s channel, MSB and lSB are swapped
<re_irc> <yruama_lairba> bye
<re_irc> <firefrommoonlight> Oh weird
<re_irc> <firefrommoonlight> see ya!
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
cr1901 has quit [Remote host closed the connection]
cr1901 has joined #rust-embedded
cr1901 has quit [Remote host closed the connection]
cr1901 has joined #rust-embedded
fabic has joined #rust-embedded
explore has joined #rust-embedded
explore has quit [Quit: Connection closed for inactivity]
emerent has quit [Killed (erbium.libera.chat (Nickname regained by services))]
emerent has joined #rust-embedded
dreamcat4 has joined #rust-embedded
gsalazar_ has joined #rust-embedded
gsalazar_ has quit [Quit: Leaving]
gsalazar has joined #rust-embedded
fabic has quit [Ping timeout: 246 seconds]
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 256 seconds]
fabic has joined #rust-embedded
cr1901 has quit [Remote host closed the connection]
cr1901 has joined #rust-embedded
<re_irc> <yruama_lairba> firefrommoonlight: no so weird, it's because how I2S hardware and DMA works. The I2S data register is 16 bits only, so when using an 32bits channel, you need to read twice the data register to get your 32 bits words. you first get the 16 MSB and then the 16 LSB.
<re_irc> <firefrommoonlight> Ah gotcha. I'm used to the 32-bit SAI regs
<re_irc> <yruama_lairba> and dma in direct mode can only write data sequentially. with the endiantness, it's swap MSB and LSB
<re_irc> <firefrommoonlight> Still a lot of bit-related things to be careful with. 2's complement 24-bit numbers without a rust i24 etc
<re_irc> <yruama_lairba> is there a way to have the equivelent functionnlity but for only one element ?
<re_irc> <yruama_lairba> heapless::spsc::Queue
<re_irc> <ryan-summers> Rust has native endian swapping tools
<re_irc> <yruama_lairba> i want a lockless way to communicate data across task. but having a queue more than 1 element is completly useless for my application
<re_irc> <yruama_lairba> ryan-summers: i know, but this is not an endian reverse issue
gsalazar has quit [Ping timeout: 246 seconds]
<re_irc> <yruama_lairba> i get this error "this implementation doesn't support shared ("&-") - exclusive ("&mut-") locks; use "x" instead of "&x""
<re_irc> <newam> yeah it's a work in progress as far as I know
<re_irc> <newam> Just lock it or use atomic data types
<re_irc> <yruama_lairba> how you can share atomic without lock ?
<re_irc> <newam> Atomics use atomic instructions, which means that hardware interrupt cannot read or store a partial value to the location.
<re_irc> <newam> * interrupts
<re_irc> <firefrommoonlight> Atomics are great. You can use them safely without any special management. Try to conbine operations where possible instead of just using store and load
<re_irc> <firefrommoonlight> However... While memory safe, they can still cause structural complication, as with all global vars
<re_irc> if you have a couple hours to kill that's a good in-depth overview of atomics and memory ordering
<re_irc> <newam> * video
<re_irc> <yruama_lairba> newam: that doesn't respond to my question, how i can sematically use atomic to share data across task without lock ?
<re_irc> <firefrommoonlight> So, you may still want to use a struct as an RTIC resource or w/e to keep your code more organized instead of firing off atomic ops from all over the code base
vancz has quit []
<re_irc> <firefrommoonlight> yruama_lairba: I don't understand the Q
vancz has joined #rust-embedded
<re_irc> <firefrommoonlight> By nature, atomics are safe without locking when used correctly
<re_irc> <firefrommoonlight> Although you can still get into synchronization trouble
<re_irc> <newam> yruama_lairba: You can share any atomic type (depends on the platform) across interrupts without locks
<re_irc> <newam> Atomics use atomic instructions, which means that you cannot read or store a partial value to the location.
<re_irc> <newam> Atomics use atomic instructions, which means that you cannot read or store a partial value
<re_irc> <firefrommoonlight> Also, I want a native Atomic enum. Please??
<re_irc> Most micros don't have AtomicU64 though (and some don't even have atomics at all)
<re_irc> <firefrommoonlight> I think Cortex M0 doesn't have atomics, right?
<re_irc> <firefrommoonlight> So, Stm32 F0 and G0 for example
<re_irc> <newam> Yeah, no atomics on thumbv6 :(
<re_irc> <yruama_lairba> how i can do that in a task : "let sample = _cx.shared.sample.load(Ordering::Acquire);"
<re_irc> static SAMPLE: AtomicU32 = AtomicU32::new(0);
<re_irc> fn my_task() {
<re_irc> let sample = SAMPLE.load(Ordering::Acquire);
<re_irc> <newam> You make it a global static (which is safe with atomics), for example
<re_irc> }
<re_irc> <yruama_lairba> thank you
<re_irc> <firefrommoonlight> Check out the various methods in the rust docs like fetch-add, compare_exchange etc
<re_irc> <firefrommoonlight> They add conceptual overhead, but keep the operations... Atomic?
<re_irc> <firefrommoonlight> They are uniform, solid, hard, incompressible, and indestructible
<re_irc> <yruama_lairba> yep, but i guess atomic operation can have side effect on optimisation
<re_irc> <yruama_lairba> anyway, i was just curious, i think i need to be used to "Ordering" concept before really using Atomics
<re_irc> <firefrommoonlight> Any C++ mats you find will be relevant
<re_irc> <firefrommoonlight> You can go far by aping before the understanding arrives
fabic has quit [Ping timeout: 256 seconds]
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
cr1901_ has joined #rust-embedded
cr1901_ has quit [Read error: Connection reset by peer]
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
<re_irc> <James Munns> Update, got "tracing-rs" working _mostly_ in a way that would allow us to use it on embedded (without using "json" as your serialization format). Definitely heavier than "defmt" (no interning), but might be interesting to some of y'all.
<re_irc> <James Munns> Right now I'm working on a sink that feeds to "bbqueue", but I'll probably make an RTT version of it too.
<re_irc> <James Munns> Where heavier means most non-trival messages are at least 100 bytes or so
dc740 has joined #rust-embedded
dc740 has quit [Quit: Leaving]
dc740 has joined #rust-embedded
dc_740 has joined #rust-embedded
dc_740 has quit [Client Quit]
dc740 has quit [Quit: Leaving]
dc740 has joined #rust-embedded
dc740 has quit [Quit: Leaving]
<re_irc> <dirbaio> Just released "embedded-io" to crates.io. IO traits for no_std, embedded-hal style. Both blocking and async.
<re_irc> <dirbaio> * Comes in both blocking and async flavors.
<re_irc> <dirbaio> Implemented in Embassy HALs for UARTs, and in embassy-net for TCP