Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTails committed Feb 8, 2024
1 parent b24c3f4 commit 5c27209
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# TODO(2) replace `$CHIP` with your chip's name (see `probe-rs chip list` output)
runner = "probe-rs run --chip $CHIP"
runner = "probe-rs run --chip STM32L412KBUx"
rustflags = [
"-C", "linker=flip-link",
"-C", "link-arg=-Tlink.x",
Expand All @@ -17,7 +17,7 @@ rustflags = [
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
# target = "thumbv7m-none-eabi" # Cortex-M3
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

[alias]
rb = "run --bin"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
Cargo.lock
Cargo.lock
.DS_Store
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ defmt = { version = "0.3", features = ["encoding-rzcobs"] }
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
panic-probe = { version = "0.3", features = ["print-defmt"] }
# TODO(4) Select the correct rtic backend
rtic = { version = "2.0.0", features = [ "$RTIC_BACKEND" ] }
rtic = { version = "2.0.0", features = [ "thumbv7-backend" ] }
# TODO(5) Add hal as dependency
some-hal = "1.2.3"
stm32l4xx-hal = { version = "0.7.1", features = ["stm32l442"] }
# TODO add a monotonic if you use scheduling
# rtic-monotonics = { version = "1.0.0", features = [ "cortex-m-systick" ]}

Expand Down
23 changes: 23 additions & 0 deletions memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MEMORY
{
/* NOTE K = KiBi = 1024 bytes */
/* TODO Adjust these memory regions to match your device memory layout */
FLASH : ORIGIN = 0x8000000, LENGTH = 128K
RAM : ORIGIN = 0x20000000, LENGTH = 32K
}

/* This is where the call stack will be allocated. */
/* The stack is of the full descending type. */
/* You may want to use this variable to locate the call stack and static
variables in different memory regions. Below is shown the default value */
/* _stack_start = ORIGIN(RAM) + LENGTH(RAM); */

/* You can use this symbol to customize the location of the .text section */
/* If omitted the .text section will be placed right after the .vector_table
section */
/* This is required only on microcontrollers that store some configuration right
after the vector table */
/* _stext = ORIGIN(FLASH) + 0x400; */

/* Size of the heap (in bytes) */
/* _heap_size = 1024; */
17 changes: 11 additions & 6 deletions src/bin/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ use test_app as _; // global logger + panicking-behavior + memory layout
// TODO(7) Configure the `rtic::app` macro
#[rtic::app(
// TODO: Replace `some_hal::pac` with the path to the PAC
device = some_hal::pac,
device = stm32l4xx_hal::pac,
// TODO: Replace the `FreeInterrupt1, ...` with free interrupt vectors if software tasks are used
// You can usually find the names of the interrupt vectors in the some_hal::pac::interrupt enum.
dispatchers = [FreeInterrupt1, ...]
dispatchers = [EXTI0]
)]
mod app {
use stm32l4xx_hal as hal;

use hal::{pac, prelude::*};

// Shared resources go here
#[shared]
struct Shared {
Expand All @@ -26,16 +30,17 @@ mod app {
}

#[init]
fn init(cx: init::Context) -> (Shared, Local) {
fn init(_cx: init::Context) -> (Shared, Local) {
let peripherals = pac::Peripherals::take();

defmt::info!("init");

// TODO setup monotonic if used
// let sysclk = { /* clock setup + returning sysclk as an u32 */ };
// let token = rtic_monotonics::create_systick_token!();
// rtic_monotonics::systick::Systick::new(cx.core.SYST, sysclk, token);


task1::spawn().ok();
blink_led::spawn().ok();

(
Shared {
Expand All @@ -59,7 +64,7 @@ mod app {

// TODO: Add tasks
#[task(priority = 1)]
async fn task1(_cx: task1::Context) {
async fn blink_led(_cx: blink_led::Context) {
defmt::info!("Hello from task1!");
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use defmt_brtt as _; // global logger
use panic_probe as _;

// TODO(6) Import your HAL
use some_hal as _; // memory layout
use stm32l4xx_hal as _; // memory layout

// same panicking *behavior* as `panic-probe` but doesn't print a panic message
// this prevents the panic message being printed *twice* when `defmt::panic` is invoked
Expand Down

0 comments on commit 5c27209

Please sign in to comment.