Skip to content

Instantly share code, notes, and snippets.

@balazsgrill
balazsgrill / mcp2200-tutorial.c
Created September 20, 2012 07:07
MCP2200 user-mode driver getting started
#include <stdio.h>
#include <sys/types.h>
#include <mcp2200.h>
int main(int argc, char** argv){
//Init MCP2200 library
int r = mcp2200_init();
if (r < 0)
return r;
@balazsgrill
balazsgrill / MCP2200.lsusb
Created August 25, 2012 18:35
MCP2200 lsusb enumeration
Bus 002 Device 020: ID 04d8:00df Microchip Technology, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 8
@balazsgrill
balazsgrill / ObservablePatternMatchList.java
Created August 3, 2012 11:27
Observable list for EMF-IncQuery query matcher results
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.databinding.observable.list.AbstractObservableList;
import org.eclipse.core.databinding.observable.list.ListDiff;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
import org.eclipse.viatra2.emf.incquery.runtime.api.IPatternMatch;
import org.eclipse.viatra2.emf.incquery.runtime.api.IncQueryMatcher;
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.misc.DeltaMonitor;
@balazsgrill
balazsgrill / (Not)Equals uint16
Created July 6, 2012 12:16
PIC16e uint16 arithmetics
checkEqual_u16(uint16 d1, uint16 d2, const bool not){
uint16 d;
d = d1-d2; //Simply subtract
//Put first byte into W
SELECTB(&d);
MOVF(&d,W);
//no need to select bank before using status
//we can select bank for result in advance
SELECTB(&result);
if (not){
@balazsgrill
balazsgrill / Branch on bool
Created July 6, 2012 12:12
PIC16e control operations
branch_bool(var bool condition, const codeaddr true, const codeaddr false){
SELECTB(&condition);
BTFSC(&condition, 0);
GOTO(true);
GOTO(false);
}
@balazsgrill
balazsgrill / Add uint8
Created July 6, 2012 11:54
PIC16e uint8 arithmetics
add_u8(var uint8 d, uint8 v){
if (isliteral(v)){
MOVLW(v);
}else{
SELECTB(&v);
MOVF(&v,W);
}
SELECTB(&d);
ADDWF(&d,F);
}