diff options
| author | yiancar <yiangosyiangou@cytanet.com.cy> | 2018-07-18 19:55:57 +0300 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-07-18 12:55:57 -0400 |
| commit | 72fd49b1468d6bbfa59e1c6334866d7aa34f31c1 (patch) | |
| tree | d9d5d7a66eebd37765e2ff103e09ed57d787eae9 | |
| parent | 7e9a7af672ab226cc57f05f362d6b1e965ac56e6 (diff) | |
| download | qmk_firmware-72fd49b1468d6bbfa59e1c6334866d7aa34f31c1.tar.gz qmk_firmware-72fd49b1468d6bbfa59e1c6334866d7aa34f31c1.zip | |
DC01 keyboard addition (#3428)
* DC01 initial commit
- Addition of directories
- Left readme
* Initial commit of left half
* Initial files for right half
* arrow
* i2c adjustments
* I2C slave and DC01 refractoring
- Cleaned up state machine of I2C slave driver
- Modified DC01 left to use already pressent I2C master driver
- Modified DC01 matrixes
* Fixed tabs to spaces
* Addition of Numpad
* Add keymaps
- Orthopad keymap for numpad module
- Numpad keymap for numpad module
- ISO, ANSI and HHKB version of keymap for right module
* Minor matrix.c fixes
* Update Readmes
50 files changed, 3747 insertions, 142 deletions
diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c index 4e76e2e7c..47c6f8e6c 100755 --- a/drivers/avr/i2c_master.c +++ b/drivers/avr/i2c_master.c | |||
| @@ -15,15 +15,15 @@ | |||
| 15 | void i2c_init(void) | 15 | void i2c_init(void) |
| 16 | { | 16 | { |
| 17 | TWSR = 0; /* no prescaler */ | 17 | TWSR = 0; /* no prescaler */ |
| 18 | TWBR = (uint8_t)TWBR_val; | 18 | TWBR = (uint8_t)TWBR_val; |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) | 21 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) |
| 22 | { | 22 | { |
| 23 | // reset TWI control register | 23 | // reset TWI control register |
| 24 | TWCR = 0; | 24 | TWCR = 0; |
| 25 | // transmit START condition | 25 | // transmit START condition |
| 26 | TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); | 26 | TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); |
| 27 | 27 | ||
| 28 | uint16_t timeout_timer = timer_read(); | 28 | uint16_t timeout_timer = timer_read(); |
| 29 | while( !(TWCR & (1<<TWINT)) ) { | 29 | while( !(TWCR & (1<<TWINT)) ) { |
| @@ -32,13 +32,13 @@ i2c_status_t i2c_start(uint8_t address, uint16_t timeout) | |||
| 32 | } | 32 | } |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | // check if the start condition was successfully transmitted | 35 | // check if the start condition was successfully transmitted |
| 36 | if(((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)){ return I2C_STATUS_ERROR; } | 36 | if(((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)){ return I2C_STATUS_ERROR; } |
| 37 | 37 | ||
| 38 | // load slave address into data register | 38 | // load slave address into data register |
| 39 | TWDR = address; | 39 | TWDR = address; |
| 40 | // start transmission of address | 40 | // start transmission of address |
| 41 | TWCR = (1<<TWINT) | (1<<TWEN); | 41 | TWCR = (1<<TWINT) | (1<<TWEN); |
| 42 | 42 | ||
| 43 | timeout_timer = timer_read(); | 43 | timeout_timer = timer_read(); |
| 44 | while( !(TWCR & (1<<TWINT)) ) { | 44 | while( !(TWCR & (1<<TWINT)) ) { |
| @@ -47,19 +47,19 @@ i2c_status_t i2c_start(uint8_t address, uint16_t timeout) | |||
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | // check if the device has acknowledged the READ / WRITE mode | 50 | // check if the device has acknowledged the READ / WRITE mode |
| 51 | uint8_t twst = TW_STATUS & 0xF8; | 51 | uint8_t twst = TW_STATUS & 0xF8; |
| 52 | if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return I2C_STATUS_ERROR; | 52 | if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return I2C_STATUS_ERROR; |
| 53 | 53 | ||
| 54 | return I2C_STATUS_SUCCESS; | 54 | return I2C_STATUS_SUCCESS; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout) | 57 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout) |
| 58 | { | 58 | { |
| 59 | // load data into data register | 59 | // load data into data register |
| 60 | TWDR = data; | 60 | TWDR = data; |
| 61 | // start transmission of data | 61 | // start transmission of data |
| 62 | TWCR = (1<<TWINT) | (1<<TWEN); | 62 | TWCR = (1<<TWINT) | (1<<TWEN); |
| 63 | 63 | ||
| 64 | uint16_t timeout_timer = timer_read(); | 64 | uint16_t timeout_timer = timer_read(); |
| 65 | while( !(TWCR & (1<<TWINT)) ) { | 65 | while( !(TWCR & (1<<TWINT)) ) { |
| @@ -68,16 +68,16 @@ i2c_status_t i2c_write(uint8_t data, uint16_t timeout) | |||
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | if( (TW_STATUS & 0xF8) != TW_MT_DATA_ACK ){ return I2C_STATUS_ERROR; } | 71 | if( (TW_STATUS & 0xF8) != TW_MT_DATA_ACK ){ return I2C_STATUS_ERROR; } |
| 72 | 72 | ||
| 73 | return I2C_STATUS_SUCCESS; | 73 | return I2C_STATUS_SUCCESS; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | int16_t i2c_read_ack(uint16_t timeout) | 76 | int16_t i2c_read_ack(uint16_t timeout) |
| 77 | { | 77 | { |
| 78 | 78 | ||
| 79 | // start TWI module and acknowledge data after reception | 79 | // start TWI module and acknowledge data after reception |
| 80 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); | 80 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); |
| 81 | 81 | ||
| 82 | uint16_t timeout_timer = timer_read(); | 82 | uint16_t timeout_timer = timer_read(); |
| 83 | while( !(TWCR & (1<<TWINT)) ) { | 83 | while( !(TWCR & (1<<TWINT)) ) { |
| @@ -86,15 +86,15 @@ int16_t i2c_read_ack(uint16_t timeout) | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | // return received data from TWDR | 89 | // return received data from TWDR |
| 90 | return TWDR; | 90 | return TWDR; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | int16_t i2c_read_nack(uint16_t timeout) | 93 | int16_t i2c_read_nack(uint16_t timeout) |
| 94 | { | 94 | { |
| 95 | 95 | ||
| 96 | // start receiving without acknowledging reception | 96 | // start receiving without acknowledging reception |
| 97 | TWCR = (1<<TWINT) | (1<<TWEN); | 97 | TWCR = (1<<TWINT) | (1<<TWEN); |
| 98 | 98 | ||
| 99 | uint16_t timeout_timer = timer_read(); | 99 | uint16_t timeout_timer = timer_read(); |
| 100 | while( !(TWCR & (1<<TWINT)) ) { | 100 | while( !(TWCR & (1<<TWINT)) ) { |
| @@ -103,39 +103,39 @@ int16_t i2c_read_nack(uint16_t timeout) | |||
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | // return received data from TWDR | 106 | // return received data from TWDR |
| 107 | return TWDR; | 107 | return TWDR; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | i2c_status_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) | 110 | i2c_status_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) |
| 111 | { | 111 | { |
| 112 | i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); | 112 | i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); |
| 113 | if (status) return status; | 113 | if (status) return status; |
| 114 | 114 | ||
| 115 | for (uint16_t i = 0; i < length; i++) { | 115 | for (uint16_t i = 0; i < length; i++) { |
| 116 | status = i2c_write(data[i], timeout); | 116 | status = i2c_write(data[i], timeout); |
| 117 | if (status) return status; | 117 | if (status) return status; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | status = i2c_stop(timeout); | 120 | status = i2c_stop(timeout); |
| 121 | if (status) return status; | 121 | if (status) return status; |
| 122 | 122 | ||
| 123 | return I2C_STATUS_SUCCESS; | 123 | return I2C_STATUS_SUCCESS; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) | 126 | i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) |
| 127 | { | 127 | { |
| 128 | i2c_status_t status = i2c_start(address | I2C_READ, timeout); | 128 | i2c_status_t status = i2c_start(address | I2C_READ, timeout); |
| 129 | if (status) return status; | 129 | if (status) return status; |
| 130 | 130 | ||
| 131 | for (uint16_t i = 0; i < (length-1); i++) { | 131 | for (uint16_t i = 0; i < (length-1); i++) { |
| 132 | status = i2c_read_ack(timeout); | 132 | status = i2c_read_ack(timeout); |
| 133 | if (status >= 0) { | 133 | if (status >= 0) { |
| 134 | data[i] = status; | 134 | data[i] = status; |
| 135 | } else { | 135 | } else { |
| 136 | return status; | 136 | return status; |
| 137 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | status = i2c_read_nack(timeout); | 140 | status = i2c_read_nack(timeout); |
| 141 | if (status >= 0 ) { | 141 | if (status >= 0 ) { |
| @@ -147,47 +147,47 @@ i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16 | |||
| 147 | status = i2c_stop(timeout); | 147 | status = i2c_stop(timeout); |
| 148 | if (status) return status; | 148 | if (status) return status; |
| 149 | 149 | ||
| 150 | return I2C_STATUS_SUCCESS; | 150 | return I2C_STATUS_SUCCESS; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) | 153 | i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) |
| 154 | { | 154 | { |
| 155 | i2c_status_t status = i2c_start(devaddr | 0x00, timeout); | 155 | i2c_status_t status = i2c_start(devaddr | 0x00, timeout); |
| 156 | if (status) return status; | 156 | if (status) return status; |
| 157 | 157 | ||
| 158 | status = i2c_write(regaddr, timeout); | 158 | status = i2c_write(regaddr, timeout); |
| 159 | if (status) return status; | 159 | if (status) return status; |
| 160 | 160 | ||
| 161 | for (uint16_t i = 0; i < length; i++) { | 161 | for (uint16_t i = 0; i < length; i++) { |
| 162 | status = i2c_write(data[i], timeout); | 162 | status = i2c_write(data[i], timeout); |
| 163 | if (status) return status; | 163 | if (status) return status; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | status = i2c_stop(timeout); | 166 | status = i2c_stop(timeout); |
| 167 | if (status) return status; | 167 | if (status) return status; |
| 168 | 168 | ||
| 169 | return I2C_STATUS_SUCCESS; | 169 | return I2C_STATUS_SUCCESS; |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) | 172 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) |
| 173 | { | 173 | { |
| 174 | i2c_status_t status = i2c_start(devaddr, timeout); | 174 | i2c_status_t status = i2c_start(devaddr, timeout); |
| 175 | if (status) return status; | 175 | if (status) return status; |
| 176 | 176 | ||
| 177 | status = i2c_write(regaddr, timeout); | 177 | status = i2c_write(regaddr, timeout); |
| 178 | if (status) return status; | 178 | if (status) return status; |
| 179 | 179 | ||
| 180 | status = i2c_start(devaddr | 0x01, timeout); | 180 | status = i2c_start(devaddr | 0x01, timeout); |
| 181 | if (status) return status; | 181 | if (status) return status; |
| 182 | 182 | ||
| 183 | for (uint16_t i = 0; i < (length-1); i++) { | 183 | for (uint16_t i = 0; i < (length-1); i++) { |
| 184 | status = i2c_read_ack(timeout); | 184 | status = i2c_read_ack(timeout); |
| 185 | if (status >= 0) { | 185 | if (status >= 0) { |
| 186 | data[i] = status; | 186 | data[i] = status; |
| 187 | } else { | 187 | } else { |
| 188 | return status; | 188 | return status; |
| 189 | } | 189 | } |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | status = i2c_read_nack(timeout); | 192 | status = i2c_read_nack(timeout); |
| 193 | if (status >= 0 ) { | 193 | if (status >= 0 ) { |
| @@ -199,13 +199,13 @@ i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16 | |||
| 199 | status = i2c_stop(timeout); | 199 | status = i2c_stop(timeout); |
| 200 | if (status) return status; | 200 | if (status) return status; |
| 201 | 201 | ||
| 202 | return I2C_STATUS_SUCCESS; | 202 | return I2C_STATUS_SUCCESS; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | i2c_status_t i2c_stop(uint16_t timeout) | 205 | i2c_status_t i2c_stop(uint16_t timeout) |
| 206 | { | 206 | { |
| 207 | // transmit STOP condition | 207 | // transmit STOP condition |
| 208 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | 208 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); |
| 209 | 209 | ||
| 210 | uint16_t timeout_timer = timer_read(); | 210 | uint16_t timeout_timer = timer_read(); |
| 211 | while(TWCR & (1<<TWSTO)) { | 211 | while(TWCR & (1<<TWSTO)) { |
| @@ -215,4 +215,4 @@ i2c_status_t i2c_stop(uint16_t timeout) | |||
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | return I2C_STATUS_SUCCESS; | 217 | return I2C_STATUS_SUCCESS; |
| 218 | } | 218 | } \ No newline at end of file |
diff --git a/drivers/avr/i2c_master.h b/drivers/avr/i2c_master.h index cf93680be..89c64599c 100755 --- a/drivers/avr/i2c_master.h +++ b/drivers/avr/i2c_master.h | |||
| @@ -28,4 +28,4 @@ i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint1 | |||
| 28 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); | 28 | i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout); |
| 29 | i2c_status_t i2c_stop(uint16_t timeout); | 29 | i2c_status_t i2c_stop(uint16_t timeout); |
| 30 | 30 | ||
| 31 | #endif // I2C_MASTER_H | 31 | #endif // I2C_MASTER_H \ No newline at end of file |
diff --git a/drivers/avr/i2c_slave.c b/drivers/avr/i2c_slave.c index 3edf85b12..27696ca01 100755 --- a/drivers/avr/i2c_slave.c +++ b/drivers/avr/i2c_slave.c | |||
| @@ -5,96 +5,64 @@ | |||
| 5 | #include <avr/io.h> | 5 | #include <avr/io.h> |
| 6 | #include <util/twi.h> | 6 | #include <util/twi.h> |
| 7 | #include <avr/interrupt.h> | 7 | #include <avr/interrupt.h> |
| 8 | #include <stdbool.h> | ||
| 8 | 9 | ||
| 9 | #include "i2c_slave.h" | 10 | #include "i2c_slave.h" |
| 10 | 11 | ||
| 11 | void i2c_init(uint8_t address){ | 12 | void i2c_init(uint8_t address){ |
| 12 | // load address into TWI address register | 13 | // load address into TWI address register |
| 13 | TWAR = (address << 1); | 14 | TWAR = (address << 1); |
| 14 | // set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt | 15 | // set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt |
| 15 | TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN); | 16 | TWCR = (1 << TWIE) | (1 << TWEA) | (1 << TWINT) | (1 << TWEN); |
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | void i2c_stop(void){ | 19 | void i2c_stop(void){ |
| 19 | // clear acknowledge and enable bits | 20 | // clear acknowledge and enable bits |
| 20 | TWCR &= ~( (1<<TWEA) | (1<<TWEN) ); | 21 | TWCR &= ~((1 << TWEA) | (1 << TWEN)); |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | ISR(TWI_vect){ | 24 | ISR(TWI_vect){ |
| 24 | 25 | uint8_t ack = 1; | |
| 25 | // temporary stores the received data | 26 | // temporary stores the received data |
| 26 | uint8_t data; | 27 | //uint8_t data; |
| 27 | 28 | ||
| 28 | // own address has been acknowledged | 29 | switch(TW_STATUS){ |
| 29 | if( (TWSR & 0xF8) == TW_SR_SLA_ACK ){ | 30 | case TW_SR_SLA_ACK: |
| 30 | buffer_address = 0xFF; | 31 | // The device is now a slave receiver |
| 31 | // clear TWI interrupt flag, prepare to receive next byte and acknowledge | 32 | slave_has_register_set = false; |
| 32 | TWCR |= (1<<TWIE) | (1<<TWINT) | (1<<TWEA) | (1<<TWEN); | 33 | break; |
| 33 | } | 34 | |
| 34 | else if( (TWSR & 0xF8) == TW_SR_DATA_ACK ){ // data has been received in slave receiver mode | 35 | case TW_SR_DATA_ACK: |
| 35 | 36 | // This device is a slave receiver and has received data | |
| 36 | // save the received byte inside data | 37 | // First byte is the location then the bytes will be writen in buffer with auto-incriment |
| 37 | data = TWDR; | 38 | if(!slave_has_register_set){ |
| 38 | 39 | buffer_address = TWDR; | |
| 39 | // check wether an address has already been transmitted or not | 40 | |
| 40 | if(buffer_address == 0xFF){ | 41 | if (buffer_address >= RX_BUFFER_SIZE){ // address out of bounds dont ack |
| 41 | 42 | ack = 0; | |
| 42 | buffer_address = data; | 43 | buffer_address = 0; |
| 43 | 44 | } | |
| 44 | // clear TWI interrupt flag, prepare to receive next byte and acknowledge | 45 | slave_has_register_set = true; // address has been receaved now fill in buffer |
| 45 | TWCR |= (1<<TWIE) | (1<<TWINT) | (1<<TWEA) | (1<<TWEN); | 46 | } else { |
| 46 | } | 47 | rxbuffer[buffer_address] = TWDR; |
| 47 | else{ // if a databyte has already been received | 48 | buffer_address++; |
| 48 | 49 | } | |
| 49 | // store the data at the current address | 50 | break; |
| 50 | rxbuffer[buffer_address] = data; | 51 | |
| 51 | 52 | case TW_ST_SLA_ACK: | |
| 52 | // increment the buffer address | 53 | case TW_ST_DATA_ACK: |
| 53 | buffer_address++; | 54 | // This device is a slave transmitter and master has requested data |
| 54 | 55 | TWDR = txbuffer[buffer_address]; | |
| 55 | // if there is still enough space inside the buffer | 56 | buffer_address++; |
| 56 | if(buffer_address < 0xFF){ | 57 | break; |
| 57 | // clear TWI interrupt flag, prepare to receive next byte and acknowledge | 58 | |
| 58 | TWCR |= (1<<TWIE) | (1<<TWINT) | (1<<TWEA) | (1<<TWEN); | 59 | case TW_BUS_ERROR: |
| 59 | } | 60 | // We got an error, reset i2c |
| 60 | else{ | 61 | TWCR = 0; |
| 61 | // Don't acknowledge | 62 | default: |
| 62 | TWCR &= ~(1<<TWEA); | 63 | break; |
| 63 | // clear TWI interrupt flag, prepare to receive last byte. | 64 | } |
| 64 | TWCR |= (1<<TWIE) | (1<<TWINT) | (1<<TWEN); | 65 | |
| 65 | } | 66 | // Reset i2c state mahcine to be ready for next interrupt |
| 66 | } | 67 | TWCR |= (1 << TWIE) | (1 << TWINT) | (ack << TWEA) | (1 << TWEN); |
| 67 | } | 68 | } \ No newline at end of file |
| 68 | else if( (TWSR & 0xF8) == TW_ST_DATA_ACK ){ // device has been addressed to be a transmitter | ||
| 69 | |||
| 70 | // copy data from TWDR to the temporary memory | ||
| 71 | data = TWDR; | ||
| 72 | |||
| 73 | // if no buffer read address has been sent yet | ||
| 74 | if( buffer_address == 0xFF ){ | ||
| 75 | buffer_address = data; | ||
| 76 | } | ||
| 77 | |||
| 78 | // copy the specified buffer address into the TWDR register for transmission | ||
| 79 | TWDR = txbuffer[buffer_address]; | ||
| 80 | // increment buffer read address | ||
| 81 | buffer_address++; | ||
| 82 | |||
| 83 | // if there is another buffer address that can be sent | ||
| 84 | if(buffer_address < 0xFF){ | ||
| 85 | // clear TWI interrupt flag, prepare to send next byte and receive acknowledge | ||
| 86 | TWCR |= (1<<TWIE) | (1<<TWINT) | (1<<TWEA) | (1<<TWEN); | ||
| 87 | } | ||
| 88 | else{ | ||
| 89 | // Don't acknowledge | ||
| 90 | TWCR &= ~(1<<TWEA); | ||
| 91 | // clear TWI interrupt flag, prepare to receive last byte. | ||
| 92 | TWCR |= (1<<TWIE) | (1<<TWINT) | (1<<TWEN); | ||
| 93 | } | ||
| 94 | |||
| 95 | } | ||
| 96 | else{ | ||
| 97 | // if none of the above apply prepare TWI to be addressed again | ||
| 98 | TWCR |= (1<<TWIE) | (1<<TWEA) | (1<<TWEN); | ||
| 99 | } | ||
| 100 | } | ||
diff --git a/drivers/avr/i2c_slave.h b/drivers/avr/i2c_slave.h index 3fda7f8c0..1c3b9ecc0 100755 --- a/drivers/avr/i2c_slave.h +++ b/drivers/avr/i2c_slave.h | |||
| @@ -8,12 +8,16 @@ | |||
| 8 | #ifndef I2C_SLAVE_H | 8 | #ifndef I2C_SLAVE_H |
| 9 | #define I2C_SLAVE_H | 9 | #define I2C_SLAVE_H |
| 10 | 10 | ||
| 11 | #define TX_BUFFER_SIZE 30 | ||
| 12 | #define RX_BUFFER_SIZE 30 | ||
| 13 | |||
| 11 | volatile uint8_t buffer_address; | 14 | volatile uint8_t buffer_address; |
| 12 | volatile uint8_t txbuffer[0xFF]; | 15 | static volatile bool slave_has_register_set = false; |
| 13 | volatile uint8_t rxbuffer[0xFF]; | 16 | volatile uint8_t txbuffer[TX_BUFFER_SIZE]; |
| 17 | volatile uint8_t rxbuffer[RX_BUFFER_SIZE]; | ||
| 14 | 18 | ||
| 15 | void i2c_init(uint8_t address); | 19 | void i2c_init(uint8_t address); |
| 16 | void i2c_stop(void); | 20 | void i2c_stop(void); |
| 17 | ISR(TWI_vect); | 21 | ISR(TWI_vect); |
| 18 | 22 | ||
| 19 | #endif // I2C_SLAVE_H | 23 | #endif // I2C_SLAVE_H \ No newline at end of file |
diff --git a/keyboards/dc01/arrow/arrow.c b/keyboards/dc01/arrow/arrow.c new file mode 100644 index 000000000..07988b809 --- /dev/null +++ b/keyboards/dc01/arrow/arrow.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "arrow.h" | ||
| 17 | |||
| 18 | void matrix_init_kb(void) { | ||
| 19 | // put your keyboard start-up code here | ||
| 20 | // runs once when the firmware starts up | ||
| 21 | |||
| 22 | matrix_init_user(); | ||
| 23 | } | ||
| 24 | |||
| 25 | void matrix_scan_kb(void) { | ||
| 26 | // put your looping keyboard code here | ||
| 27 | // runs every cycle (a lot) | ||
| 28 | |||
| 29 | matrix_scan_user(); | ||
| 30 | } | ||
| 31 | |||
| 32 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 33 | // put your per-action keyboard code here | ||
| 34 | // runs for every action, just before processing by the firmware | ||
| 35 | |||
| 36 | return process_record_user(keycode, record); | ||
| 37 | } | ||
| 38 | |||
| 39 | void led_set_kb(uint8_t usb_led) { | ||
| 40 | // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here | ||
| 41 | |||
| 42 | led_set_user(usb_led); | ||
| 43 | } | ||
diff --git a/keyboards/dc01/arrow/arrow.h b/keyboards/dc01/arrow/arrow.h new file mode 100644 index 000000000..b7fec9ee8 --- /dev/null +++ b/keyboards/dc01/arrow/arrow.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef ARROW_H | ||
| 17 | #define ARROW_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define XXX KC_NO | ||
| 22 | |||
| 23 | // This a shortcut to help you visually see your layout. | ||
| 24 | // The first section contains all of the arguments | ||
| 25 | // The second converts the arguments into a two-dimensional array | ||
| 26 | #define LAYOUT_ALL( \ | ||
| 27 | K00, K01, K02, \ | ||
| 28 | K10, K11, K12, \ | ||
| 29 | \ | ||
| 30 | K31, \ | ||
| 31 | K40, K41, K42 \ | ||
| 32 | ) \ | ||
| 33 | { \ | ||
| 34 | { K00, K01, K02 }, \ | ||
| 35 | { K10, K11, K12 }, \ | ||
| 36 | { XXX, XXX, XXX }, \ | ||
| 37 | { XXX, K31, XXX }, \ | ||
| 38 | { K40, K41, K42 } \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #endif | ||
diff --git a/keyboards/dc01/arrow/config.h b/keyboards/dc01/arrow/config.h new file mode 100644 index 000000000..75c674f63 --- /dev/null +++ b/keyboards/dc01/arrow/config.h | |||
| @@ -0,0 +1,151 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2018 Yiancar | ||
| 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 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "config_common.h" | ||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x1012 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER Mechboards | ||
| 27 | #define PRODUCT DC01 Arrow | ||
| 28 | #define DESCRIPTION Arrow cluster of DC01 keyboard | ||
| 29 | |||
| 30 | /* key matrix size */ | ||
| 31 | #define MATRIX_ROWS 5 | ||
| 32 | #define MATRIX_COLS 3 | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Keyboard Matrix Assignments | ||
| 36 | * | ||
| 37 | * Change this to how you wired your keyboard | ||
| 38 | * COLS: AVR pins used for columns, left to right | ||
| 39 | * ROWS: AVR pins used for rows, top to bottom | ||
| 40 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
| 41 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
| 42 | * | ||
| 43 | */ | ||
| 44 | #define MATRIX_ROW_PINS { B0, C7, C6, B6, B4 } | ||
| 45 | #define MATRIX_COL_PINS { F0, B7, D2 } | ||
| 46 | #define UNUSED_PINS | ||
| 47 | |||
| 48 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ | ||
| 49 | #define DIODE_DIRECTION COL2ROW | ||
| 50 | |||
| 51 | // #define BACKLIGHT_PIN B7 | ||
| 52 | // #define BACKLIGHT_BREATHING | ||
| 53 | // #define BACKLIGHT_LEVELS 3 | ||
| 54 | |||
| 55 | |||
| 56 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 57 | #define DEBOUNCING_DELAY 5 | ||
| 58 | |||
| 59 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
| 60 | //#define MATRIX_HAS_GHOST | ||
| 61 | |||
| 62 | /* number of backlight levels */ | ||
| 63 | |||
| 64 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
| 65 | #define LOCKING_SUPPORT_ENABLE | ||
| 66 | /* Locking resynchronize hack */ | ||
| 67 | #define LOCKING_RESYNC_ENABLE | ||
| 68 | |||
| 69 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
| 70 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
| 71 | */ | ||
| 72 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
| 73 | |||
| 74 | /* | ||
| 75 | * Force NKRO | ||
| 76 | * | ||
| 77 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 78 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 79 | * makefile for this to work.) | ||
| 80 | * | ||
| 81 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 82 | * until the next keyboard reset. | ||
| 83 | * | ||
| 84 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 85 | * fully operational during normal computer usage. | ||
| 86 | * | ||
| 87 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 88 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 89 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 90 | * power-up. | ||
| 91 | * | ||
| 92 | */ | ||
| 93 | //#define FORCE_NKRO | ||
| 94 | |||
| 95 | /* | ||
| 96 | * Magic Key Options | ||
| 97 | * | ||
| 98 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
| 99 | * the keyboard. They are best used in combination with the HID Listen program, | ||
| 100 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
| 101 | * | ||
| 102 | * The options below allow the magic key functionality to be changed. This is | ||
| 103 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
| 104 | * | ||
| 105 | */ | ||
| 106 | |||
| 107 | /* key combination for magic key command */ | ||
| 108 | #define IS_COMMAND() ( \ | ||
| 109 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 110 | ) | ||
| 111 | |||
| 112 | /* | ||
| 113 | * Feature disable options | ||
| 114 | * These options are also useful to firmware size reduction. | ||
| 115 | */ | ||
| 116 | |||
| 117 | /* disable debug print */ | ||
| 118 | //#define NO_DEBUG | ||
| 119 | |||
| 120 | /* disable print */ | ||
| 121 | //#define NO_PRINT | ||
| 122 | |||
| 123 | /* disable action features */ | ||
| 124 | //#define NO_ACTION_LAYER | ||
| 125 | //#define NO_ACTION_TAPPING | ||
| 126 | //#define NO_ACTION_ONESHOT | ||
| 127 | //#define NO_ACTION_MACRO | ||
| 128 | //#define NO_ACTION_FUNCTION | ||
| 129 | |||
| 130 | /* | ||
| 131 | * MIDI options | ||
| 132 | */ | ||
| 133 | |||
| 134 | /* Prevent use of disabled MIDI features in the keymap */ | ||
| 135 | //#define MIDI_ENABLE_STRICT 1 | ||
| 136 | |||
| 137 | /* enable basic MIDI features: | ||
| 138 | - MIDI notes can be sent when in Music mode is on | ||
| 139 | */ | ||
| 140 | //#define MIDI_BASIC | ||
| 141 | |||
| 142 | /* enable advanced MIDI features: | ||
| 143 | - MIDI notes can be added to the keymap | ||
| 144 | - Octave shift and transpose | ||
| 145 | - Virtual sustain, portamento, and modulation wheel | ||
| 146 | - etc. | ||
| 147 | */ | ||
| 148 | //#define MIDI_ADVANCED | ||
| 149 | |||
| 150 | /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ | ||
| 151 | //#define MIDI_TONE_KEYCODE_OCTAVES 1 \ No newline at end of file | ||
diff --git a/keyboards/dc01/arrow/info.json b/keyboards/dc01/arrow/info.json new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/dc01/arrow/info.json | |||
diff --git a/keyboards/dc01/arrow/keymaps/default/keymap.c b/keyboards/dc01/arrow/keymaps/default/keymap.c new file mode 100644 index 000000000..591deb01c --- /dev/null +++ b/keyboards/dc01/arrow/keymaps/default/keymap.c | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | [0] = LAYOUT_ALL( /* Base */ | ||
| 20 | KC_INS, KC_HOME, KC_PGUP, \ | ||
| 21 | KC_DEL, KC_END, KC_PGDN, \ | ||
| 22 | \ | ||
| 23 | KC_UP, \ | ||
| 24 | KC_LEFT, KC_DOWN, KC_RIGHT \ | ||
| 25 | ), | ||
| 26 | }; | ||
| 27 | |||
| 28 | void matrix_init_user(void) { | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | void matrix_scan_user(void) { | ||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 37 | return true; | ||
| 38 | } | ||
| 39 | |||
| 40 | void led_set_user(uint8_t usb_led) { | ||
| 41 | |||
| 42 | } | ||
diff --git a/keyboards/dc01/arrow/keymaps/default/readme.md b/keyboards/dc01/arrow/keymaps/default/readme.md new file mode 100644 index 000000000..bc2431bc1 --- /dev/null +++ b/keyboards/dc01/arrow/keymaps/default/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The default ANSI keymap for DC01 Arrow cluster | ||
| 2 | |||
| 3 | When using the arrow module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/arrow/matrix.c b/keyboards/dc01/arrow/matrix.c new file mode 100644 index 000000000..68abb6791 --- /dev/null +++ b/keyboards/dc01/arrow/matrix.c | |||
| @@ -0,0 +1,404 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Copyright 2014 Jack Humbert | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | #include <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #if defined(__AVR__) | ||
| 21 | #include <avr/io.h> | ||
| 22 | #include <avr/wdt.h> | ||
| 23 | #include <avr/interrupt.h> | ||
| 24 | #include <util/delay.h> | ||
| 25 | #endif | ||
| 26 | #include "wait.h" | ||
| 27 | #include "print.h" | ||
| 28 | #include "debug.h" | ||
| 29 | #include "util.h" | ||
| 30 | #include "matrix.h" | ||
| 31 | #include "timer.h" | ||
| 32 | #include "i2c_slave.h" | ||
| 33 | #include "lufa.h" | ||
| 34 | |||
| 35 | #define SLAVE_I2C_ADDRESS 0x23 | ||
| 36 | |||
| 37 | /* Set 0 if debouncing isn't needed */ | ||
| 38 | |||
| 39 | #ifndef DEBOUNCING_DELAY | ||
| 40 | # define DEBOUNCING_DELAY 5 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if (DEBOUNCING_DELAY > 0) | ||
| 44 | static uint16_t debouncing_time; | ||
| 45 | static bool debouncing = false; | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #if (MATRIX_COLS <= 8) | ||
| 49 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
| 50 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
| 51 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
| 52 | # define ROW_SHIFTER ((uint8_t)1) | ||
| 53 | #elif (MATRIX_COLS <= 16) | ||
| 54 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | ||
| 55 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | ||
| 56 | # define matrix_bitpop(i) bitpop16(matrix[i]) | ||
| 57 | # define ROW_SHIFTER ((uint16_t)1) | ||
| 58 | #elif (MATRIX_COLS <= 32) | ||
| 59 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | ||
| 60 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | ||
| 61 | # define matrix_bitpop(i) bitpop32(matrix[i]) | ||
| 62 | # define ROW_SHIFTER ((uint32_t)1) | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifdef MATRIX_MASKED | ||
| 66 | extern const matrix_row_t matrix_mask[]; | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | ||
| 70 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
| 71 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | /* matrix state(1:on, 0:off) */ | ||
| 75 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 76 | |||
| 77 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 78 | |||
| 79 | |||
| 80 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 81 | static void init_cols(void); | ||
| 82 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
| 83 | static void unselect_rows(void); | ||
| 84 | static void select_row(uint8_t row); | ||
| 85 | static void unselect_row(uint8_t row); | ||
| 86 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 87 | static void init_rows(void); | ||
| 88 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
| 89 | static void unselect_cols(void); | ||
| 90 | static void unselect_col(uint8_t col); | ||
| 91 | static void select_col(uint8_t col); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | __attribute__ ((weak)) | ||
| 95 | void matrix_init_quantum(void) { | ||
| 96 | matrix_init_kb(); | ||
| 97 | } | ||
| 98 | |||
| 99 | __attribute__ ((weak)) | ||
| 100 | void matrix_scan_quantum(void) { | ||
| 101 | matrix_scan_kb(); | ||
| 102 | } | ||
| 103 | |||
| 104 | __attribute__ ((weak)) | ||
| 105 | void matrix_init_kb(void) { | ||
| 106 | matrix_init_user(); | ||
| 107 | } | ||
| 108 | |||
| 109 | __attribute__ ((weak)) | ||
| 110 | void matrix_scan_kb(void) { | ||
| 111 | matrix_scan_user(); | ||
| 112 | } | ||
| 113 | |||
| 114 | __attribute__ ((weak)) | ||
| 115 | void matrix_init_user(void) { | ||
| 116 | } | ||
| 117 | |||
| 118 | __attribute__ ((weak)) | ||
| 119 | void matrix_scan_user(void) { | ||
| 120 | } | ||
| 121 | |||
| 122 | inline | ||
| 123 | uint8_t matrix_rows(void) { | ||
| 124 | return MATRIX_ROWS; | ||
| 125 | } | ||
| 126 | |||
| 127 | inline | ||
| 128 | uint8_t matrix_cols(void) { | ||
| 129 | return MATRIX_COLS; | ||
| 130 | } | ||
| 131 | |||
| 132 | void matrix_init(void) { | ||
| 133 | |||
| 134 | // initialize row and col | ||
| 135 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 136 | unselect_rows(); | ||
| 137 | init_cols(); | ||
| 138 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 139 | unselect_cols(); | ||
| 140 | init_rows(); | ||
| 141 | #endif | ||
| 142 | |||
| 143 | // initialize matrix state: all keys off | ||
| 144 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 145 | matrix[i] = 0; | ||
| 146 | matrix_debouncing[i] = 0; | ||
| 147 | } | ||
| 148 | |||
| 149 | matrix_init_quantum(); | ||
| 150 | } | ||
| 151 | |||
| 152 | uint8_t matrix_scan(void) | ||
| 153 | { | ||
| 154 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 155 | |||
| 156 | // Set row, read cols | ||
| 157 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
| 158 | # if (DEBOUNCING_DELAY > 0) | ||
| 159 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
| 160 | |||
| 161 | if (matrix_changed) { | ||
| 162 | debouncing = true; | ||
| 163 | debouncing_time = timer_read(); | ||
| 164 | } | ||
| 165 | |||
| 166 | # else | ||
| 167 | read_cols_on_row(matrix, current_row); | ||
| 168 | # endif | ||
| 169 | |||
| 170 | } | ||
| 171 | |||
| 172 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 173 | |||
| 174 | // Set col, read rows | ||
| 175 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
| 176 | # if (DEBOUNCING_DELAY > 0) | ||
| 177 | bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col); | ||
| 178 | if (matrix_changed) { | ||
| 179 | debouncing = true; | ||
| 180 | debouncing_time = timer_read(); | ||
| 181 | } | ||
| 182 | # else | ||
| 183 | read_rows_on_col(matrix, current_col); | ||
| 184 | # endif | ||
| 185 | |||
| 186 | } | ||
| 187 | |||
| 188 | #endif | ||
| 189 | |||
| 190 | # if (DEBOUNCING_DELAY > 0) | ||
| 191 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
| 192 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 193 | matrix[i] = matrix_debouncing[i]; | ||
| 194 | } | ||
| 195 | debouncing = false; | ||
| 196 | } | ||
| 197 | # endif | ||
| 198 | |||
| 199 | if (USB_DeviceState != DEVICE_STATE_Configured){ | ||
| 200 | txbuffer[1] = 0x55; | ||
| 201 | for (uint8_t i = 0; i < MATRIX_ROWS; i++){ | ||
| 202 | txbuffer[i+2] = matrix[i]; //send matrix over i2c | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | matrix_scan_quantum(); | ||
| 207 | return 1; | ||
| 208 | } | ||
| 209 | |||
| 210 | bool matrix_is_modified(void) | ||
| 211 | { | ||
| 212 | #if (DEBOUNCING_DELAY > 0) | ||
| 213 | if (debouncing) return false; | ||
| 214 | #endif | ||
| 215 | return true; | ||
| 216 | } | ||
| 217 | |||
| 218 | inline | ||
| 219 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 220 | { | ||
| 221 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 222 | } | ||
| 223 | |||
| 224 | inline | ||
| 225 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 226 | { | ||
| 227 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | ||
| 228 | // switch blocker installed and the switch is always pressed. | ||
| 229 | #ifdef MATRIX_MASKED | ||
| 230 | return matrix[row] & matrix_mask[row]; | ||
| 231 | #else | ||
| 232 | return matrix[row]; | ||
| 233 | #endif | ||
| 234 | } | ||
| 235 | |||
| 236 | void matrix_print(void) | ||
| 237 | { | ||
| 238 | print_matrix_header(); | ||
| 239 | |||
| 240 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 241 | phex(row); print(": "); | ||
| 242 | print_matrix_row(row); | ||
| 243 | print("\n"); | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | uint8_t matrix_key_count(void) | ||
| 248 | { | ||
| 249 | uint8_t count = 0; | ||
| 250 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 251 | count += matrix_bitpop(i); | ||
| 252 | } | ||
| 253 | return count; | ||
| 254 | } | ||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 259 | |||
| 260 | static void init_cols(void) | ||
| 261 | { | ||
| 262 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 263 | uint8_t pin = col_pins[x]; | ||
| 264 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 265 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 269 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
| 270 | { | ||
| 271 | // Store last value of row prior to reading | ||
| 272 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 273 | |||
| 274 | // Clear data in matrix row | ||
| 275 | current_matrix[current_row] = 0; | ||
| 276 | |||
| 277 | // Select row and wait for row selecton to stabilize | ||
| 278 | select_row(current_row); | ||
| 279 | wait_us(30); | ||
| 280 | |||
| 281 | // For each col... | ||
| 282 | for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | ||
| 283 | |||
| 284 | // Select the col pin to read (active low) | ||
| 285 | uint8_t pin = col_pins[col_index]; | ||
| 286 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
| 287 | |||
| 288 | // Populate the matrix row with the state of the col pin | ||
| 289 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
| 290 | } | ||
| 291 | |||
| 292 | // Unselect row | ||
| 293 | unselect_row(current_row); | ||
| 294 | |||
| 295 | return (last_row_value != current_matrix[current_row]); | ||
| 296 | } | ||
| 297 | |||
| 298 | static void select_row(uint8_t row) | ||
| 299 | { | ||
| 300 | uint8_t pin = row_pins[row]; | ||
| 301 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 302 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 303 | } | ||
| 304 | |||
| 305 | static void unselect_row(uint8_t row) | ||
| 306 | { | ||
| 307 | uint8_t pin = row_pins[row]; | ||
| 308 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 309 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 310 | } | ||
| 311 | |||
| 312 | static void unselect_rows(void) | ||
| 313 | { | ||
| 314 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 315 | uint8_t pin = row_pins[x]; | ||
| 316 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 317 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 322 | |||
| 323 | static void init_rows(void) | ||
| 324 | { | ||
| 325 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 326 | uint8_t pin = row_pins[x]; | ||
| 327 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 328 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | ||
| 333 | { | ||
| 334 | bool matrix_changed = false; | ||
| 335 | |||
| 336 | // Select col and wait for col selecton to stabilize | ||
| 337 | select_col(current_col); | ||
| 338 | wait_us(30); | ||
| 339 | |||
| 340 | // For each row... | ||
| 341 | for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) | ||
| 342 | { | ||
| 343 | |||
| 344 | // Store last value of row prior to reading | ||
| 345 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
| 346 | |||
| 347 | // Check row pin state | ||
| 348 | if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0) | ||
| 349 | { | ||
| 350 | // Pin LO, set col bit | ||
| 351 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
| 352 | } | ||
| 353 | else | ||
| 354 | { | ||
| 355 | // Pin HI, clear col bit | ||
| 356 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
| 357 | } | ||
| 358 | |||
| 359 | // Determine if the matrix changed state | ||
| 360 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
| 361 | { | ||
| 362 | matrix_changed = true; | ||
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 366 | // Unselect col | ||
| 367 | unselect_col(current_col); | ||
| 368 | |||
| 369 | return matrix_changed; | ||
| 370 | } | ||
| 371 | |||
| 372 | static void select_col(uint8_t col) | ||
| 373 | { | ||
| 374 | uint8_t pin = col_pins[col]; | ||
| 375 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 376 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 377 | } | ||
| 378 | |||
| 379 | static void unselect_col(uint8_t col) | ||
| 380 | { | ||
| 381 | uint8_t pin = col_pins[col]; | ||
| 382 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 383 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 384 | } | ||
| 385 | |||
| 386 | static void unselect_cols(void) | ||
| 387 | { | ||
| 388 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 389 | uint8_t pin = col_pins[x]; | ||
| 390 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 391 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 392 | } | ||
| 393 | } | ||
| 394 | |||
| 395 | #endif | ||
| 396 | |||
| 397 | //this replases tmk code | ||
| 398 | void matrix_setup(void){ | ||
| 399 | |||
| 400 | if (USB_DeviceState != DEVICE_STATE_Configured){ | ||
| 401 | i2c_init(SLAVE_I2C_ADDRESS); //setup address of slave i2c | ||
| 402 | sei(); //enable interupts | ||
| 403 | } | ||
| 404 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/arrow/readme.md b/keyboards/dc01/arrow/readme.md new file mode 100644 index 000000000..3c0ece7a3 --- /dev/null +++ b/keyboards/dc01/arrow/readme.md | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # DC01 Arrow Cluster | ||
| 2 | |||
| 3 |  | ||
| 4 | |||
| 5 | A hotpluggable four part keyboard which comes together with magnets and pogo pins! This is the arrow cluster | ||
| 6 | |||
| 7 | Keyboard Maintainer: [Yiancar](https://github.com/yiancar) | ||
| 8 | Hardware Supported: Runs on an atmega32u4 | ||
| 9 | Hardware Availability: [Mechboards](https://mechboards.co.uk/) | ||
| 10 | |||
| 11 | Make example for this keyboard (after setting up your build environment): | ||
| 12 | |||
| 13 | make dc01/arrow:default | ||
| 14 | |||
| 15 | 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/dc01/arrow/rules.mk b/keyboards/dc01/arrow/rules.mk new file mode 100644 index 000000000..c45789353 --- /dev/null +++ b/keyboards/dc01/arrow/rules.mk | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | SRC += matrix.c \ | ||
| 2 | ../../../drivers/avr/i2c_slave.c | ||
| 3 | |||
| 4 | # MCU name | ||
| 5 | #MCU = at90usb1286 | ||
| 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 | # | ||
| 23 | # LUFA specific | ||
| 24 | # | ||
| 25 | # Target architecture (see library "Board Types" documentation). | ||
| 26 | ARCH = AVR8 | ||
| 27 | |||
| 28 | # Input clock frequency. | ||
| 29 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 30 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 31 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 32 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 33 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 34 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 35 | # source code. | ||
| 36 | # | ||
| 37 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 38 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 39 | F_USB = $(F_CPU) | ||
| 40 | |||
| 41 | # Interrupt driven control endpoint task(+60) | ||
| 42 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 43 | |||
| 44 | |||
| 45 | # Boot Section Size in *bytes* | ||
| 46 | # Teensy halfKay 512 | ||
| 47 | # Teensy++ halfKay 1024 | ||
| 48 | # Atmel DFU loader 4096 | ||
| 49 | # LUFA bootloader 4096 | ||
| 50 | # USBaspLoader 2048 | ||
| 51 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 52 | |||
| 53 | |||
| 54 | # Build Options | ||
| 55 | # change yes to no to disable | ||
| 56 | # | ||
| 57 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 58 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 59 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 60 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 61 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
| 62 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 63 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 64 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 65 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 66 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
| 67 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
| 68 | UNICODE_ENABLE = no # Unicode | ||
| 69 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 70 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 71 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
| 72 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) | ||
| 73 | NO_USB_STARTUP_CHECK = yes # Disable initialization only when usb is plugged in | ||
| 74 | CUSTOM_MATRIX = yes # Use custom matrix \ No newline at end of file | ||
diff --git a/keyboards/dc01/left/config.h b/keyboards/dc01/left/config.h new file mode 100644 index 000000000..68484d835 --- /dev/null +++ b/keyboards/dc01/left/config.h | |||
| @@ -0,0 +1,152 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2018 Yiancar | ||
| 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 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "config_common.h" | ||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x1010 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER Mechboards | ||
| 27 | #define PRODUCT DC01 Left | ||
| 28 | #define DESCRIPTION Left half of DC01 keyboard | ||
| 29 | |||
| 30 | /* key matrix size */ | ||
| 31 | #define MATRIX_ROWS 5 | ||
| 32 | #define MATRIX_COLS 21 | ||
| 33 | #define MATRIX_COLS_SCANNED 6 | ||
| 34 | |||
| 35 | /* | ||
| 36 | * Keyboard Matrix Assignments | ||
| 37 | * | ||
| 38 | * Change this to how you wired your keyboard | ||
| 39 | * COLS: AVR pins used for columns, left to right | ||
| 40 | * ROWS: AVR pins used for rows, top to bottom | ||
| 41 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
| 42 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
| 43 | * | ||
| 44 | */ | ||
| 45 | #define MATRIX_ROW_PINS { B6, B5, B4, D7, D6 } | ||
| 46 | #define MATRIX_COL_PINS { F4, F1, F0, F7, F6, F5 } | ||
| 47 | #define UNUSED_PINS | ||
| 48 | |||
| 49 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ | ||
| 50 | #define DIODE_DIRECTION COL2ROW | ||
| 51 | |||
| 52 | // #define BACKLIGHT_PIN B7 | ||
| 53 | // #define BACKLIGHT_BREATHING | ||
| 54 | // #define BACKLIGHT_LEVELS 3 | ||
| 55 | |||
| 56 | |||
| 57 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 58 | #define DEBOUNCING_DELAY 5 | ||
| 59 | |||
| 60 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
| 61 | //#define MATRIX_HAS_GHOST | ||
| 62 | |||
| 63 | /* number of backlight levels */ | ||
| 64 | |||
| 65 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
| 66 | #define LOCKING_SUPPORT_ENABLE | ||
| 67 | /* Locking resynchronize hack */ | ||
| 68 | #define LOCKING_RESYNC_ENABLE | ||
| 69 | |||
| 70 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
| 71 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
| 72 | */ | ||
| 73 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
| 74 | |||
| 75 | /* | ||
| 76 | * Force NKRO | ||
| 77 | * | ||
| 78 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 79 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 80 | * makefile for this to work.) | ||
| 81 | * | ||
| 82 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 83 | * until the next keyboard reset. | ||
| 84 | * | ||
| 85 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 86 | * fully operational during normal computer usage. | ||
| 87 | * | ||
| 88 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 89 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 90 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 91 | * power-up. | ||
| 92 | * | ||
| 93 | */ | ||
| 94 | //#define FORCE_NKRO | ||
| 95 | |||
| 96 | /* | ||
| 97 | * Magic Key Options | ||
| 98 | * | ||
| 99 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
| 100 | * the keyboard. They are best used in combination with the HID Listen program, | ||
| 101 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
| 102 | * | ||
| 103 | * The options below allow the magic key functionality to be changed. This is | ||
| 104 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
| 105 | * | ||
| 106 | */ | ||
| 107 | |||
| 108 | /* key combination for magic key command */ | ||
| 109 | #define IS_COMMAND() ( \ | ||
| 110 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 111 | ) | ||
| 112 | |||
| 113 | /* | ||
| 114 | * Feature disable options | ||
| 115 | * These options are also useful to firmware size reduction. | ||
| 116 | */ | ||
| 117 | |||
| 118 | /* disable debug print */ | ||
| 119 | //#define NO_DEBUG | ||
| 120 | |||
| 121 | /* disable print */ | ||
| 122 | //#define NO_PRINT | ||
| 123 | |||
| 124 | /* disable action features */ | ||
| 125 | //#define NO_ACTION_LAYER | ||
| 126 | //#define NO_ACTION_TAPPING | ||
| 127 | //#define NO_ACTION_ONESHOT | ||
| 128 | //#define NO_ACTION_MACRO | ||
| 129 | //#define NO_ACTION_FUNCTION | ||
| 130 | |||
| 131 | /* | ||
| 132 | * MIDI options | ||
| 133 | */ | ||
| 134 | |||
| 135 | /* Prevent use of disabled MIDI features in the keymap */ | ||
| 136 | //#define MIDI_ENABLE_STRICT 1 | ||
| 137 | |||
| 138 | /* enable basic MIDI features: | ||
| 139 | - MIDI notes can be sent when in Music mode is on | ||
| 140 | */ | ||
| 141 | //#define MIDI_BASIC | ||
| 142 | |||
| 143 | /* enable advanced MIDI features: | ||
| 144 | - MIDI notes can be added to the keymap | ||
| 145 | - Octave shift and transpose | ||
| 146 | - Virtual sustain, portamento, and modulation wheel | ||
| 147 | - etc. | ||
| 148 | */ | ||
| 149 | //#define MIDI_ADVANCED | ||
| 150 | |||
| 151 | /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ | ||
| 152 | //#define MIDI_TONE_KEYCODE_OCTAVES 1 \ No newline at end of file | ||
diff --git a/keyboards/dc01/left/i2c.c b/keyboards/dc01/left/i2c.c new file mode 100644 index 000000000..c72789403 --- /dev/null +++ b/keyboards/dc01/left/i2c.c | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | #include <util/twi.h> | ||
| 2 | #include <avr/io.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <avr/interrupt.h> | ||
| 5 | #include <util/twi.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | #include "i2c.h" | ||
| 8 | |||
| 9 | // Limits the amount of we wait for any one i2c transaction. | ||
| 10 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is | ||
| 11 | // 9 bits, a single transaction will take around 90μs to complete. | ||
| 12 | // | ||
| 13 | // (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit | ||
| 14 | // poll loop takes at least 8 clock cycles to execute | ||
| 15 | #define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 | ||
| 16 | |||
| 17 | #define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) | ||
| 18 | |||
| 19 | volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 20 | |||
| 21 | static volatile uint8_t slave_buffer_pos; | ||
| 22 | static volatile bool slave_has_register_set = false; | ||
| 23 | |||
| 24 | // Wait for an i2c operation to finish | ||
| 25 | inline static | ||
| 26 | void i2c_delay(void) { | ||
| 27 | uint16_t lim = 0; | ||
| 28 | while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT) | ||
| 29 | lim++; | ||
| 30 | |||
| 31 | // easier way, but will wait slightly longer | ||
| 32 | // _delay_us(100); | ||
| 33 | } | ||
| 34 | |||
| 35 | // Setup twi to run at 100kHz | ||
| 36 | void i2c_master_init(void) { | ||
| 37 | // no prescaler | ||
| 38 | TWSR = 0; | ||
| 39 | // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10. | ||
| 40 | // Check datasheets for more info. | ||
| 41 | TWBR = ((F_CPU/SCL_CLOCK)-16)/2; | ||
| 42 | } | ||
| 43 | |||
| 44 | // Start a transaction with the given i2c slave address. The direction of the | ||
| 45 | // transfer is set with I2C_READ and I2C_WRITE. | ||
| 46 | // returns: 0 => success | ||
| 47 | // 1 => error | ||
| 48 | uint8_t i2c_master_start(uint8_t address) { | ||
| 49 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA); | ||
| 50 | |||
| 51 | i2c_delay(); | ||
| 52 | |||
| 53 | // check that we started successfully | ||
| 54 | if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START)) | ||
| 55 | return 1; | ||
| 56 | |||
| 57 | TWDR = address; | ||
| 58 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
| 59 | |||
| 60 | i2c_delay(); | ||
| 61 | |||
| 62 | if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) ) | ||
| 63 | return 1; // slave did not acknowledge | ||
| 64 | else | ||
| 65 | return 0; // success | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | // Finish the i2c transaction. | ||
| 70 | void i2c_master_stop(void) { | ||
| 71 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
| 72 | |||
| 73 | uint16_t lim = 0; | ||
| 74 | while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT) | ||
| 75 | lim++; | ||
| 76 | } | ||
| 77 | |||
| 78 | // Write one byte to the i2c slave. | ||
| 79 | // returns 0 => slave ACK | ||
| 80 | // 1 => slave NACK | ||
| 81 | uint8_t i2c_master_write(uint8_t data) { | ||
| 82 | TWDR = data; | ||
| 83 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
| 84 | |||
| 85 | i2c_delay(); | ||
| 86 | |||
| 87 | // check if the slave acknowledged us | ||
| 88 | return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1; | ||
| 89 | } | ||
| 90 | |||
| 91 | // Read one byte from the i2c slave. If ack=1 the slave is acknowledged, | ||
| 92 | // if ack=0 the acknowledge bit is not set. | ||
| 93 | // returns: byte read from i2c device | ||
| 94 | uint8_t i2c_master_read(int ack) { | ||
| 95 | TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA); | ||
| 96 | |||
| 97 | i2c_delay(); | ||
| 98 | return TWDR; | ||
| 99 | } | ||
| 100 | |||
| 101 | void i2c_reset_state(void) { | ||
| 102 | TWCR = 0; | ||
| 103 | } | ||
| 104 | |||
| 105 | void i2c_slave_init(uint8_t address) { | ||
| 106 | TWAR = address << 0; // slave i2c address | ||
| 107 | // TWEN - twi enable | ||
| 108 | // TWEA - enable address acknowledgement | ||
| 109 | // TWINT - twi interrupt flag | ||
| 110 | // TWIE - enable the twi interrupt | ||
| 111 | TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN); | ||
| 112 | } | ||
| 113 | |||
| 114 | ISR(TWI_vect); | ||
| 115 | |||
| 116 | ISR(TWI_vect) { | ||
| 117 | uint8_t ack = 1; | ||
| 118 | switch(TW_STATUS) { | ||
| 119 | case TW_SR_SLA_ACK: | ||
| 120 | // this device has been addressed as a slave receiver | ||
| 121 | slave_has_register_set = false; | ||
| 122 | break; | ||
| 123 | |||
| 124 | case TW_SR_DATA_ACK: | ||
| 125 | // this device has received data as a slave receiver | ||
| 126 | // The first byte that we receive in this transaction sets the location | ||
| 127 | // of the read/write location of the slaves memory that it exposes over | ||
| 128 | // i2c. After that, bytes will be written at slave_buffer_pos, incrementing | ||
| 129 | // slave_buffer_pos after each write. | ||
| 130 | if(!slave_has_register_set) { | ||
| 131 | slave_buffer_pos = TWDR; | ||
| 132 | // don't acknowledge the master if this memory loctaion is out of bounds | ||
| 133 | if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) { | ||
| 134 | ack = 0; | ||
| 135 | slave_buffer_pos = 0; | ||
| 136 | } | ||
| 137 | slave_has_register_set = true; | ||
| 138 | } else { | ||
| 139 | i2c_slave_buffer[slave_buffer_pos] = TWDR; | ||
| 140 | BUFFER_POS_INC(); | ||
| 141 | } | ||
| 142 | break; | ||
| 143 | |||
| 144 | case TW_ST_SLA_ACK: | ||
| 145 | case TW_ST_DATA_ACK: | ||
| 146 | // master has addressed this device as a slave transmitter and is | ||
| 147 | // requesting data. | ||
| 148 | TWDR = i2c_slave_buffer[slave_buffer_pos]; | ||
| 149 | BUFFER_POS_INC(); | ||
| 150 | break; | ||
| 151 | |||
| 152 | case TW_BUS_ERROR: // something went wrong, reset twi state | ||
| 153 | TWCR = 0; | ||
| 154 | default: | ||
| 155 | break; | ||
| 156 | } | ||
| 157 | // Reset everything, so we are ready for the next TWI interrupt | ||
| 158 | TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); | ||
| 159 | } | ||
diff --git a/keyboards/dc01/left/i2c.h b/keyboards/dc01/left/i2c.h new file mode 100644 index 000000000..25e876658 --- /dev/null +++ b/keyboards/dc01/left/i2c.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | #ifndef I2C_H | ||
| 2 | #define I2C_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | |||
| 6 | #ifndef F_CPU | ||
| 7 | #define F_CPU 16000000UL | ||
| 8 | #endif | ||
| 9 | |||
| 10 | #define I2C_READ 1 | ||
| 11 | #define I2C_WRITE 0 | ||
| 12 | |||
| 13 | #define I2C_ACK 1 | ||
| 14 | #define I2C_NACK 0 | ||
| 15 | |||
| 16 | #define SLAVE_BUFFER_SIZE 0x10 | ||
| 17 | |||
| 18 | // i2c SCL clock frequency | ||
| 19 | #define SCL_CLOCK 400000L | ||
| 20 | |||
| 21 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 22 | |||
| 23 | void i2c_master_init(void); | ||
| 24 | uint8_t i2c_master_start(uint8_t address); | ||
| 25 | void i2c_master_stop(void); | ||
| 26 | uint8_t i2c_master_write(uint8_t data); | ||
| 27 | uint8_t i2c_master_read(int); | ||
| 28 | void i2c_reset_state(void); | ||
| 29 | void i2c_slave_init(uint8_t address); | ||
| 30 | |||
| 31 | #endif | ||
diff --git a/keyboards/dc01/left/info.json b/keyboards/dc01/left/info.json new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/dc01/left/info.json | |||
diff --git a/keyboards/dc01/left/keymaps/default/keymap.c b/keyboards/dc01/left/keymaps/default/keymap.c new file mode 100644 index 000000000..07db66c8e --- /dev/null +++ b/keyboards/dc01/left/keymaps/default/keymap.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | [0] = LAYOUT_ANSI( /* Base */ | ||
| 20 | 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_BSPC, KC_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, \ | ||
| 21 | 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_BSLS, KC_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, \ | ||
| 22 | KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, KC_NO, \ | ||
| 23 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, \ | ||
| 24 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT, KC_P0, KC_NO, KC_PDOT, KC_PENT \ | ||
| 25 | ), | ||
| 26 | }; | ||
| 27 | |||
| 28 | void matrix_init_user(void) { | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | void matrix_scan_user(void) { | ||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 37 | return true; | ||
| 38 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/left/keymaps/default/readme.md b/keyboards/dc01/left/keymaps/default/readme.md new file mode 100644 index 000000000..36207e511 --- /dev/null +++ b/keyboards/dc01/left/keymaps/default/readme.md | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # The default ANSI keymap for DC01 Left | ||
| 2 | |||
| 3 | The keymap looks like a full layout keymap. | ||
| 4 | |||
| 5 | This is because the left part of the keyboard acts as the masterm coordinating all four part. | ||
| 6 | |||
| 7 | When using the keyboard to connect the other three parts, this keymap overwrites the individual keymaps of the single modules. | ||
| 8 | |||
| 9 | When using a module individually, the keymap of that module will take effect. | ||
diff --git a/keyboards/dc01/left/left.c b/keyboards/dc01/left/left.c new file mode 100644 index 000000000..1d8da186b --- /dev/null +++ b/keyboards/dc01/left/left.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "left.h" | ||
| 17 | |||
| 18 | void matrix_init_kb(void) { | ||
| 19 | // put your keyboard start-up code here | ||
| 20 | // runs once when the firmware starts up | ||
| 21 | |||
| 22 | matrix_init_user(); | ||
| 23 | } | ||
| 24 | |||
| 25 | void matrix_scan_kb(void) { | ||
| 26 | // put your looping keyboard code here | ||
| 27 | // runs every cycle (a lot) | ||
| 28 | |||
| 29 | matrix_scan_user(); | ||
| 30 | } | ||
| 31 | |||
| 32 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 33 | // put your per-action keyboard code here | ||
| 34 | // runs for every action, just before processing by the firmware | ||
| 35 | |||
| 36 | return process_record_user(keycode, record); | ||
| 37 | } | ||
| 38 | |||
| 39 | void led_set_kb(uint8_t usb_led) { | ||
| 40 | // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here | ||
| 41 | |||
| 42 | led_set_user(usb_led); | ||
| 43 | } | ||
diff --git a/keyboards/dc01/left/left.h b/keyboards/dc01/left/left.h new file mode 100644 index 000000000..82b0c6995 --- /dev/null +++ b/keyboards/dc01/left/left.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef LEFT_H | ||
| 17 | #define LEFT_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define XXX KC_NO | ||
| 22 | |||
| 23 | // This a shortcut to help you visually see your layout. | ||
| 24 | // The first section contains all of the arguments | ||
| 25 | // The second converts the arguments into a two-dimensional array | ||
| 26 | #define LAYOUT_ANSI( \ | ||
| 27 | K00, K01, K02, K03, K04, K05, K45, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0J, K0K, K0L, \ | ||
| 28 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1J, K1K, K1L, \ | ||
| 29 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, K2H, K2J, K2K, K2L, \ | ||
| 30 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3D, K3F, K3H, K3J, K3K, \ | ||
| 31 | K40, K41, K42, K43, K46, K47, K48, K49, K4A, K4B, K4E, K4F, K4G, K4H, K4J, K4K, K4L \ | ||
| 32 | ) \ | ||
| 33 | { \ | ||
| 34 | { K00, K01, K02, K03, K04, K05, XXX, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0J, K0K, K0L }, \ | ||
| 35 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1J, K1K, K1L }, \ | ||
| 36 | { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, XXX, K2D, XXX, XXX, XXX, K2H, K2J, K2K, K2L }, \ | ||
| 37 | { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, XXX, XXX, K3D, XXX, K3F, XXX, K3H, K3J, K3K, XXX }, \ | ||
| 38 | { K40, K41, K42, K43, XXX, K45, K46, K47, K48, K49, K4A, K4B, XXX, XXX, K4E, K4F, K4G, K4H, K4J, K4K, K4L } \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #endif | ||
diff --git a/keyboards/dc01/left/matrix.c b/keyboards/dc01/left/matrix.c new file mode 100644 index 000000000..792376635 --- /dev/null +++ b/keyboards/dc01/left/matrix.c | |||
| @@ -0,0 +1,479 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Copyright 2014 Jack Humbert | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | #include <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #if defined(__AVR__) | ||
| 21 | #include <avr/io.h> | ||
| 22 | #include <avr/wdt.h> | ||
| 23 | #include <avr/interrupt.h> | ||
| 24 | #include <util/delay.h> | ||
| 25 | #endif | ||
| 26 | #include "wait.h" | ||
| 27 | #include "print.h" | ||
| 28 | #include "debug.h" | ||
| 29 | #include "util.h" | ||
| 30 | #include "matrix.h" | ||
| 31 | #include "timer.h" | ||
| 32 | #include "i2c_master.h" | ||
| 33 | |||
| 34 | #define SLAVE_I2C_ADDRESS_RIGHT 0x19 | ||
| 35 | #define SLAVE_I2C_ADDRESS_NUMPAD 0x21 | ||
| 36 | #define SLAVE_I2C_ADDRESS_ARROW 0x23 | ||
| 37 | |||
| 38 | #define ERROR_DISCONNECT_COUNT 5 | ||
| 39 | static uint8_t error_count_right = 0; | ||
| 40 | static uint8_t error_count_numpad = 0; | ||
| 41 | static uint8_t error_count_arrow = 0; | ||
| 42 | |||
| 43 | /* Set 0 if debouncing isn't needed */ | ||
| 44 | |||
| 45 | #ifndef DEBOUNCING_DELAY | ||
| 46 | # define DEBOUNCING_DELAY 5 | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #if (DEBOUNCING_DELAY > 0) | ||
| 50 | static uint16_t debouncing_time; | ||
| 51 | static bool debouncing = false; | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if (MATRIX_COLS <= 8) | ||
| 55 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
| 56 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
| 57 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
| 58 | # define ROW_SHIFTER ((uint8_t)1) | ||
| 59 | #elif (MATRIX_COLS <= 16) | ||
| 60 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | ||
| 61 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | ||
| 62 | # define matrix_bitpop(i) bitpop16(matrix[i]) | ||
| 63 | # define ROW_SHIFTER ((uint16_t)1) | ||
| 64 | #elif (MATRIX_COLS <= 32) | ||
| 65 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | ||
| 66 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | ||
| 67 | # define matrix_bitpop(i) bitpop32(matrix[i]) | ||
| 68 | # define ROW_SHIFTER ((uint32_t)1) | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #ifdef MATRIX_MASKED | ||
| 72 | extern const matrix_row_t matrix_mask[]; | ||
| 73 | #endif | ||
| 74 | |||
| 75 | #if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | ||
| 76 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
| 77 | static const uint8_t col_pins[MATRIX_COLS_SCANNED] = MATRIX_COL_PINS; | ||
| 78 | #endif | ||
| 79 | |||
| 80 | /* matrix state(1:on, 0:off) */ | ||
| 81 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 82 | |||
| 83 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 84 | |||
| 85 | |||
| 86 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 87 | static void init_cols(void); | ||
| 88 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
| 89 | static void unselect_rows(void); | ||
| 90 | static void select_row(uint8_t row); | ||
| 91 | static void unselect_row(uint8_t row); | ||
| 92 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 93 | static void init_rows(void); | ||
| 94 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
| 95 | static void unselect_cols(void); | ||
| 96 | static void unselect_col(uint8_t col); | ||
| 97 | static void select_col(uint8_t col); | ||
| 98 | #endif | ||
| 99 | |||
| 100 | __attribute__ ((weak)) | ||
| 101 | void matrix_init_quantum(void) { | ||
| 102 | matrix_init_kb(); | ||
| 103 | } | ||
| 104 | |||
| 105 | __attribute__ ((weak)) | ||
| 106 | void matrix_scan_quantum(void) { | ||
| 107 | matrix_scan_kb(); | ||
| 108 | } | ||
| 109 | |||
| 110 | __attribute__ ((weak)) | ||
| 111 | void matrix_init_kb(void) { | ||
| 112 | matrix_init_user(); | ||
| 113 | } | ||
| 114 | |||
| 115 | __attribute__ ((weak)) | ||
| 116 | void matrix_scan_kb(void) { | ||
| 117 | matrix_scan_user(); | ||
| 118 | } | ||
| 119 | |||
| 120 | __attribute__ ((weak)) | ||
| 121 | void matrix_init_user(void) { | ||
| 122 | } | ||
| 123 | |||
| 124 | __attribute__ ((weak)) | ||
| 125 | void matrix_scan_user(void) { | ||
| 126 | } | ||
| 127 | |||
| 128 | inline | ||
| 129 | uint8_t matrix_rows(void) { | ||
| 130 | return MATRIX_ROWS; | ||
| 131 | } | ||
| 132 | |||
| 133 | inline | ||
| 134 | uint8_t matrix_cols(void) { | ||
| 135 | return MATRIX_COLS; | ||
| 136 | } | ||
| 137 | |||
| 138 | |||
| 139 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset); | ||
| 140 | //uint8_t i2c_transaction_numpad(void); | ||
| 141 | //uint8_t i2c_transaction_arrow(void); | ||
| 142 | |||
| 143 | //this replases tmk code | ||
| 144 | void matrix_setup(void){ | ||
| 145 | i2c_init(); | ||
| 146 | } | ||
| 147 | |||
| 148 | void matrix_init(void) { | ||
| 149 | |||
| 150 | // initialize row and col | ||
| 151 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 152 | unselect_rows(); | ||
| 153 | init_cols(); | ||
| 154 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 155 | unselect_cols(); | ||
| 156 | init_rows(); | ||
| 157 | #endif | ||
| 158 | |||
| 159 | // initialize matrix state: all keys off | ||
| 160 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 161 | matrix[i] = 0; | ||
| 162 | matrix_debouncing[i] = 0; | ||
| 163 | } | ||
| 164 | |||
| 165 | matrix_init_quantum(); | ||
| 166 | } | ||
| 167 | |||
| 168 | uint8_t matrix_scan(void) | ||
| 169 | { | ||
| 170 | |||
| 171 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 172 | |||
| 173 | // Set row, read cols | ||
| 174 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
| 175 | # if (DEBOUNCING_DELAY > 0) | ||
| 176 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
| 177 | |||
| 178 | if (matrix_changed) { | ||
| 179 | debouncing = true; | ||
| 180 | debouncing_time = timer_read(); | ||
| 181 | } | ||
| 182 | |||
| 183 | # else | ||
| 184 | read_cols_on_row(matrix, current_row); | ||
| 185 | # endif | ||
| 186 | |||
| 187 | } | ||
| 188 | |||
| 189 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 190 | |||
| 191 | // Set col, read rows | ||
| 192 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
| 193 | # if (DEBOUNCING_DELAY > 0) | ||
| 194 | bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col); | ||
| 195 | if (matrix_changed) { | ||
| 196 | debouncing = true; | ||
| 197 | debouncing_time = timer_read(); | ||
| 198 | } | ||
| 199 | # else | ||
| 200 | read_rows_on_col(matrix, current_col); | ||
| 201 | # endif | ||
| 202 | |||
| 203 | } | ||
| 204 | |||
| 205 | #endif | ||
| 206 | |||
| 207 | # if (DEBOUNCING_DELAY > 0) | ||
| 208 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
| 209 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 210 | matrix[i] = matrix_debouncing[i]; | ||
| 211 | } | ||
| 212 | debouncing = false; | ||
| 213 | } | ||
| 214 | # endif | ||
| 215 | |||
| 216 | if (i2c_transaction(SLAVE_I2C_ADDRESS_RIGHT, 0x3F, 0)){ //error has occured for main right half | ||
| 217 | error_count_right++; | ||
| 218 | if (error_count_right > ERROR_DISCONNECT_COUNT){ //disconnect half | ||
| 219 | for (uint8_t i = 0; i < MATRIX_ROWS ; i++) { | ||
| 220 | matrix[i] &= 0x3F; //mask bits to keep | ||
| 221 | } | ||
| 222 | } | ||
| 223 | }else{ //no error | ||
| 224 | error_count_right = 0; | ||
| 225 | } | ||
| 226 | |||
| 227 | if (i2c_transaction(SLAVE_I2C_ADDRESS_ARROW, 0X3FFF, 8)){ //error has occured for arrow cluster | ||
| 228 | error_count_arrow++; | ||
| 229 | if (error_count_arrow > ERROR_DISCONNECT_COUNT){ //disconnect arrow cluster | ||
| 230 | for (uint8_t i = 0; i < MATRIX_ROWS ; i++) { | ||
| 231 | matrix[i] &= 0x3FFF; //mask bits to keep | ||
| 232 | } | ||
| 233 | } | ||
| 234 | }else{ //no error | ||
| 235 | error_count_arrow = 0; | ||
| 236 | } | ||
| 237 | |||
| 238 | if (i2c_transaction(SLAVE_I2C_ADDRESS_NUMPAD, 0x1FFFF, 11)){ //error has occured for numpad | ||
| 239 | error_count_numpad++; | ||
| 240 | if (error_count_numpad > ERROR_DISCONNECT_COUNT){ //disconnect numpad | ||
| 241 | for (uint8_t i = 0; i < MATRIX_ROWS ; i++) { | ||
| 242 | matrix[i] &= 0x1FFFF; //mask bits to keep | ||
| 243 | } | ||
| 244 | } | ||
| 245 | }else{ //no error | ||
| 246 | error_count_numpad = 0; | ||
| 247 | } | ||
| 248 | |||
| 249 | matrix_scan_quantum(); | ||
| 250 | return 1; | ||
| 251 | } | ||
| 252 | |||
| 253 | bool matrix_is_modified(void) | ||
| 254 | { | ||
| 255 | #if (DEBOUNCING_DELAY > 0) | ||
| 256 | if (debouncing) return false; | ||
| 257 | #endif | ||
| 258 | return true; | ||
| 259 | } | ||
| 260 | |||
| 261 | inline | ||
| 262 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 263 | { | ||
| 264 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 265 | } | ||
| 266 | |||
| 267 | inline | ||
| 268 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 269 | { | ||
| 270 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | ||
| 271 | // switch blocker installed and the switch is always pressed. | ||
| 272 | #ifdef MATRIX_MASKED | ||
| 273 | return matrix[row] & matrix_mask[row]; | ||
| 274 | #else | ||
| 275 | return matrix[row]; | ||
| 276 | #endif | ||
| 277 | } | ||
| 278 | |||
| 279 | void matrix_print(void) | ||
| 280 | { | ||
| 281 | print_matrix_header(); | ||
| 282 | |||
| 283 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 284 | phex(row); print(": "); | ||
| 285 | print_matrix_row(row); | ||
| 286 | print("\n"); | ||
| 287 | } | ||
| 288 | } | ||
| 289 | |||
| 290 | uint8_t matrix_key_count(void) | ||
| 291 | { | ||
| 292 | uint8_t count = 0; | ||
| 293 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 294 | count += matrix_bitpop(i); | ||
| 295 | } | ||
| 296 | return count; | ||
| 297 | } | ||
| 298 | |||
| 299 | |||
| 300 | |||
| 301 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 302 | |||
| 303 | static void init_cols(void) | ||
| 304 | { | ||
| 305 | for(uint8_t x = 0; x < MATRIX_COLS_SCANNED; x++) { | ||
| 306 | uint8_t pin = col_pins[x]; | ||
| 307 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 308 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 309 | } | ||
| 310 | } | ||
| 311 | |||
| 312 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
| 313 | { | ||
| 314 | // Store last value of row prior to reading | ||
| 315 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 316 | |||
| 317 | // Clear data in matrix row | ||
| 318 | current_matrix[current_row] = 0; | ||
| 319 | |||
| 320 | // Select row and wait for row selecton to stabilize | ||
| 321 | select_row(current_row); | ||
| 322 | wait_us(30); | ||
| 323 | |||
| 324 | // For each col... | ||
| 325 | for(uint8_t col_index = 0; col_index < MATRIX_COLS_SCANNED; col_index++) { | ||
| 326 | |||
| 327 | // Select the col pin to read (active low) | ||
| 328 | uint8_t pin = col_pins[col_index]; | ||
| 329 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
| 330 | |||
| 331 | // Populate the matrix row with the state of the col pin | ||
| 332 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
| 333 | } | ||
| 334 | |||
| 335 | // Unselect row | ||
| 336 | unselect_row(current_row); | ||
| 337 | |||
| 338 | return (last_row_value != current_matrix[current_row]); | ||
| 339 | } | ||
| 340 | |||
| 341 | static void select_row(uint8_t row) | ||
| 342 | { | ||
| 343 | uint8_t pin = row_pins[row]; | ||
| 344 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 345 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 346 | } | ||
| 347 | |||
| 348 | static void unselect_row(uint8_t row) | ||
| 349 | { | ||
| 350 | uint8_t pin = row_pins[row]; | ||
| 351 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 352 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 353 | } | ||
| 354 | |||
| 355 | static void unselect_rows(void) | ||
| 356 | { | ||
| 357 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 358 | uint8_t pin = row_pins[x]; | ||
| 359 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 360 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 361 | } | ||
| 362 | } | ||
| 363 | |||
| 364 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 365 | |||
| 366 | static void init_rows(void) | ||
| 367 | { | ||
| 368 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 369 | uint8_t pin = row_pins[x]; | ||
| 370 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 371 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 372 | } | ||
| 373 | } | ||
| 374 | |||
| 375 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | ||
| 376 | { | ||
| 377 | bool matrix_changed = false; | ||
| 378 | |||
| 379 | // Select col and wait for col selecton to stabilize | ||
| 380 | select_col(current_col); | ||
| 381 | wait_us(30); | ||
| 382 | |||
| 383 | // For each row... | ||
| 384 | for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) | ||
| 385 | { | ||
| 386 | |||
| 387 | // Store last value of row prior to reading | ||
| 388 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
| 389 | |||
| 390 | // Check row pin state | ||
| 391 | if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0) | ||
| 392 | { | ||
| 393 | // Pin LO, set col bit | ||
| 394 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
| 395 | } | ||
| 396 | else | ||
| 397 | { | ||
| 398 | // Pin HI, clear col bit | ||
| 399 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
| 400 | } | ||
| 401 | |||
| 402 | // Determine if the matrix changed state | ||
| 403 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
| 404 | { | ||
| 405 | matrix_changed = true; | ||
| 406 | } | ||
| 407 | } | ||
| 408 | |||
| 409 | // Unselect col | ||
| 410 | unselect_col(current_col); | ||
| 411 | |||
| 412 | return matrix_changed; | ||
| 413 | } | ||
| 414 | |||
| 415 | static void select_col(uint8_t col) | ||
| 416 | { | ||
| 417 | uint8_t pin = col_pins[col]; | ||
| 418 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 419 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 420 | } | ||
| 421 | |||
| 422 | static void unselect_col(uint8_t col) | ||
| 423 | { | ||
| 424 | uint8_t pin = col_pins[col]; | ||
| 425 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 426 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 427 | } | ||
| 428 | |||
| 429 | static void unselect_cols(void) | ||
| 430 | { | ||
| 431 | for(uint8_t x = 0; x < MATRIX_COLS_SCANNED; x++) { | ||
| 432 | uint8_t pin = col_pins[x]; | ||
| 433 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 434 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 435 | } | ||
| 436 | } | ||
| 437 | |||
| 438 | #endif | ||
| 439 | |||
| 440 | // Complete rows from other modules over i2c | ||
| 441 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) { | ||
| 442 | i2c_status_t err = i2c_start((address << 1) | I2C_WRITE, 10); | ||
| 443 | if (err) return err; | ||
| 444 | i2c_write(0x01, 10); | ||
| 445 | if (err) return err; | ||
| 446 | |||
| 447 | i2c_start((address << 1) | I2C_READ, 10); | ||
| 448 | if (err) return err; | ||
| 449 | |||
| 450 | err = i2c_read_ack(10); | ||
| 451 | if (err == 0x55) { //synchronization byte | ||
| 452 | |||
| 453 | for (uint8_t i = 0; i < MATRIX_ROWS-1 ; i++) { //assemble slave matrix in main matrix | ||
| 454 | matrix[i] &= mask; //mask bits to keep | ||
| 455 | err = i2c_read_ack(10); | ||
| 456 | if (err >= 0) { | ||
| 457 | matrix[i] |= ((uint32_t)err << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end | ||
| 458 | } else { | ||
| 459 | return err; | ||
| 460 | } | ||
| 461 | } | ||
| 462 | //last read request must be followed by a NACK | ||
| 463 | matrix[MATRIX_ROWS - 1] &= mask; //mask bits to keep | ||
| 464 | err = i2c_read_nack(10); | ||
| 465 | if (err >= 0) { | ||
| 466 | matrix[MATRIX_ROWS - 1] |= ((uint32_t)err << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end | ||
| 467 | } else { | ||
| 468 | return err; | ||
| 469 | } | ||
| 470 | } else { | ||
| 471 | i2c_stop(10); | ||
| 472 | return 1; | ||
| 473 | } | ||
| 474 | |||
| 475 | i2c_stop(10); | ||
| 476 | if (err) return err; | ||
| 477 | |||
| 478 | return 0; | ||
| 479 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/left/readme.md b/keyboards/dc01/left/readme.md new file mode 100644 index 000000000..1613297d0 --- /dev/null +++ b/keyboards/dc01/left/readme.md | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # DC01 Left Half | ||
| 2 | |||
| 3 |  | ||
| 4 | |||
| 5 | A hotpluggable four part keyboard which comes together with magnets and pogo pins! This is the left part that also acts as the master. | ||
| 6 | |||
| 7 | Keyboard Maintainer: [Yiancar](https://github.com/yiancar) | ||
| 8 | Hardware Supported: Runs on an atmega32u4 | ||
| 9 | Hardware Availability: [Mechboards](https://mechboards.co.uk/) | ||
| 10 | |||
| 11 | Make example for this keyboard (after setting up your build environment): | ||
| 12 | |||
| 13 | make dc01/left:default | ||
| 14 | |||
| 15 | 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/dc01/left/rules.mk b/keyboards/dc01/left/rules.mk new file mode 100644 index 000000000..1ea1f275b --- /dev/null +++ b/keyboards/dc01/left/rules.mk | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | SRC += matrix.c \ | ||
| 2 | ../../../drivers/avr/i2c_master.c | ||
| 3 | |||
| 4 | # MCU name | ||
| 5 | #MCU = at90usb1286 | ||
| 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 | # | ||
| 23 | # LUFA specific | ||
| 24 | # | ||
| 25 | # Target architecture (see library "Board Types" documentation). | ||
| 26 | ARCH = AVR8 | ||
| 27 | |||
| 28 | # Input clock frequency. | ||
| 29 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 30 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 31 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 32 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 33 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 34 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 35 | # source code. | ||
| 36 | # | ||
| 37 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 38 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 39 | F_USB = $(F_CPU) | ||
| 40 | |||
| 41 | # Interrupt driven control endpoint task(+60) | ||
| 42 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 43 | |||
| 44 | |||
| 45 | # Boot Section Size in *bytes* | ||
| 46 | # Teensy halfKay 512 | ||
| 47 | # Teensy++ halfKay 1024 | ||
| 48 | # Atmel DFU loader 4096 | ||
| 49 | # LUFA bootloader 4096 | ||
| 50 | # USBaspLoader 2048 | ||
| 51 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 52 | |||
| 53 | |||
| 54 | # Build Options | ||
| 55 | # change yes to no to disable | ||
| 56 | # | ||
| 57 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 58 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 59 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 60 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 61 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
| 62 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 63 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 64 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 65 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 66 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
| 67 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
| 68 | UNICODE_ENABLE = no # Unicode | ||
| 69 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 70 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 71 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
| 72 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) | ||
| 73 | CUSTOM_MATRIX = yes # Use custom matrix | ||
diff --git a/keyboards/dc01/numpad/config.h b/keyboards/dc01/numpad/config.h new file mode 100644 index 000000000..16d75b2a8 --- /dev/null +++ b/keyboards/dc01/numpad/config.h | |||
| @@ -0,0 +1,151 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2018 Yiancar | ||
| 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 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "config_common.h" | ||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x1013 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER Mechboards | ||
| 27 | #define PRODUCT DC01 Numpad | ||
| 28 | #define DESCRIPTION Numpad of DC01 keyboard | ||
| 29 | |||
| 30 | /* key matrix size */ | ||
| 31 | #define MATRIX_ROWS 5 | ||
| 32 | #define MATRIX_COLS 4 | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Keyboard Matrix Assignments | ||
| 36 | * | ||
| 37 | * Change this to how you wired your keyboard | ||
| 38 | * COLS: AVR pins used for columns, left to right | ||
| 39 | * ROWS: AVR pins used for rows, top to bottom | ||
| 40 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
| 41 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
| 42 | * | ||
| 43 | */ | ||
| 44 | #define MATRIX_ROW_PINS { B0, E6, D6, D7, B4 } | ||
| 45 | #define MATRIX_COL_PINS { F0, B7, D2, D3 } | ||
| 46 | #define UNUSED_PINS | ||
| 47 | |||
| 48 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ | ||
| 49 | #define DIODE_DIRECTION COL2ROW | ||
| 50 | |||
| 51 | // #define BACKLIGHT_PIN B7 | ||
| 52 | // #define BACKLIGHT_BREATHING | ||
| 53 | // #define BACKLIGHT_LEVELS 3 | ||
| 54 | |||
| 55 | |||
| 56 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 57 | #define DEBOUNCING_DELAY 5 | ||
| 58 | |||
| 59 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
| 60 | //#define MATRIX_HAS_GHOST | ||
| 61 | |||
| 62 | /* number of backlight levels */ | ||
| 63 | |||
| 64 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
| 65 | #define LOCKING_SUPPORT_ENABLE | ||
| 66 | /* Locking resynchronize hack */ | ||
| 67 | #define LOCKING_RESYNC_ENABLE | ||
| 68 | |||
| 69 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
| 70 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
| 71 | */ | ||
| 72 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
| 73 | |||
| 74 | /* | ||
| 75 | * Force NKRO | ||
| 76 | * | ||
| 77 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 78 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 79 | * makefile for this to work.) | ||
| 80 | * | ||
| 81 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 82 | * until the next keyboard reset. | ||
| 83 | * | ||
| 84 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 85 | * fully operational during normal computer usage. | ||
| 86 | * | ||
| 87 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 88 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 89 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 90 | * power-up. | ||
| 91 | * | ||
| 92 | */ | ||
| 93 | //#define FORCE_NKRO | ||
| 94 | |||
| 95 | /* | ||
| 96 | * Magic Key Options | ||
| 97 | * | ||
| 98 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
| 99 | * the keyboard. They are best used in combination with the HID Listen program, | ||
| 100 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
| 101 | * | ||
| 102 | * The options below allow the magic key functionality to be changed. This is | ||
| 103 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
| 104 | * | ||
| 105 | */ | ||
| 106 | |||
| 107 | /* key combination for magic key command */ | ||
| 108 | #define IS_COMMAND() ( \ | ||
| 109 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 110 | ) | ||
| 111 | |||
| 112 | /* | ||
| 113 | * Feature disable options | ||
| 114 | * These options are also useful to firmware size reduction. | ||
| 115 | */ | ||
| 116 | |||
| 117 | /* disable debug print */ | ||
| 118 | //#define NO_DEBUG | ||
| 119 | |||
| 120 | /* disable print */ | ||
| 121 | //#define NO_PRINT | ||
| 122 | |||
| 123 | /* disable action features */ | ||
| 124 | //#define NO_ACTION_LAYER | ||
| 125 | //#define NO_ACTION_TAPPING | ||
| 126 | //#define NO_ACTION_ONESHOT | ||
| 127 | //#define NO_ACTION_MACRO | ||
| 128 | //#define NO_ACTION_FUNCTION | ||
| 129 | |||
| 130 | /* | ||
| 131 | * MIDI options | ||
| 132 | */ | ||
| 133 | |||
| 134 | /* Prevent use of disabled MIDI features in the keymap */ | ||
| 135 | //#define MIDI_ENABLE_STRICT 1 | ||
| 136 | |||
| 137 | /* enable basic MIDI features: | ||
| 138 | - MIDI notes can be sent when in Music mode is on | ||
| 139 | */ | ||
| 140 | //#define MIDI_BASIC | ||
| 141 | |||
| 142 | /* enable advanced MIDI features: | ||
| 143 | - MIDI notes can be added to the keymap | ||
| 144 | - Octave shift and transpose | ||
| 145 | - Virtual sustain, portamento, and modulation wheel | ||
| 146 | - etc. | ||
| 147 | */ | ||
| 148 | //#define MIDI_ADVANCED | ||
| 149 | |||
| 150 | /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ | ||
| 151 | //#define MIDI_TONE_KEYCODE_OCTAVES 1 \ No newline at end of file | ||
diff --git a/keyboards/dc01/numpad/info.json b/keyboards/dc01/numpad/info.json new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/dc01/numpad/info.json | |||
diff --git a/keyboards/dc01/numpad/keymaps/default/keymap.c b/keyboards/dc01/numpad/keymaps/default/keymap.c new file mode 100644 index 000000000..a4461a7d4 --- /dev/null +++ b/keyboards/dc01/numpad/keymaps/default/keymap.c | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | #define _______ KC_TRNS | ||
| 19 | #define XXXXXXX KC_NO | ||
| 20 | |||
| 21 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 22 | [0] = LAYOUT_numpad_5x4( | ||
| 23 | TG(1), KC_PSLS, KC_PAST, KC_PMNS, \ | ||
| 24 | KC_P7, KC_P8, KC_P9, \ | ||
| 25 | KC_P4, KC_P5, KC_P6, KC_PPLS, \ | ||
| 26 | KC_P1, KC_P2, KC_P3, \ | ||
| 27 | KC_P0, KC_PDOT, KC_PENT \ | ||
| 28 | ), | ||
| 29 | |||
| 30 | [1] = LAYOUT_numpad_5x4( | ||
| 31 | _______, _______, _______, _______, \ | ||
| 32 | KC_HOME, KC_UP, KC_PGUP, \ | ||
| 33 | KC_LEFT, XXXXXXX, KC_RGHT, _______, \ | ||
| 34 | KC_END, KC_DOWN, KC_PGDN, \ | ||
| 35 | KC_INS, KC_DEL, _______ \ | ||
| 36 | ), | ||
| 37 | }; | ||
| 38 | |||
| 39 | void matrix_init_user(void) { | ||
| 40 | |||
| 41 | } | ||
| 42 | |||
| 43 | void matrix_scan_user(void) { | ||
| 44 | |||
| 45 | } | ||
| 46 | |||
| 47 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 48 | return true; | ||
| 49 | } | ||
| 50 | |||
| 51 | void led_set_user(uint8_t usb_led) { | ||
| 52 | |||
| 53 | } | ||
diff --git a/keyboards/dc01/numpad/keymaps/default/readme.md b/keyboards/dc01/numpad/keymaps/default/readme.md new file mode 100644 index 000000000..3691feb27 --- /dev/null +++ b/keyboards/dc01/numpad/keymaps/default/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The default keymap for DC01 Numpad | ||
| 2 | |||
| 3 | When using the numpad module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/numpad/keymaps/ortho_5x4/keymap.c b/keyboards/dc01/numpad/keymaps/ortho_5x4/keymap.c new file mode 100644 index 000000000..cde2b26e2 --- /dev/null +++ b/keyboards/dc01/numpad/keymaps/ortho_5x4/keymap.c | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | #define _______ KC_TRNS | ||
| 19 | #define XXXXXXX KC_NO | ||
| 20 | |||
| 21 | enum custom_keycodes { | ||
| 22 | KC_P00 = SAFE_RANGE | ||
| 23 | }; | ||
| 24 | |||
| 25 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 26 | [0] = LAYOUT_ortho_5x4( | ||
| 27 | TG(1), KC_PSLS, KC_PAST, KC_PMNS, \ | ||
| 28 | KC_P7, KC_P8, KC_P9, KC_PPLS, \ | ||
| 29 | KC_P4, KC_P5, KC_P6, KC_PPLS, \ | ||
| 30 | KC_P1, KC_P2, KC_P3, KC_PENT, \ | ||
| 31 | KC_P0, KC_P00, KC_PDOT, KC_PENT \ | ||
| 32 | ), | ||
| 33 | |||
| 34 | [1] = LAYOUT_ortho_5x4( | ||
| 35 | _______, _______, _______, _______, \ | ||
| 36 | KC_HOME, KC_UP, KC_PGUP, _______, \ | ||
| 37 | KC_LEFT, XXXXXXX, KC_RGHT, _______, \ | ||
| 38 | KC_END, KC_DOWN, KC_PGDN, _______, \ | ||
| 39 | KC_INS, XXXXXXX, KC_DEL, _______ \ | ||
| 40 | ), | ||
| 41 | }; | ||
| 42 | |||
| 43 | void matrix_init_user(void) { | ||
| 44 | |||
| 45 | } | ||
| 46 | |||
| 47 | void matrix_scan_user(void) { | ||
| 48 | |||
| 49 | } | ||
| 50 | |||
| 51 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 52 | if (record->event.pressed) { | ||
| 53 | switch(keycode) { | ||
| 54 | case KC_P00: | ||
| 55 | // types Numpad 0 twice | ||
| 56 | SEND_STRING(SS_TAP(X_KP_0) SS_TAP(X_KP_0)); | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | return true; | ||
| 61 | }; | ||
| 62 | |||
| 63 | void led_set_user(uint8_t usb_led) { | ||
| 64 | |||
| 65 | } | ||
diff --git a/keyboards/dc01/numpad/keymaps/ortho_5x4/readme.md b/keyboards/dc01/numpad/keymaps/ortho_5x4/readme.md new file mode 100644 index 000000000..383e02da8 --- /dev/null +++ b/keyboards/dc01/numpad/keymaps/ortho_5x4/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The orthopad keymap for DC01 Numpad | ||
| 2 | |||
| 3 | When using the numpad module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/numpad/matrix.c b/keyboards/dc01/numpad/matrix.c new file mode 100644 index 000000000..f9a9a7f63 --- /dev/null +++ b/keyboards/dc01/numpad/matrix.c | |||
| @@ -0,0 +1,404 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Copyright 2014 Jack Humbert | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | #include <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #if defined(__AVR__) | ||
| 21 | #include <avr/io.h> | ||
| 22 | #include <avr/wdt.h> | ||
| 23 | #include <avr/interrupt.h> | ||
| 24 | #include <util/delay.h> | ||
| 25 | #endif | ||
| 26 | #include "wait.h" | ||
| 27 | #include "print.h" | ||
| 28 | #include "debug.h" | ||
| 29 | #include "util.h" | ||
| 30 | #include "matrix.h" | ||
| 31 | #include "timer.h" | ||
| 32 | #include "i2c_slave.h" | ||
| 33 | #include "lufa.h" | ||
| 34 | |||
| 35 | #define SLAVE_I2C_ADDRESS 0x21 | ||
| 36 | |||
| 37 | /* Set 0 if debouncing isn't needed */ | ||
| 38 | |||
| 39 | #ifndef DEBOUNCING_DELAY | ||
| 40 | # define DEBOUNCING_DELAY 5 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if (DEBOUNCING_DELAY > 0) | ||
| 44 | static uint16_t debouncing_time; | ||
| 45 | static bool debouncing = false; | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #if (MATRIX_COLS <= 8) | ||
| 49 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
| 50 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
| 51 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
| 52 | # define ROW_SHIFTER ((uint8_t)1) | ||
| 53 | #elif (MATRIX_COLS <= 16) | ||
| 54 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | ||
| 55 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | ||
| 56 | # define matrix_bitpop(i) bitpop16(matrix[i]) | ||
| 57 | # define ROW_SHIFTER ((uint16_t)1) | ||
| 58 | #elif (MATRIX_COLS <= 32) | ||
| 59 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | ||
| 60 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | ||
| 61 | # define matrix_bitpop(i) bitpop32(matrix[i]) | ||
| 62 | # define ROW_SHIFTER ((uint32_t)1) | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifdef MATRIX_MASKED | ||
| 66 | extern const matrix_row_t matrix_mask[]; | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | ||
| 70 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
| 71 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | /* matrix state(1:on, 0:off) */ | ||
| 75 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 76 | |||
| 77 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 78 | |||
| 79 | |||
| 80 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 81 | static void init_cols(void); | ||
| 82 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
| 83 | static void unselect_rows(void); | ||
| 84 | static void select_row(uint8_t row); | ||
| 85 | static void unselect_row(uint8_t row); | ||
| 86 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 87 | static void init_rows(void); | ||
| 88 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
| 89 | static void unselect_cols(void); | ||
| 90 | static void unselect_col(uint8_t col); | ||
| 91 | static void select_col(uint8_t col); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | __attribute__ ((weak)) | ||
| 95 | void matrix_init_quantum(void) { | ||
| 96 | matrix_init_kb(); | ||
| 97 | } | ||
| 98 | |||
| 99 | __attribute__ ((weak)) | ||
| 100 | void matrix_scan_quantum(void) { | ||
| 101 | matrix_scan_kb(); | ||
| 102 | } | ||
| 103 | |||
| 104 | __attribute__ ((weak)) | ||
| 105 | void matrix_init_kb(void) { | ||
| 106 | matrix_init_user(); | ||
| 107 | } | ||
| 108 | |||
| 109 | __attribute__ ((weak)) | ||
| 110 | void matrix_scan_kb(void) { | ||
| 111 | matrix_scan_user(); | ||
| 112 | } | ||
| 113 | |||
| 114 | __attribute__ ((weak)) | ||
| 115 | void matrix_init_user(void) { | ||
| 116 | } | ||
| 117 | |||
| 118 | __attribute__ ((weak)) | ||
| 119 | void matrix_scan_user(void) { | ||
| 120 | } | ||
| 121 | |||
| 122 | inline | ||
| 123 | uint8_t matrix_rows(void) { | ||
| 124 | return MATRIX_ROWS; | ||
| 125 | } | ||
| 126 | |||
| 127 | inline | ||
| 128 | uint8_t matrix_cols(void) { | ||
| 129 | return MATRIX_COLS; | ||
| 130 | } | ||
| 131 | |||
| 132 | void matrix_init(void) { | ||
| 133 | |||
| 134 | // initialize row and col | ||
| 135 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 136 | unselect_rows(); | ||
| 137 | init_cols(); | ||
| 138 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 139 | unselect_cols(); | ||
| 140 | init_rows(); | ||
| 141 | #endif | ||
| 142 | |||
| 143 | // initialize matrix state: all keys off | ||
| 144 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 145 | matrix[i] = 0; | ||
| 146 | matrix_debouncing[i] = 0; | ||
| 147 | } | ||
| 148 | |||
| 149 | matrix_init_quantum(); | ||
| 150 | } | ||
| 151 | |||
| 152 | uint8_t matrix_scan(void) | ||
| 153 | { | ||
| 154 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 155 | |||
| 156 | // Set row, read cols | ||
| 157 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
| 158 | # if (DEBOUNCING_DELAY > 0) | ||
| 159 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
| 160 | |||
| 161 | if (matrix_changed) { | ||
| 162 | debouncing = true; | ||
| 163 | debouncing_time = timer_read(); | ||
| 164 | } | ||
| 165 | |||
| 166 | # else | ||
| 167 | read_cols_on_row(matrix, current_row); | ||
| 168 | # endif | ||
| 169 | |||
| 170 | } | ||
| 171 | |||
| 172 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 173 | |||
| 174 | // Set col, read rows | ||
| 175 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
| 176 | # if (DEBOUNCING_DELAY > 0) | ||
| 177 | bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col); | ||
| 178 | if (matrix_changed) { | ||
| 179 | debouncing = true; | ||
| 180 | debouncing_time = timer_read(); | ||
| 181 | } | ||
| 182 | # else | ||
| 183 | read_rows_on_col(matrix, current_col); | ||
| 184 | # endif | ||
| 185 | |||
| 186 | } | ||
| 187 | |||
| 188 | #endif | ||
| 189 | |||
| 190 | # if (DEBOUNCING_DELAY > 0) | ||
| 191 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
| 192 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 193 | matrix[i] = matrix_debouncing[i]; | ||
| 194 | } | ||
| 195 | debouncing = false; | ||
| 196 | } | ||
| 197 | # endif | ||
| 198 | |||
| 199 | if (USB_DeviceState != DEVICE_STATE_Configured){ | ||
| 200 | txbuffer[1] = 0x55; | ||
| 201 | for (uint8_t i = 0; i < MATRIX_ROWS; i++){ | ||
| 202 | txbuffer[i+2] = matrix[i]; //send matrix over i2c | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | matrix_scan_quantum(); | ||
| 207 | return 1; | ||
| 208 | } | ||
| 209 | |||
| 210 | bool matrix_is_modified(void) | ||
| 211 | { | ||
| 212 | #if (DEBOUNCING_DELAY > 0) | ||
| 213 | if (debouncing) return false; | ||
| 214 | #endif | ||
| 215 | return true; | ||
| 216 | } | ||
| 217 | |||
| 218 | inline | ||
| 219 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 220 | { | ||
| 221 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 222 | } | ||
| 223 | |||
| 224 | inline | ||
| 225 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 226 | { | ||
| 227 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | ||
| 228 | // switch blocker installed and the switch is always pressed. | ||
| 229 | #ifdef MATRIX_MASKED | ||
| 230 | return matrix[row] & matrix_mask[row]; | ||
| 231 | #else | ||
| 232 | return matrix[row]; | ||
| 233 | #endif | ||
| 234 | } | ||
| 235 | |||
| 236 | void matrix_print(void) | ||
| 237 | { | ||
| 238 | print_matrix_header(); | ||
| 239 | |||
| 240 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 241 | phex(row); print(": "); | ||
| 242 | print_matrix_row(row); | ||
| 243 | print("\n"); | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | uint8_t matrix_key_count(void) | ||
| 248 | { | ||
| 249 | uint8_t count = 0; | ||
| 250 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 251 | count += matrix_bitpop(i); | ||
| 252 | } | ||
| 253 | return count; | ||
| 254 | } | ||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 259 | |||
| 260 | static void init_cols(void) | ||
| 261 | { | ||
| 262 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 263 | uint8_t pin = col_pins[x]; | ||
| 264 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 265 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 269 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
| 270 | { | ||
| 271 | // Store last value of row prior to reading | ||
| 272 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 273 | |||
| 274 | // Clear data in matrix row | ||
| 275 | current_matrix[current_row] = 0; | ||
| 276 | |||
| 277 | // Select row and wait for row selecton to stabilize | ||
| 278 | select_row(current_row); | ||
| 279 | wait_us(30); | ||
| 280 | |||
| 281 | // For each col... | ||
| 282 | for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | ||
| 283 | |||
| 284 | // Select the col pin to read (active low) | ||
| 285 | uint8_t pin = col_pins[col_index]; | ||
| 286 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
| 287 | |||
| 288 | // Populate the matrix row with the state of the col pin | ||
| 289 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
| 290 | } | ||
| 291 | |||
| 292 | // Unselect row | ||
| 293 | unselect_row(current_row); | ||
| 294 | |||
| 295 | return (last_row_value != current_matrix[current_row]); | ||
| 296 | } | ||
| 297 | |||
| 298 | static void select_row(uint8_t row) | ||
| 299 | { | ||
| 300 | uint8_t pin = row_pins[row]; | ||
| 301 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 302 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 303 | } | ||
| 304 | |||
| 305 | static void unselect_row(uint8_t row) | ||
| 306 | { | ||
| 307 | uint8_t pin = row_pins[row]; | ||
| 308 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 309 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 310 | } | ||
| 311 | |||
| 312 | static void unselect_rows(void) | ||
| 313 | { | ||
| 314 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 315 | uint8_t pin = row_pins[x]; | ||
| 316 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 317 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 322 | |||
| 323 | static void init_rows(void) | ||
| 324 | { | ||
| 325 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 326 | uint8_t pin = row_pins[x]; | ||
| 327 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 328 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | ||
| 333 | { | ||
| 334 | bool matrix_changed = false; | ||
| 335 | |||
| 336 | // Select col and wait for col selecton to stabilize | ||
| 337 | select_col(current_col); | ||
| 338 | wait_us(30); | ||
| 339 | |||
| 340 | // For each row... | ||
| 341 | for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) | ||
| 342 | { | ||
| 343 | |||
| 344 | // Store last value of row prior to reading | ||
| 345 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
| 346 | |||
| 347 | // Check row pin state | ||
| 348 | if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0) | ||
| 349 | { | ||
| 350 | // Pin LO, set col bit | ||
| 351 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
| 352 | } | ||
| 353 | else | ||
| 354 | { | ||
| 355 | // Pin HI, clear col bit | ||
| 356 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
| 357 | } | ||
| 358 | |||
| 359 | // Determine if the matrix changed state | ||
| 360 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
| 361 | { | ||
| 362 | matrix_changed = true; | ||
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 366 | // Unselect col | ||
| 367 | unselect_col(current_col); | ||
| 368 | |||
| 369 | return matrix_changed; | ||
| 370 | } | ||
| 371 | |||
| 372 | static void select_col(uint8_t col) | ||
| 373 | { | ||
| 374 | uint8_t pin = col_pins[col]; | ||
| 375 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 376 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 377 | } | ||
| 378 | |||
| 379 | static void unselect_col(uint8_t col) | ||
| 380 | { | ||
| 381 | uint8_t pin = col_pins[col]; | ||
| 382 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 383 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 384 | } | ||
| 385 | |||
| 386 | static void unselect_cols(void) | ||
| 387 | { | ||
| 388 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 389 | uint8_t pin = col_pins[x]; | ||
| 390 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 391 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 392 | } | ||
| 393 | } | ||
| 394 | |||
| 395 | #endif | ||
| 396 | |||
| 397 | //this replases tmk code | ||
| 398 | void matrix_setup(void){ | ||
| 399 | |||
| 400 | if (USB_DeviceState != DEVICE_STATE_Configured){ | ||
| 401 | i2c_init(SLAVE_I2C_ADDRESS); //setup address of slave i2c | ||
| 402 | sei(); //enable interupts | ||
| 403 | } | ||
| 404 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/numpad/numpad.c b/keyboards/dc01/numpad/numpad.c new file mode 100644 index 000000000..04d0a33af --- /dev/null +++ b/keyboards/dc01/numpad/numpad.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "numpad.h" | ||
| 17 | |||
| 18 | void matrix_init_kb(void) { | ||
| 19 | // put your keyboard start-up code here | ||
| 20 | // runs once when the firmware starts up | ||
| 21 | |||
| 22 | matrix_init_user(); | ||
| 23 | } | ||
| 24 | |||
| 25 | void matrix_scan_kb(void) { | ||
| 26 | // put your looping keyboard code here | ||
| 27 | // runs every cycle (a lot) | ||
| 28 | |||
| 29 | matrix_scan_user(); | ||
| 30 | } | ||
| 31 | |||
| 32 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 33 | // put your per-action keyboard code here | ||
| 34 | // runs for every action, just before processing by the firmware | ||
| 35 | |||
| 36 | return process_record_user(keycode, record); | ||
| 37 | } | ||
| 38 | |||
| 39 | void led_set_kb(uint8_t usb_led) { | ||
| 40 | // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here | ||
| 41 | |||
| 42 | led_set_user(usb_led); | ||
| 43 | } | ||
diff --git a/keyboards/dc01/numpad/numpad.h b/keyboards/dc01/numpad/numpad.h new file mode 100644 index 000000000..15e031b07 --- /dev/null +++ b/keyboards/dc01/numpad/numpad.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef NUMPAD_H | ||
| 17 | #define NUMPAD_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define XXX KC_NO | ||
| 22 | |||
| 23 | // This a shortcut to help you visually see your layout. | ||
| 24 | // The first section contains all of the arguments | ||
| 25 | // The second converts the arguments into a two-dimensional array | ||
| 26 | #define LAYOUT_numpad_5x4( \ | ||
| 27 | K00, K01, K02, K03, \ | ||
| 28 | K10, K11, K12, K13, \ | ||
| 29 | K20, K21, K22, \ | ||
| 30 | K30, K31, K32, \ | ||
| 31 | K40, K42, K43 \ | ||
| 32 | ) \ | ||
| 33 | { \ | ||
| 34 | { K00, K01, K02, K03 }, \ | ||
| 35 | { K10, K11, K12, K13 }, \ | ||
| 36 | { K20, K21, K22, XXX }, \ | ||
| 37 | { K30, K31, K32, XXX }, \ | ||
| 38 | { K40, XXX, K42, K43 } \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #define LAYOUT_ortho_5x4( \ | ||
| 42 | K00, K01, K02, K03, \ | ||
| 43 | K10, K11, K12, K13, \ | ||
| 44 | K20, K21, K22, K23, \ | ||
| 45 | K30, K31, K32, K33, \ | ||
| 46 | K40, K41, K42, K43 \ | ||
| 47 | ) \ | ||
| 48 | { \ | ||
| 49 | { K00, K01, K02, K03 }, \ | ||
| 50 | { K10, K11, K12, K13 }, \ | ||
| 51 | { K20, K21, K22, K23 }, \ | ||
| 52 | { K30, K31, K32, K33 }, \ | ||
| 53 | { K40, K41, K42, K43 } \ | ||
| 54 | } | ||
| 55 | |||
| 56 | #endif | ||
diff --git a/keyboards/dc01/numpad/readme.md b/keyboards/dc01/numpad/readme.md new file mode 100644 index 000000000..977100dde --- /dev/null +++ b/keyboards/dc01/numpad/readme.md | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # DC01 Numpad | ||
| 2 | |||
| 3 |  | ||
| 4 | |||
| 5 | A hotpluggable four part keyboard which comes together with magnets and pogo pins! This is the numpad | ||
| 6 | |||
| 7 | Keyboard Maintainer: [Yiancar](https://github.com/yiancar) | ||
| 8 | Hardware Supported: Runs on an atmega32u4 | ||
| 9 | Hardware Availability: [Mechboards](https://mechboards.co.uk/) | ||
| 10 | |||
| 11 | Make example for this keyboard (after setting up your build environment): | ||
| 12 | |||
| 13 | make dc01/numpad:default | ||
| 14 | |||
| 15 | 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/dc01/numpad/rules.mk b/keyboards/dc01/numpad/rules.mk new file mode 100644 index 000000000..4b6cb0e47 --- /dev/null +++ b/keyboards/dc01/numpad/rules.mk | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | SRC += matrix.c \ | ||
| 2 | ../../../drivers/avr/i2c_slave.c | ||
| 3 | |||
| 4 | # MCU name | ||
| 5 | #MCU = at90usb1286 | ||
| 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 | # | ||
| 23 | # LUFA specific | ||
| 24 | # | ||
| 25 | # Target architecture (see library "Board Types" documentation). | ||
| 26 | ARCH = AVR8 | ||
| 27 | |||
| 28 | # Input clock frequency. | ||
| 29 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 30 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 31 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 32 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 33 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 34 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 35 | # source code. | ||
| 36 | # | ||
| 37 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 38 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 39 | F_USB = $(F_CPU) | ||
| 40 | |||
| 41 | # Interrupt driven control endpoint task(+60) | ||
| 42 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 43 | |||
| 44 | |||
| 45 | # Boot Section Size in *bytes* | ||
| 46 | # Teensy halfKay 512 | ||
| 47 | # Teensy++ halfKay 1024 | ||
| 48 | # Atmel DFU loader 4096 | ||
| 49 | # LUFA bootloader 4096 | ||
| 50 | # USBaspLoader 2048 | ||
| 51 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 52 | |||
| 53 | |||
| 54 | # Build Options | ||
| 55 | # change yes to no to disable | ||
| 56 | # | ||
| 57 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 58 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 59 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 60 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 61 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
| 62 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 63 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 64 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 65 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 66 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
| 67 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
| 68 | UNICODE_ENABLE = no # Unicode | ||
| 69 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 70 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 71 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
| 72 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) | ||
| 73 | NO_USB_STARTUP_CHECK = yes # Disable initialization only when usb is plugged in | ||
| 74 | CUSTOM_MATRIX = yes # Use custom matrix \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/config.h b/keyboards/dc01/right/config.h new file mode 100644 index 000000000..a1d49cc5c --- /dev/null +++ b/keyboards/dc01/right/config.h | |||
| @@ -0,0 +1,151 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2018 Yiancar | ||
| 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 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "config_common.h" | ||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x1011 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER Mechboards | ||
| 27 | #define PRODUCT DC01 Right | ||
| 28 | #define DESCRIPTION Right half of DC01 keyboard | ||
| 29 | |||
| 30 | /* key matrix size */ | ||
| 31 | #define MATRIX_ROWS 5 | ||
| 32 | #define MATRIX_COLS 8 | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Keyboard Matrix Assignments | ||
| 36 | * | ||
| 37 | * Change this to how you wired your keyboard | ||
| 38 | * COLS: AVR pins used for columns, left to right | ||
| 39 | * ROWS: AVR pins used for rows, top to bottom | ||
| 40 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
| 41 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
| 42 | * | ||
| 43 | */ | ||
| 44 | #define MATRIX_ROW_PINS { C7, C6, B6, B5, B4 } | ||
| 45 | #define MATRIX_COL_PINS { F1, E6, F6, F5, F4, D4, D6, D7 } | ||
| 46 | #define UNUSED_PINS | ||
| 47 | |||
| 48 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ | ||
| 49 | #define DIODE_DIRECTION COL2ROW | ||
| 50 | |||
| 51 | // #define BACKLIGHT_PIN B7 | ||
| 52 | // #define BACKLIGHT_BREATHING | ||
| 53 | // #define BACKLIGHT_LEVELS 3 | ||
| 54 | |||
| 55 | |||
| 56 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 57 | #define DEBOUNCING_DELAY 5 | ||
| 58 | |||
| 59 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
| 60 | //#define MATRIX_HAS_GHOST | ||
| 61 | |||
| 62 | /* number of backlight levels */ | ||
| 63 | |||
| 64 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
| 65 | #define LOCKING_SUPPORT_ENABLE | ||
| 66 | /* Locking resynchronize hack */ | ||
| 67 | #define LOCKING_RESYNC_ENABLE | ||
| 68 | |||
| 69 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
| 70 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
| 71 | */ | ||
| 72 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
| 73 | |||
| 74 | /* | ||
| 75 | * Force NKRO | ||
| 76 | * | ||
| 77 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 78 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 79 | * makefile for this to work.) | ||
| 80 | * | ||
| 81 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 82 | * until the next keyboard reset. | ||
| 83 | * | ||
| 84 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 85 | * fully operational during normal computer usage. | ||
| 86 | * | ||
| 87 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 88 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 89 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 90 | * power-up. | ||
| 91 | * | ||
| 92 | */ | ||
| 93 | //#define FORCE_NKRO | ||
| 94 | |||
| 95 | /* | ||
| 96 | * Magic Key Options | ||
| 97 | * | ||
| 98 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
| 99 | * the keyboard. They are best used in combination with the HID Listen program, | ||
| 100 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
| 101 | * | ||
| 102 | * The options below allow the magic key functionality to be changed. This is | ||
| 103 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
| 104 | * | ||
| 105 | */ | ||
| 106 | |||
| 107 | /* key combination for magic key command */ | ||
| 108 | #define IS_COMMAND() ( \ | ||
| 109 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 110 | ) | ||
| 111 | |||
| 112 | /* | ||
| 113 | * Feature disable options | ||
| 114 | * These options are also useful to firmware size reduction. | ||
| 115 | */ | ||
| 116 | |||
| 117 | /* disable debug print */ | ||
| 118 | //#define NO_DEBUG | ||
| 119 | |||
| 120 | /* disable print */ | ||
| 121 | //#define NO_PRINT | ||
| 122 | |||
| 123 | /* disable action features */ | ||
| 124 | //#define NO_ACTION_LAYER | ||
| 125 | //#define NO_ACTION_TAPPING | ||
| 126 | //#define NO_ACTION_ONESHOT | ||
| 127 | //#define NO_ACTION_MACRO | ||
| 128 | //#define NO_ACTION_FUNCTION | ||
| 129 | |||
| 130 | /* | ||
| 131 | * MIDI options | ||
| 132 | */ | ||
| 133 | |||
| 134 | /* Prevent use of disabled MIDI features in the keymap */ | ||
| 135 | //#define MIDI_ENABLE_STRICT 1 | ||
| 136 | |||
| 137 | /* enable basic MIDI features: | ||
| 138 | - MIDI notes can be sent when in Music mode is on | ||
| 139 | */ | ||
| 140 | //#define MIDI_BASIC | ||
| 141 | |||
| 142 | /* enable advanced MIDI features: | ||
| 143 | - MIDI notes can be added to the keymap | ||
| 144 | - Octave shift and transpose | ||
| 145 | - Virtual sustain, portamento, and modulation wheel | ||
| 146 | - etc. | ||
| 147 | */ | ||
| 148 | //#define MIDI_ADVANCED | ||
| 149 | |||
| 150 | /* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ | ||
| 151 | //#define MIDI_TONE_KEYCODE_OCTAVES 1 \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/info.json b/keyboards/dc01/right/info.json new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/keyboards/dc01/right/info.json | |||
diff --git a/keyboards/dc01/right/keymaps/default/keymap.c b/keyboards/dc01/right/keymaps/default/keymap.c new file mode 100644 index 000000000..556b77d69 --- /dev/null +++ b/keyboards/dc01/right/keymaps/default/keymap.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | [0] = LAYOUT_ANSI( /* Base */ | ||
| 20 | KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \ | ||
| 21 | KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,KC_BSLS, \ | ||
| 22 | KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, \ | ||
| 23 | KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, \ | ||
| 24 | KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL \ | ||
| 25 | ), | ||
| 26 | }; | ||
| 27 | |||
| 28 | void matrix_init_user(void) { | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | void matrix_scan_user(void) { | ||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 37 | return true; | ||
| 38 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/default/readme.md b/keyboards/dc01/right/keymaps/default/readme.md new file mode 100644 index 000000000..25567a4d3 --- /dev/null +++ b/keyboards/dc01/right/keymaps/default/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The default ANSI keymap for DC01 Right | ||
| 2 | |||
| 3 | When using the right module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/hhkb_ansi/keymap.c b/keyboards/dc01/right/keymaps/hhkb_ansi/keymap.c new file mode 100644 index 000000000..3d38787d3 --- /dev/null +++ b/keyboards/dc01/right/keymaps/hhkb_ansi/keymap.c | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | [0] = LAYOUT_HHKB_ANSI( /* Base */ | ||
| 20 | KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, \ | ||
| 21 | KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,KC_BSPC, \ | ||
| 22 | KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, \ | ||
| 23 | KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,MO(1), \ | ||
| 24 | KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL \ | ||
| 25 | ), | ||
| 26 | |||
| 27 | [1] = LAYOUT_HHKB_ANSI( | ||
| 28 | KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \ | ||
| 29 | KC_TRNS,KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC, \ | ||
| 30 | KC_PAST,KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT, \ | ||
| 31 | KC_PPLS,KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \ | ||
| 32 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \ | ||
| 33 | ), | ||
| 34 | }; | ||
| 35 | |||
| 36 | void matrix_init_user(void) { | ||
| 37 | |||
| 38 | } | ||
| 39 | |||
| 40 | void matrix_scan_user(void) { | ||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 44 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 45 | return true; | ||
| 46 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/hhkb_ansi/readme.md b/keyboards/dc01/right/keymaps/hhkb_ansi/readme.md new file mode 100644 index 000000000..e3025fe3e --- /dev/null +++ b/keyboards/dc01/right/keymaps/hhkb_ansi/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The default HHKB ANSI keymap for DC01 Right | ||
| 2 | |||
| 3 | When using the right module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/hhkb_iso/keymap.c b/keyboards/dc01/right/keymaps/hhkb_iso/keymap.c new file mode 100644 index 000000000..8e020bb50 --- /dev/null +++ b/keyboards/dc01/right/keymaps/hhkb_iso/keymap.c | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | [0] = LAYOUT_HHKB_ISO( /* Base */ | ||
| 20 | KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_BSPC, \ | ||
| 21 | KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, \ | ||
| 22 | KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_NUHS,KC_ENT, \ | ||
| 23 | KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,MO(1), \ | ||
| 24 | KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL \ | ||
| 25 | ), | ||
| 26 | |||
| 27 | [1] = LAYOUT_HHKB_ISO( | ||
| 28 | KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \ | ||
| 29 | KC_TRNS,KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, \ | ||
| 30 | KC_PAST,KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_TRNS, KC_PENT, \ | ||
| 31 | KC_PPLS,KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \ | ||
| 32 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \ | ||
| 33 | ), | ||
| 34 | }; | ||
| 35 | |||
| 36 | void matrix_init_user(void) { | ||
| 37 | |||
| 38 | } | ||
| 39 | |||
| 40 | void matrix_scan_user(void) { | ||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 44 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 45 | return true; | ||
| 46 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/hhkb_iso/readme.md b/keyboards/dc01/right/keymaps/hhkb_iso/readme.md new file mode 100644 index 000000000..36cae20ac --- /dev/null +++ b/keyboards/dc01/right/keymaps/hhkb_iso/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The default HHKB ISO keymap for DC01 Right | ||
| 2 | |||
| 3 | When using the right module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/iso/keymap.c b/keyboards/dc01/right/keymaps/iso/keymap.c new file mode 100644 index 000000000..b02a5ffdb --- /dev/null +++ b/keyboards/dc01/right/keymaps/iso/keymap.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include QMK_KEYBOARD_H | ||
| 17 | |||
| 18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 19 | [0] = LAYOUT_ISO( /* Base */ | ||
| 20 | KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \ | ||
| 21 | KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, \ | ||
| 22 | KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_NUHS,KC_ENT, \ | ||
| 23 | KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, \ | ||
| 24 | KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL \ | ||
| 25 | ), | ||
| 26 | }; | ||
| 27 | |||
| 28 | void matrix_init_user(void) { | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | void matrix_scan_user(void) { | ||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 37 | return true; | ||
| 38 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/keymaps/iso/readme.md b/keyboards/dc01/right/keymaps/iso/readme.md new file mode 100644 index 000000000..250169ed5 --- /dev/null +++ b/keyboards/dc01/right/keymaps/iso/readme.md | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | # The default ISO keymap for DC01 Right | ||
| 2 | |||
| 3 | When using the right module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module. \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/matrix.c b/keyboards/dc01/right/matrix.c new file mode 100644 index 000000000..aa2e880d0 --- /dev/null +++ b/keyboards/dc01/right/matrix.c | |||
| @@ -0,0 +1,404 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Copyright 2014 Jack Humbert | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | #include <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #if defined(__AVR__) | ||
| 21 | #include <avr/io.h> | ||
| 22 | #include <avr/wdt.h> | ||
| 23 | #include <avr/interrupt.h> | ||
| 24 | #include <util/delay.h> | ||
| 25 | #endif | ||
| 26 | #include "wait.h" | ||
| 27 | #include "print.h" | ||
| 28 | #include "debug.h" | ||
| 29 | #include "util.h" | ||
| 30 | #include "matrix.h" | ||
| 31 | #include "timer.h" | ||
| 32 | #include "i2c_slave.h" | ||
| 33 | #include "lufa.h" | ||
| 34 | |||
| 35 | #define SLAVE_I2C_ADDRESS 0x19 | ||
| 36 | |||
| 37 | /* Set 0 if debouncing isn't needed */ | ||
| 38 | |||
| 39 | #ifndef DEBOUNCING_DELAY | ||
| 40 | # define DEBOUNCING_DELAY 5 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if (DEBOUNCING_DELAY > 0) | ||
| 44 | static uint16_t debouncing_time; | ||
| 45 | static bool debouncing = false; | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #if (MATRIX_COLS <= 8) | ||
| 49 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
| 50 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
| 51 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
| 52 | # define ROW_SHIFTER ((uint8_t)1) | ||
| 53 | #elif (MATRIX_COLS <= 16) | ||
| 54 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | ||
| 55 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | ||
| 56 | # define matrix_bitpop(i) bitpop16(matrix[i]) | ||
| 57 | # define ROW_SHIFTER ((uint16_t)1) | ||
| 58 | #elif (MATRIX_COLS <= 32) | ||
| 59 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | ||
| 60 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | ||
| 61 | # define matrix_bitpop(i) bitpop32(matrix[i]) | ||
| 62 | # define ROW_SHIFTER ((uint32_t)1) | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifdef MATRIX_MASKED | ||
| 66 | extern const matrix_row_t matrix_mask[]; | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | ||
| 70 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
| 71 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | /* matrix state(1:on, 0:off) */ | ||
| 75 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 76 | |||
| 77 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 78 | |||
| 79 | |||
| 80 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 81 | static void init_cols(void); | ||
| 82 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
| 83 | static void unselect_rows(void); | ||
| 84 | static void select_row(uint8_t row); | ||
| 85 | static void unselect_row(uint8_t row); | ||
| 86 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 87 | static void init_rows(void); | ||
| 88 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
| 89 | static void unselect_cols(void); | ||
| 90 | static void unselect_col(uint8_t col); | ||
| 91 | static void select_col(uint8_t col); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | __attribute__ ((weak)) | ||
| 95 | void matrix_init_quantum(void) { | ||
| 96 | matrix_init_kb(); | ||
| 97 | } | ||
| 98 | |||
| 99 | __attribute__ ((weak)) | ||
| 100 | void matrix_scan_quantum(void) { | ||
| 101 | matrix_scan_kb(); | ||
| 102 | } | ||
| 103 | |||
| 104 | __attribute__ ((weak)) | ||
| 105 | void matrix_init_kb(void) { | ||
| 106 | matrix_init_user(); | ||
| 107 | } | ||
| 108 | |||
| 109 | __attribute__ ((weak)) | ||
| 110 | void matrix_scan_kb(void) { | ||
| 111 | matrix_scan_user(); | ||
| 112 | } | ||
| 113 | |||
| 114 | __attribute__ ((weak)) | ||
| 115 | void matrix_init_user(void) { | ||
| 116 | } | ||
| 117 | |||
| 118 | __attribute__ ((weak)) | ||
| 119 | void matrix_scan_user(void) { | ||
| 120 | } | ||
| 121 | |||
| 122 | inline | ||
| 123 | uint8_t matrix_rows(void) { | ||
| 124 | return MATRIX_ROWS; | ||
| 125 | } | ||
| 126 | |||
| 127 | inline | ||
| 128 | uint8_t matrix_cols(void) { | ||
| 129 | return MATRIX_COLS; | ||
| 130 | } | ||
| 131 | |||
| 132 | void matrix_init(void) { | ||
| 133 | |||
| 134 | // initialize row and col | ||
| 135 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 136 | unselect_rows(); | ||
| 137 | init_cols(); | ||
| 138 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 139 | unselect_cols(); | ||
| 140 | init_rows(); | ||
| 141 | #endif | ||
| 142 | |||
| 143 | // initialize matrix state: all keys off | ||
| 144 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 145 | matrix[i] = 0; | ||
| 146 | matrix_debouncing[i] = 0; | ||
| 147 | } | ||
| 148 | |||
| 149 | matrix_init_quantum(); | ||
| 150 | } | ||
| 151 | |||
| 152 | uint8_t matrix_scan(void) | ||
| 153 | { | ||
| 154 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 155 | |||
| 156 | // Set row, read cols | ||
| 157 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
| 158 | # if (DEBOUNCING_DELAY > 0) | ||
| 159 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
| 160 | |||
| 161 | if (matrix_changed) { | ||
| 162 | debouncing = true; | ||
| 163 | debouncing_time = timer_read(); | ||
| 164 | } | ||
| 165 | |||
| 166 | # else | ||
| 167 | read_cols_on_row(matrix, current_row); | ||
| 168 | # endif | ||
| 169 | |||
| 170 | } | ||
| 171 | |||
| 172 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 173 | |||
| 174 | // Set col, read rows | ||
| 175 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
| 176 | # if (DEBOUNCING_DELAY > 0) | ||
| 177 | bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col); | ||
| 178 | if (matrix_changed) { | ||
| 179 | debouncing = true; | ||
| 180 | debouncing_time = timer_read(); | ||
| 181 | } | ||
| 182 | # else | ||
| 183 | read_rows_on_col(matrix, current_col); | ||
| 184 | # endif | ||
| 185 | |||
| 186 | } | ||
| 187 | |||
| 188 | #endif | ||
| 189 | |||
| 190 | # if (DEBOUNCING_DELAY > 0) | ||
| 191 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
| 192 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 193 | matrix[i] = matrix_debouncing[i]; | ||
| 194 | } | ||
| 195 | debouncing = false; | ||
| 196 | } | ||
| 197 | # endif | ||
| 198 | |||
| 199 | if (USB_DeviceState != DEVICE_STATE_Configured){ | ||
| 200 | txbuffer[1] = 0x55; | ||
| 201 | for (uint8_t i = 0; i < MATRIX_ROWS; i++){ | ||
| 202 | txbuffer[i+2] = matrix[i]; //send matrix over i2c | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | matrix_scan_quantum(); | ||
| 207 | return 1; | ||
| 208 | } | ||
| 209 | |||
| 210 | bool matrix_is_modified(void) | ||
| 211 | { | ||
| 212 | #if (DEBOUNCING_DELAY > 0) | ||
| 213 | if (debouncing) return false; | ||
| 214 | #endif | ||
| 215 | return true; | ||
| 216 | } | ||
| 217 | |||
| 218 | inline | ||
| 219 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 220 | { | ||
| 221 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 222 | } | ||
| 223 | |||
| 224 | inline | ||
| 225 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 226 | { | ||
| 227 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | ||
| 228 | // switch blocker installed and the switch is always pressed. | ||
| 229 | #ifdef MATRIX_MASKED | ||
| 230 | return matrix[row] & matrix_mask[row]; | ||
| 231 | #else | ||
| 232 | return matrix[row]; | ||
| 233 | #endif | ||
| 234 | } | ||
| 235 | |||
| 236 | void matrix_print(void) | ||
| 237 | { | ||
| 238 | print_matrix_header(); | ||
| 239 | |||
| 240 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 241 | phex(row); print(": "); | ||
| 242 | print_matrix_row(row); | ||
| 243 | print("\n"); | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | uint8_t matrix_key_count(void) | ||
| 248 | { | ||
| 249 | uint8_t count = 0; | ||
| 250 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 251 | count += matrix_bitpop(i); | ||
| 252 | } | ||
| 253 | return count; | ||
| 254 | } | ||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 259 | |||
| 260 | static void init_cols(void) | ||
| 261 | { | ||
| 262 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 263 | uint8_t pin = col_pins[x]; | ||
| 264 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 265 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 269 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
| 270 | { | ||
| 271 | // Store last value of row prior to reading | ||
| 272 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 273 | |||
| 274 | // Clear data in matrix row | ||
| 275 | current_matrix[current_row] = 0; | ||
| 276 | |||
| 277 | // Select row and wait for row selecton to stabilize | ||
| 278 | select_row(current_row); | ||
| 279 | wait_us(30); | ||
| 280 | |||
| 281 | // For each col... | ||
| 282 | for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | ||
| 283 | |||
| 284 | // Select the col pin to read (active low) | ||
| 285 | uint8_t pin = col_pins[col_index]; | ||
| 286 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
| 287 | |||
| 288 | // Populate the matrix row with the state of the col pin | ||
| 289 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
| 290 | } | ||
| 291 | |||
| 292 | // Unselect row | ||
| 293 | unselect_row(current_row); | ||
| 294 | |||
| 295 | return (last_row_value != current_matrix[current_row]); | ||
| 296 | } | ||
| 297 | |||
| 298 | static void select_row(uint8_t row) | ||
| 299 | { | ||
| 300 | uint8_t pin = row_pins[row]; | ||
| 301 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 302 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 303 | } | ||
| 304 | |||
| 305 | static void unselect_row(uint8_t row) | ||
| 306 | { | ||
| 307 | uint8_t pin = row_pins[row]; | ||
| 308 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 309 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 310 | } | ||
| 311 | |||
| 312 | static void unselect_rows(void) | ||
| 313 | { | ||
| 314 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 315 | uint8_t pin = row_pins[x]; | ||
| 316 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 317 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 322 | |||
| 323 | static void init_rows(void) | ||
| 324 | { | ||
| 325 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
| 326 | uint8_t pin = row_pins[x]; | ||
| 327 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 328 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | ||
| 333 | { | ||
| 334 | bool matrix_changed = false; | ||
| 335 | |||
| 336 | // Select col and wait for col selecton to stabilize | ||
| 337 | select_col(current_col); | ||
| 338 | wait_us(30); | ||
| 339 | |||
| 340 | // For each row... | ||
| 341 | for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) | ||
| 342 | { | ||
| 343 | |||
| 344 | // Store last value of row prior to reading | ||
| 345 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
| 346 | |||
| 347 | // Check row pin state | ||
| 348 | if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0) | ||
| 349 | { | ||
| 350 | // Pin LO, set col bit | ||
| 351 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
| 352 | } | ||
| 353 | else | ||
| 354 | { | ||
| 355 | // Pin HI, clear col bit | ||
| 356 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
| 357 | } | ||
| 358 | |||
| 359 | // Determine if the matrix changed state | ||
| 360 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
| 361 | { | ||
| 362 | matrix_changed = true; | ||
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 366 | // Unselect col | ||
| 367 | unselect_col(current_col); | ||
| 368 | |||
| 369 | return matrix_changed; | ||
| 370 | } | ||
| 371 | |||
| 372 | static void select_col(uint8_t col) | ||
| 373 | { | ||
| 374 | uint8_t pin = col_pins[col]; | ||
| 375 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
| 376 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
| 377 | } | ||
| 378 | |||
| 379 | static void unselect_col(uint8_t col) | ||
| 380 | { | ||
| 381 | uint8_t pin = col_pins[col]; | ||
| 382 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 383 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 384 | } | ||
| 385 | |||
| 386 | static void unselect_cols(void) | ||
| 387 | { | ||
| 388 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 389 | uint8_t pin = col_pins[x]; | ||
| 390 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
| 391 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
| 392 | } | ||
| 393 | } | ||
| 394 | |||
| 395 | #endif | ||
| 396 | |||
| 397 | //this replases tmk code | ||
| 398 | void matrix_setup(void){ | ||
| 399 | |||
| 400 | if (USB_DeviceState != DEVICE_STATE_Configured){ | ||
| 401 | i2c_init(SLAVE_I2C_ADDRESS); //setup address of slave i2c | ||
| 402 | sei(); //enable interupts | ||
| 403 | } | ||
| 404 | } \ No newline at end of file | ||
diff --git a/keyboards/dc01/right/readme.md b/keyboards/dc01/right/readme.md new file mode 100644 index 000000000..c8b72aaa1 --- /dev/null +++ b/keyboards/dc01/right/readme.md | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # DC01 Right Half | ||
| 2 | |||
| 3 |  | ||
| 4 | |||
| 5 | A hotpluggable four part keyboard which comes together with magnets and pogo pins! This is the right part | ||
| 6 | |||
| 7 | Keyboard Maintainer: [Yiancar](https://github.com/yiancar) | ||
| 8 | Hardware Supported: Runs on an atmega32u4 | ||
| 9 | Hardware Availability: [Mechboards](https://mechboards.co.uk/) | ||
| 10 | |||
| 11 | Make example for this keyboard (after setting up your build environment): | ||
| 12 | |||
| 13 | make dc01/right:default | ||
| 14 | |||
| 15 | 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/dc01/right/right.c b/keyboards/dc01/right/right.c new file mode 100644 index 000000000..fc2dead4c --- /dev/null +++ b/keyboards/dc01/right/right.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include "right.h" | ||
| 17 | |||
| 18 | void matrix_init_kb(void) { | ||
| 19 | // put your keyboard start-up code here | ||
| 20 | // runs once when the firmware starts up | ||
| 21 | |||
| 22 | matrix_init_user(); | ||
| 23 | } | ||
| 24 | |||
| 25 | void matrix_scan_kb(void) { | ||
| 26 | // put your looping keyboard code here | ||
| 27 | // runs every cycle (a lot) | ||
| 28 | |||
| 29 | matrix_scan_user(); | ||
| 30 | } | ||
| 31 | |||
| 32 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 33 | // put your per-action keyboard code here | ||
| 34 | // runs for every action, just before processing by the firmware | ||
| 35 | |||
| 36 | return process_record_user(keycode, record); | ||
| 37 | } | ||
| 38 | |||
| 39 | void led_set_kb(uint8_t usb_led) { | ||
| 40 | // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here | ||
| 41 | |||
| 42 | led_set_user(usb_led); | ||
| 43 | } | ||
diff --git a/keyboards/dc01/right/right.h b/keyboards/dc01/right/right.h new file mode 100644 index 000000000..aa5c10ca2 --- /dev/null +++ b/keyboards/dc01/right/right.h | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* Copyright 2018 Yiancar | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef RIGHT_H | ||
| 17 | #define RIGHT_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | #define XXX KC_NO | ||
| 22 | |||
| 23 | // This a shortcut to help you visually see your layout. | ||
| 24 | // The first section contains all of the arguments | ||
| 25 | // The second converts the arguments into a two-dimensional array | ||
| 26 | #define LAYOUT_ANSI( \ | ||
| 27 | K01, K02, K03, K04, K05, K06, K07, \ | ||
| 28 | K10, K11, K12, K13, K14, K15, K16, K17, \ | ||
| 29 | K20, K21, K22, K23, K24, K25, K27, \ | ||
| 30 | K30, K31, K32, K33, K34, K37, \ | ||
| 31 | K40, K41, K42, K43, K44, K45 \ | ||
| 32 | ) \ | ||
| 33 | { \ | ||
| 34 | { XXX, K01, K02, K03, K04, K05, K06, K07 }, \ | ||
| 35 | { K10, K11, K12, K13, K14, K15, K16, K17 }, \ | ||
| 36 | { K20, K21, K22, K23, K24, K25, XXX, K27 }, \ | ||
| 37 | { K30, K31, K32, K33, K34, XXX, XXX, K37 }, \ | ||
| 38 | { K40, K41, K42, K43, K44, K45, XXX, XXX } \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #define LAYOUT_ISO( \ | ||
| 42 | K01, K02, K03, K04, K05, K06, K07, \ | ||
| 43 | K10, K11, K12, K13, K14, K15, K16, \ | ||
| 44 | K20, K21, K22, K23, K24, K25, K26, K27, \ | ||
| 45 | K30, K31, K32, K33, K34, K37, \ | ||
| 46 | K40, K41, K42, K43, K44, K45 \ | ||
| 47 | ) \ | ||
| 48 | { \ | ||
| 49 | { XXX, K01, K02, K03, K04, K05, K06, K07 }, \ | ||
| 50 | { K10, K11, K12, K13, K14, K15, K16, XXX }, \ | ||
| 51 | { K20, K21, K22, K23, K24, K25, K26, K27 }, \ | ||
| 52 | { K30, K31, K32, K33, K34, XXX, XXX, K37 }, \ | ||
| 53 | { K40, K41, K42, K43, K44, K45, XXX, XXX } \ | ||
| 54 | } | ||
| 55 | |||
| 56 | #define LAYOUT_HHKB_ANSI( \ | ||
| 57 | K01, K02, K03, K04, K05, K06, K07, K00, \ | ||
| 58 | K10, K11, K12, K13, K14, K15, K16, K17, \ | ||
| 59 | K20, K21, K22, K23, K24, K25, K27, \ | ||
| 60 | K30, K31, K32, K33, K34, K36, K37, \ | ||
| 61 | K40, K41, K42, K43, K44, K45 \ | ||
| 62 | ) \ | ||
| 63 | { \ | ||
| 64 | { K00, K01, K02, K03, K04, K05, K06, K07 }, \ | ||
| 65 | { K10, K11, K12, K13, K14, K15, K16, K17 }, \ | ||
| 66 | { K20, K21, K22, K23, K24, K25, XXX, K27 }, \ | ||
| 67 | { K30, K31, K32, K33, K34, XXX, K36, K37 }, \ | ||
| 68 | { K40, K41, K42, K43, K44, K45, XXX, XXX } \ | ||
| 69 | } | ||
| 70 | |||
| 71 | #define LAYOUT_HHKB_ISO( \ | ||
| 72 | K01, K02, K03, K04, K05, K06, K07, K00, \ | ||
| 73 | K10, K11, K12, K13, K14, K15, K16, \ | ||
| 74 | K20, K21, K22, K23, K24, K25, K26, K27, \ | ||
| 75 | K30, K31, K32, K33, K34, K36, K37, \ | ||
| 76 | K40, K41, K42, K43, K44, K45 \ | ||
| 77 | ) \ | ||
| 78 | { \ | ||
| 79 | { K00, K01, K02, K03, K04, K05, K06, K07 }, \ | ||
| 80 | { K10, K11, K12, K13, K14, K15, K16, XXX }, \ | ||
| 81 | { K20, K21, K22, K23, K24, K25, K26, K27 }, \ | ||
| 82 | { K30, K31, K32, K33, K34, XXX, K36, K37 }, \ | ||
| 83 | { K40, K41, K42, K43, K44, K45, XXX, XXX } \ | ||
| 84 | } | ||
| 85 | |||
| 86 | #endif | ||
diff --git a/keyboards/dc01/right/rules.mk b/keyboards/dc01/right/rules.mk new file mode 100644 index 000000000..c45789353 --- /dev/null +++ b/keyboards/dc01/right/rules.mk | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | SRC += matrix.c \ | ||
| 2 | ../../../drivers/avr/i2c_slave.c | ||
| 3 | |||
| 4 | # MCU name | ||
| 5 | #MCU = at90usb1286 | ||
| 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 | # | ||
| 23 | # LUFA specific | ||
| 24 | # | ||
| 25 | # Target architecture (see library "Board Types" documentation). | ||
| 26 | ARCH = AVR8 | ||
| 27 | |||
| 28 | # Input clock frequency. | ||
| 29 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 30 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 31 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 32 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 33 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 34 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 35 | # source code. | ||
| 36 | # | ||
| 37 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 38 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 39 | F_USB = $(F_CPU) | ||
| 40 | |||
| 41 | # Interrupt driven control endpoint task(+60) | ||
| 42 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 43 | |||
| 44 | |||
| 45 | # Boot Section Size in *bytes* | ||
| 46 | # Teensy halfKay 512 | ||
| 47 | # Teensy++ halfKay 1024 | ||
| 48 | # Atmel DFU loader 4096 | ||
| 49 | # LUFA bootloader 4096 | ||
| 50 | # USBaspLoader 2048 | ||
| 51 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 52 | |||
| 53 | |||
| 54 | # Build Options | ||
| 55 | # change yes to no to disable | ||
| 56 | # | ||
| 57 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 58 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 59 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 60 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 61 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
| 62 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 63 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 64 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 65 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 66 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | ||
| 67 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | ||
| 68 | UNICODE_ENABLE = no # Unicode | ||
| 69 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 70 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 71 | FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches | ||
| 72 | HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) | ||
| 73 | NO_USB_STARTUP_CHECK = yes # Disable initialization only when usb is plugged in | ||
| 74 | CUSTOM_MATRIX = yes # Use custom matrix \ No newline at end of file | ||
