Skip to content

Instantly share code, notes, and snippets.

View BobBurns's full-sized avatar

Bob Burns BobBurns

  • Santa Cruz, CA
View GitHub Profile
@BobBurns
BobBurns / write_pn532.asm
Created July 19, 2015 12:04
avr code to control pn532 and write to MiFare classic.
;new program to set up and test the PN532 chip reader
;compile with gavrasm write_pn532.asm ;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:write_pn532.asm
;
; I/O pins:
; ** use PORTB except RDYN on PORTD **
; ** SCK on pin 5 configured as output **
; ** MISO on pin 4 configured as input with pullup **
; ** MOSI on pin 3 configured as output **
; ** NSS on pin 2 configured as output **
; ** NSS on pin 2 not selected (high)
@BobBurns
BobBurns / read_dec.asm
Created July 19, 2015 12:08
avr code to control pn532 to read and decrement MiFare card value
;this program attempts to read a MiFare card initialized with a name at address 0x04
; and a value block at 0x05
;
;compile with gavrasm read_dec.asm ;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:read_dec.hex
;
; I/O pins:
; ** use PORTB except RDYN on PORTD **
; ** SCK on pin 5 configured as output **
; ** MISO on pin 4 configured as input with pullup **
; ** MOSI on pin 3 configured as output **
@BobBurns
BobBurns / nfc_server.ino
Created July 22, 2015 12:10
nfc server for particle web ide
// firmware to receive bytes from atmega186 over USART and send over Wifi
// The atmega168 is programmed to talk to the pn532 nfc card reader and then send the card info
// over USART.
#define debug 0
#define MAXLEN 256
TCPServer server = TCPServer(2342);
TCPClient client;
bool unlocked = false;
@BobBurns
BobBurns / blinky.s
Created July 31, 2015 16:45
blink led on stm32 L1 Discovery with ARM assembly
@ lets try to blink an LED on the discovery stm32 L1 board
@ uses LED on PB7
@ how to compile and flash:
@ arm-none-eabi-as -mcpu=cortex-m3 blinky.s -o blinky.o
@ arm-none-eabi-ld -v -T stm32.ld -nostartfiles -o blinky.elf blinky.o
@ arm-none-eabi-objcopy -O binary blinky.elf blinky.bin
@ then from st-link (https://github.com/texane/stlink)
@ ./st-flash write ../first_arm/blinky.bin 0x08000000
.thumb
@BobBurns
BobBurns / stm32.ld
Created July 31, 2015 16:50
linker script to go with blinky.s
/* linker script for STM32 Cortex M3 c/o pygmy.utoh.org */
SECTIONS
{
/* interupt vectors start at zero */
. = 0x0; /* start of flash */
.text : { *(text) }
/* constant data follows code but still in flash */
@BobBurns
BobBurns / cylon_eyes.s
Created August 14, 2015 21:05
cylon eyes program in arm assembly for stm32L discovery
@ cylon eyes for stm32L discovery
@ uses lcd software driver 1/4 duty 1/3 bias
@ how to compile and flash:
@ arm-none-eabi-as -mcpu=cortex-m3 cylon_eyes.s -o cylon_eyes.o
@ arm-none-eabi-ld -v -T stm32.ld -nostartfiles -o cylon_eyes.elf cylon_eyes.o
@ arm-none-eabi-objcopy -O binary cylon_eyes.elf cylon_eyes.bin
@ then from st-link (https://github.com/texane/stlink)
@ ./st-flash write ../first_arm/cylon_eyes.bin 0x08000000
.thumb
@ program: systick_tst.s
@ programmer: reb
@ device: stm32L152c discovery eval board
@ description: blink led with systick count down
@ uses systick interrupt routine
@
@ how to compile and flash:
@ arm-none-eabi-as -mcpu=cortex-m3 systick_tst.s -o systick_tst.o
@ arm-none-eabi-ld -v -T stm32.ld -nostartfiles -o systick_tst.elf systick_tst.o
@ arm-none-eabi-objcopy -O binary systick_tst.elf systick_tst.bin
@BobBurns
BobBurns / rijndal_field_mul_inv.c
Created December 28, 2015 21:29
program to calculate the multiplicative inverse in Rijndal's Galois Feild.
#include <stdio.h>
/* program to demonstrate how to find multiplicative inverse in Rijndal's Galois Field
* part of the AES encryption algorithm or Rijndal's block cipher.
*
* code expanded on blog @ www.samiam/galois.html
*/
/* global vars */
@BobBurns
BobBurns / rijndael_field_sbox.c
Created December 30, 2015 19:35
Rijndail S-box the long way
#include <stdio.h>
/* Rijndael Field S-box transformation
* part of the AES encryption algorythm or Rijndal's block cipher.
*
* code expanded on blog @ www.samiam/galois.html
*/
/* global vars */
@BobBurns
BobBurns / aff_c.c
Created January 3, 2016 01:06
c algorithm to decipher affine cipher
#include <stdio.h>
#include <stdlib.h>
/* quick program to solve affine cipher with key a, b mod 26 */
/* usage: ./aff_c <key a> <key b> <optional e=encrypt>
* cipher-text from stdin or pipe
*/
int