Skip to content

Instantly share code, notes, and snippets.

View kalkyl's full-sized avatar

Henrik Alsér kalkyl

View GitHub Profile
@kalkyl
kalkyl / interrupt.rs
Last active May 8, 2024 12:45
Raw interrupt handler example
#![no_std]
#![no_main]
use core::cell::{Cell, RefCell};
use defmt::*;
use embassy_executor::Spawner;
use embassy_rp::{gpio::Pull, peripherals::PWM_SLICE4};
use embassy_rp::adc::{self, Adc, Blocking};
use embassy_rp::interrupt;
@kalkyl
kalkyl / drop.rs
Last active April 15, 2024 08:54
OnDrop handling
#![no_std]
#![no_main]
use core::mem::{self, MaybeUninit};
use defmt::*;
use embassy_executor::Spawner;
use embassy_futures::join::join;
use embassy_futures::select::{select, Either};
use embassy_rp::gpio::{AnyPin, Input, Level, Output, Pull};
@kalkyl
kalkyl / animation.rs
Last active July 13, 2024 18:33
Cancellation of running async fn
#![no_std]
#![no_main]
use embassy_executor::Spawner;
use embassy_futures::join::join;
use embassy_futures::select::{select, Either};
use embassy_rp::gpio::{AnyPin, Input, Level, Output, Pull};
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::signal::Signal;
use embassy_time::Timer;
@kalkyl
kalkyl / pio_stepper.rs
Last active October 30, 2023 19:15
Stepper motor driver using PIO (rp2040)
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use core::mem::{self, MaybeUninit};
use defmt::info;
use embassy_executor::Spawner;
use embassy_rp::bind_interrupts;
use embassy_rp::peripherals::PIO0;
use embassy_rp::pio::{Common, Config, Direction, Instance, InterruptHandler, Irq, Pio, PioPin, StateMachine};
@kalkyl
kalkyl / shared-bus-async.rs
Created April 25, 2022 22:59
Async shared spi
use core::{fmt::Debug, future::Future};
use embassy::blocking_mutex::raw::RawMutex;
use embassy::mutex::Mutex;
use embedded_hal::digital::blocking::OutputPin;
pub use embedded_hal::spi::{
blocking, Error, ErrorKind, ErrorType, Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3,
};
use embedded_hal_async::spi;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]