Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement the embedded-hal traits and ... #81

Closed
japaric opened this issue Aug 2, 2017 · 17 comments
Closed

implement the embedded-hal traits and ... #81

japaric opened this issue Aug 2, 2017 · 17 comments

Comments

@japaric
Copy link
Owner

japaric commented Aug 2, 2017

make implementations like Serial generic around the USART peripheral instance. Basically do the same thing that the blue-pill does.

I don't think I'm going to have time to do this myself. So tagging as help-wanted.

cc @brandonedens @Susurrus maybe one of you is interested in tackling this?

@tekjar
Copy link

tekjar commented Aug 3, 2017

@japaric I'll try this next week. Will play around and try to understand the framework this week

@Susurrus
Copy link

Susurrus commented Aug 3, 2017

@tekjar Please CC me on your work for this. I'd be happy to help review it.

@japaric
Copy link
Owner Author

japaric commented Aug 3, 2017

@tekjar 👍. I believe that @brandonedens was also going to look into this after tackling rust-embedded/svd2rust#107. You might want to let the other know when you start working on this you don't both end up doing the same work.

@brandonedens
Copy link
Contributor

I added support for the HAL serial at #83
What other HAL interfaces do I need to implement?
@Susurrus @tekjar
Can you all take a look and confirm that it works on your f3? I'm finding that mine doesn't have proper serial behavior currently nor in the past.

@getreu
Copy link
Contributor

getreu commented Sep 18, 2017

@brandonedens

Can you all take a look and confirm that it works on your f3?

I can confirm that it compiles in debug and release mode.
Unfortunately I could not try out some examples because I am still struggling with #84.

@tekjar
Copy link

tekjar commented Sep 20, 2017

@brandonedens Thanks a lot for this. Build works for me after adding below lines to lib.rs

#![feature(const_cell_new)]
#![feature(const_unsafe_cell_new)]

Set compiler_builtins version in Xargo.toml

[dependencies.compiler_builtins]
features = ["mem"]
version = "0.1"
stage = 1

or else I'm facing this error

error: no matching version `= 0.0.0` found for package `compiler_builtins` (required by `sysroot`)

Unfortunately openocd isn't working on my Mac. Will test on ubuntu in some time.

@nordmoen
Copy link

Is anyone working on SPI support? I have tried to take a stab at it, copying most of the implementation from blue-pil, but I'm having some issues when trying to use the implementation together with the built-in L3GD20 gyroscope.

The trouble I'm having is that the initialization is subtly different between stm32f30x and stm32f103xx (the later having gpioa::crl which I'm unsure how to translate to stm32f30x). If anyone is willing to help I would gladly try to implement SPI and support for the gyroscope.

@tekjar
Copy link

tekjar commented Oct 13, 2017

@nordmoen I got this working few days back but couldn't structure it well due to lack of time

https://github.com/tekjar/f3/blob/spi/src/spi.rs
https://github.com/tekjar/rust-on-f3/blob/master/demos/l3gd-demo/src/main.rs

@nordmoen
Copy link

Thanks @tekjar I tried with your initialization and now I'm able to communicate! I'll take a stab at creating a l3gd20 interface, for learning if for nothing else.

@nordmoen
Copy link

nordmoen commented Oct 16, 2017

So I have tried to implement support for the l3gd20 gyroscope here: https://github.com/nordmoen/f3/blob/master/src/l3gd20.rs , but I'm having some problems. When trying to read the sensor I always get back 255. It doesn't matter if it's before or after the sensor is configured. If anyone has a second to look it over I would be very glad for the help.

Edit:
Got it to work, simply forgot to enable GPIOE...

@tekjar
Copy link

tekjar commented Oct 17, 2017

@nordmoen Awesome :). Do you have plans for working on accelerometer as well?

@nordmoen
Copy link

@tekjar Thanks =]. I'll have a look at it, however, since blue-pill doesn't have a I2C interface I don't know to structure the implementation, so I will probably wait until someone more talented than me does that.

@tekjar
Copy link

tekjar commented Oct 17, 2017

@nordmoen I'll try to work on it after your spi pull request

@nordmoen
Copy link

I still have some questions for the SPI portion of the code. There should be 2 SPI interfaces on the F3Discovery, but the the two GPIO modules does not share the same RegisterBlock type and so can't be implemented in the same way as with blue-pill, is that something that should be solved before a pull-request? In addition, the way my code is structured now it is mostly setup for using SPI1 for communication with the gyroscope, but it seems it could also be used for external communication, but for that to work it should configure the NSS line (?) which is not done in my version as far as I understand.

Unrelated to the above, I was wondering how I can get the gyroscope interrupt to function. I think I'm doing everything correct on the sensor side, but I can't figure out how to set it up within the RTFMv2 framework. I have tried the following to enable interrupt on Line0 selecting GPIOE as source(?)

    // Enable interrupt from Gyroscope
    p.SYSCFG.exticr1.write(|w| unsafe {
        w.exti0().bits(0x04)
    });
    p.EXTI.imr1.write(|w| w.mr0().set_bit());
    p.EXTI.rtsr1.write(|w| w.tr0().set_bit());

@japaric
Copy link
Owner Author

japaric commented Oct 19, 2017

Btw, v0.2 of this crate had support for both the gyro and the accelerometer. You can look at the code of that release for guidance.

I haven't tried to use the gyroscope interrupt feature or the EXTI* stuff so I can't comment on that.

Also, it's fine to send a PR with gyro API and a single (not generic) SPI API. We can make it generic later.

@nordmoen
Copy link

I have stolen almost all taken great inspiration from earlier versions of this crate.

I just wanted to test for my self that I understood the interrupt mechanics of the RTFMv2 framework before submitting. The only thing left I think is to properly scale the measurements according to the sensitivity.

@japaric
Copy link
Owner Author

japaric commented Jan 21, 2018

This has been done in v0.5.0

@japaric japaric closed this as completed Jan 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants