Skip to content

Commit d85d642

Browse files
authored
Merge pull request #36 from Neotron-Compute/keyboard-spi-support
Draft: Keyboard SPI support
2 parents d395bdd + 2b9e51d commit d85d642

File tree

10 files changed

+468
-169
lines changed

10 files changed

+468
-169
lines changed

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[workspace]
2+
3+
# Include all the generic library crates
4+
members = [
5+
"neotron-bmc-protocol",
6+
"neotron-bmc-commands"
7+
]
8+
9+
# Exclude the BMC firmwares as they build using different targets/features
10+
exclude = [
11+
"neotron-bmc-pico",
12+
"neotron-bmc-nucleo",
13+
]

neotron-bmc-commands/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "neotron-bmc-commands"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
num_enum = { version = "0.5", default-features=false }

neotron-bmc-commands/src/lib.rs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
//! # Neotron BMC Commands
2+
//!
3+
//! Definitions of all the commands supported by the BMC.
4+
5+
#![no_std]
6+
7+
#[derive(Debug, Copy, Clone, num_enum::IntoPrimitive, num_enum::TryFromPrimitive)]
8+
#[repr(u8)]
9+
pub enum Command {
10+
/// # Protocol Version
11+
/// The NBMC protocol version, [1, 0, 0]
12+
/// * Length: 3
13+
/// * Mode: RO
14+
ProtocolVersion = 0x00,
15+
/// # Firmware Version
16+
/// The NBMC firmware version, as a null-padded UTF-8 string
17+
/// * Length: 32
18+
/// * Mode: RO
19+
FirmwareVersion = 0x01,
20+
/// # Interrupt Status
21+
/// Which interrupts are currently active, as a bitmask.
22+
/// * Length: 2
23+
/// * Mode: R/W1C
24+
InterruptStatus = 0x10,
25+
/// # Interrupt Control
26+
/// Which interrupts are currently enabled, as a bitmask.
27+
/// * Length: 2
28+
/// * Mode: R/W
29+
InterruptControl = 0x11,
30+
/// # Button Status
31+
/// The current state of the buttons
32+
/// * Length: 1
33+
/// * Mode: RO
34+
ButtonStatus = 0x20,
35+
/// # System Temperature
36+
/// Temperature in °C, as an `i8`
37+
/// * Length: 1
38+
/// * Mode: RO
39+
SystemTemperature = 0x21,
40+
/// # System Voltage (Standby 3.3V rail)
41+
/// Voltage in Volts/32, as a `u8`
42+
/// * Length: 1
43+
/// * Mode: RO
44+
SystemVoltage33S = 0x22,
45+
/// # System Voltage (Main 3.3V rail)
46+
/// Voltage in Volts/32, as a `u8`
47+
/// * Length: 1
48+
/// * Mode: RO
49+
SystemVoltage33 = 0x23,
50+
/// # System Voltage (5.0V rail)
51+
/// Voltage in Volts/32, as a `u8`
52+
/// * Length: 1
53+
/// * Mode: RO
54+
SystemVoltage55 = 0x24,
55+
/// # Power Control
56+
/// Enable/disable the power supply
57+
/// * Length: 1
58+
/// * Mode: R/W
59+
PowerControl = 0x25,
60+
/// # UART Receive/Transmit Buffer
61+
/// Data received/to be sent over the UART
62+
/// * Length: up to 64
63+
/// * Mode: FIFO
64+
UartBuffer = 0x30,
65+
/// # UART FIFO Control
66+
/// Settings for the UART FIFO
67+
/// * Length: 1
68+
/// * Mode: R/W
69+
UartFifoControl = 0x31,
70+
/// # UART Control
71+
/// Settings for the UART
72+
/// * Length: 1
73+
/// * Mode: R/W
74+
UartControl = 0x32,
75+
/// # UART Status
76+
/// The current state of the UART
77+
/// * Length: 1
78+
/// * Mode: R/W1C
79+
UartStatus = 0x33,
80+
/// # UART Baud Rate
81+
/// The UART baud rate in bps, as a `u32le`
82+
/// * Length: 4
83+
/// * Mode: R/W
84+
UartBaudRate = 0x34,
85+
/// # PS/2 Keyboard Receive/Transmit Buffer
86+
/// Data received/to be sent over the PS/2 keyboard port
87+
/// * Length: up to 16
88+
/// * Mode: FIFO
89+
Ps2KbBuffer = 0x40,
90+
/// # PS/2 Keyboard Control
91+
/// Settings for the PS/2 Keyboard port
92+
/// * Length: 1
93+
/// * Mode: R/W
94+
Ps2KbControl = 0x41,
95+
/// # PS/2 Keyboard Status
96+
/// Current state of the PS/2 Keyboard port
97+
/// * Length: 1
98+
/// * Mode: R/W1C
99+
Ps2KbStatus = 0x42,
100+
/// # PS/2 Mouse Receive/Transmit Buffer
101+
/// Data received/to be sent over the PS/2 Mouse port
102+
/// * Length: up to 16
103+
/// * Mode: FIFO
104+
Ps2MouseBuffer = 0x50,
105+
/// # PS/2 Mouse Control
106+
/// Settings for the PS/2 Mouse port
107+
/// * Length: 1
108+
/// * Mode: R/W
109+
Ps2MouseControl = 0x51,
110+
/// # PS/2 Mouse Status
111+
/// Current state of the PS/2 Mouse port
112+
/// * Length: 1
113+
/// * Mode: R/W1C
114+
Ps2MouseStatus = 0x52,
115+
/// # I²C Receive/Transmit Buffer
116+
/// Data received/to be sent over the I²C Bus
117+
/// * Length: up to 16
118+
/// * Mode: FIFO
119+
I2cBuffer = 0x60,
120+
/// # I²C FIFO Control
121+
/// Settings for the I²C FIFO
122+
/// * Length: 1
123+
/// * Mode: R/W
124+
I2cFifoControl = 0x61,
125+
/// # I²C Control
126+
/// Settings for the I²C Bus
127+
/// * Length: 1
128+
/// * Mode: R/W
129+
I2cControl = 0x62,
130+
/// # I²C Status
131+
/// Current state of the I²C Bus
132+
/// * Length: 1
133+
/// * Mode: R/W1C
134+
I2cStatus = 0x63,
135+
/// # I²C Baud Rate
136+
/// The I²C clock rate in Hz, as a `u32le`
137+
/// * Length: 4
138+
/// * Mode: R/W
139+
I2cBaudRate = 0x64,
140+
}

neotron-bmc-pico/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ defmt-rtt = "0.4"
1313
heapless= "0.7"
1414
panic-probe = { version = "0.3", features = ["print-defmt"] }
1515
stm32f0xx-hal = { version = "0.18", features = ["stm32f030x6", "rt"] }
16-
neotron-bmc-protocol = { version = "0.1", path = "../neotron-bmc-protocol" }
16+
neotron-bmc-protocol = { version = "0.1", path = "../neotron-bmc-protocol", features = ["defmt"] }
17+
neotron-bmc-commands = { version = "0.1", path = "../neotron-bmc-commands" }
1718
systick-monotonic = "1.0"
1819
embedded-hal = "*"
1920

neotron-bmc-pico/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
// Generate a file containing the firmware version
2020
let version_output = std::process::Command::new("git")
2121
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
22-
.args(&["describe", "--tags", "--all", "--dirty"])
22+
.args(["describe", "--tags", "--all", "--dirty"])
2323
.output()
2424
.expect("running git-describe");
2525
assert!(version_output.status.success());

0 commit comments

Comments
 (0)