Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
@stecman
stecman / avr_eprom_dump_over_serial.c
Last active July 19, 2018 08:35
Dump EPROM over serial with AVR
/**
* Thrown together program to dump 512 kbit EPROMs from an AVR ATMega64A/128A
* More specifically, a bunch of ST M27C512 from the early 90's
*
* Connections:
*
* Port A 0-7: low address byte (output)
* Port B 0-7: high address byte (output)
* Port D 0-7: data (input)
*
@stecman
stecman / GridFieldStreamExportButton.php
Created April 5, 2016 05:20
Streamed CSV export for SilverStripe GridField
<?php
/**
* Improved GridFieldExportButton that streams CSV data to the client instead of building
* the entire CSV in memory and sending that (which doesn't work for large data sets).
*/
class GridFieldStreamExportButton extends GridFieldExportButton
{
/**
@stecman
stecman / TimerModule.h
Created August 22, 2016 22:45
React Native get relative time
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@interface TimerModule : NSObject <RCTBridgeModule>
@end
@stecman
stecman / README.md
Last active May 13, 2019 01:03
Python interface to control https://github.com/stecman/avr-usb-status-light over USB

Requirements

Install https://pypi.python.org/pypi/libusb1

Allowing control without root privileges

# Create rule so the device can be controlled by any user
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="f055", ATTR{idProduct}=="05df", MODE="0666"' \
 | tee /etc/udev/rules.d/99-status-light.rules
@stecman
stecman / Makefile
Last active June 5, 2019 04:25
AVR basics
DEVICE = atmega328p
CLOCK = 16000000
PROGRAMMER = -c arduino -P /dev/ttyUSB0 -b57600
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
SOURCES = $(shell find . -name '*.c')
OBJECTS = $(SOURCES:.c=.o)
# Automatic dependency resolution
@stecman
stecman / index.htm
Last active August 9, 2019 17:02
CSS3 playing cards with flexbox
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cards</title>
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
@stecman
stecman / silverstripe-remove-empty-tabs.php
Last active August 13, 2019 22:45
Remove empty tabs in the SilverStripe CMS
/**
* Recurse through tabs and remove any with no child fields
*
* The way SilverStripe's field scaffolding works can leave empty tabs around after
* fields are moved or removed by the slices module.
*
* @param FieldList $fields
* @return FieldList
*/
protected function removeEmptyTabs(FieldList $fields)
@stecman
stecman / _NMEA GPS datetime for AVR.md
Last active October 16, 2019 23:29
NMEA GPRMC sentence parsing for low memory microcontrollers: read GPS date and time from UART

Date/time from GPS without storing NMEA string

This is a first pass at reading the date and time from a serial GPS device on a tiny microcontroller. The target device is an ATTiny13A with only 64 bytes of RAM, which isn't enough to store the full 79 characters of a NMEA sentence, so something like minmea wouldn't work (their API passes around full sentence strings).

When compiled with avr-gcc -Os, this is around 500 bytes of program space. The size can be reduced by 100 bytes if the handling of checksums is removed.

@stecman
stecman / Makefile
Last active February 18, 2020 13:03
ATTiny13A Button Pusher - Remember how many times a button was pushed and push it electronically on startup
DEVICE = attiny13a
CLOCK = 1200000
PROGRAMMER = -c dragon_isp
SOURCES = $(shell find . -name '*.c' -or -name '*.cpp' -or -name '*.S')
OBJECTS = $(SOURCES:.c=.o)
AVRDUDE = avrdude $(PROGRAMMER) -p t13
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
COMPILE += -I -I. -I./lib/
COMPILE += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
@stecman
stecman / _stm32f070-libopencm3-usb-clock.md
Last active February 23, 2020 22:21
OpenCM3 USB clock configuration

USB with libopenCM3 on the STM32F070F6

This specific part doesn't work out of the box with the OpenCM3 STM32 F0 USB example/testcase for two reasons:

  • The USB pins (PA11/PA12) are hidden behind a mux on pins PA9/PA10 and need to be switched in. This physically connects the USB peripheral to the pins.
  • The STM32F070 must use an external oscillator to drive the 48MHz USB clock. My design used a 12MHz HSE, which libopencm3 didn't have a built-in clock configuration function for.