Skip to content

Instantly share code, notes, and snippets.

Ken Shirriff shirriff

Block or report user

Report or block shirriff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View analyze-IR-signal.py
#!/usr/bin/python
""" Download an IR remote signal from a Rigol DS1052E and
analyze it for a NEC protocol signal.
Ken Shirriff
http://righto.com
"""
import array
import sys
View PRU-GPIO-EXAMPLE-00A0.dts
// This DTS overlay sets up one input and one output pin for use by
// PRU0 via its Enhanced GPIO mode, which will let us access those pins
// by writing to R30 bit 15 or reading from R31 bit 14.
// Save this file wherever you want (but I recommend /lib/firmware), as
// "PRU-GPIO-EXAMPLE-00A0.dts".
// Compile with:
// dtc -O dtb -I dts -o /lib/firmware/PRU-GPIO-EXAMPLE-00A0.dtbo -b 0 -@ PRU-GPIO-EXAMPLE-00A0.dts
@shirriff
shirriff / blink.p
Last active May 15, 2019
Assembly code to demonstrate the PRU on the BeagleBone Black. This code blinks an LED 10 times.
View blink.p
@shirriff
shirriff / loader.c
Created Aug 23, 2016
Loads a PRU text.bin (and optionally data.bin) file, executes it, and waits for completion.
View loader.c
// Loads a PRU text.bin (and optionally data.bin) file,
// executes it, and waits for completion.
//
// Usage:
// $ ./loader text.bin [data.bin]
//
// Compile with:
// gcc -o loader loader.c -lprussdrv
//
// Based on https://credentiality2.blogspot.com/2015/09/beaglebone-pru-gpio-example.html
@shirriff
shirriff / main.c
Last active Sep 19, 2016
C code to blink an LED on the BeagleBone, using the PRU microcontroller.
View main.c
/*
* blink demo: blink LED ten times
* LED should be connected to P8_11 (pr1_pru0_pru_r30_15)
*
*/
volatile register unsigned int __R31, __R30;
int main(void) {
unsigned int loops, delay;
for (loops = 0; loops < 10; loops++) {
@shirriff
shirriff / bin.cmd
Created Sep 19, 2016
Linker file for BeagleBone Black PRU code. This creates loadable image files text.bin and data.bin.
View bin.cmd
-b
-image
ROMS {
PAGE 0:
text: o = 0x0, l = 0x1000, files={text.bin}
PAGE 1:
data: o = 0x0, l = 0x1000, files={data.bin}
}
@shirriff
shirriff / loader.c
Created Sep 19, 2016
Loads a PRU text.bin (and optionally data.bin) file, executes it, and waits for completion. This version enables timer interrupt 15 for the PRU.
View loader.c
// Loads a PRU text.bin (and optionally data.bin) file,
// executes it, and waits for completion.
// This version enables interrupt event 15 (ecap timer)
//
// Usage:
// $ ./loader text.bin [data.bin]
//
// Compile with:
// gcc -o loader loader.c -lprussdrv
//
@shirriff
shirriff / main.c
Last active May 13, 2020
Example code using a timer with the BeagleBone Black's PRU microcontroller. This code generates 5 pulses with 100ns width.
View main.c
/*
* Demonstration of the BeagleBone's PRU, using a timer.
* Ken Shirriff, http://righto.com
*/
#include <stdint.h>
#define DELAY_NS 100 // Use 500000000 for 0.5 second delay
#define WRITE_PIN 15 /* P8_11, Ethernet output data, pr1_PRU0_pru_r30_15 */
// PRU Interrupt control registers
@shirriff
shirriff / mandel.bcpl
Last active Jun 18, 2017
Mandelbrot set code for the Xerox Alto, written in BCPL.
View mandel.bcpl
get "streams.d"
external
[
Ws;
Wns;
MulFull;
DoubleAdd;
keys;
Gets;
]
@shirriff
shirriff / ac.py
Created Dec 7, 2017
Process air conditioner remote control data: find inputs differing in one bit and print the difference in the output.
View ac.py
import re
data="""\
10100001 10010011 01100011 => 01110111
10100001 10010011 01100100 => 01110001
10100001 10010011 01100101 => 01110000
10100001 10010011 01100110 => 01110010
10100001 10010011 01100111 => 01110011
10100001 10010011 01101000 => 01111001
10100001 10010011 01101001 => 01111000
You can’t perform that action at this time.