Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise examples #13

Merged
merged 4 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/blinky/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[target.mipsel-unknown-none]
rustflags = ["-C", "link-arg=-T32MX270F256B_procdefs.ld"]
rustflags = ["-C", "link-arg=-Tlink.x"]

[build]
target = "mipsel-unknown-none"
Expand Down
40 changes: 0 additions & 40 deletions examples/blinky/32MX270F256B_procdefs.ld

This file was deleted.

39 changes: 23 additions & 16 deletions examples/blinky/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions examples/blinky/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blinky"
version = "0.2.0"
version = "0.3.0"
authors = ["Stephan <kiffie@mailbox.org>"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand All @@ -13,10 +13,13 @@ default = ["pic32mx2xxfxxxb"]

[dependencies]
mips-mcu = { version = "0.3.0", features = ["critical-section-single-core"] }
mips-rt = "0.3.0"
mips-rt = "0.3.2"
panic-halt = "0.2.0"
embedded-hal = "0.2.7"
pic32-hal = "0.9.0"
pic32-config-sector = "0.2.0"
pic32-hal = "0.10.0"
pic32-config-sector = "0.3.0"

[profile.release]
opt-level = 2
lto = true
debug = true
36 changes: 36 additions & 0 deletions examples/blinky/memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Memory region of PIC32MX devices
*
* LENGTH values need to be adapted to specific device variant.
* REGION_ALIAS functions are used to put the startup code either into the boot
* flash memory or into the program flash memory keeping the boot flash free for
* a boot loader.
*/

/* Symbols used for interrupt-vector table generation */
PROVIDE(_vector_spacing = 0x0001);
PROVIDE(_ebase_address = 0x9D000000); /* first 4 KiB of program flash */

MEMORY
{
boot_flash (rx) : ORIGIN = 0xBFC00000, LENGTH = 3k - 0x10
program_flash (rx) : ORIGIN = 0x9D000000, LENGTH = 128k
sram (w!x) : ORIGIN = 0x80000000, LENGTH = 32k
configsfrs : ORIGIN = ORIGIN(boot_flash) + LENGTH(boot_flash), LENGTH = 0x10
}

REGION_ALIAS("exception_mem", program_flash)
REGION_ALIAS("program_mem", program_flash)
REGION_ALIAS("data_mem", sram)

/* aliases for direct start without bootloader
* put the reset handler into the boot flash.
*/
REGION_ALIAS(reset_mem, boot_flash)

/* aliases for bootloader support
* put the bootloader into the boot flash memory and the reset handler at the
* beginning of the normal program flash memory.
*/
/* REGION_ALIAS(reset_mem, program_flash)
REGION_ALIAS(bootloader_mem, boot_flash) */
17 changes: 3 additions & 14 deletions examples/blinky/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#![no_main]
#![no_std]

use core::{fmt::Write, panic::PanicInfo};

use core::fmt::Write;
use embedded_hal::{blocking::delay::DelayMs, digital::v2::*, serial::Read};
use mips_rt::{self, entry};
use panic_halt as _;
use pic32_config_sector::pic32mx2xx::*;
use pic32_hal::{
clock::Osc,
Expand Down Expand Up @@ -48,8 +48,6 @@ pub static CONFIGSFRS: ConfigSector = ConfigSector::default()
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();

//pps.rpb0r.write(|w| unsafe { w.rpb0r().bits(0b0010) }); // U2TX on RPB0

// setup clock control object
let sysclock = 40_000_000_u32.hz();
let clock = Osc::new(p.OSC, sysclock);
Expand Down Expand Up @@ -77,20 +75,11 @@ fn main() -> ! {
let mut on = true;
loop {
writeln!(tx, "LED status: {}", on).unwrap();
if on {
led.set_high().unwrap();
} else {
led.set_low().unwrap();
}
led.set_state(on.into()).unwrap();
on = !on;
if let Ok(byte) = rx.read() {
writeln!(tx, "read char: '{}'", byte as char).unwrap();
}
timer.delay_ms(1000u32);
}
}

#[panic_handler]
fn panic(_panic_info: &PanicInfo<'_>) -> ! {
loop {}
}
2 changes: 1 addition & 1 deletion examples/i2c_oled_display/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[target.mipsel-unknown-none]
rustflags = ["-C", "link-arg=-T32MX270F256B_procdefs.ld"]
rustflags = ["-C", "link-arg=-Tlink.x"]

[build]
target = "mipsel-unknown-none"
Expand Down
45 changes: 23 additions & 22 deletions examples/i2c_oled_display/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading