Skip to content

Instantly share code, notes, and snippets.

@kevinmehall
kevinmehall / rust-cross-libs.sh
Last active November 3, 2023 13:23
Cross-compile Rust standard library for Tessel without full bootstrap build [A work in progress]
#!/bin/bash
# THIS IS A GIANT HACK
# if you think this would be a good idea if it weren't so terrible, go read https://github.com/rust-lang/rfcs/pull/1133
set -e
# Parse args
for i in "$@"
do
@kevinmehall
kevinmehall / Readme.md
Created March 12, 2018 07:17
Loading 3DEP elevation data in C++ with GDAL
@kevinmehall
kevinmehall / gist:1335347
Created November 2, 2011 23:57
PWM on Xmega
#include "usb.h"
// PORT C
#define PWM1 (1<<0)
#define PWM2 (1<<1)
int main(void){
sei();
@kevinmehall
kevinmehall / gist:1223301
Created September 16, 2011 22:22
USB Arduino demo
#include <UsbSimple.h>
void setup(){
USB.begin();
}
void loop(){
USB.refresh();
USB.set(0, analogRead(5));
@kevinmehall
kevinmehall / gist:1223343
Created September 16, 2011 22:45
Buttons / LEDs
void setup(){
pinMode(6,INPUT); // Button
digitalWrite(6, HIGH); // Enable pull-up on pin 6
pinMode(8,OUTPUT); // LED
}
int counter = 0;
int state = 0;
void loop(){
int button = digitalRead(6);
@kevinmehall
kevinmehall / gist:1338529
Created November 4, 2011 02:30
Quadrature Encoder with the Xmega event system
#include "usb.h"
// PORT C
#define QDEC1 (1<<2)
#define QDEC2 (1<<3)
int main(void){
sei();
@kevinmehall
kevinmehall / packetbuf.c
Created May 11, 2012 22:11
FIFO ring buffer for USB packets on xmega
// Bufferred BULK streaming
// http://nonolithlabs.com
// (C) 2011 Kevin Mehall (Nonolith Labs) <km@kevinmehall.net>
//
// Licensed under the terms of the GNU GPLv3+
#include "packetbuffer.h"
// CEE to PC buffer
Ringbuf in_ring;
@kevinmehall
kevinmehall / instructions.md
Created October 20, 2012 23:42
Compiling the Atmel-patched AVR toolchain
@kevinmehall
kevinmehall / README.md
Created April 25, 2014 16:29
USB Power Monitoring with CEE

Connect CEE chA to the 5V output pin of the USB breakout. GND, D+ and D- are passed through by the breakout by default.

pinout

Use ConnectClientPython and the following script:

@kevinmehall
kevinmehall / build-libs.sh
Created May 29, 2015 19:14
Rust OpenWrt cross compile (full bootstrap)
#!/bin/bash
set -e -u
# Run this in a rust-lang/rust checkout with the above patch applied
git fetch
git checkout $1
mkdir -p build-cross
cd build-cross