Skip to content

Commit

Permalink
Added config.h [example included] and added a Arduino Uno configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
archi committed Mar 16, 2016
1 parent f764cd2 commit caa9cca
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 61 deletions.
75 changes: 75 additions & 0 deletions emulator/config.dist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* You can either configure everything in this file,
* or include one of the predefined configurations
* Just copy your variant of config.dist.h to config.h
*/
//#include "configs/uno.h"
//#include "configs/promicro.h"

// SOFTWARE CONFIG
/**
* Enable MDC and/or CDC.
* Just define MDC and/or CDC
*/
#define MDC
//#define CDC

/**
* Enable serial output
*/
//#define ENABLE_SERIAL

// HARDWARE CONFIG

/**
* Pin Configuration:
* Use pins on the same port. I.e., use ATmega PINs:
* Pnd for Data
* Pnc for Clock (needs to support interrupts!)
* Pnb for Busy
*
* Than set DDRx, PORTx and PINx to the port n out of {A,B,C,D}
* The Pin numbers are d,c,b
* For the clock, we also need the interrupt number and name.
* You can look these things up in your boards pin mapping online
*
* My config on a Sparkfun Pro Micro:
* DATA: Digital Pin 2 = PD1 (SDA/INT1)
* CLK: Digital Pin 3 = PD0 (OC0B/SCL/INT0)
* BUSY: Digital Pin 4 = PD4 (ICP1/ADC8)
*
* -> Port D, DATA on 1, CLK on 0, BUSY on 4.
* -> Clock is on INT0
*
* Arduino Code was too slow, so this is done the fast way
*/
//#define DDRx DDRD
//#define PORTx PORTD
//#define PINx PIND
//#define DATA_PIN 1
//#define BUSY_PIN 4
//#define CLK_PIN 0
//#define CLK_INT 0
//#define CLK_INTx INT0

/**
* This macro controls a LED to signal error [perma on] or init/signaling [blink]
* For the pro micro it's predefined in the default header files,
* but you might want to write one for other boards
*
* LED blink for 1s -> signaling presence
* LED on -> processing was too low
*/
//#define RXLED1 digitalWrite (your_led_pin, HIGH)
//#define RXLED0 digitalWrite (your_led_pin, LOW)

/**
* This macro controls a LED to signal communication
* For the pro micro it's predefined in the default header files,
* but you might want to write one for other boards
*
* LED on -> no data to process (but we saw the master)
* LED off -> processing data
*/
//#define TXLED1 digitalWrite (your_led_pin, HIGH)
//#define TXLED0 digitalWrite (your_led_pin, LOW)
21 changes: 21 additions & 0 deletions emulator/config_promicro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//make sure to include just a single config file
#ifndef CONFIGURED
#define CONFIGURED
#else
#error JUST INCLUDE A SINGLE CONFIG FILE
#endif

/**
* My config on a Sparkfun Pro Micro:
* DATA: Digital Pin 2 = PD1 (SDA/INT1)
* CLK: Digital Pin 3 = PD0 (OC0B/SCL/INT0)
* BUSY: Digital Pin 4 = PD4 (ICP1/ADC8)
*/
#define DDRx DDRD
#define PORTx PORTD
#define PINx PIND
#define DATA_PIN 1
#define BUSY_PIN 4
#define CLK_PIN 0
#define CLK_INT 0
#define CLK_INTx INT0
26 changes: 26 additions & 0 deletions emulator/config_uno.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//make sure to include just a single config file
#ifndef CONFIGURED
#define CONFIGURED
#else
#error JUST INCLUDE A SINGLE CONFIG FILE
#endif

/**
* My config on a Arduino Uno/ATmega 168
* DATA: Digital Pin 3 = PD3 (PCINT19/OC2B/INT1) OLD: PD1 (SDA/INT1)
* CLK: Digital Pin 2 = PD2 (PCINT18/INT0) OLD: PD0 (OC0B/SCL/INT0)
* BUSY: Digital Pin 4 = PD4 (PCINT20/XCK/T0) OLD: PD4 (ICP1/ADC8)
*/
#define DDRx DDRD
#define PORTx PORTD
#define PINx PIND
#define DATA_PIN 3
#define BUSY_PIN 4
#define CLK_PIN 2
#define CLK_INT 0
#define CLK_INTx INT0

#define TXLED0
#define TXLED1
#define RXLED0
#define RXLED1
65 changes: 4 additions & 61 deletions emulator/emulator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,10 @@
*/

/**
* Enable MDC and/or CDC.
* Just define MDC and/or CDC
* Your configuration goes to config.h
* Take a look at config.dist.h for details
*/
#define MDC
//#define CDC

/**
* Pin Configuration:
* Use pins on the same port. I.e., use ATmega PINs:
* Pnd for Data
* Pnc for Clock (needs to support interrupts!)
* Pnb for Busy
*
* Than set DDRx, PORTx and PINx to the port n out of {A,B,C,D}
* The Pin numbers are d,c,b
* For the clock, we also need the interrupt number and name.
* You can look these things up in your boards pin mapping online
*
* My config on a Sparkfun Pro Micro:
* DATA: Digital Pin 2 = PD1 (SDA/INT1)
* CLK: Digital Pin 3 = PD0 (OC0B/SCL/INT0)
* BUSY: Digital Pin 4 = PD4 (ICP1/ADC8)
*
* -> Port D, DATA on 1, CLK on 0, BUSY on 4.
* -> Clock is on INT0
*
* Arduino Code was too slow, so this is done the fast way
*/
#define DDRx DDRD
#define PORTx PORTD
#define PINx PIND
#define DATA_PIN 1
#define BUSY_PIN 4
#define CLK_PIN 0
#define CLK_INT 0
#define CLK_INTx INT0

/**
* Enable serial output
*/
//#define ENABLE_SERIAL

/**
* This macro controls a LED to signal error [perma on] or init/signaling [blink]
* For the pro micro it's predefined, but you might want to write one for other boards
*
* LED blink for 1s -> signaling presence
* LED on -> processing was too low
*/
//#define RXLED1 digitalWrite (your_led_pin, HIGH)
//#define RXLED0 digitalWrite (your_led_pin, LOW)

/**
* This macro controls a LED to signal communication
* For the pro micro it's predefined, but you might want to write one for other boards
*
* LED on -> no data to process (but we saw the master)
* LED off -> processing data
*/
//#define TXLED1 digitalWrite (your_led_pin, HIGH)
//#define TXLED0 digitalWrite (your_led_pin, LOW)
#include "config.h"

#include "blink.h"
#include "io.h"
Expand Down Expand Up @@ -202,4 +145,4 @@ bool SerialEvent () {
}
return false;
}
#endif
#endif

0 comments on commit caa9cca

Please sign in to comment.