Created
December 16, 2020 08:19
-
-
Save zacck-zz/ac88b2d6fb544303ca51c6b43e7b8ae3 to your computer and use it in GitHub Desktop.
Rust Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(unsafe_code)] | |
#![no_main] | |
#![no_std] | |
use panic_halt as _; | |
use nb::block; | |
use cortex_m_rt::entry; | |
use stm32f1xx_hal::{ | |
delay, | |
pac, | |
prelude::*, | |
serial::{Config, Serial}, | |
}; | |
use hd44780_driver::{Cursor, CursorBlink, Display, DisplayMode, HD44780}; | |
use core::fmt::Write; | |
#[entry] | |
fn main() -> ! { | |
let cp = cortex_m::Peripherals::take().unwrap(); | |
// Get access to the device specific peripherals from the peripheral access crate | |
let p = pac::Peripherals::take().unwrap(); | |
// Take ownership over the raw flash and rcc devices and convert them into the corresponding | |
// HAL structs | |
let mut flash = p.FLASH.constrain(); | |
let mut rcc = p.RCC.constrain(); | |
// Freeze the configuration of all the clocks in the system and store the frozen frequencies in | |
// `clocks` | |
let clocks = rcc.cfgr.freeze(&mut flash.acr); | |
// Prepare the alternate function I/O registers | |
let mut afio = p.AFIO.constrain(&mut rcc.apb2); | |
// Prepare the GPIOB peripheral | |
let mut gpiob = p.GPIOB.split(&mut rcc.apb2); | |
// setup lcd screen | |
let mut gpioa = p.GPIOA.split(&mut rcc.apb2); | |
let mut delay = delay::Delay::new(cp.SYST, clocks); | |
let rs = gpioa.pa7.into_push_pull_output(&mut gpioa.crl); | |
let en = gpioa.pa6.into_push_pull_output(&mut gpioa.crl); | |
let d4 = gpioa.pa5.into_push_pull_output(&mut gpioa.crl); | |
let d5 = gpioa.pa4.into_push_pull_output(&mut gpioa.crl); | |
let d6 = gpioa.pa3.into_push_pull_output(&mut gpioa.crl); | |
let d7 = gpioa.pa2.into_push_pull_output(&mut gpioa.crl); | |
let mut lcd = HD44780::new_4bit(rs, en, d4, d5, d6, d7, &mut delay); | |
//Setup LCD | |
lcd.reset(&mut delay); | |
lcd.clear(); | |
lcd.set_display_mode( | |
DisplayMode { | |
display: Display::On, | |
cursor_visibility: Cursor::Visible, | |
cursor_blink: CursorBlink::On, | |
} | |
); | |
lcd.write_str("Boot successful"); | |
// USART3 | |
// Configure pb10 as a push_pull output, this will be the tx pin | |
let tx = gpiob.pb10.into_alternate_push_pull(&mut gpiob.crh); | |
// Take ownership over pb11 | |
let rx = gpiob.pb11; | |
// Set up the usart device. Taks ownership over the USART register and tx/rx pins. The rest of | |
// the registers are used to enable and configure the device. | |
let serial = Serial::usart3( | |
p.USART3, | |
(tx, rx), | |
&mut afio.mapr, | |
Config::default().baudrate(9600.bps()), | |
clocks, | |
&mut rcc.apb1, | |
); | |
// Split the serial struct into a receiving and a transmitting part | |
let (mut tx, _rx) = serial.split(); | |
writeln!(tx, "AT").unwrap(); | |
delay.delay_ms(500_u16 ); | |
writeln!(tx, "AT+CREG=1").unwrap(); | |
delay.delay_ms(500_u16 ); | |
//config to sms | |
writeln!(tx, "AT+CMGF=1").unwrap(); | |
delay.delay_ms(500_u16); | |
// set recipient | |
writeln!(tx, "AT+CMGS=\"+254111338104\"").unwrap(); | |
delay.delay_ms(500_u16); | |
//send message | |
writeln!(tx, "This is from the device on your desk").unwrap(); | |
delay.delay_ms(500_u16); | |
block!(tx.write(26)).ok(); | |
delay.delay_ms(500_u16); | |
loop {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ chungabox git:(master) ✗ cargo build | |
Compiling chungabox v0.1.0 (/Users/zacck/Documents/LK/chungabox) | |
error[E0599]: no method named `reset` found for enum `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` in the current scope | |
--> src/main.rs:63:9 | |
| | |
63 | lcd.reset(&mut delay); | |
| ^^^^^ method not found in `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` | |
error[E0599]: no method named `clear` found for enum `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` in the current scope | |
--> src/main.rs:64:9 | |
| | |
64 | lcd.clear(); | |
| ^^^^^ method not found in `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` | |
error[E0599]: no method named `set_display_mode` found for enum `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` in the current scope | |
--> src/main.rs:65:9 | |
| | |
65 | lcd.set_display_mode( | |
| ^^^^^^^^^^^^^^^^ method not found in `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` | |
error[E0599]: no method named `write_str` found for enum `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` in the current scope | |
--> src/main.rs:72:9 | |
| | |
72 | lcd.write_str("Boot successful"); | |
| ^^^^^^^^^ method not found in `core::result::Result<HD44780<FourBitBus<PA7<Output<PushPull>>, PA6<Output<PushPull>>, PA5<Output<PushPull>>, PA4<Output<PushPull>>, PA3<Output<PushPull>>, PA2<Output<PushPull>>>>, hd44780_driver::error::Error>` | |
error: aborting due to 4 previous errors | |
For more information about this error, try `rustc --explain E0599`. | |
error: could not compile `chungabox` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment