Skip to content

Commit

Permalink
Merge pull request #467 from stm32-rs/merge-queue
Browse files Browse the repository at this point in the history
merge queue
  • Loading branch information
therealprof authored Jul 28, 2023
2 parents 49aefa1 + 318f25f commit 773836d
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 40 deletions.
11 changes: 0 additions & 11 deletions .github/bors.toml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
pull_request_target:

name: Changelog check

jobs:
changelog:
name: Changelog check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Changelog updated
uses: Zomzog/[email protected]
with:
fileName: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
on:
push:
branches: [ staging, trying, master ]
branches: master
pull_request:
merge_group:

name: Continuous integration

jobs:
ci:
name: CI
runs-on: ubuntu-latest
needs: [check]
if: always()
steps:
- name: Done
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

check:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -33,7 +43,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: check
args: --features=${{ matrix.mcu }},rt --examples
args: --features=${{ matrix.mcu }},rtic,high --examples

- uses: actions-rs/cargo@v1
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
on: [push, pull_request]
on:
push:
branches: master
pull_request:

name: Clippy check
jobs:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
on: [push, pull_request]
on:
push:
branches: master
pull_request:
merge_group:

name: Code formatting check

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Move from bors/manual merge to GH merge queue
- Add tools/check.py python script for local check
- Add changelog check on PRs

## [v0.10.0] - 2022-12-12

- `Timer`: adds `get_interrupt` to `Timer`
Expand Down
23 changes: 12 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ unwrap-infallible = "0.1.5"
[features]
device-selected = []
doc = []
rt = ["stm32f1/rt"]
# deprecated feature
rt = []
stm32f100 = ["stm32f1/stm32f100", "device-selected"]
stm32f101 = ["stm32f1/stm32f101", "device-selected"]
stm32f103 = ["stm32f1/stm32f103", "device-selected", "has-can", "stm32-usbd"]
Expand All @@ -68,7 +69,7 @@ connectivity = ["medium", "has-can"]
# Devices with CAN interface
has-can = []

rtic = ["rt", "rtic-monotonic"]
rtic = ["rtic-monotonic"]

[profile.dev]
incremental = false
Expand All @@ -81,35 +82,35 @@ lto = true

[[example]]
name = "usb_serial"
required-features = ["rt", "stm32-usbd"]
required-features = ["stm32-usbd"]

[[example]]
name = "usb_serial_interrupt"
required-features = ["rt", "stm32-usbd"]
required-features = ["stm32-usbd"]

[[example]]
name = "usb_serial_rtic"
required-features = ["rt", "stm32-usbd"]
required-features = ["stm32-usbd"]

[[example]]
name = "blinky_timer_irq"
required-features = ["rt"]
required-features = []

[[example]]
name = "blinky_rtcalarm_irq"
required-features = ["rt"]
required-features = []

[[example]]
name = "qei"
required-features = ["medium"]

[[example]]
name = "timer-interrupt-rtic"
required-features = ["rt", "medium"]
required-features = ["stm32f103", "medium"]

[[example]]
name = "exti"
required-features = ["rt"]
required-features = []

[[example]]
name = "can-echo"
Expand All @@ -121,12 +122,12 @@ required-features = ["has-can"]

[[example]]
name = "can-rtic"
required-features = ["has-can", "rt"]
required-features = ["has-can"]

[[example]]
name = "gpio_input"
required-features = ["stm32f103"]

[[example]]
name = "serial-interrupt-idle"
required-features = ["stm32f103", "rt", "medium"]
required-features = ["stm32f103", "medium"]
12 changes: 3 additions & 9 deletions examples/serial-interrupt-idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use stm32f1xx_hal::{
pac::interrupt,
pac::USART1,
prelude::*,
serial::{Config, Rx, Serial, Tx},
serial::{Rx, Serial, Tx},
};

static mut RX: Option<Rx<USART1>> = None;
Expand Down Expand Up @@ -44,14 +44,8 @@ fn main() -> ! {

// Set up the usart device. Takes ownership over the USART register and tx/rx pins. The rest of
// the registers are used to enable and configure the device.
let (mut tx, mut rx) = Serial::usart1(
p.USART1,
(tx, rx),
&mut afio.mapr,
Config::default().baudrate(115200.bps()),
clocks,
)
.split();
let (mut tx, mut rx) =
Serial::new(p.USART1, (tx, rx), &mut afio.mapr, 115200.bps(), &clocks).split();
tx.listen();
rx.listen();
rx.listen_idle();
Expand Down
6 changes: 3 additions & 3 deletions src/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a> FlashWriter<'a> {
}

fn valid_length(&self, offset: u32, length: usize) -> Result<()> {
if offset + length as u32 > self.flash_sz.kbytes() as u32 {
if offset + length as u32 > self.flash_sz.kbytes() {
Err(Error::LengthTooLong)
} else if length & 0x1 != 0 {
Err(Error::LengthNotMultiple2)
Expand Down Expand Up @@ -178,7 +178,7 @@ impl<'a> FlashWriter<'a> {
let size = self.sector_sz.kbytes() as u32;
let start = start_offset & !(size - 1);
for idx in (start..start + size).step_by(2) {
let write_address = (FLASH_START + idx as u32) as *const u16;
let write_address = (FLASH_START + idx) as *const u16;
let verify: u16 = unsafe { core::ptr::read_volatile(write_address) };
if verify != 0xFFFF {
return Err(Error::VerifyError);
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<'a> FlashWriter<'a> {
pub fn read(&self, offset: u32, length: usize) -> Result<&[u8]> {
self.valid_address(offset)?;

if offset + length as u32 > self.flash_sz.kbytes() as u32 {
if offset + length as u32 > self.flash_sz.kbytes() {
return Err(Error::LengthTooLong);
}

Expand Down
3 changes: 3 additions & 0 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ pub trait GpioExt {
fn split(self) -> Self::Parts;

/// Splits the GPIO block into independent pins and registers without resetting its state.
///
/// # Safety
/// Make sure that all pins modes are set in reset state.
unsafe fn split_without_reset(self) -> Self::Parts;
}

Expand Down
3 changes: 1 addition & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ use crate::time::Hertz;
pub mod monotonic;
#[cfg(feature = "rtic")]
pub use monotonic::*;
pub mod pwm_input;
pub use pwm_input::*;
pub(crate) mod pins;
pub mod pwm_input;
pub use pins::*;
pub mod delay;
pub use delay::*;
Expand Down
50 changes: 50 additions & 0 deletions tools/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /usr/bin/env python3

import json
import subprocess
import sys


def run_inner(args):
print("Running `{}`...".format(" ".join(args)))
ret = subprocess.call(args) == 0
print("")
return ret


def run(mcu, cargo_cmd):
if mcu == "":
return run_inner(cargo_cmd)
else:
return run_inner(cargo_cmd + ["--features={}".format(mcu)])


def main():
cargo_meta = json.loads(
subprocess.check_output("cargo metadata --no-deps --format-version=1",
shell=True,
universal_newlines=True)
)

crate_info = cargo_meta["packages"][0]

features = ["{},rtic,high".format(x)
for x in crate_info["features"].keys()
if x.startswith("stm32f1")]

if 'size_check' in sys.argv:
cargo_cmd = ['cargo', 'build', '--release']
else:
cargo_cmd = ['cargo', 'check']

if '--examples' in sys.argv:
cargo_cmd += ['--examples']

if not all(map(lambda f: run(f, cargo_cmd),
features)):
sys.exit(-1)


if __name__ == "__main__":
main()

0 comments on commit 773836d

Please sign in to comment.