Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Command line arguments:

```bash
# This command will update the file in place
cargo run --bin=evaluator ../../../hat-psu/hat-psu/BD9E302EFJ-5V1.sch
cargo run --bin=evaluator ../../../hat-psu/hat-psu/BD9E302EFJ_5V1.sch
```

### Parser
Expand All @@ -30,7 +30,7 @@ Command line arguments:
```bash
# Or any other .sch file. This command writes to stdout, you can save it in a
# file like this or pipe it to the classifier.
cargo run --bin=parser ../../../hat-psu/hat-psu/BD9E302EFJ-5V1.sch > parsed.yaml
cargo run --bin=parser ../../../hat-psu/hat-psu/BD9E302EFJ_5V1.sch > parsed.yaml
```

### Classifier
Expand All @@ -46,7 +46,7 @@ Command line arguments:
cat parsed.yaml | cargo run --bin=classifier sample_policy.cue > classified.yaml

# ... pipe the output from the parser like this (writes to stdout)
cargo run --bin=parser ../../../hat-psu/hat-psu/BD9E302EFJ-5V1.sch | cargo run --bin=classifier sample_policy.cue
cargo run --bin=parser ../../../hat-psu/hat-psu/BD9E302EFJ_5V1.sch | cargo run --bin=classifier sample_policy.cue
```

## Contributing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 2 2
Sheet 7 9
Title "Compute unit HAT attachment"
Date "2021-06-13"
Rev "0.1.1"
Expand All @@ -20,7 +20,7 @@ P 6700 3600
AR Path="/60A118D6" Ref="L2" Part="1"
AR Path="/60A0E5A4/60A118D6" Ref="L2" Part="1"
AR Path="/60F06CF1/60A118D6" Ref="L?" Part="1"
F 0 "L?" V 6890 3600 50 0000 C CNN
F 0 "L2" V 6890 3600 50 0000 C CNN
F 1 "8.2" V 6799 3600 50 0000 C CNN
F 2 "racklet:DEM8045C" H 6700 3600 50 0001 C CNN
F 3 "https://media.digikey.com/pdf/Data%20Sheets/Murata%20PDFs/DEMO80(30,40,45)C%20Type.pdf" H 6700 3600 50 0001 C CNN
Expand All @@ -36,7 +36,7 @@ L Device:C_Small C?
U 1 1 60A1617F
P 7150 3750
F 0 "C?" H 7242 3796 50 0000 L CNN
F 1 "47" H 7242 3705 50 0000 L CNN
F 1 "0.1" H 7242 3705 50 0000 L CNN
F 2 "Capacitor_SMD:C_1206_3216Metric" H 7150 3750 50 0001 C CNN
F 3 "~" H 7150 3750 50 0001 C CNN
F 4 "true" H 7150 3750 50 0001 C CNN "ICCC_Show"
Expand Down Expand Up @@ -187,15 +187,15 @@ $EndComp
Wire Wire Line
7700 4250 7550 4250
$Comp
L Device:C_Small C?
L Device:C_Small C3
U 1 1 60A2522A
P 3900 4000
F 0 "C?" H 3992 4046 50 0000 L CNN
F 1 "0.1" H 3992 3955 50 0000 L CNN
F 0 "C3" H 3992 4046 50 0000 L CNN
F 1 "51" H 3992 3955 50 0000 L CNN
F 2 "Capacitor_SMD:C_0603_1608Metric" H 3900 4000 50 0001 C CNN
F 3 "~" H 3900 4000 50 0001 C CNN
F 4 "true" H 3900 4000 50 0001 C CNN "ICCC_Show"
F 5 "0.1" H 3900 4000 50 0001 C CNN "value_expr"
F 5 "Properties.Globals.TargetVoltage * 10" H 3900 4000 50 0001 C CNN "value_expr"
F 6 "35" H 3900 4000 50 0001 C CNN "voltagerating_expr"
F 7 "V" H 3900 4000 50 0001 C CNN "voltagerating_unit"
F 8 "35 V" H 3900 4000 50 0001 C CNN "voltagerating"
Expand Down Expand Up @@ -288,15 +288,15 @@ Wire Wire Line
Wire Wire Line
3500 3900 3500 3700
$Comp
L Device:C_Small C?
L Device:C_Small C2
U 1 1 60A24C15
P 3500 4000
F 0 "C?" H 3592 4046 50 0000 L CNN
F 1 "10 F" H 3592 3955 50 0000 L CNN
F 0 "C2" H 3592 4046 50 0000 L CNN
F 1 "5100 F" H 3592 3955 50 0000 L CNN
F 2 "Capacitor_SMD:C_1206_3216Metric" H 3500 4000 50 0001 C CNN
F 3 "~" H 3500 4000 50 0001 C CNN
F 4 "true" H 3500 4000 50 0001 C CNN "ICCC_Show"
F 5 "C3.Value*100" H 3500 4000 50 0001 C CNN "value_expr"
F 5 "C3*100" H 3500 4000 50 0001 C CNN "value_expr"
F 6 "F" H 3500 4000 50 0001 C CNN "value_unit"
1 3500 4000
1 0 0 -1
Expand Down Expand Up @@ -349,4 +349,10 @@ Wire Wire Line
Connection ~ 6250 3600
Wire Wire Line
6250 3600 6550 3600
$Sheet
S 2950 2600 500 150
U 60FFED3D
F0 "Properties_BD9E302EFJ_5V1" 50
F1 "Properties.sch" 50
$EndSheet
$EndSCHEMATC
8 changes: 4 additions & 4 deletions hat-psu/hat-psu/BMC.sch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 2
Sheet 1 9
Title "Compute unit HAT attachment"
Date "2021-06-13"
Rev "0.1.1"
Expand Down Expand Up @@ -168,9 +168,9 @@ Wire Wire Line
Text HLabel 3250 5450 0 50 Input ~ 0
3V3
$Sheet
S 7700 3750 950 350
S 7700 3750 950 350
U 60F06CF1
F0 "BD9E302EFJ" 50
F1 "BD9E302EFJ-5V1.sch" 50
F0 "BD9E302EFJ_5V1" 50
F1 "BD9E302EFJ_5V1.sch" 50
$EndSheet
$EndSCHEMATC
31 changes: 31 additions & 0 deletions hat-psu/hat-psu/Properties.sch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 9 9
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L Device:R Globals
U 1 1 610002DE
P 4400 3350
AR Path="/60A0E5A4/60FFED3D/610002DE" Ref="Globals" Part="1"
AR Path="/60FF8D0D/610002DE" Ref="Globals" Part="1"
F 0 "Globals" H 4470 3396 50 0000 L CNN
F 1 "R" H 4470 3305 50 0000 L CNN
F 2 "Resistor_SMD:R_0603_1608Metric" V 4330 3350 50 0001 C CNN
F 3 "~" H 4400 3350 50 0001 C CNN
F 4 "5.1" H 4400 3350 50 0001 C CNN "TargetVoltage"
F 5 "5.1" H 4400 3350 50 0001 C CNN "TargetVoltage_expr"
1 4400 3350
1 0 0 -1
$EndComp
$EndSCHEMATC
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 2 5
Sheet 2 9
Title "Compute unit HAT attachment"
Date "2021-06-13"
Rev "0.1.1"
Expand Down
File renamed without changes.
102 changes: 60 additions & 42 deletions hat-psu/hat-psu/hat-psu.sch → hat-psu/hat-psu/hat_psu.sch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 5
Sheet 1 9
Title "Compute unit HAT attachment"
Date "2021-06-13"
Rev "0.1.1"
Expand Down Expand Up @@ -125,14 +125,6 @@ Wire Wire Line
3800 3000 3850 3000
Text Notes 4950 2700 0 50 ~ 0
current sense shunt\nTODO: Does this\nhave to be 10mohm?
$Sheet
S 9200 2700 950 600
U 60AD3F6A
F0 "compute-sbc" 50
F1 "compute-sbc.sch" 50
F2 "5.1V" I L 9200 2850 50
F3 "GND" U L 9200 3200 50
$EndSheet
Wire Wire Line
9200 3200 9050 3200
Wire Wire Line
Expand Down Expand Up @@ -177,14 +169,6 @@ Text Label 3800 3000 2 50 ~ 0
DCDC_EN
Text GLabel 4850 2800 1 50 Input ~ 0
5V1
$Sheet
S 7900 2750 800 200
U 60A9D2A2
F0 "ideal-diode" 50
F1 "ideal-diode.sch" 50
F2 "CATHODE" O R 8700 2850 50
F3 "ANODE" I L 7900 2850 50
$EndSheet
Wire Wire Line
8700 2850 9200 2850
Text Notes 7900 2600 0 50 ~ 0
Expand Down Expand Up @@ -424,21 +408,6 @@ F 3 "~" H 7100 3650 50 0001 C CNN
$EndComp
Wire Wire Line
6300 3850 6900 3850
$Sheet
S 7250 3350 800 2050
U 60AC90CC
F0 "BMC" 50
F1 "BMC.sch" 50
F2 "PAC_CLK" O L 7250 3750 50
F3 "PAC_DATA" B L 7250 3850 50
F4 "PAC_INT" O L 7250 3950 50
F5 "DCDC_EN" O L 7250 4300 50
F6 "PAC_DAC" I L 7250 4050 50
F7 "USB_D-" I L 7250 4700 50
F8 "USB_D+" I L 7250 4600 50
F9 "USB_5V" I L 7250 4500 50
F10 "3V3" I L 7250 3450 50
$EndSheet
Text Notes 7250 3250 0 50 ~ 0
TODO: Design BMC
Text Notes 7350 5100 0 50 ~ 0
Expand Down Expand Up @@ -508,15 +477,6 @@ Wire Wire Line
5800 3950 7250 3950
Wire Wire Line
7250 4050 5800 4050
$Sheet
S 3850 2700 550 400
U 60A0E5A4
F0 "BD9E302EFJ-5V1" 50
F1 "BD9E302EFJ-5V1.sch" 50
F2 "VOUT" O R 4400 2850 50
F3 "VIN" I L 3850 2850 50
F4 "EN" I L 3850 3000 50
$EndSheet
$Comp
L power:VBUS #PWR0104
U 1 1 60BFD071
Expand Down Expand Up @@ -679,7 +639,7 @@ Wire Wire Line
1350 4250 1350 4200
Connection ~ 1350 4200
Wire Wire Line
1350 4200 950 4200
1350 4200 950 4200
$Comp
L power:VBUS #PWR014
U 1 1 60C85D7C
Expand Down Expand Up @@ -817,4 +777,62 @@ F 3 "" H 8650 1400 50 0001 C CNN
$EndComp
Text Label 6150 3350 2 50 ~ 0
BMC_3V3
$Comp
L Device:R R99
U 1 1 60FFD411
P 5050 1700
F 0 "R99" H 5120 1746 50 0000 L CNN
F 1 "5.1" H 5120 1655 50 0000 L CNN
F 2 "Resistor_SMD:R_0603_1608Metric" V 4980 1700 50 0001 C CNN
F 3 "~" H 5050 1700 50 0001 C CNN
F 4 "Properties.Globals.TargetVoltage" H 5050 1700 50 0001 C CNN "Value_expr"
1 5050 1700
1 0 0 -1
$EndComp
$Sheet
S 9200 2700 950 600
U 60AD3F6A
F0 "compute_sbc" 50
F1 "compute_sbc.sch" 50
F2 "5.1V" I L 9200 2850 50
F3 "GND" U L 9200 3200 50
$EndSheet
$Sheet
S 7900 2750 800 200
U 60A9D2A2
F0 "ideal_diode" 50
F1 "ideal_diode.sch" 50
F2 "CATHODE" O R 8700 2850 50
F3 "ANODE" I L 7900 2850 50
$EndSheet
$Sheet
S 7250 3350 800 2050
U 60AC90CC
F0 "BMC" 50
F1 "BMC.sch" 50
F2 "PAC_CLK" O L 7250 3750 50
F3 "PAC_DATA" B L 7250 3850 50
F4 "PAC_INT" O L 7250 3950 50
F5 "DCDC_EN" O L 7250 4300 50
F6 "PAC_DAC" I L 7250 4050 50
F7 "USB_D-" I L 7250 4700 50
F8 "USB_D+" I L 7250 4600 50
F9 "USB_5V" I L 7250 4500 50
F10 "3V3" I L 7250 3450 50
$EndSheet
$Sheet
S 3850 2700 550 400
U 60A0E5A4
F0 "BD9E302EFJ_5V1" 50
F1 "BD9E302EFJ_5V1.sch" 50
F2 "VOUT" O R 4400 2850 50
F3 "VIN" I L 3850 2850 50
F4 "EN" I L 3850 3000 50
$EndSheet
$Sheet
S 3850 1600 500 150
U 60FF8D0D
F0 "Properties_hat_psu" 50
F1 "Properties.sch" 50
$EndSheet
$EndSCHEMATC
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 3 5
Sheet 3 9
Title "Compute unit HAT attachment"
Date "2021-06-13"
Rev "0.1.1"
Expand Down Expand Up @@ -49,7 +49,7 @@ F 0 "Q1" H 5840 4104 50 0000 L CNN
F 1 "BCM857BS" H 5840 4195 50 0000 L CNN
F 2 "Package_TO_SOT_SMD:SOT-363_SC-70-6" H 5850 4250 50 0001 C CNN
F 3 "https://www.diodes.com/assets/Datasheets/BCM857BS.pdf" H 5650 4150 50 0001 C CNN
2 5650 4150
1 5650 4150
1 0 0 1
$EndComp
$Comp
Expand Down
1 change: 1 addition & 0 deletions tools/kicad/kicad_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "2.33"
evalexpr = "6"
kicad_functions = { path = "../kicad_functions" }
kicad_parse_gen = { git = "https://github.com/racklet/kicad-parse-gen" }
Expand Down
22 changes: 19 additions & 3 deletions tools/kicad/kicad_rs/src/bin/evaluator.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
use clap::{App, Arg};
use kicad_rs::error::DynamicResult;
use kicad_rs::eval;
use kicad_rs::parser::SchematicTree;
use std::env;

// Get crate version information from Cargo
const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");

// Main function, can return different kinds of errors
fn main() -> DynamicResult<()> {
let args: Vec<String> = env::args().collect();
let path = std::path::Path::new(args.get(1).ok_or("expected file as first argument")?);
let matches = App::new("KiCad evaluator")
.about("Evaluates expressions in KiCad Eeschema schematics")
.author("Dennis Marttinen (@twelho), The Racklet Project")
.version(VERSION.unwrap_or("unknown"))
.version_short("v")
.arg(
Arg::with_name("SCHEMATIC")
.help("Path to the schematic file to process")
.required(true),
)
.get_matches();

// Calling .unwrap() is safe here because "SCHEMATIC" is required (if "SCHEMATIC"
// wasn't required we could have used an 'if let' to conditionally get the value)
let path = std::path::Path::new(matches.value_of("SCHEMATIC").unwrap());

// Load the hierarchical schematic tree and parse it
let mut tree = SchematicTree::load(path)?;
Expand Down
Loading