mirror of
https://github.com/laanwj/k210-sdk-stuff.git
synced 2024-11-21 17:06:19 +04:00
rust: Fixes for newer dependencies
This commit is contained in:
parent
d7245693a7
commit
67078f6242
@ -21,6 +21,12 @@ members = [
|
||||
|
||||
[patch.crates-io]
|
||||
|
||||
k210-hal = { git = "https://github.com/riscv-rust/k210-hal.git", rev = "fdf1ad61af8f756765a65133bb2d08cda686be6f" }
|
||||
riscv = { git = "https://github.com/rust-embedded/riscv.git", rev = "422a1625cfd666f927eae485629fa7f96be5ebd0" }
|
||||
|
||||
# Remove this after https://github.com/ilya-epifanov/riscv-target/pull/1 or similar merged
|
||||
riscv-target = { git = "https://github.com/laanwj/riscv-target.git", rev = "189b5261ecdd40f18eb1b82614d6876aa88bd744" }
|
||||
|
||||
# This patch was merged upstream, unfortunately, rust-secp256k1 puts a restriction on
|
||||
# cc_rs <= 1.0.41 so we can't actually use the newer version yet.
|
||||
cc = { git = "https://github.com/laanwj/cc-rs.git", rev = "83e66a79a25b55d0aa84db42257a8edbb0095cf8" }
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
libm = "0.1"
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,MSA300_SLV_ADDR,MSA300_ADDR_BITS,MSA300_CLK};
|
||||
@ -63,7 +63,7 @@ fn main() -> ! {
|
||||
usleep(200000);
|
||||
|
||||
// Configure UART
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -1,4 +0,0 @@
|
||||
[target.riscv64gc-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Ttrap.x",
|
||||
]
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bare-metal = "0.2.0"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = { version = "0.5", features = ["inline-asm"] }
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -1,13 +0,0 @@
|
||||
use std::{env, fs};
|
||||
use std::path::PathBuf;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
// Put the linker script somewhere the linker can find it
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
|
||||
fs::File::create(out_dir.join("trap.x")).unwrap()
|
||||
.write_all(include_bytes!("trap.x")).unwrap();
|
||||
println!("cargo:rerun-if-changed=trap.x");
|
||||
}
|
@ -11,7 +11,7 @@ use k210_hal::pac;
|
||||
use k210_shared::soc::sysctl;
|
||||
use pac::interrupt::Interrupt;
|
||||
use riscv::asm;
|
||||
use riscv::register::{mcause, mhartid, mie, mip, mstatus};
|
||||
use riscv::register::{mhartid, mie, mip, mstatus};
|
||||
|
||||
const UART_BUFSIZE: usize = 8192;
|
||||
/** UART ring buffer */
|
||||
@ -80,42 +80,34 @@ fn interrupt_uart1() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Global trap handler */
|
||||
/** PLIC interrupts */
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
fn my_trap_handler() {
|
||||
let hartid = mhartid::read();
|
||||
let cause = mcause::read().cause();
|
||||
match cause {
|
||||
// PLIC interrupts
|
||||
mcause::Trap::Interrupt(mcause::Interrupt::MachineExternal) => {
|
||||
if mip::read().mext() {
|
||||
unsafe {
|
||||
let plic = pac::PLIC::ptr();
|
||||
let target = &(*plic).targets[hartid * 2];
|
||||
let int_num = target.claim.read().bits();
|
||||
let int = Interrupt::try_from(int_num as u8).unwrap();
|
||||
fn MachineExternal() {
|
||||
if mip::read().mext() {
|
||||
unsafe {
|
||||
let hartid = mhartid::read();
|
||||
let plic = pac::PLIC::ptr();
|
||||
let target = &(*plic).targets[hartid * 2];
|
||||
let int_num = target.claim.read().bits();
|
||||
let int = Interrupt::try_from(int_num as u8).unwrap();
|
||||
|
||||
// Does this really need the 'disable other interrupts, change threshold' dance
|
||||
// as done in handle_irq_m_ext in plic.c?
|
||||
match int {
|
||||
Interrupt::UART1 => interrupt_uart1(),
|
||||
// We'll get a spurious UARTHS interrupt, ignore it
|
||||
Interrupt::UARTHS => {}
|
||||
_ => {
|
||||
panic!(
|
||||
"unknown machineexternal {:?} on {}, int {:?}",
|
||||
cause, hartid, int
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform IRQ complete
|
||||
target.claim.write(|w| w.bits(int_num));
|
||||
// Does this really need the 'disable other interrupts, change threshold' dance
|
||||
// as done in handle_irq_m_ext in plic.c?
|
||||
match int {
|
||||
Interrupt::UART1 => interrupt_uart1(),
|
||||
// We'll get a spurious UARTHS interrupt, ignore it
|
||||
Interrupt::UARTHS => {}
|
||||
_ => {
|
||||
panic!(
|
||||
"unknown machineexternal hart {}, int {:?}",
|
||||
hartid, int
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
panic!("unknown trap {:?}", cause);
|
||||
|
||||
// Perform IRQ complete
|
||||
target.claim.write(|w| w.bits(int_num));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
/* set our own trap handler */
|
||||
trap_handler = my_trap_handler;
|
@ -8,7 +8,7 @@ edition = "2018"
|
||||
k210-hal = "0.2.0"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
riscv = "0.5"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
hex-literal = "0.2"
|
||||
sha2 = { version = "0.8", default-features = false }
|
||||
aes-soft = { version = "0.3" }
|
||||
|
@ -8,7 +8,7 @@ use core::iter;
|
||||
use hex_literal::hex;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_shared::soc::sleep::usleep;
|
||||
use k210_shared::soc::sysctl;
|
||||
use k210_shared::soc::aes::{self, cipher_mode, encrypt_sel};
|
||||
@ -50,7 +50,7 @@ fn main() -> ! {
|
||||
// Configure UART
|
||||
let serial = p
|
||||
.UARTHS
|
||||
.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,DISP_PIXELS};
|
||||
@ -68,7 +68,7 @@ fn main() -> ! {
|
||||
usleep(200000);
|
||||
|
||||
// Configure UART
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
libm = "0.1"
|
||||
|
@ -13,7 +13,7 @@ use embedded_graphics::primitives::{Circle, Rectangle};
|
||||
use embedded_graphics::{text_6x8, Drawing};
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_shared::board::def::{io, DISP_HEIGHT, DISP_PIXELS, DISP_WIDTH};
|
||||
use k210_shared::board::lcd::{self, LCD, LCDHL};
|
||||
use k210_shared::board::lcd_render::ScreenImage;
|
||||
@ -96,7 +96,7 @@ fn main() -> ! {
|
||||
// Configure UART
|
||||
let serial = p
|
||||
.UARTHS
|
||||
.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,DISP_PIXELS,NS2009_SLV_ADDR,NS2009_CAL,NS2009_ADDR_BITS,NS2009_CLK};
|
||||
@ -150,7 +150,7 @@ fn main() -> ! {
|
||||
usleep(200000);
|
||||
|
||||
// Configure UART
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -7,7 +7,7 @@
|
||||
use k210_console::console::{Console, ScreenImage};
|
||||
use k210_console::cp437;
|
||||
use k210_console::cp437_8x8::{FONT, GLYPH_BY_FILL};
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT,DISP_PIXELS};
|
||||
@ -79,7 +79,7 @@ fn main() -> ! {
|
||||
usleep(200000);
|
||||
|
||||
// Configure UART
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -1,4 +0,0 @@
|
||||
[target.riscv64gc-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Ttrap.x",
|
||||
]
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = { version = "0.5", features = ["inline-asm"] }
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -1,13 +0,0 @@
|
||||
use std::{env, fs};
|
||||
use std::path::PathBuf;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
// Put the linker script somewhere the linker can find it
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
|
||||
fs::File::create(out_dir.join("trap.x")).unwrap()
|
||||
.write_all(include_bytes!("trap.x")).unwrap();
|
||||
println!("cargo:rerun-if-changed=trap.x");
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
@ -29,8 +28,9 @@ struct IntrInfo {
|
||||
|
||||
static mut INTR_INFO: Option<IntrInfo> = None;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
fn my_trap_handler() {
|
||||
fn MachineSoft() {
|
||||
let hartid = mhartid::read();
|
||||
let cause = mcause::read().cause();
|
||||
|
||||
@ -44,7 +44,7 @@ fn my_trap_handler() {
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let p = Peripherals::take().unwrap();
|
||||
let p = pac::Peripherals::take().unwrap();
|
||||
sysctl::pll_set_freq(sysctl::pll::PLL0, 800_000_000).unwrap();
|
||||
sysctl::pll_set_freq(sysctl::pll::PLL1, 300_000_000).unwrap();
|
||||
sysctl::pll_set_freq(sysctl::pll::PLL2, 45_158_400).unwrap();
|
||||
@ -53,7 +53,7 @@ fn main() -> ! {
|
||||
usleep(200000);
|
||||
|
||||
// Configure UART
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -1,2 +0,0 @@
|
||||
/* set our own trap handler */
|
||||
trap_handler = my_trap_handler;
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -9,7 +9,7 @@ mod lfsr;
|
||||
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_shared::board::def::io;
|
||||
use k210_shared::board::lcd::{self, LCD, LCDHL};
|
||||
use k210_shared::board::lcd_colors;
|
||||
@ -62,7 +62,7 @@ fn main() -> ! {
|
||||
// Configure UART
|
||||
let serial = p
|
||||
.UARTHS
|
||||
.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -8,4 +8,4 @@ edition = "2018"
|
||||
k210-hal = "0.2.0"
|
||||
libm = "0.1"
|
||||
riscv = "0.5"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** Panic handler: based on ARM panic-itm */
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use core::panic::PanicInfo;
|
||||
@ -12,7 +12,7 @@ fn panic(info: &PanicInfo) -> ! {
|
||||
// also, can we really know the state?
|
||||
let p = unsafe { Peripherals::steal() };
|
||||
let clocks = k210_hal::clock::Clocks::new();
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
writeln!(stdout, "{}", info).unwrap();
|
||||
|
@ -59,7 +59,7 @@ impl<IF: I2CExt> I2C for I2CImpl<IF> {
|
||||
sysctl::clock_set_threshold(IF::DIV, 3);
|
||||
sysctl::reset(IF::RESET);
|
||||
|
||||
let v_i2c_freq = sysctl::clock_get_freq(sysctl::clock::I2C0);
|
||||
let v_i2c_freq = sysctl::clock_get_freq(IF::CLK);
|
||||
let v_period_clk_cnt = v_i2c_freq / i2c_clk / 2;
|
||||
let v_period_clk_cnt: u16 = v_period_clk_cnt.try_into().unwrap();
|
||||
let v_period_clk_cnt = cmp::max(v_period_clk_cnt, 1);
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
mod palette;
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::{io,DISP_WIDTH,DISP_HEIGHT};
|
||||
@ -65,7 +65,7 @@ fn main() -> ! {
|
||||
usleep(200000);
|
||||
|
||||
// Configure UART
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -8,4 +8,4 @@ edition = "2018"
|
||||
k210-hal = "0.2.0"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
riscv = "0.5"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
|
@ -5,7 +5,7 @@
|
||||
#![no_main]
|
||||
|
||||
use core::cmp::{min,max};
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::{
|
||||
@ -76,7 +76,7 @@ fn main() -> ! {
|
||||
|
||||
usleep(200000);
|
||||
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
nb = "0.1.1"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -10,7 +10,7 @@
|
||||
use core::convert::TryInto;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_shared::board::def::{io, DISP_HEIGHT, DISP_PIXELS, DISP_WIDTH};
|
||||
use k210_shared::board::lcd::{self, LCD, LCDHL};
|
||||
use k210_shared::board::lcd_colors;
|
||||
@ -67,7 +67,7 @@ fn main() -> ! {
|
||||
// Configure UART
|
||||
let serial = p
|
||||
.UARTHS
|
||||
.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
nb = "0.1.1"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -7,7 +7,7 @@
|
||||
use core::convert::TryInto;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_shared::board::def::io;
|
||||
use k210_shared::board::sdcard;
|
||||
use k210_shared::soc::dmac::{dma_channel, DMACExt};
|
||||
@ -69,7 +69,7 @@ fn main() -> ! {
|
||||
// Configure UART
|
||||
let serial = p
|
||||
.UARTHS
|
||||
.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -6,7 +6,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use riscv_rt::entry;
|
||||
@ -30,7 +30,7 @@ fn main() -> ! {
|
||||
|
||||
usleep(200000);
|
||||
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -1,4 +0,0 @@
|
||||
[target.riscv64gc-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Ttrap.x",
|
||||
]
|
@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
embedded-hal = { version = "0.2.1", features = ["unproven"] }
|
||||
nb = "0.1.1"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -8,7 +8,7 @@ use core::str;
|
||||
use esp8266at::handler::{NetworkEvent, SerialNetworkHandler};
|
||||
use esp8266at::response::{parse, ParseResult};
|
||||
use esp8266at::traits;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::io;
|
||||
@ -77,7 +77,7 @@ fn main() -> ! {
|
||||
io_init();
|
||||
|
||||
// Configure UARTHS (→host)
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), DEFAULT_BAUD.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(DEFAULT_BAUD.bps(), &clocks);
|
||||
let (mut tx, mut _rx) = serial.split();
|
||||
let mut debug = Stdout(&mut tx);
|
||||
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
nb = "0.1.1"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::serial::Serial;
|
||||
use k210_shared::board::def::io;
|
||||
@ -27,17 +27,19 @@ fn main() -> ! {
|
||||
let clocks = k210_hal::clock::Clocks::new();
|
||||
|
||||
// Configure UARTHS (→host)
|
||||
let mut serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), DEFAULT_BAUD.bps(), &clocks);
|
||||
let mut serial = p.UARTHS.configure( DEFAULT_BAUD.bps(), &clocks);
|
||||
let (mut tx, mut rx) = serial.split();
|
||||
|
||||
// Configure UART1 (→WIFI)
|
||||
sysctl::clock_enable(sysctl::clock::UART1);
|
||||
sysctl::reset(sysctl::reset::UART1);
|
||||
fpioa::set_function(io::WIFI_RX, fpioa::function::UART1_TX);
|
||||
fpioa::set_function(io::WIFI_TX, fpioa::function::UART1_RX);
|
||||
fpioa::set_function(io::WIFI_EN, fpioa::function::GPIOHS8);
|
||||
fpioa::set_io_pull(io::WIFI_EN, fpioa::pull::DOWN);
|
||||
gpiohs::set_pin(8, true);
|
||||
gpiohs::set_direction(8, gpio::direction::OUTPUT);
|
||||
let mut wifi_serial = p.UART1.configure((p.pins.pin7, p.pins.pin6), DEFAULT_BAUD.bps(), &clocks);
|
||||
let mut wifi_serial = p.UART1.configure(DEFAULT_BAUD.bps(), &clocks);
|
||||
let (mut wtx, mut wrx) = wifi_serial.split();
|
||||
|
||||
// Relay characters between UARTs
|
||||
@ -46,8 +48,8 @@ fn main() -> ! {
|
||||
// OOB restores safe baudrate for UARTHS, to be sure we're able to recover from
|
||||
// sync failures
|
||||
let mut rate = DEFAULT_BAUD;
|
||||
let (userial, pins) = Serial::join(tx, rx).free();
|
||||
serial = userial.configure(pins, rate.bps(), &clocks);
|
||||
let userial = Serial::join(tx, rx).free();
|
||||
serial = userial.configure(rate.bps(), &clocks);
|
||||
let s = serial.split();
|
||||
tx = s.0;
|
||||
rx = s.1;
|
||||
@ -59,8 +61,8 @@ fn main() -> ! {
|
||||
rate = u32::from(d[0]) | (u32::from(d[1]) << 8) | (u32::from(d[2]) << 16) | (u32::from(d[3]) << 24);
|
||||
|
||||
// re-configure UARTHS at new rate
|
||||
let (userial, pins) = Serial::join(tx, rx).free();
|
||||
serial = userial.configure(pins, rate.bps(), &clocks);
|
||||
let userial = Serial::join(tx, rx).free();
|
||||
serial = userial.configure(rate.bps(), &clocks);
|
||||
let s = serial.split();
|
||||
tx = s.0;
|
||||
rx = s.1;
|
||||
@ -73,8 +75,8 @@ fn main() -> ! {
|
||||
_ => {}
|
||||
}
|
||||
// re-configure UART1
|
||||
let (wifi_userial, wifi_pins) = Serial::join(wtx, wrx).free();
|
||||
wifi_serial = wifi_userial.configure(wifi_pins, rate.bps(), &clocks);
|
||||
let wifi_userial = Serial::join(wtx, wrx).free();
|
||||
wifi_serial = wifi_userial.configure(rate.bps(), &clocks);
|
||||
let s = wifi_serial.split();
|
||||
wtx = s.0;
|
||||
wrx = s.1;
|
||||
|
@ -5,7 +5,7 @@ authors = ["W.J. van der Laan <laanwj@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -7,7 +7,7 @@ use libm::F32Ext;
|
||||
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_hal::Peripherals;
|
||||
use k210_hal::pac::Peripherals;
|
||||
use k210_shared::board::def::{io, DISP_HEIGHT, DISP_PIXELS, DISP_WIDTH, MSA300_SLV_ADDR,MSA300_ADDR_BITS,MSA300_CLK};
|
||||
use k210_shared::board::lcd::{self, LCD, LCDHL};
|
||||
use k210_shared::board::lcd_colors;
|
||||
@ -178,7 +178,7 @@ fn main() -> ! {
|
||||
// Configure UART
|
||||
let serial = p
|
||||
.UARTHS
|
||||
.configure((p.pins.pin5, p.pins.pin4), 115_200.bps(), &clocks);
|
||||
.configure(115_200.bps(), &clocks);
|
||||
let (mut tx, _) = serial.split();
|
||||
|
||||
let mut stdout = Stdout(&mut tx);
|
||||
|
@ -1,4 +0,0 @@
|
||||
[target.riscv64gc-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Ttrap.x",
|
||||
]
|
@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
embedded-hal = { version = "0.2.1", features = ["unproven"] }
|
||||
nb = "0.1.1"
|
||||
riscv-rt = "0.6"
|
||||
riscv-rt = "0.7"
|
||||
k210-hal = "0.2.0"
|
||||
riscv = "0.5"
|
||||
k210-shared = { path = "../k210-shared" }
|
||||
|
@ -8,7 +8,7 @@ use core::str;
|
||||
use esp8266at::handler::{NetworkEvent, SerialNetworkHandler};
|
||||
use esp8266at::response::{parse, ConnectionType, ParseResult};
|
||||
use esp8266at::traits::{self, Write};
|
||||
use k210_hal::{Peripherals, pac};
|
||||
use k210_hal::pac;
|
||||
use k210_hal::prelude::*;
|
||||
use k210_hal::stdout::Stdout;
|
||||
use k210_shared::board::def::io;
|
||||
@ -106,7 +106,7 @@ fn show_uart_info(debug: &mut dyn core::fmt::Write, uart: *const pac::uart1::Reg
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let p = Peripherals::take().unwrap();
|
||||
let p = pac::Peripherals::take().unwrap();
|
||||
sysctl::pll_set_freq(sysctl::pll::PLL0, 800_000_000).unwrap();
|
||||
sysctl::pll_set_freq(sysctl::pll::PLL1, 300_000_000).unwrap();
|
||||
sysctl::pll_set_freq(sysctl::pll::PLL2, 45_158_400).unwrap();
|
||||
@ -116,7 +116,7 @@ fn main() -> ! {
|
||||
io_init();
|
||||
|
||||
// Configure UARTHS (→host)
|
||||
let serial = p.UARTHS.configure((p.pins.pin5, p.pins.pin4), DEFAULT_BAUD.bps(), &clocks);
|
||||
let serial = p.UARTHS.configure(DEFAULT_BAUD.bps(), &clocks);
|
||||
let (mut tx, mut _rx) = serial.split();
|
||||
let mut debug = Stdout(&mut tx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user