Skip to content

Instantly share code, notes, and snippets.

View chmanie's full-sized avatar
🦦

Christian Maniewski chmanie

🦦
View GitHub Profile
@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);

Keybase proof

I hereby claim:

  • I am chmanie on github.
  • I am chmanie (https://keybase.io/chmanie) on keybase.
  • I have a public key ASAFB4NQ0BDlZuAIUVEAdEGpvKTb2iOKpmzPA6SNDkUc4Ao

To claim this, I am signing this object:

@chmanie
chmanie / connectall.rb
Created January 26, 2021 18:02
Connect all MIDI inputs to all MIDI outputs (except themselves). Supports multi-port devices
#!/usr/bin/ruby
t = `aconnect -i -l`
$devices = {}
$device = 0
t.lines.each do |l|
match = /client (\d*)\:((?:(?!client).)*)?/.match(l)
# we skip empty lines and the "Through" port
unless match.nil? || match[1] == '0' || /Through/=~l
$device = match[1]
  1. cd mutable-dev-environment
  2. vagrant up
  3. vagrant ssh
  4. cd /vagrant
  5. git clone https://github.com/forestcaver/parasites.git --recursive # Mind the --recursive!!! It will fail at the last step but we'll fix it
  6. cd parasites
  7. git clone https://github.com/mqtthiqs/stmlib.git
  8. cd stmlib && git checkout 8ab2aae
  9. Go into parasites folder and see if there is a folder labeled build, if not, then create one.
  10. Go inside build folder. Create another folder and label the new folder as warps_bootloader
Open On-Chip Debugger 0.9.0 (2020-04-13-15:29)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz