Skip to content

Commit

Permalink
Make clippy warnings errors (#53)
Browse files Browse the repository at this point in the history
* Make clippy warnings errors

* Fix examples and clippy warnings
  • Loading branch information
9names authored Jan 11, 2024
1 parent f1a1f23 commit a61b296
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ on: [push, pull_request]
name: Clippy check
jobs:
clippy_check:
runs-on: ubuntu-latest
name: Run Clippy
runs-on: ubuntu-20.04
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
target: riscv32imac-unknown-none-elf
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: cargo clippy --workspace --examples -- -Dwarnings
- run: cargo clippy --workspace --examples --all-features -- -Dwarnings
2 changes: 1 addition & 1 deletion examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![no_main]

use bl602_hal as hal;
use embedded_hal::delay::DelayUs;
use embedded_hal::delay::DelayNs;
use embedded_hal::digital::OutputPin;
use hal::{
clock::{Strict, SysclkFreq, UART_PLL_FREQ},
Expand Down
8 changes: 7 additions & 1 deletion examples/i2c_ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use embedded_graphics::{
text::{Baseline, Text},
Drawable,
};
use embedded_hal::delay::DelayNs;

use hal::{
clock::{Strict, SysclkFreq, UART_PLL_FREQ},
pac,
Expand Down Expand Up @@ -57,5 +59,9 @@ fn main() -> ! {

display.flush().unwrap();

loop {}
// Create a blocking delay function based on the current cpu frequency
let mut d = bl602_hal::delay::McycleDelay::new(clocks.sysclk().0);
loop {
d.delay_ms(1000);
}
}
2 changes: 1 addition & 1 deletion examples/led_timer_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use bl602_hal as hal;
use core::cell::RefCell;
use core::ops::DerefMut;
use critical_section::{self, Mutex};
use embedded_hal::digital::{OutputPin, ToggleableOutputPin};
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
use embedded_hal_zero::timer::CountDown;
use embedded_time::{duration::*, rate::*};
use hal::{
Expand Down
2 changes: 1 addition & 1 deletion examples/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use bl602_hal as hal;
use core::fmt::Write;
use embedded_hal::delay::DelayUs;
use embedded_hal::delay::DelayNs;
use hal::{
clock::{Strict, SysclkFreq, UART_PLL_FREQ},
pac,
Expand Down
6 changes: 3 additions & 3 deletions examples/watchdog_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use core::cell::RefCell;
use core::fmt::Write;
use core::ops::DerefMut;
use critical_section::{self, Mutex};
use embedded_hal::delay::DelayUs;
use embedded_hal::digital::{OutputPin, ToggleableOutputPin};
use embedded_hal::delay::DelayNs;
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
use embedded_hal_zero::watchdog::{Watchdog, WatchdogEnable};
use embedded_time::{duration::*, rate::*};
use hal::{
Expand Down Expand Up @@ -152,7 +152,7 @@ fn Watchdog(_: &mut TrapFrame) {
// Toggle the red led whenever the interrupt is triggered:
critical_section::with(|cs| {
if let Some(led_pin) = G_INTERRUPT_LED_PIN_R.borrow(cs).borrow_mut().deref_mut() {
led_pin.toggle();
led_pin.toggle().unwrap();
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl ConfiguredWatchdog0 {
impl embedded_hal_zero::watchdog::Watchdog for ConfiguredWatchdog0 {
/// This feeds the watchdog by resetting its counter value to 0.
/// WCR register is write-only, no need to preserve register contents
fn feed(&mut self) -> () {
fn feed(&mut self) {
let timer = unsafe { &*pac::TIMER::ptr() };
send_access_codes();
timer.wcr.write(|w| w.wcr().set_bit());
Expand Down

0 comments on commit a61b296

Please sign in to comment.