Skip to content

Very weird error when compiling a very basic program: __addsf3 multiple defenitions #541

Open
@itamarsch

Description

@itamarsch

image

#![no_std]
#![no_main]
use arduino_hal::clock::MHz16;
use arduino_hal::hal::delay::Delay;
use arduino_hal::{delay_ms, i2c};
use arduino_hal::{I2c, Peripherals};
use lcd_lcm1602_i2c::Lcd;
use numtoa::NumToA;
use panic_serial;
const PHI: f64 = 1.61803398;

type LCD<'a> = Lcd<'a, I2c, Delay<MHz16>>;
const LCD_ADDRESS: u8 = 0x3f;
//
panic_serial::impl_panic_handler!(
  arduino_hal::usart::Usart<
    arduino_hal::pac::USART0,
    arduino_hal::port::Pin<arduino_hal::port::mode::Input, arduino_hal::hal::port::PD0>,
    arduino_hal::port::Pin<arduino_hal::port::mode::Output, arduino_hal::hal::port::PD1>
  >
);

fn lcd_init<'a>(i2c: &'a mut I2c, delay: &'a mut Delay<MHz16>) -> Result<LCD<'a>, i2c::Error> {
    let mut lcd = lcd_lcm1602_i2c::Lcd::new(i2c, delay)
        .address(LCD_ADDRESS)
        .rows(2) // two rows
        .init()?;

    lcd.backlight(lcd_lcm1602_i2c::Backlight::On)?;
    lcd.clear()?;
    lcd.set_cursor(0, 0)?;
    Ok(lcd)
}

#[arduino_hal::entry]
fn main() -> ! {
    let dp = Peripherals::take().unwrap();
    let pins = arduino_hal::pins!(dp);
    let serial = arduino_hal::default_serial!(dp, pins, 57600);
    let serial = share_serial_port_with_panic(serial);

    let mut i2c = arduino_hal::I2c::new(
        dp.TWI,
        pins.a4.into_pull_up_input(),
        pins.a5.into_pull_up_input(),
        50000,
    );

    let mut delay = arduino_hal::Delay::new();

    let mut lcd = lcd_init(&mut i2c, &mut delay).unwrap();

    let mut i: f64 = 1.0;
    let mut buf = [0u8; 100];

    loop {
        i = libm::round(i * PHI);
        let u32v = i as u32;
        delay_ms(10);
        lcd.clear().unwrap();
        lcd.set_cursor(0, 0).unwrap();
        lcd.write_str(u32v.numtoa_str(10, &mut buf)).unwrap();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler-bugNot a bug in avr-hal, but a bug in the rust compiler/LLVM

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions