<re_irc>
<@gauteh:matrix.org> Hi. I'm about to get going with a sparkfun artemis redboard nano with an amiq apollo3 MCU (cortex-m). there does not seem to be any hal implementations ready. are there any generic cortex-m hal crates? seems like e.g. implementing I2C for the apollo3 would have a lot in common with other MCU's on the same cpu?
<Lumpio->
The generic cortex-m crate(s) are for using the processor specific features, which are a very small thing compared to actual peripherals
<Lumpio->
And those are pretty much hardware specific.
<Lumpio->
However a lot of peripherals can have similarities just because they do the same thing in the end, so taking another HAL's implementation as a base, removing all the register manipulation, and putting new registers in can be helpful
<Lumpio->
Just to get a good idea for the Rust API design
<Lumpio->
But in the end you'll have to look at the datasheet/reference manual for your chip to figure out how to implement it. Or maybe examples from a C HAL or something.
<re_irc>
<@gauteh:matrix.org> Ok, thanks.
<re_irc>
<@gauteh:matrix.org> So the cortex-m pac is for the cpu, while the apollo3_pac is a level above more or less.. but probably re-exports the same stuff as cortex-m
<re_irc>
<@gauteh:matrix.org> (or re-implements)
<Lumpio->
Usually the -pac crate is autogenerated from an SVD file or similar and only contains platform specific register access stuff
<Lumpio->
And I don't think they usually re-export cortex-m stuff
<re_irc>
<@gauteh:matrix.org> Ok
<re_irc>
<@ildar:matrix.org> greetings! another newbie question:
<re_irc>
<@ildar:matrix.org> Q: in HAL to use a peripheral I take it moving away from the `xxx_hal::pac::Peripherals`. Then how I can move it back?
<re_irc>
<@ildar:matrix.org> I guess I missed a documentation fragment
<Lumpio->
Usually you don't move it back
<re_irc>
<@ryan-summers:matrix.org> If you move it away, the only way to move it back is to re-assign back into the original struct
<re_irc>
<@ryan-summers:matrix.org> But as mentioned above, you typically don't move it back
<re_irc>
<@ildar:matrix.org> typically, yes. I'll try to move back then...
<Lumpio->
Why do you need to put it back tho
<re_irc>
<@ryan-summers:matrix.org> I've needed to do something like this for re-using a GPIO for multiple purposes during setup
<re_irc>
<@ildar:matrix.org> btw is it possible to e.g. use pins as GPIO after I released the TWIM using that pins?
<re_irc>
<@ryan-summers:matrix.org> Only if your HAL returns the pins via some `free()` API - not all HALs implement that
<re_irc>
<@ildar:matrix.org> irc_libera_lumpio-:psion.agg.io: I'm writing an interactive multipurpose FW that allows using multiple protocols on user's demand
<re_irc>
<@ryan-summers:matrix.org> A lot of HALs will just silently consume and delete the pins themselves. Some (but not all) expose a way to re-acquire the consumed pins via a `free()`-like function
<re_irc>
<@ildar:matrix.org> I see. Back to experimenting then )))
<re_irc>
<@ildar:matrix.org> thanks
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 245 seconds]
<re_irc>
<@9names:matrix.org> is there a way to get svdtools to not modify the description when arrayifying registers?
<re_irc>
<@adamgreig:matrix.org> I feel like maybe you can set a new description
<re_irc>
<@adamgreig:matrix.org> hmm, might be misremembering, can't see anything for that in the code
<re_irc>
<@9names:matrix.org> i can (in modify), but any zeros in the description get replaced with %s
<re_irc>
<@9names:matrix.org> what i've got now is this:
<re_irc>
<@dirbaio:matrix.org> maybe it's not worth it, I dunno
<re_irc>
<@mabez:matrix.org> Honestly its really quite good! To me it works how the cfg macro should work anyways, and I've searched zulip and its popped up a few times
<re_irc>
<@mabez:matrix.org> Maybe worth popping in its own crate? 🤔
<re_irc>
<@dirbaio:matrix.org> mhmm maybe
<re_irc>
<@yruama_lairba:matrix.org> very frustrating, i'm unable to enable a dma stream and i really don't why. the hardware doesn't event show me any error
<re_irc>
<@adamgreig:matrix.org> dirbaio:matrix.org: hideous, I love it
* re_irc
@eldruin:matrix.org dirbaio:matrix.org: *screams in horror* :D
<re_irc>
<@eldruin:matrix.org> renaming `$x` might help slightly
<re_irc>
<@yruama_lairba:matrix.org> i went back compared to this
<re_irc>
<@yruama_lairba:matrix.org> i went back just before i tried to enable dma. i'm now trying make it work one by one
<re_irc>
<@yruama_lairba:matrix.org> i found some error, i forgot to setup dma stuff in rcc registers. But even fixing that it still no working
<re_irc>
<@yruama_lairba:matrix.org> finally, i made a stream run!
<re_irc>
<@yruama_lairba:matrix.org> it run, but i don't get the right data
tokomak has quit [Ping timeout: 252 seconds]
hosewiejacke has joined #rust-embedded
hosewiejacke has quit [Client Quit]
<re_irc>
<@henrik_alser:matrix.org> yruama_lairba: i’ll have a better look later but quick first glance you should be using a ’static buffer for the dma
<re_irc>
<@yruama_lairba:matrix.org> henrik_alser thank you, rtic resources aren't static and this is was a source of trouble
<re_irc>
<@yruama_lairba:matrix.org> does it happen to you to frequently to be stuck on stuff like this for days ?
<re_irc>
<@yruama_lairba:matrix.org> i passed at least 3 day on my dma stuff. it was evil because i already did the same thing working outside of rtic, but i forgot few things when copying my old work
<re_irc>
<@henrik_alser:matrix.org> yruama_lairba:matrix.org: Did you figure out how to fix it? (In rtic 0.5 if you put a ”static mut” at the start of the init fn it will do a &’static mut transform for you, in 0.6 you initialize it as ”local” in the init attribute)
<re_irc>
<@yruama_lairba:matrix.org> i managed to fix it by declaring my static buffer outside of rtic
<re_irc>
<@yruama_lairba:matrix.org> i just need unsafe block to access it
<re_irc>
<@henrik_alser:matrix.org> You can have it as a resource if you do as per above :)
<re_irc>
<@henrik_alser:matrix.org> Just change your let mut to static mut and make sure it’s at the top of the init fn
<re_irc>
<@yruama_lairba:matrix.org> dma example interess me, especially i there is a bit of abstraction to make thing clearer
<re_irc>
<@yruama_lairba:matrix.org> i find my code not easy to understand
<re_irc>
<@henrik_alser:matrix.org> Just stick it in Resources as a &’static mut and at the start of init you make it a static mut then return it in LateResources
<re_irc>
<@henrik_alser:matrix.org> It will do the static mut -> &’static mut transform for you
cyrozap has quit [Remote host closed the connection]
<re_irc>
<@henrik_alser:matrix.org> Like the singleton! macro
<re_irc>
<@henrik_alser:matrix.org> This has been a source of confusion in 0.5 (and same thing in cortex-m-rt) because it's not obvious and has therefore been replaced by the attribute declaration in 0.6
<re_irc>
<@henrik_alser:matrix.org> To provide a safe dma abstraction you will usually see something like that Transfer api in most hals that will own both the buffer and the peripheral
<re_irc>
<@yruama_lairba:matrix.org> > Just stick it in Resources as a &’static mut and at the start of init you make it a static mut then return it in LateResources
<re_irc>
<@yruama_lairba:matrix.org> may don't understand, don't work
<re_irc>
<@henrik_alser:matrix.org> Need more info to give you hints :)
<re_irc>
<@yruama_lairba:matrix.org> lol, make if work
<re_irc>
<@yruama_lairba:matrix.org> the static declaration need really to be the first thing in the init
<re_irc>
<@yruama_lairba:matrix.org> i did this error many times
<re_irc>
<@henrik_alser:matrix.org> Yeah that's why it was removed :)
<re_irc>
<@yruama_lairba:matrix.org> it's also removed from cortex_m_rt ?
<re_irc>
<@henrik_alser:matrix.org> I don’t think so but haven’t really used rt in quite a while
<re_irc>
<@henrik_alser:matrix.org> (You can also use the singleton! macro for this)
sauce has quit [Remote host closed the connection]