Skip to content

Instantly share code, notes, and snippets.

View spirilis's full-sized avatar

Eric spirilis

  • Maryland, USA
View GitHub Profile
@spirilis
spirilis / reset_program_hoco.asm
Created September 8, 2015 00:30
Renesas RX startup ASM HOCO switch
/* Enable HOCO, set to 50MHz, set CKSEL to HOCO
* ICLK by default is CKSEL / 1
*/
mov.l #0x80000, r10
mov.w #0xA507, 1022[r10] ; Enable writing to Clock, Operating Power and VRCR registers
mov.b #0, 160[r10] ; Prepare for High-Speed power mode
nop
while_power_transitioning:
mov.b 160[r10], r11
and #16, r11
@spirilis
spirilis / carnet_controller.ino
Created September 4, 2014 14:32
Snippet of Rotary Encoder processing code for Arduino - Detent-based encoders
/* Rotary Encoder ISR */
ISR(PCINT0_vect) {
// Strawman ~3.75uS delay (@16MHz) so we can reliably detect the detent signal (A & B transition at the same time) even though
// the A & B signals are still technically 1-2uS apart.
_delay_loop_1(20);
// Analog inputs are all on PORTA
char pins = (~PINA) & 0x03; // A0 + A1
if ( (pins == 0x03 && rotPinsLast == 0x00) || (pins == 0x00 && rotPinsLast == 0x03) ) { // A & B
if (rotTurning) {
if (rotDir == 1) { // Completed a clockwise turn
@spirilis
spirilis / main.c
Created September 4, 2014 14:23
Remote control illustrating Graycode incremental encoder interpretation
/* nRFDMX Remote Control implementation to send 3-letter RGB values based
* on a user-adjusted HSV colorspace system.
* Value adjusted by sliding potentiometer
* Hue adjusted by rotating a Rotary Encoder
* Saturation flipped between 1.0 and 0.1 by the rotary encoder pushbutton
*/
#include <msp430.h>
#include <stdint.h>
#include <sys/cdefs.h>
@spirilis
spirilis / Wolv_Franklin_Logger.ino
Last active August 29, 2015 14:06
TI MSP430 Wolverine + AS3935 Franklin Lightning Sensor - Energia logger sketch
/* Wolverine Lightning Sensor Logger
*
* A sensor logging application for the TI MSP430 Wolverine which utilizes
* the Austria Microsystems AS3935 Franklin Lightning Sensor to sense lightning
* strikes and log them, timestamped, into the Wolverine's FRAM.
*/
#include <SPI.h>
#include <Franklin.h>
#include <RTC_B.h>
#include <string.h>
@spirilis
spirilis / gist:69ba53bf631c03fdc5fc
Last active August 29, 2015 14:06
First legit datalog from TI MSP430 Wolverine + AS3935 Franklin Lightning Sensor!
> help
Wolverine Franklin Lightning Logger
CLI syntax:
help - Print this help
count - Get a count of lightning events currently logged
limit - Get the max # of events storable in the FRAM buffer
retrieve <#> - Retrieve the #'th entry (starting at 0), or "all" pulls all events.
purge - Purge all lightning events from FRAM buffer
disable - Place AS3935 in low-power off mode
enable - Wake AS3935 into listening mode
@spirilis
spirilis / dmx512.c
Created September 1, 2014 14:51
MSP430F5xxx infomem flash example
#include <msp430.h>
#include <stdint.h>
#include "flash.h"
#define SEG_INFOB __attribute__((section(".infob")))
#define DMX_PASSWORD_VALID ((uint16_t) 0xFEF5)
uint16_t SEG_INFOB _dmx_password = 0x0505;
uint16_t SEG_INFOB _dmx_red = 0x00FF;
@spirilis
spirilis / flash.c
Last active August 29, 2015 14:05
MSP430F5xxx infomem flasher
/* Simple F5xxx Flash Erase/Write primitives
* 2014 Eric Brundick <spirilis@linux.com>
*/
#include <msp430.h>
#include <stdint.h>
#include <stdbool.h>
#include "flash.h"
int flash_erase_info(void *loc)
{
@spirilis
spirilis / Wolv_Lightning_Logger.ino
Last active August 29, 2015 14:05
Current revision: MSP430 Wolverine logging system for AS3935 Franklin Lightning Sensor
/* Wolverine Lightning Sensor Logger
*
* A sensor logging application for the TI MSP430 Wolverine which utilizes
* the Austria Microsystems AS3935 Franklin Lightning Sensor to sense lightning
* strikes and log them, timestamped, into the Wolverine's FRAM.
*/
#include <SPI.h>
#include <Franklin.h>
#include <RTC_B.h>
#include <string.h>
@spirilis
spirilis / RadioBot.ino
Created July 11, 2014 17:15
IRC of Things bot - IrcBot, Enrf24, Pkt on Tiva-C Connected LaunchPad
/* RadioBot - IRC bot with Radio support */
#include <IrcBot.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <Enrf24.h>
#include <SPI.h>
#include <Pkt.h>
byte ourMac[] = { 0x52, 0x54, 0xFF, 0xFF, 0xFF, 0x01 };
@spirilis
spirilis / highmem_inline.h
Last active August 29, 2015 14:00
MSP430 20-bit read/write from 16-bit-only compiler; inline-able form
/* Public domain software */
#ifndef HIGHMEM_INLINE_H
#define HIGHMEM_INLINE_H
#include <msp430.h>
#include <stdint.h>
__attribute__((always_inline))
inline static void highmem_write(uint32_t dstaddr, void *srcaddr, uint16_t len)
{