Skip to content

Instantly share code, notes, and snippets.

@rxseger
rxseger / read-eeprom16.py
Created August 26, 2016 06:52
read 16-bit EEPROMs over I2C
#!/usr/bin/python
# read 16-bit EEPROMs over I2C. tested with 24FC512 and 24LC515
import sys
import smbus
bus = smbus.SMBus(1) # /dev/i2c-1
if len(sys.argv) < 3:
sys.stderr.write("usage: %s device_address size > filename\n" % (sys.argv[0],))
raise SystemExit
@rxseger
rxseger / write-eeprom16.py
Created August 26, 2016 06:55
write 16-bit EEPROMs over I2C
#!/usr/bin/python
# write 16-bit EEPROMs over I2C
import sys
import smbus
import time
bus = smbus.SMBus(1)
if len(sys.argv) < 2:
sys.stderr.write("usage: %s device-address\n" % (sys.argv[0],))
@rxseger
rxseger / gist:251bffd789a6414a6b1f3c9e3b1ccf64
Last active August 28, 2016 22:14
Samsung DVD-M101 DVD Player MIC4 2K EEPROM I2C dump using Bus Pirate
00000000 ?? 88 56 82 8c 6f 58 50 80 50 82 22 5d a0 b0 c2 |..V..oXP.P."]...|
00000010 20 86 c0 9a 82 94 79 6a 50 80 70 71 36 54 a0 b0 | .....yjP.pq6T..|
00000020 c2 20 82 92 58 88 96 6f 00 a0 80 70 81 02 4b a0 |. ..X..o...p..K.|
00000030 b0 c5 20 60 89 cb 80 70 60 00 a0 80 80 82 03 03 |.. `...p`.......|
00000040 a0 a8 cd 2c 84 f6 0c 20 61 c8 0c 20 61 c8 08 20 |...,... a.. a.. |
00000050 60 08 40 f4 40 43 40 f4 40 43 40 f4 42 41 ff ff |`.@.@C@.@[email protected]..|
00000060 00 11 00 7b 7b 7b 00 ff ff ff ff 7b 7b 7b 7b 00 |...{{{.....{{{{.|
00000070 ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00 7b |...............{|
00000080 00 02 00 02 00 02 00 01 04 00 00 00 00 00 00 00 |................|
00000090 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 |................|
@rxseger
rxseger / parallel-eprom-dump.py
Last active August 29, 2016 03:53
parallel memory dumping using Raspberry Pi GPIO, for AT27C080 8Mbit CMOS EPROM
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
# Data and address pins
# MSB first
@rxseger
rxseger / gptray.py
Last active August 31, 2016 05:29
CD/DVD ROM tray open/closed switch GPIO script for Raspberry Pi
#!/usr/bin/python
# turn on yellow LED when CD/DVD tray fully open, blue LED when fully closed
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
OPSW = 22 # G25
@rxseger
rxseger / gpeject.py
Created August 31, 2016 05:29
eject CD/DVD tray using GPIO
#!/usr/bin/python
# eject CD/DVD tray using GPIO to turn on motor until switch closes
import RPi.GPIO as GPIO
import signal
import sys
import time
GPIO.setmode(GPIO.BOARD)
@rxseger
rxseger / hbridge1.py
Created September 5, 2016 20:50
control 4-input H-Bridge via Raspberry Pi GPIO
#!/usr/bin/python
import RPi.GPIO as GPIO
import sys
GPIO.setmode(GPIO.BOARD)
K1 = 38 # G20
K2 = 7 # G4
K3 = 36 # G16
@rxseger
rxseger / hbridge2.py
Created September 6, 2016 01:26
control 2-input H-Bridge with control and disable bit (K1=K4=C, K2=K3=not (C or D))
#!/usr/bin/python
import RPi.GPIO as GPIO
import sys
GPIO.setmode(GPIO.BOARD)
C = 38 # G20
D = 40 # G21
@rxseger
rxseger / netbus.py
Last active September 7, 2016 06:07
open/close CD/DVD tray from Raspberry Pi GPIO via H-Bridge
#!/usr/bin/python
# open/close CD/DVD tray from Raspberry Pi GPIO via H-Bridge
import RPi.GPIO as GPIO
import time
import sys
import signal
GPIO.setmode(GPIO.BOARD)
@rxseger
rxseger / SPI_MCP3304.py
Created September 15, 2016 06:20
read 8-channel ADC (MCP3304 chip) via SPI on Raspberry Pi
#!/usr/bin/python
# -*- coding: utf-8 -*-
# SPI_MCP3304.py: read 8-channel ADC, based on http://www.havnemark.dk/?p=54
# mcp3008_lm35.py - read an LM35 on CH0 of an MCP3008 on a Raspberry Pi
# mostly nicked from
# http://jeremyblythe.blogspot.ca/2012/09/raspberry-pi-hardware- spi-analog-inp$
# Changed to work w. MCP3308 by Kim H. Rasmussen, June 2013
import spidev
import time