Skip to content

Commit cc4ab29

Browse files
committed
Initial commit
0 parents  commit cc4ab29

30 files changed

+2692
-0
lines changed

.cargo/config.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build]
2+
target = "avr-specs/avr-atmega32u4.json"
3+
4+
[target.'cfg(target_arch = "avr")']
5+
runner = "ravedude promicro"
6+
7+
[unstable]
8+
build-std = ["core"]

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/ws2812-avr/target
2+
/target
3+
/Cargo.lock

Cargo.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[profile.dev]
2+
panic = "abort"
3+
lto = true
4+
opt-level = "s"
5+
6+
[profile.release]
7+
panic = "abort"
8+
codegen-units = 1
9+
debug = true
10+
lto = true
11+
opt-level = "s"
12+
13+
[workspace]
14+
members = [
15+
"ws2812-avr",
16+
"examples/rainbow",
17+
"examples/custom-timings"
18+
]

LICENSE

+674
Large diffs are not rendered by default.

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ws2812-avr
2+
3+
WS2812 clockless led strip driver for AVR devices developed in pure
4+
Rust.
5+
6+
This project was done for fun as a part of a Rust learning process. It
7+
uses extremely unstable features from the nigthly compiler, such as
8+
`const_generic_exprs`, or `specialization` because it is more
9+
entertaining and useful for me to using them than not doing so. This
10+
library may be used as long as you keep that in mind.
11+
12+
Tested on Rust nightly 2022-07-03.
13+
14+
## Usage
15+
16+
1. Follow instructions [here](https://github.com/Rahix/avr-hal) to
17+
setup a Rust AVR project using avr-hal crates.
18+
19+
2. Add it to your Cargo.toml as follows:
20+
```
21+
[dependencies]
22+
...
23+
ws2812-avr = { git = "https://github.com/devcexx/ws2812-avr", rev = "<commit id>", features = ["<avr-hal processor name>"] }
24+
```
25+
26+
3. Add the feature `#![feature(generic_const_exprs)]` to your main
27+
Rust file.
28+
29+
Check the [examples](examples) folder for checking some examples on
30+
how to use the library. Review the library docstrings for getting
31+
documentation about the components of the library.

avr-specs/avr-atmega1280.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "atmega1280",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=atmega1280",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-atmega168.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "atmega168",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=atmega168",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-atmega2560.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "atmega2560",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=atmega2560",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-atmega328p.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "atmega328p",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=atmega328p",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-atmega32u4.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "atmega32u4",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=atmega32u4",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-atmega48p.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "atmega48p",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=atmega48p",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-attiny85.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "attiny85",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=attiny85",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

avr-specs/avr-attiny88.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"arch": "avr",
3+
"atomic-cas": false,
4+
"cpu": "attiny88",
5+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
6+
"eh-frame-header": false,
7+
"exe-suffix": ".elf",
8+
"executables": true,
9+
"late-link-args": {
10+
"gcc": [
11+
"-lgcc"
12+
]
13+
},
14+
"linker": "avr-gcc",
15+
"linker-is-gnu": true,
16+
"llvm-target": "avr-unknown-unknown",
17+
"max-atomic-width": 8,
18+
"no-default-libraries": false,
19+
"pre-link-args": {
20+
"gcc": [
21+
"-mmcu=attiny88",
22+
"-Wl,--as-needed"
23+
]
24+
},
25+
"target-c-int-width": "16",
26+
"target-pointer-width": "16"
27+
}

examples/custom-timings/Cargo.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "custom-timings"
3+
version = "0.1.0"
4+
authors = ["Roberto Guillén"]
5+
edition = "2021"
6+
license = "GPL-3.0-only"
7+
8+
[[bin]]
9+
name = "custom-timings"
10+
test = false
11+
bench = false
12+
13+
[dependencies]
14+
panic-halt = "0.2.0"
15+
ufmt = "0.1.0"
16+
nb = "0.1.2"
17+
embedded-hal = "0.2.3"
18+
ws2812-avr = { path = "../../ws2812-avr" }
19+
20+
[dependencies.arduino-hal]
21+
git = "https://github.com/rahix/avr-hal"
22+
rev = "1aacefb335517f85d0de858231e11055d9768cdf"
23+
features = ["sparkfun-promicro"]

examples/custom-timings/README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
`avr-hal-template`
2+
==================
3+
[`cargo-generate`] template for jumpstarting projects on common AVR
4+
microcontroller boards. This template supports the following hardware at this
5+
time:
6+
7+
- Arduino Leonardo
8+
- Arduino Mega 2560
9+
- Arduino Nano
10+
- Arduino Uno
11+
- SparkFun ProMicro
12+
13+
## Usage
14+
If you don't have them already, install [`cargo-generate`] and [`ravedude`]:
15+
16+
```bash
17+
cargo install cargo-generate
18+
cargo install ravedude
19+
```
20+
21+
Then instanciate this template:
22+
23+
```bash
24+
cargo generate --git https://github.com/Rahix/avr-hal-template.git
25+
```
26+
27+
You will be prompted to select your board - do so and you're ready to roll!
28+
Everything is prepared so you should be able to just
29+
30+
```bash
31+
cargo run
32+
```
33+
34+
and see a blinky flashed to your board!
35+
36+
[`cargo-generate`]: https://github.com/cargo-generate/cargo-generate
37+
[`ravedude`]: https://github.com/Rahix/avr-hal/tree/next/ravedude
38+
39+
## License
40+
Licensed under either of
41+
42+
- Apache License, Version 2.0
43+
([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
44+
- MIT license
45+
([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
46+
47+
at your option.
48+
49+
## Contribution
50+
Unless you explicitly state otherwise, any contribution intentionally submitted
51+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
52+
be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)