summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Wilson <scott.t.wilson@gmail.com>2017-12-03 10:32:07 -0500
committerJack Humbert <jack.humb@gmail.com>2017-12-09 00:01:58 -0500
commitc51dfef958bce4a792b66db337d5c7cdf0956fc4 (patch)
treeb51a3d2a95c5ba47416e2964bc98c9ad329cf168
parent8b1862330a960b0413046ed6fdba78d2570e7988 (diff)
Add support for LFKeyboard products: LFK78, LFK87 and SMK65
-rw-r--r--keyboards/lfkeyboards/TWIlib.c283
-rw-r--r--keyboards/lfkeyboards/TWIlib.h81
-rw-r--r--keyboards/lfkeyboards/issi.c244
-rw-r--r--keyboards/lfkeyboards/issi.h40
-rw-r--r--keyboards/lfkeyboards/lfk78/config.h172
-rw-r--r--keyboards/lfkeyboards/lfk78/keymaps/default/config.h8
-rw-r--r--keyboards/lfkeyboards/lfk78/keymaps/default/keymap.c123
-rw-r--r--keyboards/lfkeyboards/lfk78/keymaps/default/readme.md1
-rw-r--r--keyboards/lfkeyboards/lfk78/keymaps/default/rules.mk42
-rw-r--r--keyboards/lfkeyboards/lfk78/lfk78.c225
-rw-r--r--keyboards/lfkeyboards/lfk78/lfk78.h155
-rw-r--r--keyboards/lfkeyboards/lfk78/readme.md14
-rw-r--r--keyboards/lfkeyboards/lfk78/rules.mk34
-rw-r--r--keyboards/lfkeyboards/lfk87/config.h173
-rw-r--r--keyboards/lfkeyboards/lfk87/keymaps/default/config.h8
-rw-r--r--keyboards/lfkeyboards/lfk87/keymaps/default/keymap.c133
-rw-r--r--keyboards/lfkeyboards/lfk87/keymaps/default/rules.mk54
-rw-r--r--keyboards/lfkeyboards/lfk87/keymaps/iso/config.h8
-rw-r--r--keyboards/lfkeyboards/lfk87/keymaps/iso/keymap.c137
-rw-r--r--keyboards/lfkeyboards/lfk87/keymaps/iso/rules.mk53
-rw-r--r--keyboards/lfkeyboards/lfk87/lfk87.c215
-rw-r--r--keyboards/lfkeyboards/lfk87/lfk87.h139
-rw-r--r--keyboards/lfkeyboards/lfk87/readme.md14
-rw-r--r--keyboards/lfkeyboards/lfk87/rules.mk31
-rw-r--r--keyboards/lfkeyboards/lfkeyboards.c0
-rw-r--r--keyboards/lfkeyboards/lfkeyboards.h0
-rw-r--r--keyboards/lfkeyboards/lighting.c157
-rw-r--r--keyboards/lfkeyboards/lighting.h53
-rw-r--r--keyboards/lfkeyboards/rules.mk1
-rw-r--r--keyboards/lfkeyboards/smk65/config.h168
-rw-r--r--keyboards/lfkeyboards/smk65/keymaps/default/config.h8
-rw-r--r--keyboards/lfkeyboards/smk65/keymaps/default/keymap.c85
-rw-r--r--keyboards/lfkeyboards/smk65/keymaps/default/rules.mk36
-rw-r--r--keyboards/lfkeyboards/smk65/readme.md14
-rw-r--r--keyboards/lfkeyboards/smk65/rules.mk17
-rw-r--r--keyboards/lfkeyboards/smk65/smk65.c164
-rw-r--r--keyboards/lfkeyboards/smk65/smk65.h90
37 files changed, 3180 insertions, 0 deletions
diff --git a/keyboards/lfkeyboards/TWIlib.c b/keyboards/lfkeyboards/TWIlib.c
new file mode 100644
index 0000000000..abb12cc87a
--- /dev/null
+++ b/keyboards/lfkeyboards/TWIlib.c
@@ -0,0 +1,283 @@
+/*
+ * TWIlib.c
+ *
+ * Created: 6/01/2014 10:41:33 PM
+ * Author: Chris Herring
+ */
+
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include "TWIlib.h"
+#include "util/delay.h"
+#include "print.h"
+
+void TWIInit()
+{
+ TWIInfo.mode = Ready;
+ TWIInfo.errorCode = 0xFF;
+ TWIInfo.repStart = 0;
+ // Set pre-scalers (no pre-scaling)
+ TWSR = 0;
+ // Set bit rate
+ TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
+ // Enable TWI and interrupt
+ TWCR = (1 << TWIE) | (1 << TWEN);
+}
+
+uint8_t isTWIReady()
+{
+ if ( (TWIInfo.mode == Ready) | (TWIInfo.mode == RepeatedStartSent) )
+ {
+ return 1;
+ }
+ else
+ {
+ if(TWIInfo.mode == Initializing){
+ switch(TWIInfo.errorCode){
+ case TWI_SUCCESS:
+ case TWI_NO_RELEVANT_INFO:
+ break;
+ case TWI_LOST_ARBIT:
+ case TWI_MT_DATA_NACK:
+ // Some kind of I2C error, reset and re-init
+ xprintf("I2C init error: %d\n", TWIInfo.errorCode);
+ TWCR = (1 << TWINT)|(1 << TWSTO);
+ TWIInit();
+ break;
+ default:
+ xprintf("Other i2c init error: %d\n", TWIInfo.errorCode);
+ }
+ }
+ return 0;
+ }
+}
+
+
+void TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart, uint8_t blocking)
+{
+ // Wait until ready
+ while (!isTWIReady()) {_delay_us(1);}
+ // Reset the I2C stuff
+ TWCR = (1 << TWINT)|(1 << TWSTO);
+ TWIInit();
+ // Set repeated start mode
+ TWIInfo.repStart = repStart;
+ // Copy transmit info to global variables
+ TWITransmitBuffer = (uint8_t *)TXdata;
+ TXBuffLen = dataLen;
+ TXBuffIndex = 0;
+
+ // If a repeated start has been sent, then devices are already listening for an address
+ // and another start does not need to be sent.
+ if (TWIInfo.mode == RepeatedStartSent)
+ {
+ TWIInfo.mode = Initializing;
+ TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
+ TWISendTransmit(); // Send the data
+ }
+ else // Otherwise, just send the normal start signal to begin transmission.
+ {
+ TWIInfo.mode = Initializing;
+ TWISendStart();
+ }
+ if(blocking){
+ // Wait until ready
+ while (!isTWIReady()){_delay_us(1);}
+ }
+}
+
+
+// uint8_t TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart)
+// {
+// if (dataLen <= TXMAXBUFLEN)
+// {
+// // Wait until ready
+// while (!isTWIReady()) {_delay_us(1);}
+// // Set repeated start mode
+// TWIInfo.repStart = repStart;
+// // Copy data into the transmit buffer
+// uint8_t *data = (uint8_t *)TXdata;
+// for (int i = 0; i < dataLen; i++)
+// {
+// TWITransmitBuffer[i] = data[i];
+// }
+// // Copy transmit info to global variables
+// TXBuffLen = dataLen;
+// TXBuffIndex = 0;
+
+// // If a repeated start has been sent, then devices are already listening for an address
+// // and another start does not need to be sent.
+// if (TWIInfo.mode == RepeatedStartSent)
+// {
+// TWIInfo.mode = Initializing;
+// TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
+// TWISendTransmit(); // Send the data
+// }
+// else // Otherwise, just send the normal start signal to begin transmission.
+// {
+// TWIInfo.mode = Initializing;
+// TWISendStart();
+// }
+
+// }
+// else
+// {
+// return 1; // return an error if data length is longer than buffer
+// }
+// return 0;
+// }
+
+uint8_t TWIReadData(uint8_t TWIaddr, uint8_t bytesToRead, uint8_t repStart)
+{
+ // Check if number of bytes to read can fit in the RXbuffer
+ if (bytesToRead < RXMAXBUFLEN)
+ {
+ // Reset buffer index and set RXBuffLen to the number of bytes to read
+ RXBuffIndex = 0;
+ RXBuffLen = bytesToRead;
+ // Create the one value array for the address to be transmitted
+ uint8_t TXdata[1];
+ // Shift the address and AND a 1 into the read write bit (set to write mode)
+ TXdata[0] = (TWIaddr << 1) | 0x01;
+ // Use the TWITransmitData function to initialize the transfer and address the slave
+ TWITransmitData(TXdata, 1, repStart, 0);
+ }
+ else
+ {
+ return 0;
+ }
+ return 1;
+}
+
+ISR (TWI_vect)
+{
+ switch (TWI_STATUS)
+ {
+ // ----\/ ---- MASTER TRANSMITTER OR WRITING ADDRESS ----\/ ---- //
+ case TWI_MT_SLAW_ACK: // SLA+W transmitted and ACK received
+ // Set mode to Master Transmitter
+ TWIInfo.mode = MasterTransmitter;
+ case TWI_START_SENT: // Start condition has been transmitted
+ case TWI_MT_DATA_ACK: // Data byte has been transmitted, ACK received
+ if (TXBuffIndex < TXBuffLen) // If there is more data to send
+ {
+ TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
+ TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
+ TWISendTransmit(); // Send the data
+ }
+ // This transmission is complete however do not release bus yet
+ else if (TWIInfo.repStart)
+ {
+ TWIInfo.errorCode = 0xFF;
+ TWISendStart();
+ }
+ // All transmissions are complete, exit
+ else
+ {
+ TWIInfo.mode = Ready;
+ TWIInfo.errorCode = 0xFF;
+ TWISendStop();
+ }
+ break;
+
+ // ----\/ ---- MASTER RECEIVER ----\/ ---- //
+
+ case TWI_MR_SLAR_ACK: // SLA+R has been transmitted, ACK has been received
+ // Switch to Master Receiver mode
+ TWIInfo.mode = MasterReceiver;
+ // If there is more than one byte to be read, receive data byte and return an ACK
+ if (RXBuffIndex < RXBuffLen-1)
+ {
+ TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
+ TWISendACK();
+ }
+ // Otherwise when a data byte (the only data byte) is received, return NACK
+ else
+ {
+ TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
+ TWISendNACK();
+ }
+ break;
+
+ case TWI_MR_DATA_ACK: // Data has been received, ACK has been transmitted.
+
+ /// -- HANDLE DATA BYTE --- ///
+ TWIReceiveBuffer[RXBuffIndex++] = TWDR;
+ // If there is more than one byte to be read, receive data byte and return an ACK
+ if (RXBuffIndex < RXBuffLen-1)
+ {
+ TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
+ TWISendACK();
+ }
+ // Otherwise when a data byte (the only data byte) is received, return NACK
+ else
+ {
+ TWIInfo.errorCode = TWI_NO_RELEVANT_INFO;
+ TWISendNACK();
+ }
+ break;
+
+ case TWI_MR_DATA_NACK: // Data byte has been received, NACK has been transmitted. End of transmission.
+
+ /// -- HANDLE DATA BYTE --- ///
+ TWIReceiveBuffer[RXBuffIndex++] = TWDR;
+ // This transmission is complete however do not release bus yet
+ if (TWIInfo.repStart)
+ {
+ TWIInfo.errorCode = 0xFF;
+ TWISendStart();
+ }
+ // All transmissions are complete, exit
+ else
+ {
+ TWIInfo.mode = Ready;
+ TWIInfo.errorCode = 0xFF;
+ TWISendStop();
+ }
+ break;
+
+ // ----\/ ---- MT and MR common ----\/ ---- //
+
+ case TWI_MR_SLAR_NACK: // SLA+R transmitted, NACK received
+ case TWI_MT_SLAW_NACK: // SLA+W transmitted, NACK received
+ case TWI_MT_DATA_NACK: // Data byte has been transmitted, NACK received
+ case TWI_LOST_ARBIT: // Arbitration has been lost
+ // Return error and send stop and set mode to ready
+ if (TWIInfo.repStart)
+ {
+ TWIInfo.errorCode = TWI_STATUS;
+ TWISendStart();
+ }
+ // All transmissions are complete, exit
+ else
+ {
+ TWIInfo.mode = Ready;
+ TWIInfo.errorCode = TWI_STATUS;
+ TWISendStop();
+ }
+ break;
+ case TWI_REP_START_SENT: // Repeated start has been transmitted
+ // Set the mode but DO NOT clear TWINT as the next data is not yet ready
+ TWIInfo.mode = RepeatedStartSent;
+ break;
+
+ // ----\/ ---- SLAVE RECEIVER ----\/ ---- //
+
+ // TODO IMPLEMENT SLAVE RECEIVER FUNCTIONALITY
+
+ // ----\/ ---- SLAVE TRANSMITTER ----\/ ---- //
+
+ // TODO IMPLEMENT SLAVE TRANSMITTER FUNCTIONALITY
+
+ // ----\/ ---- MISCELLANEOUS STATES ----\/ ---- //
+ case TWI_NO_RELEVANT_INFO: // It is not really possible to get into this ISR on this condition
+ // Rather, it is there to be manually set between operations
+ break;
+ case TWI_ILLEGAL_START_STOP: // Illegal START/STOP, abort and return error
+ TWIInfo.errorCode = TWI_ILLEGAL_START_STOP;
+ TWIInfo.mode = Ready;
+ TWISendStop();
+ break;
+ }
+
+}
diff --git a/keyboards/lfkeyboards/TWIlib.h b/keyboards/lfkeyboards/TWIlib.h
new file mode 100644
index 0000000000..6db3cc9513
--- /dev/null
+++ b/keyboards/lfkeyboards/TWIlib.h
@@ -0,0 +1,81 @@
+/*
+ * TWIlib.h
+ *
+ * Created: 6/01/2014 10:38:42 PM
+ * Author: Chris Herring
+ */
+
+
+#ifndef TWILIB_H_
+#define TWILIB_H_
+// TWI bit rate
+#define TWI_FREQ 400000
+// Get TWI status
+#define TWI_STATUS (TWSR & 0xF8)
+// Transmit buffer length
+#define TXMAXBUFLEN 20
+// Receive buffer length
+#define RXMAXBUFLEN 20
+// Global transmit buffer
+volatile uint8_t *TWITransmitBuffer;
+// Global receive buffer
+volatile uint8_t TWIReceiveBuffer[RXMAXBUFLEN];
+// Buffer indexes
+volatile int TXBuffIndex; // Index of the transmit buffer. Is volatile, can change at any time.
+int RXBuffIndex; // Current index in the receive buffer
+// Buffer lengths
+int TXBuffLen; // The total length of the transmit buffer
+int RXBuffLen; // The total number of bytes to read (should be less than RXMAXBUFFLEN)
+
+typedef enum {
+ Ready,
+ Initializing,
+ RepeatedStartSent,
+ MasterTransmitter,
+ MasterReceiver,
+ SlaceTransmitter,
+ SlaveReciever
+ } TWIMode;
+
+ typedef struct TWIInfoStruct{
+ TWIMode mode;
+ uint8_t errorCode;
+ uint8_t repStart;
+ }TWIInfoStruct;
+TWIInfoStruct TWIInfo;
+
+
+// TWI Status Codes
+#define TWI_START_SENT 0x08 // Start sent
+#define TWI_REP_START_SENT 0x10 // Repeated Start sent
+// Master Transmitter Mode
+#define TWI_MT_SLAW_ACK 0x18 // SLA+W sent and ACK received
+#define TWI_MT_SLAW_NACK 0x20 // SLA+W sent and NACK received
+#define TWI_MT_DATA_ACK 0x28 // DATA sent and ACK received
+#define TWI_MT_DATA_NACK 0x30 // DATA sent and NACK received
+// Master Receiver Mode
+#define TWI_MR_SLAR_ACK 0x40 // SLA+R sent, ACK received
+#define TWI_MR_SLAR_NACK 0x48 // SLA+R sent, NACK received
+#define TWI_MR_DATA_ACK 0x50 // Data received, ACK returned
+#define TWI_MR_DATA_NACK 0x58 // Data received, NACK returned
+
+// Miscellaneous States
+#define TWI_LOST_ARBIT 0x38 // Arbitration has been lost
+#define TWI_NO_RELEVANT_INFO 0xF8 // No relevant information available
+#define TWI_ILLEGAL_START_STOP 0x00 // Illegal START or STOP condition has been detected
+#define TWI_SUCCESS 0xFF // Successful transfer, this state is impossible from TWSR as bit2 is 0 and read only
+
+
+#define TWISendStart() (TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE)) // Send the START signal, enable interrupts and TWI, clear TWINT flag to resume transfer.
+#define TWISendStop() (TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN)|(1<<TWIE)) // Send the STOP signal, enable interrupts and TWI, clear TWINT flag.
+#define TWISendTransmit() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)) // Used to resume a transfer, clear TWINT and ensure that TWI and interrupts are enabled.
+#define TWISendACK() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)|(1<<TWEA)) // FOR MR mode. Resume a transfer, ensure that TWI and interrupts are enabled and respond with an ACK if the device is addressed as a slave or after it receives a byte.
+#define TWISendNACK() (TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWIE)) // FOR MR mode. Resume a transfer, ensure that TWI and interrupts are enabled but DO NOT respond with an ACK if the device is addressed as a slave or after it receives a byte.
+
+// Function declarations
+void TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart, uint8_t blocking);
+void TWIInit(void);
+uint8_t TWIReadData(uint8_t TWIaddr, uint8_t bytesToRead, uint8_t repStart);
+uint8_t isTWIReady(void);
+
+#endif // TWICOMMS_H_ \ No newline at end of file
diff --git a/keyboards/lfkeyboards/issi.c b/keyboards/lfkeyboards/issi.c
new file mode 100644
index 0000000000..e675a59868
--- /dev/null
+++ b/keyboards/lfkeyboards/issi.c
@@ -0,0 +1,244 @@
+#ifdef ISSI_ENABLE
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <util/delay.h>
+#include <avr/sfr_defs.h>
+#include <avr/io.h>
+#include <util/twi.h>
+#include "issi.h"
+#include "print.h"
+#include "TWIlib.h"
+
+#define ISSI_ADDR_DEFAULT 0xE8
+
+#define ISSI_REG_CONFIG 0x00
+#define ISSI_REG_CONFIG_PICTUREMODE 0x00
+#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
+
+#define ISSI_CONF_PICTUREMODE 0x00
+#define ISSI_CONF_AUTOFRAMEMODE 0x04
+#define ISSI_CONF_AUDIOMODE 0x08
+
+#define ISSI_REG_PICTUREFRAME 0x01
+
+#define ISSI_REG_SHUTDOWN 0x0A
+#define ISSI_REG_AUDIOSYNC 0x06
+
+#define ISSI_COMMANDREGISTER 0xFD
+#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
+uint8_t control[8][9] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
+};
+ISSIDeviceStruct *issi_devices[4] = {0, 0, 0, 0};
+
+#ifndef cbi
+#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
+#endif
+
+#ifndef sbi
+#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
+#endif
+
+#define I2C_WRITE 0
+#define F_SCL 400000UL // SCL frequency
+#define Prescaler 1
+#define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16 ) / 2)
+
+uint8_t i2c_start(uint8_t address)
+{
+ // reset TWI control register
+ TWCR = 0;
+ // transmit START condition
+ TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
+ // wait for end of transmission
+ while( !(TWCR & (1<<TWINT)) );
+
+ // check if the start condition was successfully transmitted
+ if((TWSR & 0xF8) != TW_START){ return 1; }
+
+ // load slave address into data register
+ TWDR = address;
+ // start transmission of address
+ TWCR = (1<<TWINT) | (1<<TWEN);
+ // wait for end of transmission
+ while( !(TWCR & (1<<TWINT)) );
+
+ // check if the device has acknowledged the READ / WRITE mode
+ uint8_t twst = TW_STATUS & 0xF8;
+ if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;
+
+ return 0;
+}
+
+uint8_t i2c_write(uint8_t data)
+{
+ // load data into data register
+ TWDR = data;
+ // start transmission of data
+ TWCR = (1 << TWINT) | (1 << TWEN);
+ // wait for end of transmission
+ while (!(TWCR & (1 << TWINT)))
+ ;
+
+ if ((TWSR & 0xF8) != TW_MT_DATA_ACK) {
+ return 1;
+ }
+ return 0;
+}
+
+uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length)
+{
+ TWBR = (uint8_t)TWBR_val;
+ if (i2c_start(address | I2C_WRITE))
+ return 1;
+ for (uint16_t i = 0; i < length; i++) {
+ if (i2c_write(data[i]))
+ return 1;
+ }
+ // transmit STOP condition
+ TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
+ return 0;
+}
+
+void setFrame(uint8_t device, uint8_t frame)
+{
+ static uint8_t current_frame = -1;
+ if(current_frame != frame){
+ uint8_t payload[] = {
+ ISSI_ADDR_DEFAULT | device << 1,
+ ISSI_COMMANDREGISTER,
+ frame
+ };
+ TWITransmitData(payload, sizeof(payload), 0, 1);
+ }
+ // static uint8_t current_frame = 0xFF;
+ // if(current_frame == frame){
+ // // return;
+ // }
+ // uint8_t payload[2] = { ISSI_COMMANDREGISTER, frame };
+ // i2c_transmit(ISSI_ADDR_DEFAULT | device << 1, payload, 2);
+ // current_frame = frame;
+}
+
+void writeRegister8(uint8_t device, uint8_t frame, uint8_t reg, uint8_t data)
+{
+ // Set the frame
+ setFrame(device, frame);
+
+ // Write to the register
+ uint8_t payload[] = {
+ ISSI_ADDR_DEFAULT | device << 1,
+ reg,
+ data
+ };
+ TWITransmitData(payload, sizeof(payload), 0, 1);
+}
+
+void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm)
+{
+ uint8_t device_addr = (matrix & 0x06) >> 1;
+ ISSIDeviceStruct *device = issi_devices[device_addr];
+ if(device == 0){
+ return;
+ }
+ // xprintf("activeLED: %02X %02X %02X %02X\n", matrix, cy, cx, pwm);
+ uint8_t x = cx - 1; // funciton takes 1 based counts, but we need 0...
+ uint8_t y = cy - 1; // creating them once for less confusion
+ uint8_t control_reg = (y << 1) | (matrix & 0x01);
+ if(pwm == 0){
+ cbi(device->led_ctrl[control_reg], x);
+ cbi(device->led_blink_ctrl[control_reg], x);
+ }else{
+ sbi(device->led_ctrl[control_reg], x);
+ sbi(device->led_blink_ctrl[control_reg], x);
+ }
+ uint8_t pwm_reg = 0;
+ switch(matrix & 0x01){
+ case 0:
+ pwm_reg = 0x00;
+ break;
+ case 1:
+ pwm_reg = 0x08;
+ break;
+ }
+ pwm_reg += (y << 4) + x;
+ device->led_pwm[pwm_reg] = pwm;
+ device->led_dirty = 1;
+}
+
+void update_issi(uint8_t device_addr, uint8_t blocking)
+{
+ // This seems to take about 6ms
+ ISSIDeviceStruct *device = issi_devices[device_addr];
+ if(device != 0){
+ if(device->fn_dirty){
+ device->fn_dirty = 0;
+ setFrame(device_addr, ISSI_BANK_FUNCTIONREG);
+ TWITransmitData(&device->fn_device_addr, sizeof(device->fn_registers) + 2, 0, 1);
+ }
+ if(device->led_dirty){
+ device->led_dirty = 0;
+ setFrame(device_addr, 0);
+ TWITransmitData(&device->led_device_addr, 0xB6, 0, blocking);
+ }
+ }
+}
+
+void issi_init(void)
+{
+ TWIInit();
+ for(uint8_t device_addr = 0; device_addr < 4; device_addr++){
+ // If this device has been previously allocated, free it
+ if(issi_devices[device_addr] != 0){
+ free(issi_devices[device_addr]);
+ }
+ // Try to shutdown the device, if this fails skip this device
+ writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
+ while (!isTWIReady()){_delay_us(1);}
+ if(TWIInfo.errorCode != 0xFF){
+ xprintf("ISSI init failed %d %02X %02X\n", device_addr, TWIInfo.mode, TWIInfo.errorCode);
+ continue;
+ }
+ // Allocate the device structure - calloc zeros it for us
+ ISSIDeviceStruct *device = (ISSIDeviceStruct *)calloc(sizeof(ISSIDeviceStruct) * 2, 1);
+ issi_devices[device_addr] = device;
+ device->fn_device_addr = ISSI_ADDR_DEFAULT | device_addr << 1;
+ device->fn_register_addr = 0;
+ device->led_device_addr = ISSI_ADDR_DEFAULT | device_addr << 1;
+ device->led_register_addr = 0;
+ // set dirty bits so that all of the buffered data is written out
+ device->fn_dirty = 1;
+ device->led_dirty = 1;
+ update_issi(device_addr, 1);
+ // Set the function register to picture mode
+ // device->fn_reg[ISSI_REG_CONFIG] = ISSI_REG_CONFIG_PICTUREMODE;
+ writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
+ }
+
+ // Shutdown and set all registers to 0
+ // writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x00);
+ // for(uint8_t bank = 0; bank <= 7; bank++){
+ // for (uint8_t reg = 0x00; reg <= 0xB3; reg++) {
+ // writeRegister8(device_addr, bank, reg, 0x00);
+ // }
+ // }
+ // for (uint8_t reg = 0; reg <= 0x0C; reg++) {
+ // writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, reg, 0x00);
+ // }
+ // writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE);
+ // writeRegister8(device_addr, ISSI_BANK_FUNCTIONREG, ISSI_REG_SHUTDOWN, 0x01);
+ // picture mode
+ // writeRegister8(ISSI_BANK_FUNCTIONREG, 0x01, 0x01);
+
+ //Enable blink
+ // writeRegister8(ISSI_BANK_FUNCTIONREG, 0x05, 0x48B);
+
+ //Enable Breath
+
+}
+
+#endif \ No newline at end of file
diff --git a/keyboards/lfkeyboards/issi.h b/keyboards/lfkeyboards/issi.h
new file mode 100644
index 0000000000..51777f6ee3
--- /dev/null
+++ b/keyboards/lfkeyboards/issi.h
@@ -0,0 +1,40 @@
+#ifdef ISSI_ENABLE
+#ifndef ISSI_H
+#define ISSI_H
+
+typedef struct ISSIDeviceStruct{
+ uint8_t fn_dirty; // function registers need to be resent
+ uint8_t fn_device_addr;
+ uint8_t fn_register_addr;
+ uint8_t fn_registers[13];
+ uint8_t led_dirty; // LED data has changed and needs to be resent
+ uint8_t led_device_addr;
+ uint8_t led_register_addr;
+ uint8_t led_ctrl[18];
+ uint8_t led_blink_ctrl[18];
+ uint8_t led_pwm[144];
+}ISSIDeviceStruct;
+
+extern ISSIDeviceStruct *issi_devices[];
+
+// Low level commands- 'device' is the 2-bit i2c id.
+void issi_init(void);
+void set_shutdown(uint8_t device, uint8_t shutdown);
+void writeRegister8(uint8_t device, uint8_t frame, uint8_t reg, uint8_t data);
+
+// Higher level, no device is given, but it is calculated from 'matrix'
+// Each device has 2 blocks, max of 4 devices:
+// Device | Block = Matrix
+// 0 A 0
+// 0 B 1
+// 1 A 2
+// 1 B 3
+// 2 A 4
+// 2 B 5
+// 3 A 6
+// 3 B 7
+void activateLED(uint8_t matrix, uint8_t cx, uint8_t cy, uint8_t pwm);
+void update_issi(uint8_t device_addr, uint8_t blocking);
+
+#endif
+#endif \ No newline at end of file
diff --git a/keyboards/lfkeyboards/lfk78/config.h b/keyboards/lfkeyboards/lfk78/config.h
new file mode 100644
index 0000000000..32f4455dae
--- /dev/null
+++ b/keyboards/lfkeyboards/lfk78/config.h
@@ -0,0 +1,172 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "config_common.h"
+
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6060
+#define DEVICE_VER 0x0001
+#define MANUFACTURER LFKeyboards
+#define PRODUCT LFK78
+#define DESCRIPTION QMK keyboard firmware for LFK78 LFK_REV_STRING
+
+#ifdef LFK_REV_B
+/* RevB Matrix config */
+ #define DIODE_DIRECTION COL2ROW
+ #define MATRIX_ROWS 10
+ #define MATRIX_COLS 8
+ #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, F0, F1, F4, F5, F6}
+ #define MATRIX_COL_PINS { E6, F7, D2, D3, D4, D5, D6, D7 }
+ #define UNUSED_PINS { C7 }
+ #define RGBLED_NUM 31 // Number of LEDs
+#else
+/* RevC/D Matrix config */
+ #define DIODE_DIRECTION COL2ROW
+ #define MATRIX_ROWS 5
+ #define MATRIX_COLS 18
+ #define MATRIX_ROW_PINS {D2, D3, D4, D5, D6 }
+ #define MATRIX_COL_PINS {A0, A1, A2, A3, A4, A5, A6, A7, E6, E7,\
+ F0, F1, F2, F3, C0, C1, C2, C3 }
+ #define UNUSED_PINS {B0, B1, B2, B3, B4, B4, B5, B6, B7, C4, C5, C6, C7,\
+ D0, D1, D7, E0, E1, E2, E3, E4, D5, F4, F5, F6, F7,\
+ E6, E7, F0, F1, F2, F3, C0, C1, C2, C3}
+ #define RGBLED_NUM 27 // Number of LEDs
+#endif
+
+#define AUDIO_VOICES
+#define C6_AUDIO
+
+#define BACKLIGHT_LEVELS 8
+#define BACKLIGHT_PWM_MAP {8, 16, 40, 55, 70, 128, 200, 255}
+
+#define RGB_DI_PIN C7 // Have to set it to something to get the ws2812 code to compile
+#define RGBLIGHT_ANIMATIONS
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+#define RGBLIGHT_VAL_STEP 17
+
+#define TAPPING_TERM 200
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCING_DELAY 5
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* number of backlight levels */
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
+
+/*
+ * Force NKRO
+ *
+ * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
+ * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
+ * makefile for this to work.)
+ *
+ * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
+ * until the next keyboard reset.
+ *
+ * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
+ * fully operational during normal computer usage.
+ *
+ * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
+ * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
+ * bootmagic, NKRO mode will always be enabled until it is toggled again during a
+ * power-up.
+ *
+ */
+//#define FORCE_NKRO
+
+/*
+ * Magic Key Options
+ *
+ * Magic keys are hotkey commands that allow control over firmware functions of
+ * the keyboard. They are best used in combination with the HID Listen program,
+ * found here: https://www.pjrc.com/t