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
notgull has quit [Ping timeout: 260 seconds]
notgull has joined #rust-embedded
crabbedhaloablut has quit []
wllenyj[m] has quit [Quit: Idle timeout reached: 172800s]
Guest7221 has left #rust-embedded [Disconnected: Replaced by new connection]
euphemism[m] has joined #rust-embedded
<euphemism[m]> Hey there, quick(ish) question. I am new to the embedded world due to my aversion to C/C++. I figured I would two-birds-one-stone this with my desire to learn Rust. I have a USB device that is both CDC and UAC1. I want to build a USB host using an RP2040 that can receive both the audio stream and serial data from this device.
<euphemism[m]> Discovered tinyUSB, but as far as I can tell it does not support USB audio in the host stack. I found this C library that does: https://github.com/cherry-embedded/CherryUSB/ and my question is if anyone thinks it would be possible to use bindgen to enable use of this library from a Rust codebase.
<euphemism[m]> Got this up and running on a Pico really easily, and is currently what I'm working with: https://github.com/rp-rs/rp2040-project-template
<adamgreig[m]> not easy, it looks like their host stack requires some sort of operating system that has threads and allocation
<adamgreig[m]> certainly possible, but you'd need to be running some sort of RTOS that provides threads, which is not common in embedded rust as people tend to use async (or a framework like rtic which provides hardware threads but won't work with this, I don't think)
<adamgreig[m]> USB host mode is generally harder and rarer, so you're off to a difficult start to begin with :P
<adamgreig[m]> probably the best bet is to use something like FreeRTOS, use CherryUSB in C inside it with its provided FreeRTOS OS bindings, and then write the rest of your program in Rust using the FreeRTOS rust support (maybe https://github.com/lobaro/FreeRTOS-rust )
<adamgreig[m]> also USB audio is probably the hardest part of USB, heh
<euphemism[m]> adamgreig[m]: So it would seem..
<euphemism[m]> Okay. I will start looking into that. Thank you, adamgreig.
emerent has quit [Ping timeout: 258 seconds]
emerent has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
M9names[m] has joined #rust-embedded
<M9names[m]> might be worth asking on the cherryusb github whether adamgreig's intuition is correct WRT needing an RTOS.
<M9names[m]> no-one is going to know that USB stack better than the author
crabbedhaloablut has joined #rust-embedded
neceve has joined #rust-embedded
IlPalazzo-ojiisa has joined #rust-embedded
Guest7221 has joined #rust-embedded
ryan-summers[m] has quit [Quit: Idle timeout reached: 172800s]
Farooq has quit [Quit: Idle timeout reached: 172800s]
therealprof[m] has quit [Quit: Idle timeout reached: 172800s]
Guest7221 has left #rust-embedded [Error from remote client]
<adamgreig[m]> the readme says the host stack requires the OSAL, and the OSAL requires functions for creating a thread, so it seems likely
HumanG33k has joined #rust-embedded
Guest7221 has joined #rust-embedded
<waveguide[m]> I think cherryusb was a rip off of the zephyr usb stack?
<waveguide[m]> * usb stack? or maybe that was some other usb stack, someone ripped off someone at some point
<waveguide[m]> * <del>I think, * usb stack? or maybe that was some other usb stack, someone ripped off someone at some point</del> Just forget that, no idea what I'm talking about
IlPalazzo-ojiisa has quit [Quit: Leaving.]
TomB[m] has quit [Quit: Idle timeout reached: 172800s]
<waveguide[m]> Are there any example hal drivers for where a peripheral has something where a tx and rx handles (multiple!) may be created from a base peripheral wrapper
<waveguide[m]> e.g. struct BaseIp { ptr: BasePtr } struct Tx<N> { b: BaseIP } impl BaseIp { fn tx<N>(&mut self) { Tx { self } }, I guess I sort of need a ref count like shared object in this case? Rc<> or Arc<> or whatever, but that also seems kind of insane... in the end its a pointer to the address of the IP block I'm sharing
<waveguide[m]> The peripheral in this case is nxp's sai peripheral, which depending on the IP block instance may have N many channels, both tx and rx being optional... with each one sharing some base IP block configuration but also having their own fifo and data pin
<waveguide[m]> but at minimum there's 1 tx and rx per IP instance
<waveguide[m]> the way the mcux hal code deals with this is by assuming every instance has 4 channels and its up the author to deal with all the possibly erroneous configurations...
<waveguide[m]> s/a//
diondokter[m] has joined #rust-embedded
<diondokter[m]> Sounds similar to split uarts where one peripheral is split into a tx and an rx part
<waveguide[m]> Kind of, in this case though each tx and rx is optional
<waveguide[m]> Like maybe sai0 only transmits and sai1 only receives, or maybe sai0 transmits on some subset of the 4 channels
<waveguide[m]> Or maybe sai0 connected to a codec uses a single tx and rx pair 
<diondokter[m]> Sure, but how you share it is the same principle.
<diondokter[m]> It clones the peripheral because both parts only touch registers that don't overlap.
<waveguide[m]> Ok that might be what I need to look at
<waveguide[m]> It does seem to keep a ref count?
<waveguide[m]> I can have a bitmap instead to mark channels in use
<diondokter[m]> That's for the drop I think. Embassy turns off the peripheral once it's dropped
IlPalazzo-ojiisa has joined #rust-embedded
TimHilt[m]1 has joined #rust-embedded
<TimHilt[m]1> Hi there! I’m just learning Rust with the goal of writing an audio-application for the Orange Pi Zero LTS (http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero-LTS.html).
<TimHilt[m]1> The application should also include a few push-buttons and an SPI enabled device. I’m currently looking for a crate that I can use with this particular hardware. Do you think https://github.com/rust-embedded/linux-embedded-hal would be a good fit? I’m looking for something that’s not too low level because I fear I might be overwhelmed with too many things not working / not compiling
d3zd3z[m] has quit [Quit: Idle timeout reached: 172800s]
K900 has quit [Quit: Idle timeout reached: 172800s]
Guest7221 has left #rust-embedded [Error from remote client]
GrantM11235[m] has quit [Quit: Idle timeout reached: 172800s]
newam[m] has quit [Quit: Idle timeout reached: 172800s]
lkostka[m] has quit [Quit: Idle timeout reached: 172800s]
ian_rees[m] has quit [Quit: Idle timeout reached: 172800s]
<dirbaio[m]> Tim Hilt: yep that should work on the pi zero
<dirbaio[m]> you might have to adjust the device tree for SPI stuff, not sure
<dirbaio[m]> beware wifi support on that board is a giant mess and super unstable tho 🙃
<dirbaio[m]> (or was in ~2020 at least, when I worked with it)
<TimHilt[m]1> Alright, I’m excited to see how it goes. Never worked with Orange Pi’s before 😅
<dirbaio[m]> what's the reason for picking it? cost?
<TimHilt[m]1> Cost, availability and audio capabilities. There’s a dedicated io-shield for 3€ that hosts a line-out port
<TimHilt[m]1> If I have questions along the way - would this channel be a good place to ask?
<dirbaio[m]> yup!
<TimHilt[m]1> Great! Thanks. I’ll open source everything I’ll do anyways. :)
<dirbaio[m]> how many are you going to build? I have a box of 200 of them I can sell you for cheap 🤣
<dirbaio[m]> (used though, and the previous version based on the H2+ instead of the H3...)
<M9names[m]> <dirbaio[m]> "beware wifi support on that..." <- Xr819, yeah? Good times.
<TimHilt[m]1> Haha only one :D it’s supposed to be a child’s audio-player with Spotify integration. The songs start playing by reading an nfc tag
<dirbaio[m]> lol
<dirbaio[m]> okay 😂
<TimHilt[m]1> 9names: uhoh
<dirbaio[m]> yeah, only use that board if you're going to use it with ethernet
<TimHilt[m]1> dirbaio: this already exists (at least in Germany, no idea about global scope) and it’s named the „Tonie box“. Every nfc tag costs around 16€
<TimHilt[m]1> dirbaio[m]: I guess then the orange pi is out. Ethernet won’t be an option
<TimHilt[m]1> Any recommendations at around the same price point? I guess the obvious contender would be the raspberry pi but unfortunately that thing is much too pricey atm
<dirbaio[m]> pi zero w maybe
<euphemism[m]> <waveguide[m]> "I think cherryusb was a rip..." <- What’s this about?
neceve has quit [Ping timeout: 264 seconds]
Guest7221 has joined #rust-embedded
crabbedhaloablut has quit []