Skip to content

Commit 649aa93

Browse files
authored
Merge pull request #65 from Neotron-Compute/develop
It's a multi-crate repo, so lose the develop branch
2 parents bb08ff2 + 3996665 commit 649aa93

File tree

15 files changed

+1515
-44
lines changed

15 files changed

+1515
-44
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*/target
22
target/
3-
*Cargo.lock*
4-
*/Cargo.lock
3+
/Cargo.lock
4+
/neotron-bmc-protocol/Cargo.lock
5+
/neotron-bmc-command/Cargo.lock

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ line and a dedicated IRQ line. It provides to the system:
2222
* two analog inputs for monitoring for the 3.3V and 5.0V rails,
2323
* two GPIO inputs for a power button and a reset button, and
2424
* three GPIO outputs - nominally used for
25-
* the main DC/DC enable signal, and
26-
* the power LED
25+
* the main DC/DC enable signal, and
26+
* the power LED
2727

2828
## Hardware Interface
2929

@@ -57,7 +57,7 @@ Build requirements are available for
5757

5858
## Licence
5959

60-
This code is licenced under the GNU Public Licence version 3. See:
60+
This repository as a whole is licenced under the GNU Public Licence version 3. See:
6161

6262
* [The LICENSE file](./LICENSE)
6363
* [The GPL Website](http://www.gnu.org/licenses/gpl-3.0.html)
@@ -86,4 +86,7 @@ firmware (or products that contain it):
8686
Note that this firmware image incorporates a number of third-party modules. You
8787
should review the output of `cargo tree` and ensure that any licence terms for
8888
those modules are upheld. You should also be aware that this application was
89-
based on the Knurling Template at https://github.com/knurling-rs/app-template.
89+
based on the Knurling Template at <https://github.com/knurling-rs/app-template>.
90+
91+
Note also that some crates within this tree are made available individually
92+
under different licences. See each individual crate for details.

flake.lock

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
description = "Neotron BMC";
3+
4+
inputs = {
5+
flake-utils.url = "github:numtide/flake-utils";
6+
rust-overlay = {
7+
url = "github:oxalica/rust-overlay";
8+
inputs = {
9+
nixpkgs.follows = "nixpkgs";
10+
flake-utils.follows = "flake-utils";
11+
};
12+
};
13+
crane = {
14+
url = "github:ipetkov/crane";
15+
inputs = {
16+
nixpkgs.follows = "nixpkgs";
17+
flake-utils.follows = "flake-utils";
18+
rust-overlay.follows = "rust-overlay";
19+
};
20+
};
21+
};
22+
23+
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
24+
let
25+
# List of systems this flake.nix has been tested to work with
26+
systems = [ "x86_64-linux" ];
27+
pkgsForSystem = system: nixpkgs.legacyPackages.${system}.appendOverlays [
28+
rust-overlay.overlays.default
29+
];
30+
in
31+
flake-utils.lib.eachSystem systems
32+
(system:
33+
let
34+
pkgs = pkgsForSystem system;
35+
toolchain = pkgs.rust-bin.stable.latest.default.override {
36+
targets = [ "thumbv6m-none-eabi" ];
37+
};
38+
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
39+
40+
bmc-pico = craneLib.mkCargoDerivation {
41+
pname = "neotron-bmc-pico";
42+
version = (craneLib.crateNameFromCargoToml {
43+
cargoToml = ./neotron-bmc-pico/Cargo.toml;
44+
}).version;
45+
cargoArtifacts = null;
46+
cargoVendorDir = craneLib.vendorCargoDeps { src = ./neotron-bmc-pico; };
47+
src = with pkgs.lib;
48+
let keep = suffixes: path: type: any (s: hasSuffix s path) suffixes;
49+
in
50+
cleanSourceWith {
51+
src = craneLib.path ./.;
52+
filter = path: type: any id (map (f: f path type) [
53+
craneLib.filterCargoSources
54+
(keep [
55+
".md" # neotron-bmc-protocol needs README.md
56+
".x"
57+
])
58+
]);
59+
};
60+
buildPhaseCargoCommand = ''
61+
cd neotron-bmc-pico # because .cargo/config.toml exists here
62+
cargo build --release --target=thumbv6m-none-eabi
63+
'';
64+
nativeBuildInputs = [
65+
pkgs.makeWrapper
66+
pkgs.probe-run
67+
pkgs.flip-link
68+
];
69+
installPhase = ''
70+
mkdir -p $out/bin
71+
cp target/thumbv6m-none-eabi/release/neotron-bmc-pico $out/bin/
72+
makeWrapper ${pkgs.probe-run}/bin/probe-run $out/bin/flash-neotron-bmc-pico \
73+
--set DEFMT_LOG info \
74+
--add-flags "--chip STM32F030K6Tx $out/bin/neotron-bmc-pico"
75+
'';
76+
};
77+
in rec
78+
{
79+
packages.neotron-bmc-pico = bmc-pico;
80+
defaultPackage = packages.neotron-bmc-pico;
81+
82+
defaultApp = apps.neotron-bmc-pico;
83+
apps.neotron-bmc-pico = flake-utils.lib.mkApp {
84+
drv = bmc-pico;
85+
exePath = "/bin/flash-neotron-bmc-pico";
86+
};
87+
88+
devShell = pkgs.mkShell {
89+
nativeBuildInputs = [
90+
toolchain
91+
pkgs.probe-run
92+
pkgs.flip-link
93+
];
94+
};
95+
}
96+
);
97+
}

neotron-bmc-commands/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
[package]
2+
description = "Commands that are supported by the Neotron BMC"
3+
edition = "2021"
4+
license = "BlueOak-1.0.0"
25
name = "neotron-bmc-commands"
6+
repository = "https://github.com/neotron-compute/neotron-bmc"
37
version = "0.1.0"
4-
edition = "2021"
8+
homepage = "https://github.com/neotron-compute"
9+
readme = "README.md"
510

611
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
812
[dependencies]
9-
num_enum = { version = "0.5", default-features=false }
13+
num_enum = { version = "0.5", default-features = false }

neotron-bmc-commands/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,27 @@ should set the other three registers (if required) before setting this register.
217217
There is no way to know when the tone is ended; the host should keep track of
218218
the duration it set and wait the appropriate period of time.
219219

220-
### Address 0x71 - Speaker Tone Period (High)
220+
### Address 0x71 - Speaker Tone Period (Low)
221221

222-
Sets the upper 8 bits of the tone period. This is the inverse of frequency, in 48 kHz units.
222+
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.
223223

224-
### Address 0x72 - Speaker Tone Period (Low)
224+
### Address 0x72 - Speaker Tone Period (High)
225225

226-
Sets the lower 8 bits of the tone period. See *Speaker Tone Period (High)* for details.
226+
Sets the upper 8 bits of the tone period. This is the inverse of frequency, in
227+
48 kHz units. A value of `48000 / 440 = 109 = 0x006D` will give you a
228+
Concert-pitch A (440 Hz). Write that value as `0x00` in the high register and
229+
`0x6D` in the low register.
227230

228231
### Address 0x73 - Speaker Tone Duty Cycle
229232

230233
Sets the duty-cycle of the speaker tone. A value of 127 is 50:50 (a square wave).
234+
235+
## Licence
236+
237+
This code is licenced under the Blue Oak Model License 1.0.0. See:
238+
239+
* [The LICENSE file](./LICENSE)
240+
* [The Blue Oak Licence Website](https://blueoakcouncil.org/license/1.0.0)
241+
242+
Our intent behind picking this licence is to allow this code to be freely
243+
reused, both in open-source and commercially licensed products.

neotron-bmc-commands/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! # Neotron BMC Commands
2-
//!
3-
//! Definitions of all the commands supported by the BMC.
1+
#![doc = include_str!("../README.md")]
42

53
#![no_std]
64

@@ -142,16 +140,16 @@ pub enum Command {
142140
/// * Length: 1
143141
/// * Mode: R/W
144142
SpeakerDuration = 0x70,
145-
/// # Speaker Period (High byte)
146-
/// High byte of period (in 48kHz ticks)
143+
/// # Speaker Period (Low byte)
144+
/// Low byte of 16-bit period (in 48kHz ticks)
147145
/// * Length: 1
148146
/// * Mode: R/W
149-
SpeakerPeriodHigh = 0x71,
147+
SpeakerPeriodLow = 0x71,
150148
/// # Speaker Period (High byte)
151-
/// High byte of period (in 48kHz ticks)
149+
/// High byte of 16-bit period (in 48kHz ticks)
152150
/// * Length: 1
153151
/// * Mode: R/W
154-
SpeakerPeriodLow = 0x72,
152+
SpeakerPeriodHigh = 0x72,
155153
/// # Speaker Duty Cycle
156154
/// Speaker Duty cycle, in 1/255
157155
/// * Length: 1

0 commit comments

Comments
 (0)