Commit b1cfb4a6 authored by Astro's avatar Astro
Browse files

link against the c firmware

parent 189bc88b
[submodule "c"]
path = c
url = https://git.card10.badge.events.ccc.de/card10/firmware.git
Subproject commit 8a1b5c7f6fd026d6701bc0976f2d98bd53d4db6a
......@@ -7,3 +7,6 @@ authors = ["Astro <astro@spaceboyz.net>"]
[dependencies]
max32665 = { path = "../max32665", features = ["rt"] }
cortex-m-rt = { version = "0.6", features = ["device"] }
[build-dependencies]
cc = "1.0"
......@@ -2,7 +2,10 @@ use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
......@@ -11,5 +14,63 @@ fn main() {
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rerun-if-changed=build.rs");
cc::Build::new()
.target("thumbv7em-none-eabihf")
.compiler("arm-none-eabihf-gcc")
.define("TARGET", "MAX32665")
.define("TARGET_UC", "MAX32665")
.define("TARGET_LC", "max32665")
.define("TARGET_REV", "0x4131")
.define("BOARD", "card10")
.opt_level_str("s")
.debug(true)
.pic(false)
.include("../c/lib/card10")
.include("../c/lib/gfx")
.include("../c/lib/gfx/GUI_DEV")
.include("../c/lib/gfx/LCD")
.include("../c/lib/gfx/Fonts")
.include("../c/lib/vendor/Bosch/BHy1/driver/inc")
.include("../c/lib/vendor/Bosch/BHy1/examples/firmware")
.include("../c/lib/vendor/Bosch/BME680")
.include("../c/lib/vendor/Bosch/BMA400")
.include("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Include")
.include("../c/lib/sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Include")
.include("../c/lib/sdk/Libraries/CMSIS/Include")
.include("../c/lib/sdk/Libraries/Boards/card10/Include")
.include("../c/lib/vendor/Maxim/MAX77650")
.include("../c/lib/sdk/Libraries/Boards/Include")
.include("../c/")
.include("../c/")
.include("../c/")
.file("../c/lib/card10/card10.c")
.file("../c/lib/card10/pmic.c")
.file("../c/lib/card10/portexpander.c")
.file("../c/lib/card10/leds.c")
.file("../c/lib/card10/bosch.c")
.file("../c/lib/gfx/display.c")
.file("../c/lib/gfx/LCD/LCD_Driver.c")
.file("../c/lib/gfx/GUI_DEV/DEV_Config.c")
.file("../c/lib/gfx/GUI_DEV/GUI_Paint.c")
.file("../c/lib/sdk/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/i2c.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/gpio.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/tmr.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/tmr_utils.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/rtc.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/spi.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/spi17y.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_delay.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_lock.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_sys.c")
.file("../c/lib/sdk/Libraries/MAX32665PeriphDriver/Source/mxc_pins.c")
.file("../c/lib/sdk/Libraries/Boards/card10/Source/board.c")
// .file("../c/lib/sdk/Libraries/Boards/Source/stdio.c")
.file("../c/lib/vendor/Bosch/BMA400/bma400.c")
.file("../c/lib/vendor/Bosch/BME680/bme680.c")
.file("../c/lib/vendor/Bosch/BHy1/driver/src/bhy.c")
.file("../c/lib/vendor/Bosch/BHy1/driver/src/bhy_uc_driver.c")
.file("../c/lib/vendor/Bosch/BHy1/driver/src/bhy_support.c")
.file("../c/lib/vendor/Maxim/MAX77650/MAX77650-Arduino-Library.c")
.compile("card10");
}
......@@ -3,3 +3,26 @@
pub use max32665;
pub use cortex_m_rt as _;
pub use cortex_m_rt::entry;
#[link(name = "card10")]
extern {
fn card10_init();
fn card10_diag();
}
#[no_mangle]
pub extern "C" fn puts() {
/* Stub */
}
#[no_mangle]
pub extern "C" fn printf() {
/* Stub */
}
pub fn init() {
unsafe {
card10_init();
card10_diag();
}
}
......@@ -8,6 +8,7 @@ stdenv.mkDerivation {
buildInputs = [
gdb
rust
pkgsCross.armhf-embedded.stdenv.cc
];
# Set Environment Variables
......
......@@ -2,10 +2,12 @@
#![no_main]
use panic_abort as _;
use card10::*;
use card10::entry;
#[entry]
fn main() -> ! {
card10::init();
panic!("TODO");
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment