From 652e52ebd4c8aa7e2d903954bef0ae16f816057e Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Wed, 5 May 2021 15:40:45 +0200 Subject: [PATCH] euro-yesman-1u: add simple button/ led logic --- hardware/devices/euro-yesman-1u/.envrc | 1 + hardware/devices/euro-yesman-1u/README.md | 13 +- .../devices/euro-yesman-1u/board/README.md | 5 + .../euro-yesman-1u/board/yesman-board.sch | 32 +- .../euro-yesman-1u/board/yesman-board.sch-bak | 356 ++++++++++-------- hardware/devices/euro-yesman-1u/shell.nix | 2 +- hardware/devices/euro-yesman-1u/src/io.rs | 11 + hardware/devices/euro-yesman-1u/src/main.rs | 37 +- 8 files changed, 279 insertions(+), 178 deletions(-) create mode 100644 hardware/devices/euro-yesman-1u/.envrc create mode 100644 hardware/devices/euro-yesman-1u/src/io.rs diff --git a/hardware/devices/euro-yesman-1u/.envrc b/hardware/devices/euro-yesman-1u/.envrc new file mode 100644 index 00000000000..051d09d292a --- /dev/null +++ b/hardware/devices/euro-yesman-1u/.envrc @@ -0,0 +1 @@ +eval "$(lorri direnv)" diff --git a/hardware/devices/euro-yesman-1u/README.md b/hardware/devices/euro-yesman-1u/README.md index b49558b6ba3..8e8d20fc702 100644 --- a/hardware/devices/euro-yesman-1u/README.md +++ b/hardware/devices/euro-yesman-1u/README.md @@ -16,12 +16,23 @@ to have cargo setup for cross-compilation. If you're using nix you can use the provided shell file to load the required environment. -```console +```shell $ nix-shell ... $ cargo build --release ``` +To flash the firmware you should use the `openocd` project! For +development it's recommended you run `sudo openocd` (you can skip +`sudo` if your user has access to the USB peripherals in `/dev`), and +then run the binary with `cargo` + +```shell +$ cargo run --release +... gdb opens ... + + +``` ## The front panel diff --git a/hardware/devices/euro-yesman-1u/board/README.md b/hardware/devices/euro-yesman-1u/board/README.md index a44e607592f..fd728272688 100644 --- a/hardware/devices/euro-yesman-1u/board/README.md +++ b/hardware/devices/euro-yesman-1u/board/README.md @@ -3,3 +3,8 @@ ![](assets/wip1_layout.png) ![](assets/wip1_render.png) + + +## Notes + +- Check current limit on chip for LEDs diff --git a/hardware/devices/euro-yesman-1u/board/yesman-board.sch b/hardware/devices/euro-yesman-1u/board/yesman-board.sch index 17c6ae7d55b..bb19c046c70 100644 --- a/hardware/devices/euro-yesman-1u/board/yesman-board.sch +++ b/hardware/devices/euro-yesman-1u/board/yesman-board.sch @@ -1147,37 +1147,37 @@ Wire Wire Line Wire Wire Line 7700 3800 7600 3800 Text Label 7600 3100 2 50 ~ 0 -ST_1_LED +ST_1 Text Label 7600 3200 2 50 ~ 0 -ST_2_LED +ST_2 Text Label 7600 3300 2 50 ~ 0 -ST_3_LED +ST_3 Text Label 7600 3400 2 50 ~ 0 -ST_4_LED +ST_4 Text Label 7600 3500 2 50 ~ 0 -ST_5_LED +ST_5 Text Label 7600 3600 2 50 ~ 0 -ST_6_LED +ST_6 Text Label 7600 3700 2 50 ~ 0 -ST_7_LED +ST_7 Text Label 7600 3800 2 50 ~ 0 -ST_8_LED +ST_8 Text Label 10250 3900 0 50 ~ 0 -ST_16_LED +ST_8_LED Text Label 10250 3800 0 50 ~ 0 -ST_15_LED +ST_7_LED Text Label 10250 3700 0 50 ~ 0 -ST_14_LED +ST_6_LED Text Label 10250 3600 0 50 ~ 0 -ST_13_LED +ST_5_LED Text Label 10250 3500 0 50 ~ 0 -ST_12_LED +ST_4_LED Text Label 10250 3400 0 50 ~ 0 -ST_11_LED +ST_3_LED Text Label 10250 3300 0 50 ~ 0 -ST_10_LED +ST_2_LED Text Label 10250 3200 0 50 ~ 0 -ST_9_LED +ST_1_LED Text Label 9900 3100 0 50 ~ 0 Random Wire Wire Line diff --git a/hardware/devices/euro-yesman-1u/board/yesman-board.sch-bak b/hardware/devices/euro-yesman-1u/board/yesman-board.sch-bak index 8b1116f173d..17c6ae7d55b 100644 --- a/hardware/devices/euro-yesman-1u/board/yesman-board.sch-bak +++ b/hardware/devices/euro-yesman-1u/board/yesman-board.sch-bak @@ -922,276 +922,328 @@ F 3 "~" H 3250 1500 50 0001 C CNN 1 3250 1200 1 0 0 -1 $EndComp -Wire Wire Line - 8300 3100 8050 3100 -Wire Wire Line - 8300 3200 8050 3200 -Wire Wire Line - 8300 3300 8050 3300 -Wire Wire Line - 8300 3400 8050 3400 -Wire Wire Line - 8300 3500 8050 3500 -Wire Wire Line - 8300 3600 8050 3600 -Wire Wire Line - 8300 3700 8050 3700 $Comp L Device:R R17 U 1 1 606795C0 -P 7900 3100 -F 0 "R17" V 7900 3100 50 0000 C CNN -F 1 "R" V 7850 3250 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3100 50 0001 C CNN -F 3 "~" H 7900 3100 50 0001 C CNN - 1 7900 3100 +P 7850 3100 +F 0 "R17" V 7850 3100 50 0000 C CNN +F 1 "R" V 7800 3250 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3100 50 0001 C CNN +F 3 "~" H 7850 3100 50 0001 C CNN + 1 7850 3100 0 1 1 0 $EndComp $Comp L Device:R R18 U 1 1 6067987C -P 7900 3200 -F 0 "R18" V 7900 3200 50 0000 C CNN -F 1 "R" V 7850 3350 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3200 50 0001 C CNN -F 3 "~" H 7900 3200 50 0001 C CNN - 1 7900 3200 +P 7850 3200 +F 0 "R18" V 7850 3200 50 0000 C CNN +F 1 "R" V 7800 3350 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3200 50 0001 C CNN +F 3 "~" H 7850 3200 50 0001 C CNN + 1 7850 3200 0 1 1 0 $EndComp $Comp L Device:R R19 U 1 1 60679E90 -P 7900 3300 -F 0 "R19" V 7900 3300 50 0000 C CNN -F 1 "R" V 7850 3450 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3300 50 0001 C CNN -F 3 "~" H 7900 3300 50 0001 C CNN - 1 7900 3300 +P 7850 3300 +F 0 "R19" V 7850 3300 50 0000 C CNN +F 1 "R" V 7800 3450 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3300 50 0001 C CNN +F 3 "~" H 7850 3300 50 0001 C CNN + 1 7850 3300 0 1 1 0 $EndComp $Comp L Device:R R20 U 1 1 6067A04B -P 7900 3400 -F 0 "R20" V 7900 3400 50 0000 C CNN -F 1 "R" V 7850 3550 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3400 50 0001 C CNN -F 3 "~" H 7900 3400 50 0001 C CNN - 1 7900 3400 +P 7850 3400 +F 0 "R20" V 7850 3400 50 0000 C CNN +F 1 "R" V 7800 3550 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3400 50 0001 C CNN +F 3 "~" H 7850 3400 50 0001 C CNN + 1 7850 3400 0 1 1 0 $EndComp $Comp L Device:R R21 U 1 1 6067AC0D -P 7900 3500 -F 0 "R21" V 7900 3500 50 0000 C CNN -F 1 "R" V 7850 3650 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3500 50 0001 C CNN -F 3 "~" H 7900 3500 50 0001 C CNN - 1 7900 3500 +P 7850 3500 +F 0 "R21" V 7850 3500 50 0000 C CNN +F 1 "R" V 7800 3650 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3500 50 0001 C CNN +F 3 "~" H 7850 3500 50 0001 C CNN + 1 7850 3500 0 1 1 0 $EndComp $Comp L Device:R R22 U 1 1 6067ADF2 -P 7900 3600 -F 0 "R22" V 7900 3600 50 0000 C CNN -F 1 "R" V 7850 3750 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3600 50 0001 C CNN -F 3 "~" H 7900 3600 50 0001 C CNN - 1 7900 3600 +P 7850 3600 +F 0 "R22" V 7850 3600 50 0000 C CNN +F 1 "R" V 7800 3750 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3600 50 0001 C CNN +F 3 "~" H 7850 3600 50 0001 C CNN + 1 7850 3600 0 1 1 0 $EndComp $Comp L Device:R R23 U 1 1 6067AFD2 -P 7900 3700 -F 0 "R23" V 7900 3700 50 0000 C CNN -F 1 "R" V 7850 3850 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3700 50 0001 C CNN -F 3 "~" H 7900 3700 50 0001 C CNN - 1 7900 3700 +P 7850 3700 +F 0 "R23" V 7850 3700 50 0000 C CNN +F 1 "R" V 7800 3850 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3700 50 0001 C CNN +F 3 "~" H 7850 3700 50 0001 C CNN + 1 7850 3700 0 1 1 0 $EndComp $Comp L Device:R R24 U 1 1 6067B264 -P 7900 3800 -F 0 "R24" V 7900 3800 50 0000 C CNN -F 1 "R" V 7850 3950 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 7830 3800 50 0001 C CNN -F 3 "~" H 7900 3800 50 0001 C CNN - 1 7900 3800 +P 7850 3800 +F 0 "R24" V 7850 3800 50 0000 C CNN +F 1 "R" V 7800 3950 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 7780 3800 50 0001 C CNN +F 3 "~" H 7850 3800 50 0001 C CNN + 1 7850 3800 0 1 1 0 $EndComp Wire Wire Line - 8050 3800 8300 3800 -Wire Wire Line - 9850 3900 9600 3900 + 9850 3200 9600 3200 Wire Wire Line - 9850 4000 9600 4000 + 9850 3300 9600 3300 Wire Wire Line - 9850 4100 9600 4100 + 9850 3400 9600 3400 Wire Wire Line - 9850 4200 9600 4200 + 9850 3500 9600 3500 Wire Wire Line - 9850 4300 9600 4300 + 9850 3600 9600 3600 Wire Wire Line - 9850 4400 9600 4400 + 9850 3700 9600 3700 Wire Wire Line - 9850 4500 9600 4500 + 9850 3800 9600 3800 $Comp L Device:R R25 U 1 1 6068071A -P 10000 3900 -F 0 "R25" V 10000 3900 50 0000 C CNN -F 1 "R" V 9950 4050 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3900 50 0001 C CNN -F 3 "~" H 10000 3900 50 0001 C CNN - 1 10000 3900 +P 10000 3200 +F 0 "R25" V 10000 3200 50 0000 C CNN +F 1 "R" V 9950 3350 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3200 50 0001 C CNN +F 3 "~" H 10000 3200 50 0001 C CNN + 1 10000 3200 0 1 1 0 $EndComp $Comp L Device:R R26 U 1 1 60680724 -P 10000 4000 -F 0 "R26" V 10000 4000 50 0000 C CNN -F 1 "R" V 9950 4150 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4000 50 0001 C CNN -F 3 "~" H 10000 4000 50 0001 C CNN - 1 10000 4000 +P 10000 3300 +F 0 "R26" V 10000 3300 50 0000 C CNN +F 1 "R" V 9950 3450 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3300 50 0001 C CNN +F 3 "~" H 10000 3300 50 0001 C CNN + 1 10000 3300 0 1 1 0 $EndComp $Comp L Device:R R27 U 1 1 6068072E -P 10000 4100 -F 0 "R27" V 10000 4100 50 0000 C CNN -F 1 "R" V 9950 4250 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4100 50 0001 C CNN -F 3 "~" H 10000 4100 50 0001 C CNN - 1 10000 4100 +P 10000 3400 +F 0 "R27" V 10000 3400 50 0000 C CNN +F 1 "R" V 9950 3550 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3400 50 0001 C CNN +F 3 "~" H 10000 3400 50 0001 C CNN + 1 10000 3400 0 1 1 0 $EndComp $Comp L Device:R R28 U 1 1 60680738 -P 10000 4200 -F 0 "R28" V 10000 4200 50 0000 C CNN -F 1 "R" V 9950 4350 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4200 50 0001 C CNN -F 3 "~" H 10000 4200 50 0001 C CNN - 1 10000 4200 +P 10000 3500 +F 0 "R28" V 10000 3500 50 0000 C CNN +F 1 "R" V 9950 3650 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3500 50 0001 C CNN +F 3 "~" H 10000 3500 50 0001 C CNN + 1 10000 3500 0 1 1 0 $EndComp $Comp L Device:R R29 U 1 1 60680742 -P 10000 4300 -F 0 "R29" V 10000 4300 50 0000 C CNN -F 1 "R" V 9950 4450 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4300 50 0001 C CNN -F 3 "~" H 10000 4300 50 0001 C CNN - 1 10000 4300 +P 10000 3600 +F 0 "R29" V 10000 3600 50 0000 C CNN +F 1 "R" V 9950 3750 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3600 50 0001 C CNN +F 3 "~" H 10000 3600 50 0001 C CNN + 1 10000 3600 0 1 1 0 $EndComp $Comp L Device:R R30 U 1 1 6068074C -P 10000 4400 -F 0 "R30" V 10000 4400 50 0000 C CNN -F 1 "R" V 9950 4550 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4400 50 0001 C CNN -F 3 "~" H 10000 4400 50 0001 C CNN - 1 10000 4400 +P 10000 3700 +F 0 "R30" V 10000 3700 50 0000 C CNN +F 1 "R" V 9950 3850 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3700 50 0001 C CNN +F 3 "~" H 10000 3700 50 0001 C CNN + 1 10000 3700 0 1 1 0 $EndComp $Comp L Device:R R31 U 1 1 60680756 -P 10000 4500 -F 0 "R31" V 10000 4500 50 0000 C CNN -F 1 "R" V 9950 4650 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4500 50 0001 C CNN -F 3 "~" H 10000 4500 50 0001 C CNN - 1 10000 4500 +P 10000 3800 +F 0 "R31" V 10000 3800 50 0000 C CNN +F 1 "R" V 9950 3950 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3800 50 0001 C CNN +F 3 "~" H 10000 3800 50 0001 C CNN + 1 10000 3800 0 1 1 0 $EndComp $Comp L Device:R R32 U 1 1 60680760 -P 10000 4600 -F 0 "R32" V 10000 4600 50 0000 C CNN -F 1 "R" V 9950 4750 50 0000 C CNN -F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 4600 50 0001 C CNN -F 3 "~" H 10000 4600 50 0001 C CNN - 1 10000 4600 +P 10000 3900 +F 0 "R32" V 10000 3900 50 0000 C CNN +F 1 "R" V 9950 4050 50 0000 C CNN +F 2 "Resistor_SMD:R_0603_1608Metric" V 9930 3900 50 0001 C CNN +F 3 "~" H 10000 3900 50 0001 C CNN + 1 10000 3900 0 1 1 0 $EndComp Wire Wire Line - 9600 4600 9850 4600 + 9600 3900 9850 3900 Wire Wire Line - 10150 3900 10250 3900 + 10150 3200 10250 3200 Wire Wire Line - 10250 4000 10150 4000 + 10250 3300 10150 3300 Wire Wire Line - 10150 4100 10250 4100 + 10150 3400 10250 3400 Wire Wire Line - 10250 4200 10150 4200 + 10250 3500 10150 3500 Wire Wire Line - 10150 4300 10250 4300 + 10150 3600 10250 3600 Wire Wire Line - 10250 4400 10150 4400 + 10250 3700 10150 3700 Wire Wire Line - 10150 4500 10250 4500 + 10150 3800 10250 3800 Wire Wire Line - 10250 4600 10150 4600 + 10250 3900 10150 3900 Wire Wire Line - 7750 3100 7650 3100 + 7700 3100 7600 3100 Wire Wire Line - 7750 3200 7650 3200 + 7700 3200 7600 3200 Wire Wire Line - 7650 3300 7750 3300 + 7600 3300 7700 3300 Wire Wire Line - 7750 3400 7650 3400 + 7700 3400 7600 3400 Wire Wire Line - 7650 3500 7750 3500 + 7600 3500 7700 3500 Wire Wire Line - 7750 3600 7650 3600 + 7700 3600 7600 3600 Wire Wire Line - 7650 3700 7750 3700 + 7600 3700 7700 3700 Wire Wire Line - 7750 3800 7650 3800 -Text Label 7650 3100 2 50 ~ 0 + 7700 3800 7600 3800 +Text Label 7600 3100 2 50 ~ 0 ST_1_LED -Text Label 7650 3200 2 50 ~ 0 +Text Label 7600 3200 2 50 ~ 0 ST_2_LED -Text Label 7650 3300 2 50 ~ 0 +Text Label 7600 3300 2 50 ~ 0 ST_3_LED -Text Label 7650 3400 2 50 ~ 0 +Text Label 7600 3400 2 50 ~ 0 ST_4_LED -Text Label 7650 3500 2 50 ~ 0 +Text Label 7600 3500 2 50 ~ 0 ST_5_LED -Text Label 7650 3600 2 50 ~ 0 +Text Label 7600 3600 2 50 ~ 0 ST_6_LED -Text Label 7650 3700 2 50 ~ 0 +Text Label 7600 3700 2 50 ~ 0 ST_7_LED -Text Label 7650 3800 2 50 ~ 0 +Text Label 7600 3800 2 50 ~ 0 ST_8_LED -Text Label 10250 4600 0 50 ~ 0 +Text Label 10250 3900 0 50 ~ 0 ST_16_LED -Text Label 10250 4500 0 50 ~ 0 +Text Label 10250 3800 0 50 ~ 0 ST_15_LED -Text Label 10250 4400 0 50 ~ 0 +Text Label 10250 3700 0 50 ~ 0 ST_14_LED -Text Label 10250 4300 0 50 ~ 0 +Text Label 10250 3600 0 50 ~ 0 ST_13_LED -Text Label 10250 4200 0 50 ~ 0 +Text Label 10250 3500 0 50 ~ 0 ST_12_LED -Text Label 10250 4100 0 50 ~ 0 +Text Label 10250 3400 0 50 ~ 0 ST_11_LED -Text Label 10250 4000 0 50 ~ 0 +Text Label 10250 3300 0 50 ~ 0 ST_10_LED -Text Label 10250 3900 0 50 ~ 0 +Text Label 10250 3200 0 50 ~ 0 ST_9_LED +Text Label 9900 3100 0 50 ~ 0 +Random +Wire Wire Line + 9900 3100 9600 3100 +NoConn ~ 8300 2800 +NoConn ~ 8300 2900 +NoConn ~ 8300 2700 +NoConn ~ 8300 2400 +NoConn ~ 8300 2500 +$Comp +L power:GND #PWR? +U 1 1 6097F098 +P 7150 2200 +F 0 "#PWR?" H 7150 1950 50 0001 C CNN +F 1 "GND" V 7155 2072 50 0000 R CNN +F 2 "" H 7150 2200 50 0001 C CNN +F 3 "" H 7150 2200 50 0001 C CNN + 1 7150 2200 + 0 1 1 0 +$EndComp +$Comp +L Device:R R? +U 1 1 6097FA88 +P 7500 2200 +F 0 "R?" V 7293 2200 50 0000 C CNN +F 1 "320R" V 7500 2200 50 0000 C CNN +F 2 "" V 7430 2200 50 0001 C CNN +F 3 "~" H 7500 2200 50 0001 C CNN + 1 7500 2200 + 0 1 1 0 +$EndComp +Wire Wire Line + 8300 2200 7850 2200 +Wire Wire Line + 7350 2200 7150 2200 +$Comp +L Connector:TestPoint TP? +U 1 1 60998D6D +P 7850 2000 +F 0 "TP?" H 7700 2200 50 0000 L CNN +F 1 "TestPoint" H 7900 2200 50 0000 L CNN +F 2 "" H 8050 2000 50 0001 C CNN +F 3 "~" H 8050 2000 50 0001 C CNN + 1 7850 2000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 7850 2000 7850 2200 +Connection ~ 7850 2200 +Wire Wire Line + 7850 2200 7650 2200 +Wire Wire Line + 8300 3100 8000 3100 +Wire Wire Line + 8000 3200 8300 3200 +Wire Wire Line + 8300 3300 8000 3300 +Wire Wire Line + 8000 3400 8300 3400 +Wire Wire Line + 8300 3500 8000 3500 +Wire Wire Line + 8000 3600 8300 3600 +Wire Wire Line + 8300 3700 8000 3700 +Wire Wire Line + 8000 3800 8300 3800 +NoConn ~ 9900 3100 $EndSCHEMATC diff --git a/hardware/devices/euro-yesman-1u/shell.nix b/hardware/devices/euro-yesman-1u/shell.nix index b1f6d5ec93b..fcec4058c8f 100644 --- a/hardware/devices/euro-yesman-1u/shell.nix +++ b/hardware/devices/euro-yesman-1u/shell.nix @@ -6,7 +6,7 @@ stdenv.mkDerivation { # This shell file uses rustup to enable cross-compiling # TODO: this should be fixed at some point; get an arm-rustc, etc - rustup clangStdenv gcc-arm-embedded + rustup rust-analyzer clangStdenv gcc-arm-embedded cargo-flash cargo-binutils openocd ]; } diff --git a/hardware/devices/euro-yesman-1u/src/io.rs b/hardware/devices/euro-yesman-1u/src/io.rs new file mode 100644 index 00000000000..c04f679c267 --- /dev/null +++ b/hardware/devices/euro-yesman-1u/src/io.rs @@ -0,0 +1,11 @@ + +/// An I/O abstraction for yesman +/// +/// The main I/O of the yesman module is buttons as inputs that need +/// to be polled, and LEDs as outputs. All LED states are written at +/// the same time. An "active step" can be fed into the `Io` +/// abstraction from the `Sequencer` module. +pub struct Io { + + +} diff --git a/hardware/devices/euro-yesman-1u/src/main.rs b/hardware/devices/euro-yesman-1u/src/main.rs index 01e69e5716d..249457c7397 100644 --- a/hardware/devices/euro-yesman-1u/src/main.rs +++ b/hardware/devices/euro-yesman-1u/src/main.rs @@ -2,7 +2,7 @@ #![no_main] use cortex_m_rt::entry; -use embedded_hal::digital::v2::OutputPin; +use embedded_hal::digital::v2::{InputPin, OutputPin}; use stm32f1xx_hal::{delay::Delay, pac, prelude::*}; // Halt the MCU when panic @@ -20,10 +20,20 @@ fn main() -> ! { // Initialise GPIOC via the HAL let mut rcc = dp.RCC.constrain(); - let mut gpioc = dp.GPIOC.split(&mut rcc.apb2); + let mut gpioa = dp.GPIOA.split(&mut rcc.apb2); + let mut gpiob = dp.GPIOB.split(&mut rcc.apb2); - // Make it into an output - let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh); + // Create an LED output + let mut led1 = gpioa.pa1.into_push_pull_output(&mut gpioa.crl); + let mut led2 = gpioa.pa2.into_push_pull_output(&mut gpioa.crl); + let mut led3 = gpioa.pa3.into_push_pull_output(&mut gpioa.crl); + let mut led4 = gpioa.pa4.into_push_pull_output(&mut gpioa.crl); + + // Create a button input + let btn1 = gpiob.pb0.into_pull_down_input(&mut gpiob.crl); + let btn2 = gpiob.pb1.into_pull_down_input(&mut gpiob.crl); + let btn3 = gpiob.pb2.into_pull_down_input(&mut gpiob.crl); + let btn4 = gpiob.pb3.into_pull_down_input(&mut gpiob.crl); // Initialize the delay object with the MCU frequency let mut flash = dp.FLASH.constrain(); @@ -37,9 +47,20 @@ fn main() -> ! { // Now go blinkenlights loop { - led.set_high().ok(); - delay.delay_ms(1000_u16); - led.set_low().ok(); - delay.delay_ms(1000_u16); + set_led(&btn1, &mut led1); + set_led(&btn2, &mut led2); + set_led(&btn3, &mut led3); + set_led(&btn4, &mut led4); + + delay.delay_ms(5_u16); + } +} + + +fn set_led<'k, I: InputPin, O: OutputPin>(i: &'k I, o: &'k mut O) { + if let Ok(true) = i.is_high() { + o.set_low().ok(); + } else { + o.set_high().ok(); } }