Skip to content

Commit a3a9c1e

Browse files
author
Johannes Cornelis Draaijer
committed
Add environment variable for PPS output, and update CI
1 parent af97ae7 commit a3a9c1e

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ jobs:
132132
features: ""
133133
- example: rtic-echo
134134
features: smoltcp-phy
135+
- example: rtic-timestamp
136+
features: ""
135137
mcu:
136138
- stm32f107
137139
- stm32f429
@@ -143,19 +145,23 @@ jobs:
143145
pins:
144146
- nucleo
145147
- default
148+
pps:
149+
- default
150+
- alternate
151+
146152
steps:
147153
- name: Checkout
148154
uses: actions/checkout@v3
149155

150-
- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) and pins ${{ matrix.pins }}
156+
- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
151157
run: |
152158
rustup set profile minimal
153159
rustup override set ${{ matrix.toolchain }}
154160
rustup target add ${{ matrix.target }}
155161
156-
- name: Build example ${{ matrix.example.example }} for ${{ matrix.mcu }}
162+
- name: Build example ${{ matrix.example.example }} for ${{ matrix.mcu }}, eth pins ${{ matrix.pins }}, pps pin ${{ matrix.pps }}
157163
run: |
158-
STM32_ETH_EXAMPLE_PINS=${{ matrix.pins }} cargo build --release --target=${{ matrix.target }} --example ${{ matrix.example.example}} --features ${{ matrix.mcu }},${{ matrix.example.features }}
164+
STM32_ETH_EXAMPLE_PPS=${{ matrix.pps }} STM32_ETH_EXAMPLE_PINS=${{ matrix.pins }} cargo build --release --target=${{ matrix.target }} --example ${{ matrix.example.example}} --features ${{ matrix.mcu }},${{ matrix.example.features }}
159165
160166
# Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149
161167
#

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ The examples should run and compile on any MCU that has an 802.3 compatible PHY
9898

9999
The examples use `defmt` and `defmt_rtt` for logging, and `panic_probe` over `defmt_rtt` for printing panic backtraces.
100100

101-
##### Alternative pin configuration & HSE
101+
##### Alternative pin configuration, HSE & PPS
102102

103103
If the board you're developing for has a High Speed External oscillator connected to the correct pins, the HSE configuration can be activated by setting the `STM32_ETH_EXAMPLE_HSE` environment variable to one of `oscillator` or `bypass` when compiling.
104104

105105
If the board you're developing for uses the nucleo pinout (PG11 and PG13 instead of PB11 and PB12), the pin configuration can be changed by setting the `STM32_ETH_EXAMPLE_PINS` environment variable to `nucleo` when compiling.
106106

107+
If you wish to use the alternative PPS output pin (PG8 instead of PB5) for the `rtic-timestamp` example, the pin configuration can be changed by setting the `STM32_ETH_EXAMPLE_PPS_PIN` environment variable to `alternate` when compiling.
108+
107109
### Building examples
108110
To build an example, run the following command:
109111
```bash

build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ fn main() {
2424
}
2525
}
2626

27+
let pps_pin = std::env::var("STM32_ETH_EXAMPLE_PPS_PIN");
28+
29+
if let Ok(pps_pin) = pps_pin {
30+
if pps_pin == "alternate" {
31+
println!("cargo:rustc-cfg=pps=\"alternate\"")
32+
} else if pps_pin != "default" {
33+
panic!("Invalid STM32_ETH_EXAMPLE_PPS_PIN value. Allowed values: alternate, default");
34+
}
35+
}
36+
37+
println!("cargo:rerun-if-env-changed=STM32_ETH_EXAMPLE_PPS_PIN");
2738
println!("cargo:rerun-if-env-changed=STM32_ETH_EXAMPLE_HSE");
2839
println!("cargo:rerun-if-env-changed=STM32_ETH_EXAMPLE_PINS");
2940
}

0 commit comments

Comments
 (0)