-
Hello,
Do I need to write something like Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
Hi!
That's just because most people will be using one of those boards so that's what we tried making the easiest to get started with. Also, it is hard to write examples against a generic MCU, because you have no clue what peripherals are connected and could be used...
It really depends on the usecase I'd say. Is it a one-off application for a custom design? Then I'd just go with the HAL (
You really just need [dependencies.atmega328p-hal]
git = "https://github.com/Rahix/avr-hal"
rev = "206ff87bdc38afcffd9db1c9326c0d4d9487cb14"
features = ["atmega328p", "rt"] Note the #[atmega328p_hal::entry]
fn main() -> ! {
// ...
}
Instead of the board prelude, you'd go with the HAL prelude. E.g. use atmega328p_hal::prelude::*; Hope this helps! If you need anything else, let me know :) |
Beta Was this translation helpful? Give feedback.
-
One more thing which might be important: The board support crates re-export the bare MCU pins (PA0, PB3, etc.) in this let dp = arduino_uno::Peripherals::take().unwrap();
let mut pins = arduino_uno::Pins::new(dp.PORTB, dp.PORTC, dp.PORTD);
let mut led = pins.d0.into_output(&mut pins.ddr); you'd have to write let dp = atmega328p_hal::pac::Peripherals::take().unwrap();
let mut portb = dp.PORTB.split();
let mut led = portb.pb0.into_output(&mut portb.ddr); (This works via the |
Beta Was this translation helpful? Give feedback.
-
@Rahix
Yes, it's a special use case with a custom made PCB.
Ah, yes this was missing too. |
Beta Was this translation helpful? Give feedback.
-
I might have one last question. In my program I need to access a peripheral in a ISR, so I have to share the peripherals in some way. The Rust Embedded Book takes an approach with an However when I try to use this approach in my program I get weird linker errors (the compilation is fine) as soon as I do something like this in my critical section:
Errors:
|
Beta Was this translation helpful? Give feedback.
-
Heh, yeah, that's a known issue: rust-lang/compiler-builtins#347 There is a dirty workaround to add the following to your [profile.dev.package.compiler_builtins]
overflow-checks = false
|
Beta Was this translation helpful? Give feedback.
-
I see. Many thanks! |
Beta Was this translation helpful? Give feedback.
-
Hey @Rahix! |
Beta Was this translation helpful? Give feedback.
-
Can't say I fully understand what the project is about, but it looks really neat! Is it a controller for a telescope mount? I see you also wrote an EEPROM driver. Would you be interested in upstreaming that into avr-hal? Also, do you have any feedback regarding your experience with using avr-hal & avr-device? What were the main painpoints? Were there any things where you had to "work around" the API because it hindered you from doing what you needed to? Are there any big missing things which would have helped you a lot? |
Beta Was this translation helpful? Give feedback.
-
Thanks!
Yes exactly. The core functionality is to control a stepper motor which controls a telescope mount. The speed of the motor can be adjusted by trail and error using a Bluetooth module. Using this technique I was able to get a very good improvement in visual observation. As an additional improvement I thought of introducing a feedback loop that tries to hold a star in place with a webcam and therefore send guiding pulses to the stepper motor. This is what the C++ driver is for but unfortunately I never got this to work in a way that it actually could improve things.
I could actually imagine to work on such a feature but I think my current code isn't sophisticated enough yet to upstream it.
Well because I was new to Embedded Rust, I was confused at first by understanding the difference between the pac module and all of the other modules.
Eventually I could shorten this by utilizing some use statements but it always felt very odd to me.
I don't think so, except for the timer and eeprom which obviously had to be implemented by accessing the registers manually. |
Beta Was this translation helpful? Give feedback.
-
That's amazing!
Yeah, you're not alone with that, I've gotten that report from quite a few people now... I think I can maybe add some sort of overview to the README which explains how all the parts fit together.
Right... I think the only real way to mitigate this would be creating type aliases in the relevant HAL crates directly which downstream code can then just reference easily. I'll have a look what is possible here. |
Beta Was this translation helpful? Give feedback.
Hi!
That's just because most people will be using one of those boards so that's what we tried making the easiest to get started with. Also, it is hard to write examples against a generic MCU, because you have no clue what peripherals are connected and could be used...
It really depends on the usecase I'd say. Is it a one-off application for a custom design? Then I'd just go with the HAL (
atmega328p-hal
in your case). Is it a custom board for which you intend to write multiple programs? In this case I would sugges…