Skip to content

Commit 926ce2d

Browse files
authored
Merge pull request #6 from Neotron-Compute/add-snake
Add snake
2 parents 5e154f1 + 21c4d3e commit 926ce2d

File tree

27 files changed

+1077
-59
lines changed

27 files changed

+1077
-59
lines changed

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"rust-analyzer.linkedProjects": [
3+
"./samples/input-test/Cargo.toml",
4+
"./samples/panic/Cargo.toml",
5+
"./samples/hello/Cargo.toml",
6+
"./samples/fault/Cargo.toml",
7+
"./samples/snake/Cargo.toml",
8+
"./Cargo.toml"
9+
]
10+
}

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ version = "0.1.0"
77
authors = ["Jonathan 'theJPster' Pallant <[email protected]>"]
88

99
[dependencies]
10-
bitflags = "2"
1110
neotron-ffi = "0.1"
1211
neotron-api = "0.1"
1312

13+
[target.'cfg(unix)'.dependencies]
14+
crossterm = "0.26"
15+
16+
[target.'cfg(windows)'.dependencies]
17+
crossterm = "0.26"
18+
1419
[features]
1520
# Prints panic info. Costs you about 14K of code.
1621
fancy-panic = []

samples/.cargo/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[target.thumbv7em-none-eabihf]
2-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
2+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
33

44
[target.thumbv7em-none-eabi]
5-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
5+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
66

77
[target.thumbv7m-none-eabi]
8-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
8+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
99

1010
[target.thumbv6m-none-eabi]
11-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld"] # , "-C", "link-arg=--nmagic"]
11+
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]

samples/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
*.bin
2-
1+
target
2+
release

samples/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[workspace]
2+
members = [
3+
"fault",
4+
"hello",
5+
"input-test",
6+
"snake",
7+
"panic",
8+
]
9+
10+
[profile.release]
11+
opt-level = "z"
12+
lto = "fat"

samples/build.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
#!/bin/bash
22

3+
#
4+
# Builds all the Neotron SDK sample binaries.
5+
#
6+
# Specify the target as the first argument. Defaults to "thumbv6m-none-eabi" if
7+
# not given.
8+
#
9+
# ```console
10+
# $ ./build.sh thumbv7em-none-eabi
11+
# $ ls ./release/*.elf
12+
# ```
13+
#
14+
315
set -euo pipefail
416

517
TARGET=${1:-thumbv6m-none-eabi}
618

19+
mkdir -p ./release
20+
21+
echo "Building for host"
22+
cargo build
23+
724
echo "Building for ${TARGET}"
8-
for program in panic hello fault; do
9-
( cd ${program} && cargo build --target=${TARGET} --release )
10-
cp ./${program}/target/${TARGET}/release/${program} ${program}.elf
25+
cargo build --target ${TARGET} --release
26+
27+
for program in panic hello fault input-test snake; do
28+
cp ./target/${TARGET}/release/${program} ./release/${program}.elf
1129
done

samples/fault/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

samples/fault/Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,4 @@ description = "Hello World for Neotron systems"
99
[dependencies]
1010
neotron-sdk = { path = "../.." }
1111

12-
[profile.dev]
13-
panic = "abort"
14-
15-
[profile.release]
16-
panic = "unwind"
17-
opt-level = "z"
18-
lto = "fat"
12+
# See workspace for profile settings

samples/fault/src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
#![no_std]
2-
#![no_main]
1+
#![cfg_attr(target_os = "none", no_std)]
2+
#![cfg_attr(target_os = "none", no_main)]
3+
4+
#[cfg(not(target_os = "none"))]
5+
fn main() {
6+
neotron_sdk::init();
7+
}
38

49
use core::fmt::Write;
510

611
#[no_mangle]
712
extern "C" fn neotron_main() -> i32 {
813
let stdout = neotron_sdk::stdout();
914
writeln!(&stdout, "About to fault...\n").unwrap();
10-
let bad_address: u32 = 0xDEAD_C0DE;
15+
let bad_address: usize = 0xDEAD_C0DE;
1116
let bad_fn: fn() = unsafe { core::mem::transmute(bad_address) };
1217
bad_fn();
1318
0

samples/hello/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)