diff options
author | Jason <jagor@microsoft.com> | 2018-06-05 12:43:20 -0700 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2018-06-05 12:43:20 -0700 |
commit | 96546c79c0e931c89e4ac60a154b669925d5d34d (patch) | |
tree | 82577992a3c9fcb312b8872016a5bae40b36ceb2 | |
parent | 1ae011d91902c8a12e23ee5f1f934ac5a0238b87 (diff) | |
download | qmk_firmware-96546c79c0e931c89e4ac60a154b669925d5d34d.tar.gz qmk_firmware-96546c79c0e931c89e4ac60a154b669925d5d34d.zip |
Adding SX60 work by amnobis and configurator settings (#3122)
* Add SX60
* Add config maps and layouts as well as readmes.
* cleanup and fixes
* correct readme
* add missing closing commenty tag
* Changing includes to QMK_KEYBOARD_H
* Update settings.json
Remove config change that was added automatically by vscode.
* Update readme.md
fix readme formatting
-rw-r--r-- | keyboards/e6v2/keymaps/amnesia0287/keymap.c | 22 | ||||
-rw-r--r-- | keyboards/e6v2/keymaps/amnesia0287/readme.md | 2 | ||||
-rw-r--r-- | keyboards/e6v2/keymaps/default/readme.md | 2 | ||||
-rw-r--r-- | keyboards/e6v2/readme.md | 2 | ||||
-rwxr-xr-x | keyboards/sx60/config.h | 61 | ||||
-rw-r--r-- | keyboards/sx60/i2cmaster.h | 178 | ||||
-rw-r--r-- | keyboards/sx60/info.json | 24 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/amnobis/config.h | 1 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/amnobis/keymap.c | 92 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/amnobis/readme.md | 8 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/amnobis/rules.mk | 0 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/default/config.h | 1 | ||||
-rwxr-xr-x | keyboards/sx60/keymaps/default/keymap.c | 25 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/default/readme.md | 8 | ||||
-rw-r--r-- | keyboards/sx60/keymaps/default/rules.mk | 0 | ||||
-rw-r--r-- | keyboards/sx60/matrix.c | 307 | ||||
-rw-r--r-- | keyboards/sx60/readme.md | 20 | ||||
-rwxr-xr-x | keyboards/sx60/rules.mk | 61 | ||||
-rwxr-xr-x | keyboards/sx60/sx60.c | 38 | ||||
-rwxr-xr-x | keyboards/sx60/sx60.h | 86 | ||||
-rw-r--r-- | keyboards/sx60/twimaster.c | 207 |
21 files changed, 1131 insertions, 14 deletions
diff --git a/keyboards/e6v2/keymaps/amnesia0287/keymap.c b/keyboards/e6v2/keymaps/amnesia0287/keymap.c index 625ddb74a..7e64b1212 100644 --- a/keyboards/e6v2/keymaps/amnesia0287/keymap.c +++ b/keyboards/e6v2/keymaps/amnesia0287/keymap.c | |||
@@ -25,24 +25,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
25 | ), | 25 | ), |
26 | [_HLa] = LAYOUT_hhkb( | 26 | [_HLa] = LAYOUT_hhkb( |
27 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, | 27 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, |
28 | KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_TRNS, | 28 | KC_CAPS, KC_TRNS, KC_VOLU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_TRNS, |
29 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_TRNS, | 29 | KC_TRNS, KC_TRNS, KC_VOLD, KC_TRNS, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_TRNS, |
30 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, | 30 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, |
31 | KC_TRNS, KC_TRNS, KC_MPLY, KC_TRNS, KC_TRNS | 31 | KC_TRNS, KC_TRNS, KC_MPLY, KC_TRNS, KC_TRNS |
32 | ), | 32 | ), |
33 | [_HLb] = LAYOUT_hhkb( | 33 | [_HLb] = LAYOUT_hhkb( |
34 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, | 34 | KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, |
35 | KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_TRNS, | 35 | KC_CAPS, KC_TRNS, KC_VOLU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_TRNS, |
36 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_TRNS, | 36 | KC_TRNS, KC_TRNS, KC_VOLD, KC_TRNS, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_TRNS, |
37 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, | 37 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, |
38 | KC_TRNS, KC_TRNS, KC_MPLY, KC_TRNS, KC_TRNS | 38 | KC_TRNS, KC_TRNS, KC_MPLY, KC_TRNS, KC_TRNS |
39 | ), | 39 | ), |
40 | [_HL] = LAYOUT_hhkb( | 40 | [_HL] = LAYOUT_hhkb( |
41 | RGB_TOG, RGB_M_P, RGB_RMOD, RGB_MOD, KC_TRNS, KC_TRNS, KC_TRNS, BL_BRTG, BL_OFF, BL_STEP, BL_ON, BL_DEC, BL_INC, LALT(KC_F4), | 41 | RGB_TOG, RGB_M_P, RGB_RMOD, RGB_MOD, KC_TRNS, KC_TRNS, KC_TRNS, BL_BRTG, BL_OFF, BL_STEP, BL_ON, BL_DEC, BL_INC, LALT(KC_F4), |
42 | RESET, RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | 42 | RESET, RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, |
43 | KC_TRNS, RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | 43 | KC_TRNS, RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, |
44 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | 44 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, |
45 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS | 45 | KC_MPRV, KC_MNXT, KC_MPLY, KC_TRNS, KC_TRNS |
46 | ), | 46 | ), |
47 | }; | 47 | }; |
48 | 48 | ||
diff --git a/keyboards/e6v2/keymaps/amnesia0287/readme.md b/keyboards/e6v2/keymaps/amnesia0287/readme.md index 834604ce2..4cc97aef0 100644 --- a/keyboards/e6v2/keymaps/amnesia0287/readme.md +++ b/keyboards/e6v2/keymaps/amnesia0287/readme.md | |||
@@ -1,7 +1,7 @@ | |||
1 | amnesia0287's Keymap | 1 | amnesia0287's Keymap |
2 | === | 2 | === |
3 | 3 | ||
4 | Keymap Maintainer: [Jason Gorman](https://github.com/amnesia0287) | 4 | Keymap Maintainer: [amnesia0287](https://github.com/amnesia0287) |
5 | 5 | ||
6 | Difference from base layout: Primarily the HHKB-ness | 6 | Difference from base layout: Primarily the HHKB-ness |
7 | 7 | ||
diff --git a/keyboards/e6v2/keymaps/default/readme.md b/keyboards/e6v2/keymaps/default/readme.md index 02153cb0d..e72647364 100644 --- a/keyboards/e6v2/keymaps/default/readme.md +++ b/keyboards/e6v2/keymaps/default/readme.md | |||
@@ -3,6 +3,6 @@ Default Keymap | |||
3 | 3 | ||
4 | Super simple default keymap with only a base layer. | 4 | Super simple default keymap with only a base layer. |
5 | 5 | ||
6 | Keymap Maintainer: [Jason Gorman](https://github.com/amnesia0287) | 6 | Keymap Maintainer: [amnesia0287](https://github.com/amnesia0287) |
7 | 7 | ||
8 | Intended usage: This is mostly provided for testing before you build your own keymap and as a reference to a stock(ish) configuration | 8 | Intended usage: This is mostly provided for testing before you build your own keymap and as a reference to a stock(ish) configuration |
diff --git a/keyboards/e6v2/readme.md b/keyboards/e6v2/readme.md index 725c264ca..5fd9668f5 100644 --- a/keyboards/e6v2/readme.md +++ b/keyboards/e6v2/readme.md | |||
@@ -3,7 +3,7 @@ E6-V2 | |||
3 | 3 | ||
4 | These docs are for the QMK version of the PCB. [More info on qmk.fm](http://qmk.fm/) | 4 | These docs are for the QMK version of the PCB. [More info on qmk.fm](http://qmk.fm/) |
5 | 5 | ||
6 | Keyboard Maintainer: [Jason Gorman](https://github.com/amnesia0287) | 6 | Keyboard Maintainer: [amnesia0287](https://github.com/amnesia0287) |
7 | Hardware Supported: E6-V2 Mid Port rev.qmk | 7 | Hardware Supported: E6-V2 Mid Port rev.qmk |
8 | Hardware Availability: [geekhack.org/index.php?topic=90787.0](https://geekhack.org/index.php?topic=90787.0) | 8 | Hardware Availability: [geekhack.org/index.php?topic=90787.0](https://geekhack.org/index.php?topic=90787.0) |
9 | 9 | ||
diff --git a/keyboards/sx60/config.h b/keyboards/sx60/config.h new file mode 100755 index 000000000..f22fbe8be --- /dev/null +++ b/keyboards/sx60/config.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #ifndef CONFIG_H | ||
2 | #define CONFIG_H | ||
3 | |||
4 | #include "config_common.h" | ||
5 | |||
6 | /* USB Device descriptor parameter */ | ||
7 | #define VENDOR_ID 0xFEED | ||
8 | #define PRODUCT_ID 0x6060 | ||
9 | #define DEVICE_VER 0x0001 | ||
10 | #define MANUFACTURER qmkbuilder | ||
11 | #define PRODUCT keyboard | ||
12 | #define DESCRIPTION Keyboard | ||
13 | |||
14 | /* key matrix size */ | ||
15 | #define MATRIX_ROWS 5 | ||
16 | #define MATRIX_COLS 16 | ||
17 | #define ATMEGA_COLS 8 | ||
18 | |||
19 | /* key matrix pins */ | ||
20 | #define MATRIX_ROW_PINS { B1, B2, B3, C6, B6 } | ||
21 | #define MATRIX_COL_PINS { F6, B5, B4, D7, D6, D5, D3, D2 } | ||
22 | #define UNUSED_PINS | ||
23 | |||
24 | |||
25 | |||
26 | /* COL2ROW or ROW2COL */ | ||
27 | #define DIODE_DIRECTION COL2ROW | ||
28 | |||
29 | /* number of backlight levels */ | ||
30 | #define BACKLIGHT_PIN B7 | ||
31 | #ifdef BACKLIGHT_PIN | ||
32 | #define BACKLIGHT_LEVELS 3 | ||
33 | #endif | ||
34 | |||
35 | /* Set 0 if debouncing isn't needed */ | ||
36 | #define DEBOUNCING_DELAY 5 | ||
37 | |||
38 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
39 | #define LOCKING_SUPPORT_ENABLE | ||
40 | |||
41 | /* Locking resynchronize hack */ | ||
42 | #define LOCKING_RESYNC_ENABLE | ||
43 | |||
44 | /* key combination for command */ | ||
45 | #define IS_COMMAND() ( \ | ||
46 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
47 | ) | ||
48 | |||
49 | /* prevent stuck modifiers */ | ||
50 | #define PREVENT_STUCK_MODIFIERS | ||
51 | |||
52 | |||
53 | #ifdef RGB_DI_PIN | ||
54 | #define RGBLIGHT_ANIMATIONS | ||
55 | #define RGBLED_NUM 0 | ||
56 | #define RGBLIGHT_HUE_STEP 8 | ||
57 | #define RGBLIGHT_SAT_STEP 8 | ||
58 | #define RGBLIGHT_VAL_STEP 8 | ||
59 | #endif | ||
60 | |||
61 | #endif | ||
diff --git a/keyboards/sx60/i2cmaster.h b/keyboards/sx60/i2cmaster.h new file mode 100644 index 000000000..3917b9e6c --- /dev/null +++ b/keyboards/sx60/i2cmaster.h | |||
@@ -0,0 +1,178 @@ | |||
1 | #ifndef _I2CMASTER_H | ||
2 | #define _I2CMASTER_H 1 | ||
3 | /************************************************************************* | ||
4 | * Title: C include file for the I2C master interface | ||
5 | * (i2cmaster.S or twimaster.c) | ||
6 | * Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury | ||
7 | * File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $ | ||
8 | * Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 | ||
9 | * Target: any AVR device | ||
10 | * Usage: see Doxygen manual | ||
11 | **************************************************************************/ | ||
12 | |||
13 | #ifdef DOXYGEN | ||
14 | /** | ||
15 | @defgroup pfleury_ic2master I2C Master library | ||
16 | @code #include <i2cmaster.h> @endcode | ||
17 | |||
18 | @brief I2C (TWI) Master Software Library | ||
19 | |||
20 | Basic routines for communicating with I2C slave devices. This single master | ||
21 | implementation is limited to one bus master on the I2C bus. | ||
22 | |||
23 | This I2c library is implemented as a compact assembler software implementation of the I2C protocol | ||
24 | which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c). | ||
25 | Since the API for these two implementations is exactly the same, an application can be linked either against the | ||
26 | software I2C implementation or the hardware I2C implementation. | ||
27 | |||
28 | Use 4.7k pull-up resistor on the SDA and SCL pin. | ||
29 | |||
30 | Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module | ||
31 | i2cmaster.S to your target when using the software I2C implementation ! | ||
32 | |||
33 | Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion. | ||
34 | |||
35 | @note | ||
36 | The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted | ||
37 | to GNU assembler and AVR-GCC C call interface. | ||
38 | Replaced the incorrect quarter period delays found in AVR300 with | ||
39 | half period delays. | ||
40 | |||
41 | @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury | ||
42 | |||
43 | @par API Usage Example | ||
44 | The following code shows typical usage of this library, see example test_i2cmaster.c | ||
45 | |||
46 | @code | ||
47 | |||
48 | #include <i2cmaster.h> | ||
49 | |||
50 | |||
51 | #define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet | ||
52 | |||
53 | int main(void) | ||
54 | { | ||
55 | unsigned char ret; | ||
56 | |||
57 | i2c_init(); // initialize I2C library | ||
58 | |||
59 | // write 0x75 to EEPROM address 5 (Byte Write) | ||
60 | i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode | ||
61 | i2c_write(0x05); // write address = 5 | ||
62 | i2c_write(0x75); // write value 0x75 to EEPROM | ||
63 | i2c_stop(); // set stop conditon = release bus | ||
64 | |||
65 | |||
66 | // read previously written value back from EEPROM address 5 | ||
67 | i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode | ||
68 | |||
69 | i2c_write(0x05); // write address = 5 | ||
70 | i2c_rep_start(Dev24C02+I2C_READ); // set device address and read mode | ||
71 | |||
72 | ret = i2c_readNak(); // read one byte from EEPROM | ||
73 | i2c_stop(); | ||
74 | |||
75 | for(;;); | ||
76 | } | ||
77 | @endcode | ||
78 | |||
79 | */ | ||
80 | #endif /* DOXYGEN */ | ||
81 | |||
82 | /**@{*/ | ||
83 | |||
84 | #if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 | ||
85 | #error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" | ||
86 | #endif | ||
87 | |||
88 | #include <avr/io.h> | ||
89 | |||
90 | /** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */ | ||
91 | #define I2C_READ 1 | ||
92 | |||
93 | /** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */ | ||
94 | #define I2C_WRITE 0 | ||
95 | |||
96 | |||
97 | /** | ||
98 | @brief initialize the I2C master interace. Need to be called only once | ||
99 | @param void | ||
100 | @return none | ||
101 | */ | ||
102 | extern void i2c_init(void); | ||
103 | |||
104 | |||
105 | /** | ||
106 | @brief Terminates the data transfer and releases the I2C bus | ||
107 | @param void | ||
108 | @return none | ||
109 | */ | ||
110 | extern void i2c_stop(void); | ||
111 | |||
112 | |||
113 | /** | ||
114 | @brief Issues a start condition and sends address and transfer direction | ||
115 | |||
116 | @param addr address and transfer direction of I2C device | ||
117 | @retval 0 device accessible | ||
118 | @retval 1 failed to access device | ||
119 | */ | ||
120 | extern unsigned char i2c_start(unsigned char addr); | ||
121 | |||
122 | |||
123 | /** | ||
124 | @brief Issues a repeated start condition and sends address and transfer direction | ||
125 | |||
126 | @param addr address and transfer direction of I2C device | ||
127 | @retval 0 device accessible | ||
128 | @retval 1 failed to access device | ||
129 | */ | ||
130 | extern unsigned char i2c_rep_start(unsigned char addr); | ||
131 | |||
132 | |||
133 | /** | ||
134 | @brief Issues a start condition and sends address and transfer direction | ||
135 | |||
136 | If device is busy, use ack polling to wait until device ready | ||
137 | @param addr address and transfer direction of I2C device | ||
138 | @return none | ||
139 | */ | ||
140 | extern void i2c_start_wait(unsigned char addr); | ||
141 | |||
142 | |||
143 | /** | ||
144 | @brief Send one byte to I2C device | ||
145 | @param data byte to be transfered | ||
146 | @retval 0 write successful | ||
147 | @retval 1 write failed | ||
148 | */ | ||
149 | extern unsigned char i2c_write(unsigned char data); | ||
150 | |||
151 | |||
152 | /** | ||
153 | @brief read one byte from the I2C device, request more data from device | ||
154 | @return byte read from I2C device | ||
155 | */ | ||
156 | extern unsigned char i2c_readAck(void); | ||
157 | |||
158 | /** | ||
159 | @brief read one byte from the I2C device, read is followed by a stop condition | ||
160 | @return byte read from I2C device | ||
161 | */ | ||
162 | extern unsigned char i2c_readNak(void); | ||
163 | |||
164 | /** | ||
165 | @brief read one byte from the I2C device | ||
166 | |||
167 | Implemented as a macro, which calls either i2c_readAck or i2c_readNak | ||
168 | |||
169 | @param ack 1 send ack, request more data from device<br> | ||
170 | 0 send nak, read is followed by a stop condition | ||
171 | @return byte read from I2C device | ||
172 | */ | ||
173 | extern unsigned char i2c_read(unsigned char ack); | ||
174 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); | ||
175 | |||
176 | |||
177 | /**@}*/ | ||
178 | #endif | ||
diff --git a/keyboards/sx60/info.json b/keyboards/sx60/info.json new file mode 100644 index 000000000..24cb42772 --- /dev/null +++ b/keyboards/sx60/info.json | |||
@@ -0,0 +1,24 @@ | |||
1 | { | ||
2 | "keyboard_name": "SX60", | ||
3 | "url": "", | ||
4 | "maintainer": "https://github.com/amnobis", | ||
5 | "width": 16.25, | ||
6 | "height": 5, | ||
7 | "layouts": { | ||
8 | "LAYOUT": { | ||
9 | "layout": [{"label":"Esc", "x":1.25, "y":0}, {"label":"1!", "x":2.25, "y":0}, {"label":"2@", "x":3.25, "y":0}, {"label":"3#", "x":4.25, "y":0}, {"label":"4$", "x":5.25, "y":0}, {"label":"5%", "x":6.25, "y":0}, {"label":"6^", "x":7.25, "y":0}, {"label":"7&", "x":9.25, "y":0}, {"label":"8*", "x":10.25, "y":0}, {"label":"9(", "x":11.25, "y":0}, {"label":"0)", "x":12.25, "y":0}, {"label":"-_", "x":13.25, "y":0}, {"label":"=+", "x":14.25, "y":0}, {"label":"\\|", "x":15.25, "y":0, "w":1}, {"label":"`~", "x":16.25, "y":0, "w":1}, {"label":"M1", "x":0, "y":1, "w":1}, {"label":"Tab", "x":1.25, "y":1, "w":1.5}, {"label":"Q", "x":2.75, "y":1}, {"label":"W", "x":3.75, "y":1}, {"label":"E", "x":4.75, "y":1}, {"label":"R", "x":5.75, "y":1}, {"label":"T", "x":6.75, "y":1}, {"label":"Y", "x":7.75, "y":1}, {"label":"U", "x":8.75, "y":1}, {"label":"I", "x":9.75, "y":1}, {"label":"O", "x":10.75, "y":1}, {"label":"P", "x":11.75, "y":1}, {"label":"{", "x":12.75, "y":1}, {"label":"}", "x":13.75, "y":1}, {"label":"Backspace", "x":15.75, "y":1, "w":1.5}, {"label":"M2", "x":0, "y":2, "w":1}, {"label":"Caps Lock", "x":1.25, "y":2, "w":1.75}, {"label":"A", "x":3, "y":2}, {"label":"S", "x":4, "y":2}, {"label":"D", "x":5, "y":2}, {"label":"F", "x":6, "y":2}, {"label":"G", "x":7, "y":2}, {"label":"H", "x":9, "y":2}, {"label":"J", "x":10, "y":2}, {"label":"K", "x":11, "y":2}, {"label":"L", "x":12, "y":2}, {"label":":", "x":13, "y":2}, {"label":"\"", "x":14, "y":2}, {"label":"ANSIEnter", "x":15, "y":2, "w":1}, {"label":"ISOEnter", "x":16, "y":2, "w":1.25}, {"label":"M3", "x":0, "y":3, "w":1}, {"label":"Shift", "x":1.25, "y":3, "w":1.25}, {"label":"\\|", "x":2.5, "y":3, "w":1}, {"label":"Z", "x":3.5, "y":3}, {"label":"X", "x":4.5, "y":3}, {"label":"C", "x":5.5, "y":3}, {"label":"V", "x":6.5, "y":3}, {"label":"B", "x":7.5, "y":3}, {"label":"N", "x":9.5, "y":3}, {"label":"M", "x":1.5, "y":3}, {"label":"<", "x":11.5, "y":3}, {"label":">", "x":12.5, "y":3}, {"label":"?", "x":13.5, "y":3}, {"label":"Shift", "x":14.5, "y":3, "w":1.75}, {"label":"Fn", "x":16.25, "y":3, "w":1}, {"label":"M4", "x":0, "y":4, "w":1}, {"label":"Ctrl", "x":1.25, "y":4, "w":1.25}, {"label":"Win", "x":2.5, "y":4, "w":1.25}, {"label":"Alt", "x":3.75, "y":4, "w":1.25}, {"x":5, "y":4, "w":2}, {"x":7, "y":4, "w":1}, {"x":9, "y":4, "w":2.75}, {"label":"Alt", "x":11.75, "y":4, "w":1.25}, {"label":"Win", "x":13, "y":4, "w":1.25}, {"label":"Menu", "x":14.25, "y":4, "w":1}, {"label":"Ctrl", "x":15.25, "y":4, "w":1}, {"label":"Fn2", "x":16.25, "y":4, "w":1}] | ||
10 | }, | ||
11 | |||
12 | "LAYOUT_ansi_split_bs_rshift": { | ||
13 | "layout": [{"label":"Esc", "x":1.25, "y":0}, {"label":"1!", "x":2.25, "y":0}, {"label":"2@", "x":3.25, "y":0}, {"label":"3#", "x":4.25, "y":0}, {"label":"4$", "x":5.25, "y":0}, {"label":"5%", "x":6.25, "y":0}, {"label":"6^", "x":7.25, "y":0}, {"label":"7&", "x":9.25, "y":0}, {"label":"8*", "x":10.25, "y":0}, {"label":"9(", "x":11.25, "y":0}, {"label":"0)", "x":12.25, "y":0}, {"label":"-_", "x":13.25, "y":0}, {"label":"=+", "x":14.25, "y":0}, {"label":"\\|", "x":15.25, "y":0, "w":1}, {"label":"`~", "x":16.25, "y":0, "w":1}, {"label":"M1", "x":0, "y":1, "w":1}, {"label":"Tab", "x":1.25, "y":1, "w":1.5}, {"label":"Q", "x":2.75, "y":1}, {"label":"W", "x":3.75, "y":1}, {"label":"E", "x":4.75, "y":1}, {"label":"R", "x":5.75, "y":1}, {"label":"T", "x":6.75, "y":1}, {"label":"Y", "x":7.75, "y":1}, {"label":"U", "x":8.75, "y":1}, {"label":"I", "x":9.75, "y":1}, {"label":"O", "x":10.75, "y":1}, {"label":"P", "x":11.75, "y":1}, {"label":"{", "x":12.75, "y":1}, {"label":"}", "x":13.75, "y":1}, {"label":"Backspace", "x":15.75, "y":1, "w":1.5}, {"label":"M2", "x":0, "y":2, "w":1}, {"label":"Caps Lock", "x":1.25, "y":2, "w":1.75}, {"label":"A", "x":3, "y":2}, {"label":"S", "x":4, "y":2}, {"label":"D", "x":5, "y":2}, {"label":"F", "x":6, "y":2}, {"label":"G", "x":7, "y":2}, {"label":"H", "x":9, "y":2}, {"label":"J", "x":10, "y":2}, {"label":"K", "x":11, "y":2}, {"label":"L", "x":12, "y":2}, {"label":":", "x":13, "y":2}, {"label":"\"", "x":14, "y":2}, {"label":"Enter", "x":15, "y":2, "w":2.25}, {"label":"M3", "x":0, "y":3, "w":1}, {"label":"Shift", "x":1.25, "y":3, "w":2.25}, {"label":"Z", "x":3.5, "y":3}, {"label":"X", "x":4.5, "y":3}, {"label":"C", "x":5.5, "y":3}, {"label":"V", "x":6.5, "y":3}, {"label":"B", "x":7.5, "y":3}, {"label":"N", "x":9.5, "y":3}, {"label":"M", "x":1.5, "y":3}, {"label":"<", "x":11.5, "y":3}, {"label":">", "x":12.5, "y":3}, {"label":"?", "x":13.5, "y":3}, {"label":"Shift", "x":14.5, "y":3, "w":1.75}, {"label":"Fn", "x":16.25, "y":3, "w":1}, {"label":"M4", "x":0, "y":4, "w":1}, {"label":"Ctrl", "x":1.25, "y":4, "w":1.25}, {"label":"Win", "x":2.5, "y":4, "w":1.25}, {"label":"Alt", "x":3.75, "y":4, "w":1.25}, {"x":5, "y":4, "w":2}, {"x":7, "y":4, "w":1}, {"x":9, "y":4, "w":2.75}, {"label":"Alt", "x":11.75, "y":4, "w":1.25}, {"label":"Win", "x":13, "y":4, "w":1.25}, {"label":"Menu", "x":14.25, "y":4, "w":1}, {"label":"Ctrl", "x":15.25, "y":4, "w":1}, {"label":"Fn2", "x":16.25, "y":4, "w":1}] | ||
14 | }, | ||
15 | |||
16 | "LAYOUT_ansi_split_bs": { | ||
17 | "layout": [{"label":"Esc", "x":1.25, "y":0}, {"label":"1!", "x":2.25, "y":0}, {"label":"2@", "x":3.25, "y":0}, {"label":"3#", "x":4.25, "y":0}, {"label":"4$", "x":5.25, "y":0}, {"label":"5%", "x":6.25, "y":0}, {"label":"6^", "x":7.25, "y":0}, {"label":"7&", "x":9.25, "y":0}, {"label":"8*", "x":10.25, "y":0}, {"label":"9(", "x":11.25, "y":0}, {"label":"0)", "x":12.25, "y":0}, {"label":"-_", "x":13.25, "y":0}, {"label":"=+", "x":14.25, "y":0}, {"label":"\\|", "x":15.25, "y":0, "w":1}, {"label":"`~", "x":16.25, "y":0, "w":1}, {"label":"M1", "x":0, "y":1, "w":1}, {"label":"Tab", "x":1.25, "y":1, "w":1.5}, {"label":"Q", "x":2.75, "y":1}, {"label":"W", "x":3.75, "y":1}, {"label":"E", "x":4.75, "y":1}, {"label":"R", "x":5.75, "y":1}, {"label":"T", "x":6.75, "y":1}, {"label":"Y", "x":7.75, "y":1}, {"label":"U", "x":8.75, "y":1}, {"label":"I", "x":9.75, "y":1}, {"label":"O", "x":10.75, "y":1}, {"label":"P", "x":11.75, "y":1}, {"label":"{", "x":12.75, "y":1}, {"label":"}", "x":13.75, "y":1}, {"label":"Backspace", "x":15.75, "y":1, "w":1.5}, {"label":"M2", "x":0, "y":2, "w":1}, {"label":"Caps Lock", "x":1.25, "y":2, "w":1.75}, {"label":"A", "x":3, "y":2}, {"label":"S", "x":4, "y":2}, {"label":"D", "x":5, "y":2}, {"label":"F", "x":6, "y":2}, {"label":"G", "x":7, "y":2}, {"label":"H", "x":9, "y":2}, {"label":"J", "x":10, "y":2}, {"label":"K", "x":11, "y":2}, {"label":"L", "x":12, "y":2}, {"label":":", "x":13, "y":2}, {"label":"\"", "x":14, "y":2}, {"label":"Enter", "x":15, "y":2, "w":2.25}, {"label":"M3", "x":0, "y":3, "w":1}, {"label":"Shift", "x":1.25, "y":3, "w":2.25}, {"label":"Z", "x":3.5, "y":3}, {"label":"X", "x":4.5, "y":3}, {"label":"C", "x":5.5, "y":3}, {"label":"V", "x":6.5, "y":3}, {"label":"B", "x":7.5, "y":3}, {"label":"N", "x":9.5, "y":3}, {"label":"M", "x":1.5, "y":3}, {"label":"<", "x":11.5, "y":3}, {"label":">", "x":12.5, "y":3}, {"label":"?", "x":13.5, "y":3}, {"label":"Shift", "x":14.5, "y":3, "w":2.75}, {"label":"M4", "x":0, "y":4, "w":1}, {"label":"Ctrl", "x":1.25, "y":4, "w":1.25}, {"label":"Win", "x":2.5, "y":4, "w":1.25}, {"label":"Alt", "x":3.75, "y":4, "w":1.25}, {"x":5, "y":4, "w":2}, {"x":7, "y":4, "w":1}, {"x":9, "y":4, "w":2.75}, {"label":"Alt", "x":11.75, "y":4, "w":1.25}, {"label":"Win", "x":13, "y":4, "w":1.25}, {"label":"Menu", "x":14.25, "y":4, "w":1}, {"label":"Ctrl", "x":15.25, "y":4, "w":1}, {"label":"Fn", "x":16.25, "y":4, "w":1}] | ||
18 | }, | ||
19 | |||
20 | "LAYOUT_ansi_split_rshift": { | ||
21 | "layout": [{"label":"Esc", "x":1.25, "y":0}, {"label":"1!", "x":2.25, "y":0}, {"label":"2@", "x":3.25, "y":0}, {"label":"3#", "x":4.25, "y":0}, {"label":"4$", "x":5.25, "y":0}, {"label":"5%", "x":6.25, "y":0}, {"label":"6^", "x":7.25, "y":0}, {"label":"7&", "x":9.25, "y":0}, {"label":"8*", "x":10.25, "y":0}, {"label":"9(", "x":11.25, "y":0}, {"label":"0)", "x":12.25, "y":0}, {"label":"-_", "x":13.25, "y":0}, {"label":"=+", "x":14.25, "y":0}, {"label":"Backspace", "x":15.25, "y":0, "w":2}, {"label":"M1", "x":0, "y":1, "w":1}, {"label":"Tab", "x":1.25, "y":1, "w":1.5}, {"label":"Q", "x":2.75, "y":1}, {"label":"W", "x":3.75, "y":1}, {"label":"E", "x":4.75, "y":1}, {"label":"R", "x":5.75, "y":1}, {"label":"T", "x":6.75, "y":1}, {"label":"Y", "x":7.75, "y":1}, {"label":"U", "x":8.75, "y":1}, {"label":"I", "x":9.75, "y":1}, {"label":"O", "x":10.75, "y":1}, {"label":"P", "x":11.75, "y":1}, {"label":"{", "x":12.75, "y":1}, {"label":"}", "x":13.75, "y":1}, {"label":"\\|", "x":15.75, "y":1, "w":1.5}, {"label":"M2", "x":0, "y":2, "w":1}, {"label":"Caps Lock", "x":1.25, "y":2, "w":1.75}, {"label":"A", "x":3, "y":2}, {"label":"S", "x":4, "y":2}, {"label":"D", "x":5, "y":2}, {"label":"F", "x":6, "y":2}, {"label":"G", "x":7, "y":2}, {"label":"H", "x":9, "y":2}, {"label":"J", "x":10, "y":2}, {"label":"K", "x":11, "y":2}, {"label":"L", "x":12, "y":2}, {"label":":", "x":13, "y":2}, {"label":"\"", "x":14, "y":2}, {"label":"Enter", "x":15, "y":2, "w":2.25}, {"label":"M3", "x":0, "y":3, "w":1}, {"label":"Shift", "x":1.25, "y":3, "w":2.25}, {"label":"Z", "x":3.5, "y":3}, {"label":"X", "x":4.5, "y":3}, {"label":"C", "x":5.5, "y":3}, {"label":"V", "x":6.5, "y":3}, {"label":"B", "x":7.5, "y":3}, {"label":"N", "x":9.5, "y":3}, {"label":"M", "x":1.5, "y":3}, {"label":"<", "x":11.5, "y":3}, {"label":">", "x":12.5, "y":3}, {"label":"?", "x":13.5, "y":3}, {"label":"Shift", "x":14.5, "y":3, "w":1.75}, {"label":"Fn", "x":16.25, "y":3, "w":1}, {"label":"M4", "x":0, "y":4, "w":1}, {"label":"Ctrl", "x":1.25, "y":4, "w":1.25}, {"label":"Win", "x":2.5, "y":4, "w":1.25}, {"label":"Alt", "x":3.75, "y":4, "w":1.25}, {"x":5, "y":4, "w":2}, {"x":7, "y":4, "w":1}, {"x":9, "y":4, "w":2.75}, {"label":"Alt", "x":11.75, "y":4, "w":1.25}, {"label":"Win", "x":13, "y":4, "w":1.25}, {"label":"Menu", "x":14.25, "y":4, "w":1}, {"label":"Ctrl", "x":15.25, "y":4, "w":1}, {"label":"Fn2", "x":16.25, "y":4, "w":1}] | ||
22 | }, | ||
23 | } | ||
24 | } | ||
diff --git a/keyboards/sx60/keymaps/amnobis/config.h b/keyboards/sx60/keymaps/amnobis/config.h new file mode 100644 index 000000000..a5568e400 --- /dev/null +++ b/keyboards/sx60/keymaps/amnobis/config.h | |||
@@ -0,0 +1 @@ | |||
#include "../../config.h" | |||
diff --git a/keyboards/sx60/keymaps/amnobis/keymap.c b/keyboards/sx60/keymaps/amnobis/keymap.c new file mode 100644 index 000000000..1fcfa3d42 --- /dev/null +++ b/keyboards/sx60/keymaps/amnobis/keymap.c | |||
@@ -0,0 +1,92 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | |||
3 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
4 | |||
5 | LAYOUT_ansi_split_bs_rshift( | ||
6 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_ESC, | ||
7 | KC_SPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, | ||
8 | KC_SPC, MO(1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, | ||
9 | KC_SPC, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, KC_UP, | ||
10 | KC_SPC, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_LALT, KC_LCTL, KC_LEFT, KC_DOWN, KC_RGHT ), | ||
11 | |||
12 | LAYOUT_ansi_split_bs_rshift( | ||
13 | RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
14 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
15 | KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_LPRN, KC_RPRN, KC_GRV, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS, KC_TRNS, KC_TRNS, | ||
16 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
17 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
18 | |||
19 | LAYOUT_ansi_split_bs_rshift( | ||
20 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
21 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
22 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
23 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
24 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
25 | |||
26 | LAYOUT_ansi_split_bs_rshift( | ||
27 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
28 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
29 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
30 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
31 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
32 | |||
33 | LAYOUT_ansi_split_bs_rshift( | ||
34 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
35 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
36 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
37 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
38 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
39 | |||
40 | LAYOUT_ansi_split_bs_rshift( | ||
41 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
42 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
43 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
44 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
45 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
46 | |||
47 | LAYOUT_ansi_split_bs_rshift( | ||
48 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
49 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
50 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
51 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
52 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
53 | |||
54 | LAYOUT_ansi_split_bs_rshift( | ||
55 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
56 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
57 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
58 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
59 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
60 | |||
61 | LAYOUT_ansi_split_bs_rshift( | ||
62 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
63 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
64 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
65 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
66 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
67 | |||
68 | LAYOUT_ansi_split_bs_rshift( | ||
69 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
70 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
71 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
72 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
73 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
74 | |||
75 | LAYOUT_ansi_split_bs_rshift( | ||
76 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
77 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
78 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
79 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
80 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), | ||
81 | |||
82 | }; | ||
83 | |||
84 | void matrix_init_user(void) { | ||
85 | } | ||
86 | |||
87 | void matrix_scan_user(void) { | ||
88 | } | ||
89 | |||
90 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
91 | return true; | ||
92 | } | ||
diff --git a/keyboards/sx60/keymaps/amnobis/readme.md b/keyboards/sx60/keymaps/amnobis/readme.md new file mode 100644 index 000000000..207d24180 --- /dev/null +++ b/keyboards/sx60/keymaps/amnobis/readme.md | |||
@@ -0,0 +1,8 @@ | |||
1 | Default Keymap | ||
2 | === | ||
3 | |||
4 | Super simple default keymap. | ||
5 | |||
6 | Keymap Maintainer: [amnobis](https://github.com/amnobis) | ||
7 | |||
8 | Intended usage: This is mostly provided for testing before you build your own keymap and as a reference to a stock(ish) configuration | ||
diff --git a/keyboards/sx60/keymaps/amnobis/rules.mk b/keyboards/sx60/keymaps/amnobis/rules.mk new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/sx60/keymaps/amnobis/rules.mk | |||
diff --git a/keyboards/sx60/keymaps/default/config.h b/keyboards/sx60/keymaps/default/config.h new file mode 100644 index 000000000..a5568e400 --- /dev/null +++ b/keyboards/sx60/keymaps/default/config.h | |||
@@ -0,0 +1 @@ | |||
#include "../../config.h" | |||
diff --git a/keyboards/sx60/keymaps/default/keymap.c b/keyboards/sx60/keymaps/default/keymap.c new file mode 100755 index 000000000..942e8ef8e --- /dev/null +++ b/keyboards/sx60/keymaps/default/keymap.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | |||
3 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
4 | [0] = LAYOUT_ansi_split_bs_rshift( KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, | ||
5 | KC_HOME, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, | ||
6 | KC_PGUP, KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, | ||
7 | KC_PGDN, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, KC_UP, | ||
8 | KC_END, KC_LCTL, KC_LGUI, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), | ||
9 | |||
10 | [1] = LAYOUT_ansi_split_bs_rshift( RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
11 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
12 | KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_LPRN, KC_RPRN, KC_GRV, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS, KC_TRNS, KC_TRNS, | ||
13 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
14 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), | ||
15 | }; | ||
16 | |||
17 | void matrix_init_user(void) { | ||
18 | } | ||
19 | |||
20 | void matrix_scan_user(void) { | ||
21 | } | ||
22 | |||
23 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
24 | return true; | ||
25 | } | ||
diff --git a/keyboards/sx60/keymaps/default/readme.md b/keyboards/sx60/keymaps/default/readme.md new file mode 100644 index 000000000..898fb84a2 --- /dev/null +++ b/keyboards/sx60/keymaps/default/readme.md | |||
@@ -0,0 +1,8 @@ | |||
1 | Default Keymap | ||
2 | === | ||
3 | |||
4 | Super simple default keymap with only a base layer. | ||
5 | |||
6 | Keymap Maintainer: [amnobis](https://github.com/amnobis) | ||
7 | |||
8 | Intended usage: This is mostly provided for testing before you build your own keymap and as a reference to a stock(ish) configuration | ||
diff --git a/keyboards/sx60/keymaps/default/rules.mk b/keyboards/sx60/keymaps/default/rules.mk new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/sx60/keymaps/default/rules.mk | |||
diff --git a/keyboards/sx60/matrix.c b/keyboards/sx60/matrix.c new file mode 100644 index 000000000..e91b4f441 --- /dev/null +++ b/keyboards/sx60/matrix.c | |||
@@ -0,0 +1,307 @@ | |||
1 | /* | ||
2 | Copyright 2012-2017 Jun Wako, Jack Humbert | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | #include <stdint.h> | ||
18 | #include <stdbool.h> | ||
19 | #if defined(__AVR__) | ||
20 | #include <avr/io.h> | ||
21 | #endif | ||
22 | #include "wait.h" | ||
23 | #include "print.h" | ||
24 | #include "debug.h" | ||
25 | #include "util.h" | ||
26 | #include "matrix.h" | ||
27 | #include "timer.h" | ||
28 | #include "sx60.h" | ||
29 | |||
30 | |||
31 | /* Set 0 if debouncing isn't needed */ | ||
32 | |||
33 | #ifndef DEBOUNCING_DELAY | ||
34 | # define DEBOUNCING_DELAY 5 | ||
35 | #endif | ||
36 | |||
37 | #if (DEBOUNCING_DELAY > 0) | ||
38 | static uint16_t debouncing_time; | ||
39 | static bool debouncing = false; | ||
40 | #endif | ||
41 | |||
42 | #if (MATRIX_COLS <= 8) | ||
43 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
44 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
45 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
46 | # define ROW_SHIFTER ((uint8_t)1) | ||
47 | #elif (MATRIX_COLS <= 16) | ||
48 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | ||
49 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | ||
50 | # define matrix_bitpop(i) bitpop16(matrix[i]) | ||
51 | # define ROW_SHIFTER ((uint16_t)1) | ||
52 | #elif (MATRIX_COLS <= 32) | ||
53 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | ||
54 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | ||
55 | # define matrix_bitpop(i) bitpop32(matrix[i]) | ||
56 | # define ROW_SHIFTER ((uint32_t)1) | ||
57 | #endif | ||
58 | |||
59 | #ifdef MATRIX_MASKED | ||
60 | extern const matrix_row_t matrix_mask[]; | ||
61 | #endif | ||
62 | |||
63 | static const uint8_t col_pins[ATMEGA_COLS] = MATRIX_COL_PINS; | ||
64 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
65 | |||
66 | /* matrix state(1:on, 0:off) */ | ||
67 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
68 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
69 | static uint8_t mcp23018_reset_loop; | ||
70 | |||
71 | |||
72 | static void init_cols(void); | ||
73 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
74 | static void unselect_rows(void); | ||
75 | static void select_row(uint8_t row); | ||
76 | |||
77 | __attribute__ ((weak)) | ||
78 | void matrix_init_quantum(void) { | ||
79 | matrix_init_kb(); | ||
80 | } | ||
81 | |||
82 | __attribute__ ((weak)) | ||
83 | void matrix_scan_quantum(void) { | ||
84 | matrix_scan_kb(); | ||
85 | } | ||
86 | |||
87 | __attribute__ ((weak)) | ||
88 | void matrix_init_kb(void) { | ||
89 | matrix_init_user(); | ||
90 | } | ||
91 | |||
92 | __attribute__ ((weak)) | ||
93 | void matrix_scan_kb(void) { | ||
94 | matrix_scan_user(); | ||
95 | } | ||
96 | |||
97 | __attribute__ ((weak)) | ||
98 | void matrix_init_user(void) { | ||
99 | } | ||
100 | |||
101 | __attribute__ ((weak)) | ||
102 | void matrix_scan_user(void) { | ||
103 | } | ||
104 | |||
105 | inline | ||
106 | uint8_t matrix_rows(void) { | ||
107 | return MATRIX_ROWS; | ||
108 | } | ||
109 | |||
110 | inline | ||
111 | uint8_t matrix_cols(void) { | ||
112 | return MATRIX_COLS; | ||
113 | } | ||
114 | |||
115 | void matrix_init(void) { | ||
116 | |||
117 | /* To use PORTF disable JTAG with writing JTD bit twice within four cycles. */ | ||
118 | #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__)) | ||
119 | MCUCR |= _BV(JTD); | ||
120 | MCUCR |= _BV(JTD); | ||
121 | #endif | ||
122 | |||
123 | mcp23018_status = true; | ||
124 | |||
125 | /* initialize row and col */ | ||
126 | unselect_rows(); | ||
127 | init_cols(); | ||
128 | |||
129 | /* initialize matrix state: all keys off */ | ||
130 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
131 | matrix[i] = 0; | ||
132 | matrix_debouncing[i] = 0; | ||
133 | } | ||
134 | |||
135 | matrix_init_quantum(); | ||
136 | } | ||
137 | |||
138 | uint8_t matrix_scan(void) | ||
139 | { | ||
140 | if (mcp23018_status) { | ||
141 | /* if there was an error */ | ||
142 | if (++mcp23018_reset_loop == 0) { | ||
143 | /* since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans | ||
144 | this will be approx bit more frequent than once per second */ | ||
145 | print("trying to reset mcp23018\n"); | ||
146 | mcp23018_status = init_mcp23018(); | ||
147 | if (mcp23018_status) { | ||
148 | print("left side not responding\n"); | ||
149 | } else { | ||
150 | print("left side attached\n"); | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /* Set row, read cols */ | ||
156 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
157 | # if (DEBOUNCING_DELAY > 0) | ||
158 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
159 | |||
160 | if (matrix_changed) { | ||
161 | debouncing = true; | ||
162 | debouncing_time = timer_read(); | ||
163 | } | ||
164 | # else | ||
165 | read_cols_on_row(matrix, current_row); | ||
166 | # endif | ||
167 | } | ||
168 | |||
169 | # if (DEBOUNCING_DELAY > 0) | ||
170 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
171 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
172 | matrix[i] = matrix_debouncing[i]; | ||
173 | } | ||
174 | debouncing = false; | ||
175 | } | ||
176 | # endif | ||
177 | |||
178 | matrix_scan_quantum(); | ||
179 | return 1; | ||
180 | } | ||
181 | |||
182 | bool matrix_is_modified(void) | ||
183 | { | ||
184 | #if (DEBOUNCING_DELAY > 0) | ||
185 | if (debouncing) return false; | ||
186 | #endif | ||
187 | return true; | ||
188 | } | ||
189 | |||
190 | inline | ||
191 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
192 | { | ||
193 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
194 | } | ||
195 | |||
196 | inline | ||
197 | matrix_row_t matrix_get_row(uint8_t row) | ||
198 | { | ||
199 | /* Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | ||
200 | switch blocker installed and the switch is always pressed. */ | ||
201 | #ifdef MATRIX_MASKED | ||
202 | return matrix[row] & matrix_mask[row]; | ||
203 | #else | ||
204 | return matrix[row]; | ||
205 | #endif | ||
206 | } | ||
207 | |||
208 | void matrix_print(void) | ||
209 | { | ||
210 | print_matrix_header(); | ||
211 | |||
212 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
213 | phex(row); print(": "); | ||
214 | print_matrix_row(row); | ||
215 | print("\n"); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | uint8_t matrix_key_count(void) | ||
220 | { | ||
221 | uint8_t count = 0; | ||
222 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
223 | count += matrix_bitpop(i); | ||
224 | } | ||
225 | return count; | ||
226 | } | ||
227 | |||
228 | static void init_cols(void) | ||
229 | { | ||
230 | for(uint8_t x = 0; x < ATMEGA_COLS; x++) { | ||
231 | uint8_t pin = col_pins[x]; | ||
232 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); /* IN */ | ||
233 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); /* HI */ | ||
234 | } | ||
235 | } | ||
236 | |||
237 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
238 | { | ||
239 | /* Store last value of row prior to reading */ | ||
240 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
241 | |||
242 | /* Clear data in matrix row */ | ||
243 | current_matrix[current_row] = 0; | ||
244 | |||
245 | /* Select row and wait for row selecton to stabilize */ | ||
246 | select_row(current_row); | ||
247 | wait_us(30); | ||
248 | |||
249 | if (mcp23018_status) { | ||
250 | /* if there was an error */ | ||
251 | return 0; | ||
252 | } else { | ||
253 | uint16_t data = 0; | ||
254 | mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; | ||
255 | mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out; | ||
256 | mcp23018_status = i2c_start(I2C_ADDR_READ); if (mcp23018_status) goto out; | ||
257 | data = i2c_readNak(); | ||
258 | data = ~data; | ||
259 | out: | ||
260 | i2c_stop(); | ||
261 | current_matrix[current_row] |= (data << 8); | ||
262 | } | ||
263 | |||
264 | /* For each col... */ | ||
265 | for(uint8_t col_index = 0; col_index < ATMEGA_COLS; col_index++) { | ||
266 | /* Select the col pin to read (active low) */ | ||
267 | uint8_t pin = col_pins[col_index]; | ||
268 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
269 | |||
270 | /* Populate the matrix row with the state of the col pin */ | ||
271 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
272 | } | ||
273 | |||
274 | /* Unselect row */ | ||
275 | unselect_rows(); | ||
276 | |||
277 | return (last_row_value != current_matrix[current_row]); | ||
278 | } | ||
279 | |||
280 | static void select_row(uint8_t row) | ||
281 | { | ||
282 | if (mcp23018_status) { | ||
283 | /* if there was an error do nothing */ | ||
284 | } else { | ||
285 | /* set active row low : 0 | ||
286 | set active row output : 1 | ||
287 | set other rows hi-Z : 1 */ | ||
288 | mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; | ||
289 | mcp23018_status = i2c_write(GPIOB); if (mcp23018_status) goto out; | ||
290 | mcp23018_status = i2c_write(0xFF & ~(1<<abs(row-4))); if (mcp23018_status) goto out; | ||
291 | out: | ||
292 | i2c_stop(); | ||
293 | } | ||
294 | |||
295 | uint8_t pin = row_pins[row]; | ||
296 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); /* OUT */ | ||
297 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); /* LOW */ | ||
298 | } | ||
299 | |||
300 | static void unselect_rows(void) | ||
301 | { | ||
302 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
303 | uint8_t pin = row_pins[x]; | ||
304 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); /* IN */ | ||
305 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); /* HI */ | ||
306 | } | ||
307 | } | ||
diff --git a/keyboards/sx60/readme.md b/keyboards/sx60/readme.md new file mode 100644 index 000000000..40f33ada2 --- /dev/null +++ b/keyboards/sx60/readme.md | |||
@@ -0,0 +1,20 @@ | |||
1 | SX60 | ||
2 | === | ||
3 | |||
4 | |||
5 |  | ||
6 | |||
7 | |||
8 | Keyboard Maintainer: [amnobis](https://github.com/amnobis) | ||
9 | Hardware Supported: SX60 | ||
10 | Hardware Availability: [geekhack.org/index.php?topic=93665.0](https://geekhack.org/index.php?topic=93665.0) | ||
11 | |||
12 | Make example for this keyboard (after setting up your build environment): | ||
13 | |||
14 | make SX60:default | ||
15 | |||
16 | Or to make and flash: | ||
17 | |||
18 | make SX60:default:dfu | ||
19 | |||
20 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
diff --git a/keyboards/sx60/rules.mk b/keyboards/sx60/rules.mk new file mode 100755 index 000000000..0381293ce --- /dev/null +++ b/keyboards/sx60/rules.mk | |||
@@ -0,0 +1,61 @@ | |||
1 | # # project specific files | ||
2 | SRC = twimaster.c \ | ||
3 | matrix.c | ||
4 | |||
5 | # MCU name | ||
6 | MCU = atmega32u4 | ||
7 | |||
8 | # Processor frequency. | ||
9 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
10 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
11 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
12 | # automatically to create a 32-bit value in your source code. | ||
13 | # | ||
14 | # This will be an integer division of F_USB below, as it is sourced by | ||
15 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
16 | # does not *change* the processor frequency - it should merely be updated to | ||
17 | # reflect the processor speed set externally so that the code can use accurate | ||
18 | # software delays. | ||
19 | F_CPU = 16000000 | ||
20 | |||
21 | # | ||
22 | # LUFA specific | ||
23 | # | ||
24 | # Target architecture (see library "Board Types" documentation). | ||
25 | ARCH = AVR8 | ||
26 | |||
27 | # Input clock frequency. | ||
28 | # This will define a symbol, F_USB, in all source code files equal to the | ||
29 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
30 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
31 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
32 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
33 | # at the end, this will be done automatically to create a 32-bit value in your | ||
34 | # source code. | ||
35 | # | ||
36 | # If no clock division is performed on the input clock inside the AVR (via the | ||
37 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
38 | F_USB = $(F_CPU) | ||
39 | |||
40 | # Interrupt driven control endpoint task(+60) | ||
41 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
42 | |||
43 | |||
44 | # Boot Section Size in *bytes* | ||
45 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
46 | |||
47 | |||
48 | # Build Options | ||
49 | # comment out to disable the options. | ||
50 | # | ||
51 | BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000) | ||
52 | MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) | ||
53 | EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) | ||
54 | CONSOLE_ENABLE ?= no # Console for debug(+400) | ||
55 | COMMAND_ENABLE ?= no # Commands for debug and configuration | ||
56 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | ||
57 | NKRO_ENABLE ?= yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
58 | BACKLIGHT_ENABLE ?= yes # Enable keyboard backlight functionality | ||
59 | AUDIO_ENABLE ?= no | ||
60 | RGBLIGHT_ENABLE ?= no | ||
61 | CUSTOM_MATRIX ?= yes | ||
diff --git a/keyboards/sx60/sx60.c b/keyboards/sx60/sx60.c new file mode 100755 index 000000000..ede8c07e9 --- /dev/null +++ b/keyboards/sx60/sx60.c | |||
@@ -0,0 +1,38 @@ | |||
1 | #include "sx60.h" | ||
2 | #include "i2cmaster.h" | ||
3 | |||
4 | |||
5 | bool i2c_initialized = 0; | ||
6 | uint8_t mcp23018_status = 0x20; | ||
7 | |||
8 | uint8_t init_mcp23018(void) { | ||
9 | mcp23018_status = 0x20; | ||
10 | |||
11 | /* I2C subsystem */ | ||
12 | |||
13 | if (i2c_initialized == 0) { | ||
14 | i2c_init(); // on pins D(1,0) | ||
15 | i2c_initialized = true; | ||
16 | _delay_ms(1000); | ||
17 | } | ||
18 | |||
19 | /* B Pins are Row, A pins are Columns | ||
20 | Set them to output */ | ||
21 | mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; | ||
22 | mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out; | ||
23 | mcp23018_status = i2c_write(0b11111111); if (mcp23018_status) goto out; | ||
24 | /* Now write to IODIRB */ | ||
25 | mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; | ||
26 | i2c_stop(); | ||
27 | |||
28 | mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; | ||
29 | mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out; | ||
30 | mcp23018_status = i2c_write(0b11111111); if (mcp23018_status) goto out; | ||
31 | /* Now write to GPPUB */ | ||
32 | mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; | ||
33 | |||
34 | out: | ||
35 | i2c_stop(); | ||
36 | |||
37 | return mcp23018_status; | ||
38 | } | ||
diff --git a/keyboards/sx60/sx60.h b/keyboards/sx60/sx60.h new file mode 100755 index 000000000..e5a68ef2f --- /dev/null +++ b/keyboards/sx60/sx60.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #ifndef SX60_H | ||
2 | #define SX60_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | #include <stdint.h> | ||
6 | #include <stdbool.h> | ||
7 | #include "i2cmaster.h" | ||
8 | #include <util/delay.h> | ||
9 | |||
10 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) | ||
11 | #define CPU_16MHz 0x00 | ||
12 | |||
13 | /* I2C aliases and register addresses (see "mcp23018.md") */ | ||
14 | #define I2C_ADDR 0b0100000 | ||
15 | #define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE ) | ||
16 | #define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ ) | ||
17 | #define IODIRA 0x00 /* i/o direction register */ | ||
18 | #define IODIRB 0x01 | ||
19 | #define GPPUA 0x0C /* GPIO pull-up resistor register */ | ||
20 | #define GPPUB 0x0D | ||
21 | #define GPIOA 0x12 /* general purpose i/o port register (write modifies OLAT) */ | ||
22 | #define GPIOB 0x13 | ||
23 | #define OLATA 0x14 /* output latch register */ | ||
24 | #define OLATB 0x15 | ||
25 | |||
26 | extern uint8_t mcp23018_status; | ||
27 | |||
28 | uint8_t init_mcp23018(void); | ||
29 | |||
30 | #define LAYOUT( \ | ||
31 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, K14, \ | ||
32 | K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \ | ||
33 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K40, K41, K42, K43, K44, \ | ||
34 | K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, K57, K58, K59, \ | ||
35 | K60, K61, K62, K63, K64, K65, K66, K67, K68, K69, K70, K71 \ | ||
36 | ) { \ | ||
37 | { K00, K01, K02, K03, K04, K05, K06, KC_NO, K07, K08, K09, K10, K11, K12, K13, K14 }, \ | ||
38 | { K15, K16, K17, K18, K19, K20, K21, KC_NO, K22, K23, K24, K25, K26, K27, K28, K29 }, \ | ||
39 | { K30, K31, K32, K33, K34, K35, K36, KC_NO, K37, K38, K39, K40, K41, K42, K43, K44 }, \ | ||
40 | { K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, K57, K58, K59, K59 }, \ | ||
41 | { K60, K61, K62, K63, K64, K65, KC_NO, KC_NO, K66, K67, K68, K69, K70, K71, KC_NO, KC_NO } \ | ||
42 | } | ||
43 | |||
44 | #define LAYOUT_ansi_split_bs_rshift( \ | ||
45 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, K14, \ | ||
46 | K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \ | ||
47 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K40, K41, K42, K43, \ | ||
48 | K44, K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, K57, \ | ||
49 | K58, K59, K60, K61, K62, K63, K64, K65, K66, K67, K68, K69 \ | ||
50 | ) { \ | ||
51 | { K00, K01, K02, K03, K04, K05, K06, KC_NO, K07, K08, K09, K10, K11, K12, K13, K14 }, \ | ||
52 | { K15, K16, K17, K18, K19, K20, K21, KC_NO, K22, K23, K24, K25, K26, K27, K28, K29 }, \ | ||
53 | { K30, K31, K32, K33, K34, K35, K36, KC_NO, K37, K38, K39, K40, K41, K42, K43, KC_NO }, \ | ||
54 | { K44, K45, KC_NO, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, K57, K57 }, \ | ||
55 | { K58, K59, K60, K61, K62, K63, KC_NO, KC_NO, K64, K65, K66, K67, K68, K69, KC_NO, KC_NO } \ | ||
56 | } | ||
57 | |||
58 | #define LAYOUT_ansi_split_bs( \ | ||
59 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, K14, \ | ||
60 | K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \ | ||
61 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K40, K41, K42, K43, \ | ||
62 | K44, K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, \ | ||
63 | K57, K58, K59, K60, K61, K62, K63, K64, K65, K66, K67, K68 \ | ||
64 | ) { \ | ||
65 | { K00, K01, K02, K03, K04, K05, K06, KC_NO, K07, K08, K09, K10, K11, K12, K13, K14 }, \ | ||
66 | { K15, K16, K17, K18, K19, K20, K21, KC_NO, K22, K23, K24, K25, K26, K27, K28, K29 }, \ | ||
67 | { K30, K31, K32, K33, K34, K35, K36, KC_NO, K37, K38, K39, K40, K41, K42, K43, KC_NO }, \ | ||
68 | { K44, K45, KC_NO, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, KC_NO, KC_NO }, \ | ||
69 | { K57, K58, K59, K60, K61, K62, KC_NO, KC_NO, K63, K64, K65, K66, K67, K68, KC_NO, KC_NO } \ | ||
70 | } | ||
71 | |||
72 | #define LAYOUT_ansi_split_rshift( \ | ||
73 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, \ | ||
74 | K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, K26, K27, K28, \ | ||
75 | K29, K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K40, K41, K42, \ | ||
76 | K43, K44, K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, \ | ||
77 | K57, K58, K59, K60, K61, K62, K63, K64, K65, K66, K67, K68 \ | ||
78 | ) { \ | ||
79 | { K00, K01, K02, K03, K04, K05, K06, KC_NO, K07, K08, K09, K10, K11, K12, K13, K13 }, \ | ||
80 | { K14, K15, K16, K17, K18, K19, K20, KC_NO, K21, K22, K23, K24, K25, K26, K27, K28 }, \ | ||
81 | { K29, K30, K31, K32, K33, K34, K35, KC_NO, K36, K37, K38, K39, K40, K41, K42, KC_NO }, \ | ||
82 | { K43, K44, KC_NO, K45, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, K56 }, \ | ||
83 | { K57, K58, K59, K60, K61, K62, KC_NO, KC_NO, K63, K64, K65, K66, K67, K68, KC_NO, KC_NO } \ | ||
84 | } | ||
85 | |||
86 | #endif | ||
diff --git a/keyboards/sx60/twimaster.c b/keyboards/sx60/twimaster.c new file mode 100644 index 000000000..30d8c24bf --- /dev/null +++ b/keyboards/sx60/twimaster.c | |||
@@ -0,0 +1,207 @@ | |||
1 | /************************************************************************* | ||
2 | * Title: I2C master library using hardware TWI interface | ||
3 | * Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury | ||
4 | * File: $Id: twimaster.c,v 1.3 2005/07/02 11:14:21 Peter Exp $ | ||
5 | * Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 | ||
6 | * Target: any AVR device with hardware TWI | ||
7 | * Usage: API compatible with I2C Software Library i2cmaster.h | ||
8 | **************************************************************************/ | ||
9 | #include <inttypes.h> | ||
10 | #include <compat/twi.h> | ||
11 | |||
12 | #include <i2cmaster.h> | ||
13 | |||
14 | /* define CPU frequency in Hz here if not defined in Makefile */ | ||
15 | #ifndef F_CPU | ||
16 | #define F_CPU 16000000UL | ||
17 | #endif | ||
18 | |||
19 | /* I2C clock in Hz */ | ||
20 | #define SCL_CLOCK 400000L | ||
21 | |||
22 | |||
23 | /************************************************************************* | ||
24 | Initialization of the I2C bus interface. Need to be called only once | ||
25 | *************************************************************************/ | ||
26 | void i2c_init(void) | ||
27 | { | ||
28 | /* initialize TWI clock | ||
29 | * minimal values in Bit Rate Register (TWBR) and minimal Prescaler | ||
30 | * bits in the TWI Status Register should give us maximal possible | ||
31 | * I2C bus speed - about 444 kHz | ||
32 | * | ||
33 | * for more details, see 20.5.2 in ATmega16/32 secification | ||
34 | */ | ||
35 | |||
36 | TWSR = 0; /* no prescaler */ | ||
37 | TWBR = 10; /* must be >= 10 for stable operation */ | ||
38 | |||
39 | }/* i2c_init */ | ||
40 | |||
41 | |||
42 | /************************************************************************* | ||
43 | Issues a start condition and sends address and transfer direction. | ||
44 | return 0 = device accessible, 1= failed to access device | ||
45 | *************************************************************************/ | ||
46 | unsigned char i2c_start(unsigned char address) | ||
47 | { | ||
48 | uint8_t twst; | ||
49 | |||
50 | /* send START condition */ | ||
51 | TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); | ||
52 | |||
53 | /* wait until transmission completed */ | ||
54 | while(!(TWCR & (1<<TWINT))); | ||
55 | |||
56 | /* check value of TWI Status Register. Mask prescaler bits. */ | ||
57 | twst = TW_STATUS & 0xF8; | ||
58 | if ( (twst != TW_START) && (twst != TW_REP_START)) return 1; | ||
59 | |||
60 | /* send device address */ | ||
61 | TWDR = address; | ||
62 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
63 | |||
64 | /* wail until transmission completed and ACK/NACK has been received */ | ||
65 | while(!(TWCR & (1<<TWINT))); | ||
66 | |||
67 | /* check value of TWI Status Register. Mask prescaler bits. */ | ||
68 | twst = TW_STATUS & 0xF8; | ||
69 | if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1; | ||
70 | |||
71 | return 0; | ||
72 | |||
73 | }/* i2c_start */ | ||
74 | |||
75 | |||
76 | /************************************************************************* | ||
77 | Issues a start condition and sends address and transfer direction. | ||
78 | If device is busy, use ack polling to wait until device is ready | ||
79 | |||
80 | Input: address and transfer direction of I2C device | ||
81 | *************************************************************************/ | ||
82 | void i2c_start_wait(unsigned char address) | ||
83 | { | ||
84 | uint8_t twst; | ||
85 | |||
86 | |||
87 | while ( 1 ) | ||
88 | { | ||
89 | /* send START condition */ | ||
90 | TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); | ||
91 | |||
92 | /* wait until transmission completed */ | ||
93 | while(!(TWCR & (1<<TWINT))); | ||
94 | |||
95 | /* check value of TWI Status Register. Mask prescaler bits. */ | ||
96 | twst = TW_STATUS & 0xF8; | ||
97 | if ( (twst != TW_START) && (twst != TW_REP_START)) continue; | ||
98 | |||
99 | /* send device address */ | ||
100 | TWDR = address; | ||
101 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
102 | |||
103 | /* wail until transmission completed */ | ||
104 | while(!(TWCR & (1<<TWINT))); | ||
105 | |||
106 | /* check value of TWI Status Register. Mask prescaler bits. */ | ||
107 | twst = TW_STATUS & 0xF8; | ||
108 | if ( (twst == TW_MT_SLA_NACK )||(twst ==TW_MR_DATA_NACK) ) | ||
109 | { | ||
110 | /* device busy, send stop condition to terminate write operation */ | ||
111 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
112 | |||
113 | /* wait until stop condition is executed and bus released */ | ||
114 | while(TWCR & (1<<TWSTO)); | ||
115 | |||
116 | continue; | ||
117 | } | ||
118 | |||
119 | break; | ||
120 | } | ||
121 | |||
122 | }/* i2c_start_wait */ | ||
123 | |||
124 | |||
125 | /************************************************************************* | ||
126 | Issues a repeated start condition and sends address and transfer direction | ||
127 | |||
128 | Input: address and transfer direction of I2C device | ||
129 | |||
130 | Return: 0 device accessible | ||
131 | 1 failed to access device | ||
132 | *************************************************************************/ | ||
133 | unsigned char i2c_rep_start(unsigned char address) | ||
134 | { | ||
135 | return i2c_start( address ); | ||
136 | |||
137 | }/* i2c_rep_start */ | ||
138 | |||
139 | |||
140 | /************************************************************************* | ||
141 | Terminates the data transfer and releases the I2C bus | ||
142 | *************************************************************************/ | ||
143 | void i2c_stop(void) | ||
144 | { | ||
145 | /* send stop condition */ | ||
146 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
147 | |||
148 | /* wait until stop condition is executed and bus released */ | ||
149 | while(TWCR & (1<<TWSTO)); | ||
150 | |||
151 | }/* i2c_stop */ | ||
152 | |||
153 | |||
154 | /************************************************************************* | ||
155 | Send one byte to I2C device | ||
156 | |||
157 | Input: byte to be transfered | ||
158 | Return: 0 write successful | ||
159 | 1 write failed | ||
160 | *************************************************************************/ | ||
161 | unsigned char i2c_write( unsigned char data ) | ||
162 | { | ||
163 | uint8_t twst; | ||
164 | |||
165 | /* send data to the previously addressed device */ | ||
166 | TWDR = data; | ||
167 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
168 | |||
169 | /* wait until transmission completed */ | ||
170 | while(!(TWCR & (1<<TWINT))); | ||
171 | |||
172 | /* check value of TWI Status Register. Mask prescaler bits */ | ||
173 | twst = TW_STATUS & 0xF8; | ||
174 | if( twst != TW_MT_DATA_ACK) return 1; | ||
175 | return 0; | ||
176 | |||
177 | }/* i2c_write */ | ||
178 | |||
179 | |||
180 | /************************************************************************* | ||
181 | Read one byte from the I2C device, request more data from device | ||
182 | |||
183 | Return: byte read from I2C device | ||
184 | *************************************************************************/ | ||
185 | unsigned char i2c_readAck(void) | ||
186 | { | ||
187 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); | ||
188 | while(!(TWCR & (1<<TWINT))); | ||
189 | |||
190 | return TWDR; | ||
191 | |||
192 | }/* i2c_readAck */ | ||
193 | |||
194 | |||
195 | /************************************************************************* | ||
196 | Read one byte from the I2C device, read is followed by a stop condition | ||
197 | |||
198 | Return: byte read from I2C device | ||
199 | *************************************************************************/ | ||
200 | unsigned char i2c_readNak(void) | ||
201 | { | ||
202 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
203 | while(!(TWCR & (1<<TWINT))); | ||
204 | |||
205 | return TWDR; | ||
206 | |||
207 | }/* i2c_readNak */ | ||