I'm trying to write the typical "hello world" for a microcontroller, an attiny85 in my case. As a newbie to rust, I'm struggling a bit. This is what I have:
#![no_std]
#![no_main]
use attiny_hal::{
port::Pins,
delay,
clock,
pac,
prelude::*,
};
#[no_mangle]
pub extern fn main() {
let mut delay = delay::Delay::<clock::MHz20>::new();
let mut pins = Pins::new(pac::PORTB);
let mut pb = pins.pb0.into_output();
loop {
delay.delay_ms(500u16);
pb.toggle();
}
}
I get this compiler error:
error[E0423]: expected value, found struct `pac::PORTB`
--> src/main.rs:17:30
|
17 | let mut pins = Pins::new(pac::PORTB);
| ^^^^^^^^^^
|
::: /home/markus/.cargo/registry/src/github.com-1ecc6299db9ec823/avr-device-0.5.0/src/devices/attiny85/mod.rs:235:1
|
235 | pub struct PORTB {
| ---------------- `pac::PORTB` defined here
|
help: use struct literal syntax instead
|
17 | let mut pins = Pins::new(pac::PORTB { _marker: val });
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: consider importing this unit variant instead
|
4 | use attiny_hal::port::DynamicPort::PORTB;
|
help: if you import `PORTB`, refer to it directly
|
17 - let mut pins = Pins::new(pac::PORTB);
17 + let mut pins = Pins::new(PORTB);
Unfortunately, I don't get all the help the compiler is offering me
I understand that the struct PORTB
is not what port::Pins expects as a parameter. But the first help
doesn't compile, neither does the second one: attiny_hal::port::DynamicPort::PORTB is an enum, not an instance of the PORTB structure....
It guess it's totally simple and only my rookieness is in my way... It would be great if you could help me.
TIA
Markus