Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/gpio2nesc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-07-04 18:31:50 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-07-04 18:31:50 +0300
commit8442e979bfda600195d626f27ea3de8b4fce95d2 (patch)
treed4626366ffd7aa069fb754229c0912bea30a9fe0
parentc0b1ce67a9ab44064ccae988aac14550e5aa4871 (diff)
First commit
-rw-r--r--Makefile147
-rw-r--r--defines.h49
-rw-r--r--gpio2nesc.c217
-rw-r--r--gpio2nesc.h103
-rw-r--r--gpio2nesc.lay6bin0 -> 60195 bytes
-rw-r--r--wiimote.c296
-rw-r--r--wiimote.h20
-rw-r--r--wm_crypto.h189
8 files changed, 1021 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3437196
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,147 @@
+PRG = gpio2nesc
+OBJ = gpio2nesc.o wiimote.o
+LFUSE = E4
+HFUSE = D9
+MCU_PROGRAMMER = m8
+PROGRAMMER_TYPE = avrisp2
+PROGRAMMER_PORT = usb
+
+#MCU_TARGET = at90s2313
+#MCU_TARGET = at90s2333
+#MCU_TARGET = at90s4414
+#MCU_TARGET = at90s4433
+#MCU_TARGET = at90s4434
+#MCU_TARGET = at90s8515
+#MCU_TARGET = at90s8535
+#MCU_TARGET = atmega128
+#MCU_TARGET = atmega1280
+#MCU_TARGET = atmega1281
+#MCU_TARGET = atmega16
+#MCU_TARGET = atmega163
+#MCU_TARGET = atmega164p
+#MCU_TARGET = atmega165
+#MCU_TARGET = atmega165p
+#MCU_TARGET = atmega168
+#MCU_TARGET = atmega169
+#MCU_TARGET = atmega169p
+#MCU_TARGET = atmega32
+#MCU_TARGET = atmega324p
+#MCU_TARGET = atmega325
+#MCU_TARGET = atmega3250
+#MCU_TARGET = atmega329
+#MCU_TARGET = atmega3290
+#MCU_TARGET = atmega48
+#MCU_TARGET = atmega64
+#MCU_TARGET = atmega640
+#MCU_TARGET = atmega644
+#MCU_TARGET = atmega644p
+#MCU_TARGET = atmega645
+#MCU_TARGET = atmega6450
+#MCU_TARGET = atmega649
+#MCU_TARGET = atmega6490
+MCU_TARGET = atmega8
+#MCU_TARGET = atmega8515
+#MCU_TARGET = atmega8535
+#MCU_TARGET = atmega88
+#MCU_TARGET = attiny2313
+#MCU_TARGET = attiny24
+#MCU_TARGET = attiny25
+#MCU_TARGET = attiny26
+#MCU_TARGET = attiny261
+#MCU_TARGET = attiny44
+#MCU_TARGET = attiny45
+#MCU_TARGET = attiny461
+#MCU_TARGET = attiny84
+#MCU_TARGET = attiny85
+#MCU_TARGET = attiny861
+OPTIMIZE = -O2
+
+DEFS =
+LIBS =
+
+# You should not have to change anything below here.
+
+CC = avr-gcc
+
+# Override is only needed by avr-lib build system.
+
+override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
+override LDFLAGS = -Wl,-Map,$(PRG).map
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+
+all: $(PRG).elf lst text eeprom
+
+$(PRG).elf: $(OBJ) defines.h gpio2nesc.h wiimote.h wm_crypto.h
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+clean:
+ rm -rf *.o $(PRG).elf *.eps *.bak
+ rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
+
+lst: $(PRG).lst
+
+%.lst: %.elf
+ $(OBJDUMP) -h -S $< > $@
+
+# Rules for building the .text rom images
+
+text: hex bin srec
+
+hex: $(PRG).hex
+bin: $(PRG).bin
+srec: $(PRG).srec
+
+%.hex: %.elf
+ $(OBJCOPY) -j .text -j .data -O ihex $< $@
+
+%.srec: %.elf
+ $(OBJCOPY) -j .text -j .data -O srec $< $@
+
+%.bin: %.elf
+ $(OBJCOPY) -j .text -j .data -O binary $< $@
+
+# Rules for building the .eeprom rom images
+
+eeprom: ehex ebin esrec
+
+ehex: $(PRG)_eeprom.hex
+ebin: $(PRG)_eeprom.bin
+esrec: $(PRG)_eeprom.srec
+
+%_eeprom.hex: %.elf
+ $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \
+ || { echo empty $@ not generated; exit 0; }
+
+%_eeprom.srec: %.elf
+ $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \
+ || { echo empty $@ not generated; exit 0; }
+
+%_eeprom.bin: %.elf
+ $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \
+ || { echo empty $@ not generated; exit 0; }
+
+# Every thing below here is used by avr-libc's build system and can be ignored
+# by the casual user.
+
+FIG2DEV = fig2dev
+EXTRA_CLEAN_FILES = *.hex *.bin *.srec
+
+dox: eps png pdf
+
+eps: $(PRG).eps
+png: $(PRG).png
+pdf: $(PRG).pdf
+
+%.eps: %.fig
+ $(FIG2DEV) -L eps $< $@
+
+%.pdf: %.fig
+ $(FIG2DEV) -L pdf $< $@
+
+%.png: %.fig
+ $(FIG2DEV) -L png $< $@
+
+program: hex
+ avrdude -V -p $(MCU_PROGRAMMER) -c $(PROGRAMMER_TYPE) -P $(PROGRAMMER_PORT) -U flash:w:$(PRG).hex -U lfuse:w:0x$(LFUSE):m -U hfuse:w:0x$(HFUSE):m
diff --git a/defines.h b/defines.h
new file mode 100644
index 0000000..90c296e
--- /dev/null
+++ b/defines.h
@@ -0,0 +1,49 @@
+#ifndef _DEFINES_H_
+#define _DEFINES_H_
+
+#define F_CPU 8000000L
+
+#define TWI_PORT C
+#define TWI_SCL_PIN 5
+#define TWI_SDA_PIN 4
+
+#define DETECT_PORT C
+#define DETECT_PIN 3
+
+#define RED_LED_PORT D
+#define RED_LED_PIN 4
+#define GREEN_LED_PORT D
+#define GREEN_LED_PIN 3
+
+#define BUTTON_A_PORT C
+#define BUTTON_A_PIN 1
+#define BUTTON_B_PORT B
+#define BUTTON_B_PIN 4
+#define BUTTON_X_PORT D
+#define BUTTON_X_PIN 0
+#define BUTTON_Y_PORT B
+#define BUTTON_Y_PIN 5
+#define BUTTON_UP_PORT B
+#define BUTTON_UP_PIN 1
+#define BUTTON_DOWN_PORT D
+#define BUTTON_DOWN_PIN 6
+#define BUTTON_LEFT_PORT B
+#define BUTTON_LEFT_PIN 2
+#define BUTTON_RIGHT_PORT D
+#define BUTTON_RIGHT_PIN 7
+#define BUTTON_SELECT_PORT C
+#define BUTTON_SELECT_PIN 0
+#define BUTTON_START_PORT C
+#define BUTTON_START_PIN 2
+#define BUTTON_L_PORT B
+#define BUTTON_L_PIN 3
+#define BUTTON_R_PORT B
+#define BUTTON_R_PIN 0
+#define BUTTON_ZL_PORT B
+#define BUTTON_ZL_PIN 6
+#define BUTTON_ZR_PORT B
+#define BUTTON_ZR_PIN 7
+#define BUTTON_HOME_PORT D
+#define BUTTON_HOME_PIN 5
+
+#endif
diff --git a/gpio2nesc.c b/gpio2nesc.c
new file mode 100644
index 0000000..827c758
--- /dev/null
+++ b/gpio2nesc.c
@@ -0,0 +1,217 @@
+#include "gpio2nesc.h"
+#include "defines.h"
+#include <util/delay.h>
+#include <avr/eeprom.h>
+#include <inttypes.h>
+#include "wiimote.h"
+#include <avr/wdt.h>
+
+// classic controller id
+const unsigned char classic_controller_id[6] = {0x00, 0x00, 0xA4, 0x20, 0x01, 0x01};
+
+volatile int jx = 0, jy = 0, rx = 0, ry = 0, tl = 0, tr = 0;
+volatile uint8_t left = 0, right = 0, up = 0, down = 0, a = 0, b = 0, x = 0, y = 0,
+ select = 0, start = 0, home = 0, l = 0, r = 0, zl = 0, zr = 0;
+
+// calibration data
+const unsigned char cal_data[32] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+void wiimote_query()
+{
+ wdt_reset();
+ RED_ON;
+ unsigned char but_dat[8]; // struct containing button data
+ if (twi_reg[0xFE] == 1) // data format
+ {
+ but_dat[0] = 0b00000000; // RX<4:3> LX<5:0>
+ but_dat[1] = 0b00000000; // RX<2:1> LY<5:0>
+ but_dat[2] = 0b00000000; // RX<0> LT<4:3> RY<4:0>
+ but_dat[3] = 0b00000000; // LT<2:0> RT<4:0>
+ but_dat[4] = 0b11111111; // BDR BDD BLT B- BH B+ BRT 1
+ but_dat[5] = 0b11111111; // BZL BB BY BA BX BZR BDL BDU
+ but_dat[6] = 0;
+ but_dat[7] = 0;
+
+ but_dat[0] |= (jx / 4 + 0x20) & 0x3F;
+ but_dat[1] |= (jy / -4 + 0x20) & 0x3F;
+ but_dat[0] |= ((rx / 8 + 0x10) & 0x18) << 3;
+ but_dat[1] |= ((rx / 8 + 0x10) & 0x06) << 5;
+ but_dat[2] |= ((rx / 8 + 0x10) & 0x01) << 7;
+ but_dat[2] |= (ry / -8 + 0x10) & 0x1F;
+ but_dat[2] |= ((tl / 8) & 0x18) << 2;
+ but_dat[3] |= ((tl / 8) & 0x07) << 5;
+ but_dat[3] |= (tr / 8) & 0x1F;
+
+ if (right) but_dat[4] &= ~(1<<7);
+ if (down) but_dat[4] &= ~(1<<6);
+ if (l) but_dat[4] &= ~(1<<5);
+ if (select) but_dat[4] &= ~(1<<4);
+ if (home) but_dat[4] &= ~(1<<3);
+ if (start) but_dat[4] &= ~(1<<2);
+ if (r) but_dat[4] &= ~(1<<1);
+
+ if (zl) but_dat[5] &= ~(1<<7);
+ if (b) but_dat[5] &= ~(1<<6);
+ if (y) but_dat[5] &= ~(1<<5);
+ if (a) but_dat[5] &= ~(1<<4);
+ if (x) but_dat[5] &= ~(1<<3);
+ if (zr) but_dat[5] &= ~(1<<2);
+ if (left) but_dat[5] &= ~(1<<1);
+ if (up) but_dat[5] &= ~(1<<0);
+
+ but_dat[6] = 0;
+ but_dat[7] = 0;
+
+ if (((but_dat[4] & 0xFE) == 0xFE) && (but_dat[5] == 0xFF))
+ GREEN_OFF;
+ else
+ GREEN_ON;
+
+ wm_newaction(but_dat);
+ }
+ else if (twi_reg[0xFE] == 3) // data format
+ {
+ but_dat[0] = jx + 0x80;
+ but_dat[1] = rx + 0x80;
+ but_dat[2] = 0x7fl - jy;
+ but_dat[3] = 0x7fl - ry;
+ but_dat[4] = tl;
+ but_dat[5] = tr;
+
+ but_dat[6] = 0b11111111; // BDR BDD BLT B- BH B+ BRT 1
+ but_dat[7] = 0b11111111; // BZL BB BY BA BX BZR BDL BDU
+
+ if (right) but_dat[6] &= ~(1<<7);
+ if (down) but_dat[6] &= ~(1<<6);
+ if (l) but_dat[6] &= ~(1<<5);
+ if (select) but_dat[6] &= ~(1<<4);
+ if (home) but_dat[6] &= ~(1<<3);
+ if (start) but_dat[6] &= ~(1<<2);
+ if (r) but_dat[6] &= ~(1<<1);
+
+ if (zl) but_dat[7] &= ~(1<<7);
+ if (b) but_dat[7] &= ~(1<<6);
+ if (y) but_dat[7] &= ~(1<<5);
+ if (a) but_dat[7] &= ~(1<<4);
+ if (x) but_dat[7] &= ~(1<<3);
+ if (zr) but_dat[7] &= ~(1<<2);
+ if (left) but_dat[7] &= ~(1<<1);
+ if (up) but_dat[7] &= ~(1<<0);
+
+ if (((but_dat[6] & 0xFE) == 0xFE) && (but_dat[7] == 0xFF))
+ GREEN_OFF;
+ else
+ GREEN_ON;
+
+ wm_newaction(but_dat);
+ }
+}
+
+int main()
+{
+ DDR(RED_LED_PORT) |= (1<<RED_LED_PIN); // Red led, output
+ DDR(GREEN_LED_PORT) |= (1<<GREEN_LED_PIN); // Red led, output
+ RED_ON;
+ GREEN_ON;
+ _delay_ms(100);
+ RED_OFF;
+ GREEN_OFF;
+#ifdef BUTTON_A_PIN
+ DDR(BUTTON_A_PORT) &= ~(1<<BUTTON_A_PIN);
+ PORT(BUTTON_A_PORT) |= 1<<BUTTON_A_PIN;
+#endif
+#ifdef BUTTON_B_PIN
+ DDR(BUTTON_B_PORT) &= ~(1<<BUTTON_B_PIN);
+ PORT(BUTTON_B_PORT) |= 1<<BUTTON_B_PIN;
+#endif
+#ifdef BUTTON_X_PIN
+ DDR(BUTTON_X_PORT) &= ~(1<<BUTTON_X_PIN);
+ PORT(BUTTON_X_PORT) |= 1<<BUTTON_X_PIN;
+#endif
+#ifdef BUTTON_Y_PIN
+ DDR(BUTTON_Y_PORT) &= ~(1<<BUTTON_Y_PIN);
+ PORT(BUTTON_Y_PORT) |= 1<<BUTTON_Y_PIN;
+#endif
+#ifdef BUTTON_UP_PIN
+ DDR(BUTTON_UP_PORT) &= ~(1<<BUTTON_UP_PIN);
+ PORT(BUTTON_UP_PORT) |= 1<<BUTTON_UP_PIN;
+#endif
+#ifdef BUTTON_DOWN_PIN
+ DDR(BUTTON_DOWN_PORT) &= ~(1<<BUTTON_DOWN_PIN);
+ PORT(BUTTON_DOWN_PORT) |= 1<<BUTTON_DOWN_PIN;
+#endif
+#ifdef BUTTON_LEFT_PIN
+ DDR(BUTTON_LEFT_PORT) &= ~(1<<BUTTON_LEFT_PIN);
+ PORT(BUTTON_LEFT_PORT) |= 1<<BUTTON_LEFT_PIN;
+#endif
+#ifdef BUTTON_RIGHT_PIN
+ DDR(BUTTON_RIGHT_PORT) &= ~(1<<BUTTON_RIGHT_PIN);
+ PORT(BUTTON_RIGHT_PORT) |= 1<<BUTTON_RIGHT_PIN;
+#endif
+#ifdef BUTTON_SELECT_PIN
+ DDR(BUTTON_SELECT_PORT) &= ~(1<<BUTTON_SELECT_PIN);
+ PORT(BUTTON_SELECT_PORT) |= 1<<BUTTON_SELECT_PIN;
+#endif
+#ifdef BUTTON_START_PIN
+ DDR(BUTTON_START_PORT) &= ~(1<<BUTTON_START_PIN);
+ PORT(BUTTON_START_PORT) |= 1<<BUTTON_START_PIN;
+#endif
+#ifdef BUTTON_L_PIN
+ DDR(BUTTON_L_PORT) &= ~(1<<BUTTON_L_PIN);
+ PORT(BUTTON_L_PORT) |= 1<<BUTTON_L_PIN;
+#endif
+#ifdef BUTTON_R_PIN
+ DDR(BUTTON_R_PORT) &= ~(1<<BUTTON_R_PIN);
+ PORT(BUTTON_R_PORT) |= 1<<BUTTON_R_PIN;
+#endif
+#ifdef BUTTON_ZL_PIN
+ DDR(BUTTON_ZL_PORT) &= ~(1<<BUTTON_ZL_PIN);
+ PORT(BUTTON_ZL_PORT) |= 1<<BUTTON_ZL_PIN;
+#endif
+#ifdef BUTTON_ZR_PIN
+ DDR(BUTTON_ZR_PORT) &= ~(1<<BUTTON_ZR_PIN);
+ PORT(BUTTON_ZR_PORT) |= 1<<BUTTON_ZR_PIN;
+#endif
+#ifdef BUTTON_HOME_PIN
+ DDR(BUTTON_HOME_PORT) &= ~(1<<BUTTON_HOME_PIN);
+ PORT(BUTTON_HOME_PORT) |= 1<<BUTTON_HOME_PIN;
+#endif
+ uint8_t connected = 0;
+
+ while(1)
+ {
+ if (!connected)
+ {
+ wm_init((void*)classic_controller_id, (void*)cal_data, wiimote_query);
+ connected = 1;
+ wdt_enable(WDTO_2S);
+ }
+
+ a = BTN_A;
+ b = BTN_B;
+ x = BTN_X;
+ y = BTN_Y;
+ select = BTN_SELECT;
+ start = BTN_START;
+ up = BTN_UP;
+ down = BTN_DOWN;
+ left = BTN_LEFT;
+ right = BTN_RIGHT;
+ l = BTN_L;
+ r = BTN_R;
+ zl = BTN_ZL;
+ zr = BTN_ZR;
+ home = BTN_HOME;
+ _delay_ms(1);
+ }
+ return 0;
+}
diff --git a/gpio2nesc.h b/gpio2nesc.h
new file mode 100644
index 0000000..660489b
--- /dev/null
+++ b/gpio2nesc.h
@@ -0,0 +1,103 @@
+#ifndef _NES2WII_H_
+#define _NES2WII_H_
+
+#include "defines.h"
+
+#define GLUE(a,b) a##b
+#define DDR(p) GLUE(DDR,p)
+#define PORT(p) GLUE(PORT,p)
+#define PIN(p) GLUE(PIN,p)
+
+#define twi_port PORT(TWI_PORT)
+#define twi_ddr DDR(TWI_PORT)
+#define twi_scl_pin TWI_SCL_PIN
+#define twi_sda_pin TWI_SDA_PIN
+
+#ifdef DETECT_PORT
+#define dev_detect_port PORT(DETECT_PORT)
+#define dev_detect_ddr DDR(DETECT_PORT)
+#define dev_detect_pin DETECT_PIN
+#endif
+
+#define RED_ON PORT(RED_LED_PORT) &= ~(1<<RED_LED_PIN)
+#define RED_OFF PORT(RED_LED_PORT) |= (1<<RED_LED_PIN)
+#define GREEN_ON PORT(GREEN_LED_PORT) &= ~(1<<GREEN_LED_PIN)
+#define GREEN_OFF PORT(GREEN_LED_PORT) |= (1<<GREEN_LED_PIN)
+
+#ifdef BUTTON_A_PIN
+ #define BTN_A (!(PIN(BUTTON_A_PORT)&(1<<BUTTON_A_PIN)))
+#else
+ #define BTN_A 0
+#endif
+#ifdef BUTTON_B_PIN
+ #define BTN_B (!(PIN(BUTTON_B_PORT)&(1<<BUTTON_B_PIN)))
+#else
+ #define BTN_B 0
+#endif
+#ifdef BUTTON_X_PIN
+ #define BTN_X (!(PIN(BUTTON_X_PORT)&(1<<BUTTON_X_PIN)))
+#else
+ #define BTN_X 0
+#endif
+#ifdef BUTTON_Y_PIN
+ #define BTN_Y (!(PIN(BUTTON_Y_PORT)&(1<<BUTTON_Y_PIN)))
+#else
+ #define BTN_Y 0
+#endif
+#ifdef BUTTON_UP_PIN
+ #define BTN_UP (!(PIN(BUTTON_UP_PORT)&(1<<BUTTON_UP_PIN)))
+#else
+ #define BTN_UP 0
+#endif
+#ifdef BUTTON_DOWN_PIN
+ #define BTN_DOWN (!(PIN(BUTTON_DOWN_PORT)&(1<<BUTTON_DOWN_PIN)))
+#else
+ #define BTN_DOWN 0
+#endif
+#ifdef BUTTON_LEFT_PIN
+ #define BTN_LEFT (!(PIN(BUTTON_LEFT_PORT)&(1<<BUTTON_LEFT_PIN)))
+#else
+ #define BTN_LEFT 0
+#endif
+#ifdef BUTTON_RIGHT_PIN
+ #define BTN_RIGHT (!(PIN(BUTTON_RIGHT_PORT)&(1<<BUTTON_RIGHT_PIN)))
+#else
+ #define BTN_RIGHT 0
+#endif
+#ifdef BUTTON_SELECT_PIN
+ #define BTN_SELECT (!(PIN(BUTTON_SELECT_PORT)&(1<<BUTTON_SELECT_PIN)))
+#else
+ #define BTN_SELECT 0
+#endif
+#ifdef BUTTON_START_PIN
+ #define BTN_START (!(PIN(BUTTON_START_PORT)&(1<<BUTTON_START_PIN)))
+#else
+ #define BTN_START 0
+#endif
+#ifdef BUTTON_L_PIN
+ #define BTN_L (!(PIN(BUTTON_L_PORT)&(1<<BUTTON_L_PIN)))
+#else
+ #define BTN_L 0
+#endif
+#ifdef BUTTON_R_PIN
+ #define BTN_R (!(PIN(BUTTON_R_PORT)&(1<<BUTTON_R_PIN)))
+#else
+ #define BTN_R 0
+#endif
+#ifdef BUTTON_ZL_PIN
+ #define BTN_ZL (!(PIN(BUTTON_ZL_PORT)&(1<<BUTTON_ZL_PIN)))
+#else
+ #define BTN_ZL 0
+#endif
+#ifdef BUTTON_ZR_PIN
+ #define BTN_ZR (!(PIN(BUTTON_ZR_PORT)&(1<<BUTTON_ZR_PIN)))
+#else
+ #define BTN_ZR 0
+#endif
+#ifdef BUTTON_HOME_PIN
+ #define BTN_HOME (!(PIN(BUTTON_HOME_PORT)&(1<<BUTTON_HOME_PIN)))
+#else
+ #define BTN_HOME 0
+#endif
+
+#endif
diff --git a/gpio2nesc.lay6 b/gpio2nesc.lay6
new file mode 100644
index 0000000..3b8e9e6
--- /dev/null
+++ b/gpio2nesc.lay6
Binary files differ
diff --git a/wiimote.c b/wiimote.c
new file mode 100644
index 0000000..d3dd667
--- /dev/null
+++ b/wiimote.c
@@ -0,0 +1,296 @@
+/*
+WiiExtensionLibrary (c) Circle of Current
+http://code.google.com/p/circle-of-current/wiki/WiiExtensionLibrary
+*/
+
+
+#include "wiimote.h"
+#include "wm_crypto.h"
+#include "gpio2nesc.h"
+
+// pointer to user function
+static void (*wm_sample_event)();
+
+// crypto data
+static volatile unsigned char wm_rand[10];
+static volatile unsigned char wm_key[6];
+static volatile unsigned char wm_ft[8];
+static volatile unsigned char wm_sb[8];
+
+// virtual register
+volatile unsigned char twi_reg[256];
+volatile unsigned int twi_reg_addr;
+
+static volatile unsigned char twi_first_addr_flag; // set address flag
+static volatile unsigned char twi_rw_len; // length of most recent operation
+
+void twi_slave_init(unsigned char addr)
+{
+ // initialize stuff
+ twi_reg_addr = 0;
+
+ // set slave address
+ TWAR = addr << 1;
+
+ // enable twi module, acks, and twi interrupt
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
+
+ // enable interrupts
+ sei();
+}
+
+void twi_clear_int(unsigned char ack)
+{
+ // get ready by clearing interrupt, with or without ack
+ if(ack != 0)
+ {
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
+ }
+ else
+ {
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
+ }
+}
+
+/*
+
+I'd like to thank Hector Martin for posting his encryption method!
+His website is http://www.marcansoft.com/
+Decryption method found at http://www.derkeiler.com/pdf/Newsgroups/sci.crypt/2008-11/msg00110.pdf
+
+*/
+
+unsigned char wm_ror8(unsigned char a, unsigned char b)
+{
+ // bit shift with roll-over
+ return (a >> b) | ((a << (8 - b)) & 0xFF);
+}
+
+void wm_gentabs()
+{
+ unsigned char idx;
+
+ // check all idx
+ for(idx = 0; idx < 7; idx++)
+ {
+ // generate test key
+ unsigned char ans[6];
+ unsigned char tkey[6];
+ unsigned char t0[10];
+
+ unsigned char i;
+ for(i = 0; i < 6; i++)
+ {
+ ans[i] = pgm_read_byte(&(ans_tbl[idx][i]));
+ }
+ for(i = 0; i < 10; i++)
+ {
+ t0[i] = pgm_read_byte(&(sboxes[0][wm_rand[i]]));
+ }
+
+ tkey[0] = ((wm_ror8((ans[0] ^ t0[5]), (t0[2] % 8)) - t0[9]) ^ t0[4]);
+ tkey[1] = ((wm_ror8((ans[1] ^ t0[1]), (t0[0] % 8)) - t0[5]) ^ t0[7]);
+ tkey[2] = ((wm_ror8((ans[2] ^ t0[6]), (t0[8] % 8)) - t0[2]) ^ t0[0]);
+ tkey[3] = ((wm_ror8((ans[3] ^ t0[4]), (t0[7] % 8)) - t0[3]) ^ t0[2]);
+ tkey[4] = ((wm_ror8((ans[4] ^ t0[1]), (t0[6] % 8)) - t0[3]) ^ t0[4]);
+ tkey[5] = ((wm_ror8((ans[5] ^ t0[7]), (t0[8] % 8)) - t0[5]) ^ t0[9]);
+
+ // compare with actual key
+ if(memcmp(tkey, (void*)wm_key, 6) == 0) break; // if match, then use this idx
+ }
+
+ // generate encryption from idx key and rand
+ wm_ft[0] = pgm_read_byte(&(sboxes[idx + 1][wm_key[4]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[3]]));
+ wm_ft[1] = pgm_read_byte(&(sboxes[idx + 1][wm_key[2]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[5]]));
+ wm_ft[2] = pgm_read_byte(&(sboxes[idx + 1][wm_key[5]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[7]]));
+ wm_ft[3] = pgm_read_byte(&(sboxes[idx + 1][wm_key[0]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[2]]));
+ wm_ft[4] = pgm_read_byte(&(sboxes[idx + 1][wm_key[1]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[4]]));
+ wm_ft[5] = pgm_read_byte(&(sboxes[idx + 1][wm_key[3]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[9]]));
+ wm_ft[6] = pgm_read_byte(&(sboxes[idx + 1][wm_rand[0]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[6]]));
+ wm_ft[7] = pgm_read_byte(&(sboxes[idx + 1][wm_rand[1]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[8]]));
+
+ wm_sb[0] = pgm_read_byte(&(sboxes[idx + 1][wm_key[0]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[1]]));
+ wm_sb[1] = pgm_read_byte(&(sboxes[idx + 1][wm_key[5]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[4]]));
+ wm_sb[2] = pgm_read_byte(&(sboxes[idx + 1][wm_key[3]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[0]]));
+ wm_sb[3] = pgm_read_byte(&(sboxes[idx + 1][wm_key[2]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[9]]));
+ wm_sb[4] = pgm_read_byte(&(sboxes[idx + 1][wm_key[4]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[7]]));
+ wm_sb[5] = pgm_read_byte(&(sboxes[idx + 1][wm_key[1]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[8]]));
+ wm_sb[6] = pgm_read_byte(&(sboxes[idx + 1][wm_rand[3]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[5]]));
+ wm_sb[7] = pgm_read_byte(&(sboxes[idx + 1][wm_rand[2]])) ^ pgm_read_byte(&(sboxes[idx + 2][wm_rand[6]]));
+}
+
+void wm_slaveTxStart(unsigned char addr)
+{
+ //twi_reg[0xfe] = 1;
+ if(addr >= 0x00 && addr < 0x08)
+ {
+ // call user event
+ wm_sample_event();
+ }
+}
+
+void wm_slaveRx(unsigned char addr, unsigned char l)
+{
+ // if encryption data is sent, store them accordingly
+ unsigned int i;
+ if(addr >= 0x40 && addr < 0x46)
+ {
+ for(i = 0; i < 6; i++)
+ {
+ wm_rand[9 - i] = twi_reg[0x40 + i];
+ }
+ }
+ else if(addr >= 0x46 && addr < 0x4C)
+ {
+ for(i = 6; i < 10; i++)
+ {
+ wm_rand[9 - i] = twi_reg[0x40 + i];
+ }
+ for(i = 0; i < 2; i++)
+ {
+ wm_key[5 - i] = twi_reg[0x40 + 10 + i];
+ }
+ }
+ else if(addr >= 0x4C && addr < 0x50)
+ {
+ for(i = 2; i < 6; i++)
+ {
+ wm_key[5 - i] = twi_reg[0x40 + 10 + i];
+ }
+ if(addr + l == 0x50)
+ {
+ // generate decryption once all data is loaded
+ wm_gentabs();
+ }
+ }
+}
+
+void wm_newaction(unsigned char * d)
+{
+ // load button data from user application
+ memcpy((void*)twi_reg, d, 8);
+}
+
+void wm_init(unsigned char * id, unsigned char * cal_data, void (*function)(void))
+{
+ // link user function
+ wm_sample_event = function;
+
+ // start state
+ twi_reg[0xF0] = 0; // disable encryption
+
+ // set id
+ unsigned int i, j;
+ for(i = 0, j = 0xFA; i < 6; i++, j++)
+ {
+ twi_reg[j] = id[i];
+ }
+
+ // set calibration data
+ for(i = 0, j = 0x20; i < 6; i++, j++)
+ {
+ twi_reg[j] = cal_data[i];
+ }
+
+#ifdef dev_detect_port
+ // initialize device detect pin
+ dev_detect_port &= 0xFF ^ _BV(dev_detect_pin);
+ dev_detect_ddr |= _BV(dev_detect_pin);
+ _delay_ms(500); // delay to simulate disconnect
+
+ // ready twi bus, no pull-ups
+ twi_port &= 0xFF ^ _BV(twi_scl_pin);
+ twi_port &= 0xFF ^ _BV(twi_sda_pin);
+#endif
+
+ // start twi slave, link events
+ twi_slave_init(0x52);
+
+#ifdef dev_detect_port
+ // make the wiimote think something is connected
+ dev_detect_port |= _BV(dev_detect_pin);
+#endif
+}
+
+ISR(TWI_vect)
+{
+ switch(TW_STATUS)
+ {
+ // Slave Rx
+ case TW_SR_SLA_ACK: // addressed, returned ack
+ case TW_SR_GCALL_ACK: // addressed generally, returned ack
+ case TW_SR_ARB_LOST_SLA_ACK: // lost arbitration, returned ack
+ case TW_SR_ARB_LOST_GCALL_ACK: // lost arbitration generally, returned ack
+ // get ready to receive pointer
+ twi_first_addr_flag = 0;
+ // ack
+ twi_clear_int(1);
+ break;
+ case TW_SR_DATA_ACK: // data received, returned ack
+ case TW_SR_GCALL_DATA_ACK: // data received generally, returned ack
+ if(twi_first_addr_flag != 0)
+ {
+ // put byte in register
+ unsigned char t = TWDR;
+ if(twi_reg[0xF0] == 0xAA && twi_reg_addr != 0xF0) // if encryption is on
+ {
+ // decrypt
+ twi_reg[twi_reg_addr] = (t ^ wm_sb[twi_reg_addr % 8]) + wm_ft[twi_reg_addr % 8];
+ }
+ else
+ {
+ twi_reg[twi_reg_addr] = t;
+ }
+ twi_reg_addr++;
+ twi_rw_len++;
+ }
+ else
+ {
+ // set address
+ twi_reg_addr = TWDR;
+ twi_first_addr_flag = 1;
+ twi_rw_len = 0;
+ }
+ twi_clear_int(1); // ack
+ break;
+ case TW_SR_STOP: // stop or repeated start condition received
+ // run user defined function
+ wm_slaveRx(twi_reg_addr - twi_rw_len, twi_rw_len);
+ twi_clear_int(1); // ack future responses
+ break;
+ case TW_SR_DATA_NACK: // data received, returned nack
+ case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
+ twi_clear_int(0); // nack back at master
+ break;
+
+ // Slave Tx
+ case TW_ST_SLA_ACK: // addressed, returned ack
+ case TW_ST_ARB_LOST_SLA_ACK: // arbitration lost, returned ack
+ // run user defined function
+ wm_slaveTxStart(twi_reg_addr);
+ twi_rw_len = 0;
+ case TW_ST_DATA_ACK: // byte sent, ack returned
+ // ready output byte
+ if(twi_reg[0xF0] == 0xAA) // encryption is on
+ {
+ // encrypt
+ TWDR = (twi_reg[twi_reg_addr] - wm_ft[twi_reg_addr % 8]) ^ wm_sb[twi_reg_addr % 8];
+ }
+ else
+ {
+ TWDR = twi_reg[twi_reg_addr];
+ }
+ twi_reg_addr++;
+ twi_rw_len++;
+ twi_clear_int(1); // ack
+ break;
+ case TW_ST_DATA_NACK: // received nack, we are done
+ case TW_ST_LAST_DATA: // received ack, but we are done already!
+ // ack future responses
+ twi_clear_int(1);
+ break;
+ default:
+ twi_clear_int(0);
+ break;
+ }
+}
diff --git a/wiimote.h b/wiimote.h
new file mode 100644
index 0000000..26890d0
--- /dev/null
+++ b/wiimote.h
@@ -0,0 +1,20 @@
+#ifndef wiimote_h
+
+#include "defines.h"
+#include <string.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include <util/twi.h>
+#include <avr/interrupt.h>
+
+extern volatile unsigned char twi_reg[256];
+extern volatile unsigned int twi_reg_addr;
+
+// initialize wiimote interface with id, starting data, and calibration data
+void wm_init(unsigned char *, unsigned char *, void (*)(void));
+
+// set button data
+void wm_newaction(unsigned char *);
+
+#define wiimote_h
+#endif
diff --git a/wm_crypto.h b/wm_crypto.h
new file mode 100644
index 0000000..8735587
--- /dev/null
+++ b/wm_crypto.h
@@ -0,0 +1,189 @@
+#ifndef wm_crypto_h
+
+#include <avr/pgmspace.h>
+
+/*
+
+I'd like to thank Hector Martin for posting his encryption method!
+His website is http://www.marcansoft.com/
+Decryption method found at http://www.derkeiler.com/pdf/Newsgroups/sci.crypt/2008-11/msg00110.pdf
+
+*/
+
+const unsigned char ans_tbl[7][6] PROGMEM = {
+ {0xA8,0x77,0xA6,0xE0,0xF7,0x43},
+ {0x5A,0x35,0x85,0xE2,0x72,0x97},
+ {0x8F,0xB7,0x1A,0x62,0x87,0x38},
+ { 0xD,0x67,0xC7,0xBE,0x4F,0x3E},
+ {0x20,0x76,0x37,0x8F,0x68,0xB7},
+ {0xA9,0x26,0x3F,0x2B,0x10,0xE3},
+ {0x30,0x7E,0x90, 0xE,0x85, 0xA},
+};
+
+const unsigned char sboxes[10][256] PROGMEM = {
+ {
+ 0x70,0x51, 3,0x86,0x40, 0xD,0x4F,0xEB,0x3E,0xCC,0xD1,0x87,0x35,0xBD,0xF5, 0xB,
+ 0x5E,0xD0,0xF8,0xF2,0xD5,0xE2,0x6C,0x31, 0xC,0xAD,0xFC,0x21,0xC3,0x78,0xC1, 6,
+ 0xC2,0x4C,0x55,0xE6,0x4A,0x34,0x48,0x11,0x1E,0xDA,0xE7,0x1A,0x84,0xA0,0x96,0xA7,
+ 0xE3,0x7F,0xAF,0x63,0x9C,0xFA,0x23,0x5B,0x79,0xC8,0x9E,0xBA,0xB2,0xC9,0x22,0x12,
+ 0x4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