summaryrefslogtreecommitdiffstats
path: root/keyboards
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/ergodox/ez/ez.h41
-rw-r--r--keyboards/ergodox/ez/keymaps/default_80/ergodox80.pngbin0 -> 20663 bytes
-rw-r--r--keyboards/ergodox/ez/keymaps/default_80/keymap.c (renamed from keyboards/ergodox80/keymaps/default/keymap.c)8
-rw-r--r--keyboards/ergodox/ez/keymaps/default_80/readme.md10
-rw-r--r--keyboards/ergodox80/Makefile5
-rw-r--r--keyboards/ergodox80/config.h31
-rw-r--r--keyboards/ergodox80/ergodox80.c0
-rw-r--r--keyboards/ergodox80/ergodox80.h5
-rwxr-xr-xkeyboards/ergodox80/ergodox80/190hotfix.sh19
-rw-r--r--keyboards/ergodox80/ergodox80/Makefile3
-rw-r--r--keyboards/ergodox80/ergodox80/config.h65
-rw-r--r--keyboards/ergodox80/ergodox80/ergodox80.c85
-rw-r--r--keyboards/ergodox80/ergodox80/ergodox80.h122
-rw-r--r--keyboards/ergodox80/ergodox80/i2cmaster.h178
-rw-r--r--keyboards/ergodox80/ergodox80/matrix.c382
-rw-r--r--keyboards/ergodox80/ergodox80/rules.mk76
-rw-r--r--keyboards/ergodox80/ergodox80/twimaster.c208
-rw-r--r--keyboards/ergodox80/ergodox80/util/compile_keymap.py710
-rw-r--r--keyboards/ergodox80/ergodox80/util/readme.md3
-rw-r--r--keyboards/ergodox80/readme.md6
-rw-r--r--keyboards/ergodox80/rules.mk28
21 files changed, 55 insertions, 1930 deletions
diff --git a/keyboards/ergodox/ez/ez.h b/keyboards/ergodox/ez/ez.h
index db4ec867bc..124bf850e7 100644
--- a/keyboards/ergodox/ez/ez.h
+++ b/keyboards/ergodox/ez/ez.h
@@ -119,4 +119,45 @@ inline void ergodox_led_all_set(uint8_t n)
{ k0D, k1D, k2D, k3D, k4D, KC_NO } \
}
+#define KEYMAP_80( \
+ \
+ /* left hand, spatial positions */ \
+ k00,k01,k02,k03,k04,k05,k06, \
+ k10,k11,k12,k13,k14,k15,k16, \
+ k20,k21,k22,k23,k24,k25, \
+ k30,k31,k32,k33,k34,k35,k36, \
+ k40,k41,k42,k43,k44, \
+ k55,k56, \
+ k45,k46,k54, \
+ k53,k52,k51, \
+ \
+ /* right hand, spatial positions */ \
+ k07,k08,k09,k0A,k0B,k0C,k0D, \
+ k17,k18,k19,k1A,k1B,k1C,k1D, \
+ k28,k29,k2A,k2B,k2C,k2D, \
+ k37,k38,k39,k3A,k3B,k3C,k3D, \
+ k49,k4A,k4B,k4C,k4D, \
+ k57,k58, \
+ k59,k47,k48, \
+ k5C,k5B,k5A ) \
+ \
+ /* matrix positions */ \
+ { \
+ { k00, k10, k20, k30, k40, KC_NO }, \
+ { k01, k11, k21, k31, k41, k51 }, \
+ { k02, k12, k22, k32, k42, k52 }, \
+ { k03, k13, k23, k33, k43, k53 }, \
+ { k04, k14, k24, k34, k44, k54 }, \
+ { k05, k15, k25, k35, k45, k55 }, \
+ { k06, k16, KC_NO, k36, k46, k56 }, \
+ \
+ { k07, k17, KC_NO, k37, k47, k57 }, \
+ { k08, k18, k28, k38, k48, k58 }, \
+ { k09, k19, k29, k39, k49, k59 }, \
+ { k0A, k1A, k2A, k3A, k4A, k5A }, \
+ { k0B, k1B, k2B, k3B, k4B, k5B }, \
+ { k0C, k1C, k2C, k3C, k4C, k5C }, \
+ { k0D, k1D, k2D, k3D, k4D, KC_NO } \
+ }
+
#endif
diff --git a/keyboards/ergodox/ez/keymaps/default_80/ergodox80.png b/keyboards/ergodox/ez/keymaps/default_80/ergodox80.png
new file mode 100644
index 0000000000..66b9752ebc
--- /dev/null
+++ b/keyboards/ergodox/ez/keymaps/default_80/ergodox80.png
Binary files differ
diff --git a/keyboards/ergodox80/keymaps/default/keymap.c b/keyboards/ergodox/ez/keymaps/default_80/keymap.c
index 2da2c5b0e4..505ff29722 100644
--- a/keyboards/ergodox80/keymaps/default/keymap.c
+++ b/keyboards/ergodox/ez/keymaps/default_80/keymap.c
@@ -1,4 +1,4 @@
-#include "ergodox80.h"
+#include "ergodox.h"
#include "debug.h"
#include "action_layer.h"
#include "version.h"
@@ -31,7 +31,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
// If it accepts an argument (i.e, is a function), it doesn't need KC_.
// Otherwise, it needs KC_*
-[BASE] = KEYMAP( // layer 0 : default
+[BASE] = KEYMAP_80( // layer 0 : default
// left hand
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
@@ -73,7 +73,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `--------------------' `--------------------'
*/
// SYMBOLS
-[SYMB] = KEYMAP(
+[SYMB] = KEYMAP_80(
// left hand
M(0), KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS,
@@ -115,7 +115,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `--------------------' `------------------------'
*/
// MEDIA AND MOUSE
-[MDIA] = KEYMAP(
+[MDIA] = KEYMAP_80(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
diff --git a/keyboards/ergodox/ez/keymaps/default_80/readme.md b/keyboards/ergodox/ez/keymaps/default_80/readme.md
new file mode 100644
index 0000000000..b6bbb86d2c
--- /dev/null
+++ b/keyboards/ergodox/ez/keymaps/default_80/readme.md
@@ -0,0 +1,10 @@
+# ErgoDox 80 Default Configuration
+
+This is based on the default Ergodox EZ keymap.
+The difference is that this keymap supports 80 key layouts.
+If you own an 80 key Ergodox, use this as an example to get your desired keymap.
+
+**NOTE:** This layout is not physically supported by the Ergodox EZ.
+
+
+![Default80](ergodox80.png)
diff --git a/keyboards/ergodox80/Makefile b/keyboards/ergodox80/Makefile
deleted file mode 100644
index 94fa847ff8..0000000000
--- a/keyboards/ergodox80/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-SUBPROJECT_DEFAULT = ergodox80
-
-ifndef MAKEFILE_INCLUDED
- include ../../Makefile
-endif
diff --git a/keyboards/ergodox80/config.h b/keyboards/ergodox80/config.h
deleted file mode 100644
index 5dd6daa15f..0000000000
--- a/keyboards/ergodox80/config.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef KEYBOARDS_ERGODOX_CONFIG_H_
-#define KEYBOARDS_ERGODOX_CONFIG_H_
-
-#define MOUSEKEY_DELAY 100
-#define MOUSEKEY_INTERVAL 20
-#define MOUSEKEY_MAX_SPEED 3
-#define MOUSEKEY_TIME_TO_MAX 10
-
-#define TAPPING_TOGGLE 1
-
-/* define if matrix has ghost */
-//#define MATRIX_HAS_GHOST
-
-#define TAPPING_TERM 200
-#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
-
-/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
-#define LOCKING_SUPPORT_ENABLE
-/* Locking resynchronize hack */
-#define LOCKING_RESYNC_ENABLE
-
-/* key combination for command */
-#define IS_COMMAND() ( \
- keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
- keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
-)
-
-#include "ergodox80/config.h"
-
-
-#endif /* KEYBOARDS_ERGODOX_CONFIG_H_ */
diff --git a/keyboards/ergodox80/ergodox80.c b/keyboards/ergodox80/ergodox80.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/keyboards/ergodox80/ergodox80.c
+++ /dev/null
diff --git a/keyboards/ergodox80/ergodox80.h b/keyboards/ergodox80/ergodox80.h
deleted file mode 100644
index ea40f4d455..0000000000
--- a/keyboards/ergodox80/ergodox80.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef KEYBOARDS_ERGODOX_ERGODOX_H_
-#define KEYBOARDS_ERGODOX_ERGODOX_H_
-#include "ergodox80.h"
-
-#endif /* KEYBOARDS_ERGODOX_ERGODOX_H_ */
diff --git a/keyboards/ergodox80/ergodox80/190hotfix.sh b/keyboards/ergodox80/ergodox80/190hotfix.sh
deleted file mode 100755
index bdc3adce22..0000000000
--- a/keyboards/ergodox80/ergodox80/190hotfix.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-#a tool to fix broken keymaps as a result of pull request #190
-#changing the declaration of matrix_scan_user() and matrix_init_user()
-#
-#This script will save a copy of the specified keymap as keymap.c.bak
-#and then create a new keymap.c with the definion corrected.
-#this script must be run from the ergodox_ez directory
-if [ $# -ne 1 ]; then
- echo $0: usage: ./190hotfix keymap_name
- exit 1
-fi
-
-echo Saving backup as ./keymaps/$1/keymap.c.bak ...
-mv ./keymaps/$1/keymap.c ./keymaps/$1/keymap.c.bak
-
-echo Modifying ./keymaps/$1/keymap.c ...
-cat ./keymaps/$1/keymap.c.bak | sed -r 's/^void \* matrix_/void matrix_/'>./keymaps/$1/keymap.c
-
-echo Complete!
diff --git a/keyboards/ergodox80/ergodox80/Makefile b/keyboards/ergodox80/ergodox80/Makefile
deleted file mode 100644
index 191c6bb664..0000000000
--- a/keyboards/ergodox80/ergodox80/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-ifndef MAKEFILE_INCLUDED
- include ../../../Makefile
-endif \ No newline at end of file
diff --git a/keyboards/ergodox80/ergodox80/config.h b/keyboards/ergodox80/ergodox80/config.h
deleted file mode 100644
index 084a044ee1..0000000000
--- a/keyboards/ergodox80/ergodox80/config.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Copyright 2012 Jun Wako <wakojun@gmail.com>
-Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef ERGODOX_EZ_CONFIG_H
-#define ERGODOX_EZ_CONFIG_H
-
-#include "../config.h"
-
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0xFEED
-#define PRODUCT_ID 0x1307
-#define DEVICE_VER 0x0001
-#define MANUFACTURER ErgoDox EZ
-#define PRODUCT ErgoDox EZ
-#define DESCRIPTION QMK keyboard firmware for Ergodox EZ
-
-/* key matrix size */
-#define MATRIX_ROWS 14
-#define MATRIX_COLS 6
-
-/* number of backlight levels */
-#define BACKLIGHT_LEVELS 3
-
-#define LED_BRIGHTNESS_LO 15
-#define LED_BRIGHTNESS_HI 255
-
-
-/* Set 0 if debouncing isn't needed */
-#define DEBOUNCE 5
-
-/*
- * Feature disable options
- * These options are also useful to firmware size reduction.
- */
-
-/* disable debug print */
-// #define NO_DEBUG
-
-/* disable print */
-// #define NO_PRINT
-
-/* disable action features */
-//#define NO_ACTION_LAYER
-//#define NO_ACTION_TAPPING
-//#define NO_ACTION_ONESHOT
-//#define NO_ACTION_MACRO
-//#define NO_ACTION_FUNCTION
-//#define DEBUG_MATRIX_SCAN_RATE
-
-#endif
diff --git a/keyboards/ergodox80/ergodox80/ergodox80.c b/keyboards/ergodox80/ergodox80/ergodox80.c
deleted file mode 100644
index b21b1073b4..0000000000
--- a/keyboards/ergodox80/ergodox80/ergodox80.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "ergodox80.h"
-#include "i2cmaster.h"
-
-bool i2c_initialized = 0;
-uint8_t mcp23018_status = 0x20;
-
-void matrix_init_kb(void) {
- // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md")
- TCCR1A = 0b10101001; // set and configure fast PWM
- TCCR1B = 0b00001001; // set and configure fast PWM
-
- // (tied to Vcc for hardware convenience)
- DDRB &= ~(1<<4); // set B(4) as input
- PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
-
- // unused pins - C7, D4, D5, D7, E6
- // set as input with internal pull-ip enabled
- DDRC &= ~(1<<7);
- DDRD &= ~(1<<7 | 1<<5 | 1<<4);
- DDRE &= ~(1<<6);
- PORTC |= (1<<7);
- PORTD |= (1<<7 | 1<<5 | 1<<4);
- PORTE |= (1<<6);
-
- ergodox_blink_all_leds();
-
- matrix_init_user();
-}
-
-void ergodox_blink_all_leds(void)
-{
- ergodox_led_all_off();
- ergodox_led_all_set(LED_BRIGHTNESS_HI);
- ergodox_right_led_1_on();
- _delay_ms(50);
- ergodox_right_led_2_on();
- _delay_ms(50);
- ergodox_right_led_3_on();
- _delay_ms(50);
- ergodox_right_led_1_off();
- _delay_ms(50);
- ergodox_right_led_2_off();
- _delay_ms(50);
- ergodox_right_led_3_off();
- //ergodox_led_all_on();
- //_delay_ms(333);
- ergodox_led_all_off();
-}
-
-uint8_t init_mcp23018(void) {
- mcp23018_status = 0x20;
-
- // I2C subsystem
- if (i2c_initialized == 0) {
- i2c_init(); // on pins D(1,0)
- i2c_initialized++;
- _delay_ms(1000);
- }
-
- // set pin direction
- // - unused : input : 1
- // - input : input : 1
- // - driving : output : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
- i2c_stop();
-
- // set pull-up
- // - unused : on : 1
- // - input : on : 1
- // - driving : off : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
-
-out:
- i2c_stop();
-
- return mcp23018_status;
-}
-
-
diff --git a/keyboards/ergodox80/ergodox80/ergodox80.h b/keyboards/ergodox80/ergodox80/ergodox80.h
deleted file mode 100644
index 8012b0a749..0000000000
--- a/keyboards/ergodox80/ergodox80/ergodox80.h
+++ /dev/null
@@ -1,122 +0,0 @@
-#ifndef ERGODOX_EZ_H
-#define ERGODOX_EZ_H
-
-#include "quantum.h"
-#include <stdint.h>
-#include <stdbool.h>
-#include "i2cmaster.h"
-#include <util/delay.h>
-
-#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
-#define CPU_16MHz 0x00
-
-// I2C aliases and register addresses (see "mcp23018.md")
-#define I2C_ADDR 0b0100000
-#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
-#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
-#define IODIRA 0x00 // i/o direction register
-#define IODIRB 0x01
-#define GPPUA 0x0C // GPIO pull-up resistor register
-#define GPPUB 0x0D
-#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
-#define GPIOB 0x13
-#define OLATA 0x14 // output latch register
-#define OLATB 0x15
-
-extern uint8_t mcp23018_status;
-
-void init_ergodox(void);
-void ergodox_blink_all_leds(void);
-uint8_t init_mcp23018(void);
-uint8_t ergodox_left_leds_update(void);
-
-#define LED_BRIGHTNESS_LO 15
-#define LED_BRIGHTNESS_HI 255
-
-
-inline void ergodox_board_led_on(void) { DDRD |= (1<<6); PORTD |= (1<<6); }
-inline void ergodox_right_led_1_on(void) { DDRB |= (1<<5); PORTB |= (1<<5); }
-inline void ergodox_right_led_2_on(void) { DDRB |= (1<<6); PORTB |= (1<<6); }
-inline void ergodox_right_led_3_on(void) { DDRB |= (1<<7); PORTB |= (1<<7); }
-inline void ergodox_right_led_on(uint8_t led) { DDRB |= (1<<(led+4)); PORTB |= (1<<(led+4)); }
-
-inline void ergodox_board_led_off(void) { DDRD &= ~(1<<6); PORTD &= ~(1<<6); }
-inline void ergodox_right_led_1_off(void) { DDRB &= ~(1<<5); PORTB &= ~(1<<5); }
-inline void ergodox_right_led_2_off(void) { DDRB &= ~(1<<6); PORTB &= ~(1<<6); }
-inline void ergodox_right_led_3_off(void) { DDRB &= ~(1<<7); PORTB &= ~(1<<7); }
-inline void ergodox_right_led_off(uint8_t led) { DDRB &= ~(1<<(led+4)); PORTB &= ~(1<<(led+4)); }
-
-inline void ergodox_led_all_on(void)
-{
- ergodox_board_led_on();
- ergodox_right_led_1_on();
- ergodox_right_led_2_on();
- ergodox_right_led_3_on();
-}
-
-inline void ergodox_led_all_off(void)
-{
- ergodox_board_led_off();
- ergodox_right_led_1_off();
- ergodox_right_led_2_off();
- ergodox_right_led_3_off();
-}
-
-inline void ergodox_right_led_1_set(uint8_t n) { OCR1A = n; }
-inline void ergodox_right_led_2_set(uint8_t n) { OCR1B = n; }
-inline void ergodox_right_led_3_set(uint8_t n) { OCR1C = n; }
-inline void ergodox_right_led_set(uint8_t led, uint8_t n) {
- (led == 1) ? (OCR1A = n) :
- (led == 2) ? (OCR1B = n) :
- (OCR1C = n);
-}
-
-inline void ergodox_led_all_set(uint8_t n)
-{
- ergodox_right_led_1_set(n);
- ergodox_right_led_2_set(n);
- ergodox_right_led_3_set(n);
-}
-
-#define KEYMAP( \
- \
- /* left hand, spatial positions */ \
- k00,k01,k02,k03,k04,k05,k06, \
- k10,k11,k12,k13,k14,k15,k16, \
- k20,k21,k22,k23,k24,k25, \
- k30,k31,k32,k33,k34,k35,k36, \
- k40,k41,k42,k43,k44, \
- k55,k56, \
- k45,k46,k54, \
- k53,k52,k51, \
- \
- /* right hand, spatial positions */ \
- k07,k08,k09,k0A,k0B,k0C,k0D, \
- k17,k18,k19,k1A,k1B,k1C,k1D, \
- k28,k29,k2A,k2B,k2C,k2D, \
- k37,k38,k39,k3A,k3B,k3C,k3D, \
- k49,k4A,k4B,k4C,k4D, \
- k57,k58, \
- k59,k47,k48, \
- k5C,k5B,k5A ) \
- \
- /* matrix positions */ \
- { \
- { k00, k10, k20, k30, k40, KC_NO }, \
- { k01, k11, k21, k31, k41, k51 }, \
- { k02, k12, k22, k32, k42, k52 }, \
- { k03, k13, k23, k33, k43, k53 }, \
- { k04, k14, k24, k34, k44, k54 }, \
- { k05, k15, k25, k35, k45, k55 }, \
- { k06, k16, KC_NO, k36, k46, k56 }, \
- \
- { k07, k17, KC_NO, k37, k47, k57 }, \
- { k08, k18, k28, k38, k48, k58 }, \
- { k09, k19, k29, k39, k49, k59 }, \
- { k0A, k1A, k2A, k3A, k4A, k5A }, \
- { k0B, k1B, k2B, k3B, k4B, k5B }, \
- { k0C, k1C, k2C, k3C, k4C, k5C }, \
- { k0D, k1D, k2D, k3D, k4D, KC_NO } \
- }
-
-#endif
diff --git a/keyboards/ergodox80/ergodox80/i2cmaster.h b/keyboards/ergodox80/ergodox80/i2cmaster.h
deleted file mode 100644
index 3917b9e6c0..0000000000
--- a/keyboards/ergodox80/ergodox80/i2cmaster.h
+++ /dev/null
@@ -1,178 +0,0 @@
-#ifndef _I2CMASTER_H
-#define _I2CMASTER_H 1
-/*************************************************************************
-* Title: C include file for the I2C master interface
-* (i2cmaster.S or twimaster.c)
-* Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
-* File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $
-* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3
-* Target: any AVR device
-* Usage: see Doxygen manual
-**************************************************************************/
-
-#ifdef DOXYGEN
-/**
- @defgroup pfleury_ic2master I2C Master library
- @code #include <i2cmaster.h> @endcode
-
- @brief I2C (TWI) Master Software Library
-
- Basic routines for communicating with I2C slave devices. This single master
- implementation is limited to one bus master on the I2C bus.
-
- This I2c library is implemented as a compact assembler software implementation of the I2C protocol
- which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c).
- Since the API for these two implementations is exactly the same, an application can be linked either against the
- software I2C implementation or the hardware I2C implementation.
-
- Use 4.7k pull-up resistor on the SDA and SCL pin.
-
- Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module
- i2cmaster.S to your target when using the software I2C implementation !
-
- Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion.
-
- @note
- The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted
- to GNU assembler and AVR-GCC C call interface.
- Replaced the incorrect quarter period delays found in AVR300 with
- half period delays.
-
- @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
-
- @par API Usage Example
- The following code shows typical usage of this library, see example test_i2cmaster.c
-
- @code
-
- #include <i2cmaster.h>
-
-
- #define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet
-
- int main(void)
- {
- unsigned char ret;
-
- i2c_init(); // initialize I2C library
-
- // write 0x75 to EEPROM address 5 (Byte Write)
- i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode
- i2c_write(0x05); // write address = 5
- i2c_write(0x75); // write value 0x75 to EEPROM
- i2c_stop(); // set stop conditon = release bus
-
-
- // read previously written value back from EEPROM address 5
- i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode
-
- i2c_write(0x05); // write address = 5
- i2c_rep_start(Dev24C02+I2C_READ); // set device address and read mode
-
- ret = i2c_readNak(); // read one byte from EEPROM
- i2c_stop();
-
- for(;;);
- }
- @endcode
-
-*/
-#endif /* DOXYGEN */
-
-/**@{*/
-
-#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
-#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
-#endif
-
-#include <avr/io.h>
-
-/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */
-#define I2C_READ 1
-
-/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */
-#define I2C_WRITE 0
-
-
-/**
- @brief initialize the I2C master interace. Need to be called only once
- @param void
- @return none
- */
-extern void i2c_init(void);
-
-
-/**
- @brief Terminates the data transfer and releases the I2C bus
- @param void
- @return none
- */
-extern void i2c_stop(void);
-
-
-/**
- @brief Issues a start condition and sends address and transfer direction
-
- @param addr address and transfer direction of I2C device
- @retval 0 device accessible
- @retval 1 failed to access device
- */
-extern unsigned char i2c_start(unsigned char addr);
-
-
-/**
- @brief Issues a repeated start condition and sends address and transfer direction
-
- @param addr address and transfer direction of I2C device
- @retval 0 device accessible
- @retval 1 failed to access device
- */
-extern unsigned char i2c_rep_start(unsigned char addr);
-
-
-/**
- @brief Issues a start condition and sends address and transfer direction
-
- If device is busy, use ack polling to wait until device ready
- @param addr address and transfer direction of I2C device
- @return none
- */
-extern void i2c_start_wait(unsigned char addr);
-
-
-/**
- @brief Send one byte to I2C device
- @param data byte to be transfered
- @retval 0 write successful
- @retval 1 write failed
- */
-extern unsigned char i2c_write(unsigned char data);
-
-
-/**
- @brief read one byte from the I2C device, request more data from device
- @return byte read from I2C device
- */
-extern unsigned char i2c_readAck(void);
-
-/**
- @brief read one byte from the I2C device, read is followed by a stop condition
- @return byte read from I2C device
- */
-extern unsigned char i2c_readNak(void);
-
-/**
- @brief read one byte from the I2C device
-
- Implemented as a macro, which calls either i2c_readAck or i2c_readNak
-
- @param ack 1 send ack, request more data from device<br>
- 0 send nak, read is followed by a stop condition
- @return byte read from I2C device
- */
-extern unsigned char i2c_read(unsigned char ack);
-#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
-
-
-/**@}*/
-#endif
diff --git a/keyboards/ergodox80/ergodox80/matrix.c b/keyboards/ergodox80/ergodox80/matrix.c
deleted file mode 100644
index c352924b52..0000000000
--- a/keyboards/ergodox80/ergodox80/matrix.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
-
-Note for ErgoDox EZ customizers: Here be dragons!
-This is not a file you want to be messing with.
-All of the interesting stuff for you is under keymaps/ :)
-Love, Erez
-
-Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/*
- * scan matrix
- */
-#include <stdint.h>
-#include <stdbool.h>
-#include <avr/io.h>
-#include "wait.h"
-#include "action_layer.h"
-#include "print.h"
-#include "debug.h"
-#include "util.h"
-#include "matrix.h"
-#include "ergodox80.h"
-#include "i2cmaster.h"
-#ifdef DEBUG_MATRIX_SCAN_RATE
-#include "timer.h"
-#endif
-
-/*
- * This constant define not debouncing time in msecs, but amount of matrix
- * scan loops which should be made to get stable debounced results.
- *
- * On Ergodox matrix scan rate is relatively low, because of slow I2C.
- * Now it's only 317 scans/second, or about 3.15 msec/scan.
- * According to Cherry specs, debouncing time is 5 msec.
- *
- * And so, there is no sense to have DEBOUNCE higher than 2.
- */
-
-#ifndef DEBOUNCE
-# define DEBOUNCE 5
-#endif
-static uint8_t debouncing = DEBOUNCE;
-
-/* matrix state(1:on, 0:off) */
-static matrix_row_t matrix[MATRIX_ROWS];
-static matrix_row_t matrix_debouncing[MATRIX_ROWS];
-
-static matrix_row_t read_cols(uint8_t row);
-static void init_cols(void);
-static void unselect_rows(void);
-static void select_row(uint8_t row);
-
-static uint8_t mcp23018_reset_loop;
-
-#ifdef DEBUG_MATRIX_SCAN_RATE
-uint32_t matrix_timer;
-uint32_t matrix_scan_count;
-#endif
-
-
-__attribute__ ((weak))
-void matrix_init_user(void) {}
-
-__attribute__ ((weak))
-void matrix_scan_user(void) {}
-
-__attribute__ ((weak))
-void matrix_init_kb(void) {
- matrix_init_user();
-}
-
-__attribute__ ((weak))
-void matrix_scan_kb(void) {
- matrix_scan_user();
-}
-
-inline
-uint8_t matrix_rows(void)
-{
- return MATRIX_ROWS;
-}
-
-inline
-uint8_t matrix_cols(void)
-{
- return MATRIX_COLS;
-}
-
-void matrix_init(void)
-{
- // initialize row and col
-
- mcp23018_status = init_mcp23018();
-
-
- unselect_rows();
- init_cols();
-
- // initialize matrix state: all keys off
- for (uint8_t i=0; i < MATRIX_ROWS; i++) {
- matrix[i] = 0;
- matrix_debouncing[i] = 0;
- }
-
-#ifdef DEBUG_MATRIX_SCAN_RATE
- matrix_timer = timer_read32();
- matrix_scan_count = 0;
-#endif
-
- matrix_init_kb();
-
-}
-
-void matrix_power_up(void) {
- mcp23018_status = init_mcp23018();
-
- unselect_rows();
- init_cols();
-
- // initialize matrix state: all keys off
- for (uint8_t i=0; i < MATRIX_ROWS; i++) {
- matrix[i] = 0;
- matrix_debouncing[i] = 0;
- }
-
-#ifdef DEBUG_MATRIX_SCAN_RATE
- matrix_timer = timer_read32();
- matrix_scan_count = 0;
-#endif
-
-}
-
-uint8_t matrix_scan(void)
-{
- if (mcp23018_status) { // if there was an error
- if (++mcp23018_reset_loop == 0) {
- // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
- // this will be approx bit more frequent than once per second
- print("trying to reset mcp23018\n");
- mcp23018_status = init_mcp23018();
- if (mcp23018_status) {
- print("left side not responding\n");
- } else {
- print("left side attached\n");
- ergodox_blink_all_leds();
- }
- }
- }
-
-#ifdef DEBUG_MATRIX_SCAN_RATE
- matrix_scan_count++;
-
- uint32_t timer_now = timer_read32();
- if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
- print("matrix scan frequency: ");
- pdec(matrix_scan_count);
- print("\n");
-
- matrix_timer = timer_now;
- matrix_scan_count = 0;
- }
-#endif
-
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- select_row(i);
- wait_us(30); // without this wait read unstable value.
- matrix_row_t cols = read_cols(i);
- if (matrix_debouncing[i] != cols) {
- matrix_debouncing[i] = cols;
- if (debouncing) {
- debug("bounce!: "); debug_hex(debouncing); debug("\n");
- }
- debouncing = DEBOUNCE;
- }
- unselect_rows();
- }
-
- if (debouncing) {
- if (--debouncing) {
- wait_us(1);
- // this should be wait_ms(1) but has been left as-is at EZ's request
- } else {
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- matrix[i] = matrix_debouncing[i];
- }
- }
- }
-
- matrix_scan_quantum();
-
- return 1;
-}
-
-bool matrix_is_modified(void)
-{
- if (debouncing) return false;
- return true;
-}
-
-inline
-bool matrix_is_on(uint8_t row, uint8_t col)
-{
- return (matrix[row] & ((matrix_row_t)1<<col));
-}
-
-inline
-matrix_row_t matrix_get_row(uint8_t row)
-{
- return matrix[row];
-}
-
-void matrix_print(void)
-{
- print("\nr/c 0123456789ABCDEF\n");
- for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- phex(row); print(": ");
- pbin_reverse16(matrix_get_row(row));
- print("\n");
- }
-}
-
-uint8_t matrix_key_count(void)
-{
- uint8_t count = 0;
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {