-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Schaefer <[email protected]>
- Loading branch information
1 parent
c6e0710
commit f215351
Showing
7 changed files
with
155 additions
and
47 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[build] | ||
target = "thumbv6m-none-eabi" | ||
|
||
[target.thumbv6m-none-eabi] | ||
runner = "elf2uf2-rs -d" | ||
# runner = "picotool load -x -t elf" | ||
# runner = "probe-run --chip RP2040" | ||
|
||
rustflags = [ | ||
"-C", "link-arg=-Tlink.x", | ||
"-C", "link-arg=--nmagic", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
edition = "2021" | ||
name = "is31fl3741-qt-py-rp2040" | ||
version = "0.3.0" | ||
|
||
[dependencies] | ||
embedded-hal = "0.2.7" | ||
embedded-graphics-core = { optional = true, version = "0.4.0" } | ||
|
||
cortex-m-rt = "0.7.3" | ||
cortex-m = "0.7.7" | ||
panic-halt = "0.2.0" | ||
rp-pico = "0.7.0" | ||
adafruit-qt-py-rp2040 = {version = "0.6.0", features = ["rt"]} | ||
tinybmp = "0.5.0" | ||
embedded-graphics = "0.8.1" | ||
fugit = "0.3.7" | ||
|
||
is31fl3743a = { path = "../.." } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! This build script copies the `memory.x` file from the crate root into | ||
//! a directory where the linker can always find it at build time. | ||
//! For many projects this is optional, as the linker always searches the | ||
//! project root directory -- wherever `Cargo.toml` is. However, if you | ||
//! are using a workspace or have a more complicated build setup, this | ||
//! build script becomes required. Additionally, by requesting that | ||
//! Cargo re-run the build script whenever `memory.x` is changed, | ||
//! updating `memory.x` ensures a rebuild of the application with the | ||
//! new memory settings. | ||
use std::env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
// Put `memory.x` in our output directory and ensure it's | ||
// on the linker search path. | ||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
File::create(out.join("memory.x")) | ||
.unwrap() | ||
.write_all(include_bytes!("memory.x")) | ||
.unwrap(); | ||
println!("cargo:rustc-link-search={}", out.display()); | ||
|
||
// By default, Cargo will re-run a build script whenever | ||
// any file in the project changes. By specifying `memory.x` | ||
// here, we ensure the build script is only re-run when | ||
// `memory.x` is changed. | ||
println!("cargo:rerun-if-changed=memory.x"); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
MEMORY { | ||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 | ||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 | ||
RAM : ORIGIN = 0x20000000, LENGTH = 256K | ||
} | ||
|
||
EXTERN(BOOT2_FIRMWARE) | ||
|
||
SECTIONS { | ||
/* ### Boot loader */ | ||
.boot2 ORIGIN(BOOT2) : | ||
{ | ||
KEEP(*(.boot2)); | ||
} > BOOT2 | ||
} INSERT BEFORE .text; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
// pick a panicking behavior | ||
use panic_halt as _; | ||
|
||
use adafruit_qt_py_rp2040::entry; | ||
use adafruit_qt_py_rp2040::{ | ||
hal::{ | ||
clocks::{init_clocks_and_plls, Clock}, | ||
i2c::I2C, | ||
pac, | ||
watchdog::Watchdog, | ||
Sio, | ||
}, | ||
Pins, XOSC_CRYSTAL_FREQ, | ||
}; | ||
use fugit::RateExtU32; | ||
use is31fl3743a::devices::UnknownDevice; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let mut pac = pac::Peripherals::take().unwrap(); | ||
let core = pac::CorePeripherals::take().unwrap(); | ||
|
||
let mut watchdog = Watchdog::new(pac.WATCHDOG); | ||
|
||
let clocks = init_clocks_and_plls( | ||
XOSC_CRYSTAL_FREQ, | ||
pac.XOSC, | ||
pac.CLOCKS, | ||
pac.PLL_SYS, | ||
pac.PLL_USB, | ||
&mut pac.RESETS, | ||
&mut watchdog, | ||
) | ||
.ok() | ||
.unwrap(); | ||
|
||
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz()); | ||
let sio = Sio::new(pac.SIO); | ||
let pins = Pins::new( | ||
pac.IO_BANK0, | ||
pac.PADS_BANK0, | ||
sio.gpio_bank0, | ||
&mut pac.RESETS, | ||
); | ||
|
||
// Using STEMMA QT connector | ||
let sda = pins.sda1.into_mode(); // gpio22 | ||
let scl = pins.scl1.into_mode(); // gpio23 | ||
|
||
//let sda = pins.sda.into_mode(); // gpio24 | ||
//let scl = pins.scl.into_mode(); // gpio25 | ||
|
||
let i2c = I2C::i2c1( | ||
pac.I2C1, | ||
sda, | ||
scl, | ||
400.kHz(), | ||
&mut pac.RESETS, | ||
125_000_000.Hz(), | ||
); | ||
|
||
let mut matrix = UnknownDevice::configure(i2c); | ||
matrix | ||
.setup(&mut delay) | ||
.expect("failed to setup rgb controller"); | ||
|
||
matrix.set_scaling(0xFF).expect("failed to set scaling"); | ||
|
||
loop { | ||
matrix.device.fill(0xFF).expect("couldn't turn on"); | ||
delay.delay_ms(100u32); | ||
matrix.device.fill(0x00).expect("couldn't turn off"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.