Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI #92

Merged
merged 8 commits into from
Dec 16, 2023
Merged

CI #92

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
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,32 @@ on:

name: Continuous integration

# Make sure CI fails on all warnings, including Clippy lints
env:
RUSTFLAGS: "-Dwarnings"

jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
feature:
device:
- stm32g431
- stm32g441
- stm32g471
- stm32g473
- stm32g474
- stm32g483
- stm32g484
#- stm32g491 # Does not seem ready yet
#- stm32g4a1 # Does not seem ready yet
features:
- log-rtt,defmt
# TODO: -log-rtt # log-rtt without defmt, more combos?
- log-itm
- log-semihost

steps:
- uses: actions/checkout@v2
Expand All @@ -29,4 +40,8 @@ jobs:
override: true

- name: Regular build
run: cargo check --features ${{ matrix.feature }}
run: cargo check --features ${{ matrix.device }} --features ${{ matrix.features }}
- name: Build examples
run: cargo check --examples --features ${{ matrix.device }} --features ${{ matrix.features }}
- name: Clippy
run: cargo clippy --examples --features ${{ matrix.device }} --features ${{ matrix.features }}
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --features=stm32g431 --target thumbv7em-none-eabihf
args: --features=stm32g484,log-rtt,defmt --target thumbv7em-none-eabihf
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ lto = true

[[example]]
name = "flash_with_rtic"
required-features = ["stm32g474"]
required-features = ["stm32g474"]
2 changes: 2 additions & 0 deletions examples/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ fn EXTI15_10() {

#[entry]
fn main() -> ! {
utils::logger::init();

let mut dp = stm32::Peripherals::take().expect("cannot take peripherals");
let mut rcc = dp.RCC.constrain();
let mut syscfg = dp.SYSCFG.constrain();
Expand Down
1 change: 1 addition & 0 deletions examples/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rt::entry;
#[cfg(not(feature = "stm32g474"))]
#[entry]
fn main() -> ! {
#[allow(clippy::empty_loop)]
loop {} // TODO: add support for more devices
}

Expand Down
1 change: 1 addition & 0 deletions examples/comp_w_dac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rt::entry;
#[cfg(not(feature = "stm32g474"))]
#[entry]
fn main() -> ! {
#[allow(clippy::empty_loop)]
loop {} // TODO: add support for more devices
}

Expand Down
2 changes: 2 additions & 0 deletions examples/flash_with_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ mod app {

#[init]
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
crate::utils::logger::init();

let dp = cx.device;
let cp = cx.core;

Expand Down
2 changes: 2 additions & 0 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use utils::logger::println;

#[entry]
fn main() -> ! {
utils::logger::init();

println!("Hello, STM32G4!");

#[allow(clippy::empty_loop)]
Expand Down
2 changes: 1 addition & 1 deletion examples/independent_watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use utils::logger::info;

#[entry]
fn main() -> ! {
//utils::logger::init();
utils::logger::init();
let dp = Peripherals::take().unwrap();

let mut watchdog = IndependentWatchdog::new(dp.IWDG);
Expand Down
2 changes: 2 additions & 0 deletions examples/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub fn exit() -> ! {

#[cortex_m_rt::entry]
fn main() -> ! {
utils::logger::init();

logger::info!("main");

panic!("Something bad");
Expand Down
36 changes: 25 additions & 11 deletions examples/utils/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@
cfg_if::cfg_if! {
if #[cfg(all(feature = "log-rtt", feature = "defmt"))] {
pub use defmt::{info, trace, warn, debug, error};
pub use defmt::println as println;

} else {
pub use log::{info, trace, warn, debug, error};

#[allow(unused_macros)]
macro_rules! println {
($($tt:tt)*) => {
$crate::cortex_m_semihosting::hprintln!($($tt,)*).unwrap();
};
}
}
}

cfg_if::cfg_if! {
if #[cfg(any(feature = "log-itm"))] {
if #[cfg(feature = "log-itm")] {
use panic_itm as _;

use lazy_static::lazy_static;
Expand All @@ -32,7 +25,7 @@ cfg_if::cfg_if! {
};

lazy_static! {
static ref LOGGER: Logger<ItmSync<InterruptFree>> = Logger {
pub static ref LOGGER: Logger<ItmSync<InterruptFree>> = Logger {
level: LevelFilter::Info,
inner: unsafe {
InterruptSync::new(
Expand All @@ -44,6 +37,16 @@ cfg_if::cfg_if! {
};
}

#[allow(unused_macros)]
macro_rules! println {
($($tt:tt)*) => {
log::info!($($tt,)*);
};
}

#[allow(unused_imports)]
pub(crate) use println;

#[allow(dead_code)]
pub fn init() {
cortex_m_log::log::init(&LOGGER).unwrap();
Expand All @@ -54,14 +57,15 @@ cfg_if::cfg_if! {
use defmt_rtt as _; // global logger
use panic_probe as _;
pub use defmt::Logger;
pub use defmt::println;

#[allow(dead_code)]
pub fn init() {}
}
else if #[cfg(all(feature = "log-rtt", not(feature = "defmt")))] {
// TODO
}
else if #[cfg(any(feature = "log-semihost"))] {
else if #[cfg(feature = "log-semihost")] {
use panic_semihosting as _;

use lazy_static::lazy_static;
Expand All @@ -80,6 +84,16 @@ cfg_if::cfg_if! {
};
}

#[allow(unused_macros)]
macro_rules! println {
($($tt:tt)*) => {
cortex_m_semihosting::hprintln!($($tt,)*).unwrap();
};
}

#[allow(unused_imports)]
pub(crate) use println;

#[allow(dead_code)]
pub fn init() {
cortex_m_log::log::init(&LOGGER).unwrap();
Expand Down
2 changes: 0 additions & 2 deletions src/fdcan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

/// Configuration of an FdCAN instance
pub mod config;
#[cfg(feature = "embedded-can-03")]
mod embedded_can;
/// Filtering of CAN Messages
pub mod filter;
/// Header and info of transmitted and receiving frames
Expand Down
12 changes: 10 additions & 2 deletions src/i2c.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
//! I2C
use hal::blocking::i2c::{Read, Write, WriteRead};

use crate::gpio::{gpioa::*, gpiob::*, gpioc::*, gpiof::*, gpiog::*};
use crate::gpio::{AlternateOD, AF2, AF3, AF4, AF8};
use crate::gpio::{gpioa::*, gpiob::*, gpioc::*, gpiof::*};
#[cfg(any(
feature = "stm32g471",
feature = "stm32g473",
feature = "stm32g474",
feature = "stm32g483",
feature = "stm32g484"
))]
use crate::gpio::{gpiog::*, AF3};
use crate::gpio::{AlternateOD, AF2, AF4, AF8};
use crate::rcc::{Enable, GetBusFreq, Rcc, RccBus, Reset};
#[cfg(any(
feature = "stm32g471",
Expand Down
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
feature = "stm32g474",
feature = "stm32g483",
feature = "stm32g484",
feature = "stm32g491",
feature = "stm32g4a1"
)))]

compile_error!(
Expand All @@ -18,7 +20,9 @@ compile_error!(
stm32g473
stm32g474
stm32g483
stm32g484"
stm32g484
stm32g491
stm32g4a1"
);

extern crate bare_metal;
Expand Down Expand Up @@ -57,6 +61,12 @@ pub use stm32g4::stm32g483 as stm32;
#[cfg(feature = "stm32g484")]
pub use stm32g4::stm32g484 as stm32;

#[cfg(feature = "stm32g491")]
pub use stm32g4::stm32g491 as stm32;

#[cfg(feature = "stm32g4a1")]
pub use stm32g4::stm32g4a1 as stm32;

#[cfg(feature = "rt")]
pub use crate::stm32::interrupt;

Expand Down
8 changes: 8 additions & 0 deletions src/rcc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ impl AHB1 {
fn rstr(rcc: &RccRB) -> &rcc::AHB1RSTR {
&rcc.ahb1rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::AHB1SMENR {
&rcc.ahb1smenr
Expand All @@ -346,6 +347,7 @@ impl AHB2 {
fn rstr(rcc: &RccRB) -> &rcc::AHB2RSTR {
&rcc.ahb2rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::AHB2SMENR {
&rcc.ahb2smenr
Expand All @@ -356,14 +358,17 @@ pub struct AHB3 {
_0: (),
}
impl AHB3 {
#[allow(unused)]
#[inline(always)]
fn enr(rcc: &RccRB) -> &rcc::AHB3ENR {
&rcc.ahb3enr
}
#[allow(unused)]
#[inline(always)]
fn rstr(rcc: &RccRB) -> &rcc::AHB3RSTR {
&rcc.ahb3rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::AHB3SMENR {
&rcc.ahb3smenr
Expand All @@ -382,6 +387,7 @@ impl APB1_1 {
fn rstr(rcc: &RccRB) -> &rcc::APB1RSTR1 {
&rcc.apb1rstr1
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::APB1SMENR1 {
&rcc.apb1smenr1
Expand All @@ -400,6 +406,7 @@ impl APB1_2 {
fn rstr(rcc: &RccRB) -> &rcc::APB1RSTR2 {
&rcc.apb1rstr2
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::APB1SMENR2 {
&rcc.apb1smenr2
Expand All @@ -418,6 +425,7 @@ impl APB2 {
fn rstr(rcc: &RccRB) -> &rcc::APB2RSTR {
&rcc.apb2rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::APB2SMENR {
&rcc.apb2smenr
Expand Down
Loading