Skip to content

Instantly share code, notes, and snippets.

View chmanie's full-sized avatar
🦦

Christian Maniewski chmanie

🦦
View GitHub Profile
@chmanie
chmanie / acquire.asm
Created December 13, 2024 17:50
asm acquire/release
.section ".text.<embassy_rp::critical_section_impl::RpSpinlockCs as critical_section::Impl>::acquire","ax",%progbits
.p2align 1
.type <embassy_rp::critical_section_impl::RpSpinlockCs as critical_section::Impl>::acquire,%function
.code 16
.thumb_func
<embassy_rp::critical_section_impl::RpSpinlockCs as critical_section::Impl>::acquire:
.fnstart
.cfi_startproc
.save {r7, lr}
push {r7, lr}
@chmanie
chmanie / lock.rs
Last active December 8, 2024 19:36
Embassy task lock
#![no_std]
#![no_main]
use embassy_executor::{Executor, Spawner};
use embassy_futures::join::join;
use embassy_futures::join::join3;
use embassy_rp::block::ImageDef;
use embassy_rp::multicore::{spawn_core1, Stack};
use embassy_rp::peripherals::{PIN_12, PIN_13, PIN_14, PIN_15, USB};
use embassy_rp::usb;
@chmanie
chmanie / rp2350.diff
Last active December 8, 2024 14:16
Embassy RP2040 vs RP2350
diff --git a/.cargo/config.toml b/.cargo/config.toml
index a87e324..51c8973 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -1,8 +1,10 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
-runner = "probe-rs run --chip RP2040"
+#runner = "probe-rs run --chip RP2040"
+#runner = "elf2uf2-rs -d"
+runner = "picotool load -u -v -x -t elf"
@chmanie
chmanie / embassy-rp-async.rs
Created August 2, 2024 16:07
SPI transfer performance using rp-hal and embassy-rp (sync/async)
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_rp::{
gpio::{Level, Output},
spi::{self, Spi},
};
use {defmt_rtt as _, panic_probe as _};
@chmanie
chmanie / basic-dma.rs
Last active July 18, 2022 20:34
RP2040 Simple DMA Example
#![no_std]
#![no_main]
/**
* Basic RP2040 DMA example, just copying one value in memory to another place in memory using DMA
*/
use bsp::entry;
use cortex_m::singleton;
use defmt::*;
use defmt_rtt as _;
@chmanie
chmanie / adc-dma.rs
Last active July 17, 2022 13:57
RP2040 ADC over DMA Round-Robin in Rust
/**
* Configure DMA to copy ADC FIFO round-robin values into memory
*
* The strategy is as follows:
* - Have a static array which is the DMA target address, holding 3 u16 values
* - Enable DMA with a data-size of halfword (16bits), increase the write address after each transfer and wrap at 8 bytes
* - Start the ADC according to datasheet section 4.9.2.5 (round robin with FIFO enabled and DREQ threshold 1)
*
* The result will be an array with 16bit values of ADC results where the first bit indicates an error if set
*/
@chmanie
chmanie / rp-i2c.rs
Created February 25, 2022 10:39
Trying to get i2c to work
//! # I²C Example
//!
//! This application demonstrates how to talk to I²C devices with an RP2040.
//!
//! It may need to be adapted to your particular board layout and/or pin assignment.
//!
//! See the `Cargo.toml` file for Copyright and licence details.
#![no_std]
#![no_main]
@chmanie
chmanie / lib.rs
Created February 18, 2022 14:21
MAX11300 rust-embedded driver prototype
use core::cell::RefCell;
use embedded_hal::blocking::spi::{Transfer, Write};
use embedded_hal::digital::v2::OutputPin;
use heapless::Vec;
use seq_macro::seq;
/// Static device id
const DEVICE_ID: u16 = 0x0424;
/// Highest addressable register address
@chmanie
chmanie / drummie.lua
Created August 23, 2021 22:29
Just a little norns drum sequencer PoC using grid
lattice = require("lattice")
function createGridState()
local grid = {}
for i = 1, 16 do
grid[i] = {}
for j = 1, 8 do
grid[i][j] = 0
end
use std::convert::TryFrom;
use wmidi::MidiMessage;
fn create_midi_message(bytes: &[u8]) -> Option<MidiMessage> {
MidiMessage::try_from(bytes).ok()
}
fn main() {
let mut message_buffer: [u8; 1024] = [0; 1024];
let mut stream_parser = StreamParser::new(&mut message_buffer);