Skip to content

Commit

Permalink
ergodone - Refactor use of legacy i2c implementation (qmk#14340)
Browse files Browse the repository at this point in the history
* Refactor use of legacy i2c implementation

* copy-paste error
  • Loading branch information
zvecr authored and nhongooi committed Dec 5, 2021
1 parent 45b100f commit 7bc5402
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 417 deletions.
28 changes: 6 additions & 22 deletions keyboards/ktec/ergodone/expander.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <stdbool.h>
#include "action.h"
#include "i2cmaster.h"
#include "i2c_master.h"
#include "expander.h"
#include "debug.h"

#define I2C_TIMEOUT 100

static uint8_t expander_status = 0;
static uint8_t expander_input = 0;

Expand All @@ -20,7 +22,7 @@ void expander_init(void)
void expander_scan(void)
{
dprintf("expander status: %d ... ", expander_status);
uint8_t ret = i2c_start(EXPANDER_ADDR | I2C_WRITE);
uint8_t ret = i2c_start(EXPANDER_ADDR | I2C_WRITE, I2C_TIMEOUT);
if (ret == 0) {
i2c_stop();
if (expander_status == 0) {
Expand Down Expand Up @@ -90,31 +92,13 @@ uint8_t expander_write(uint8_t reg, uint8_t data)
if (expander_status == 0) {
return 0;
}
uint8_t ret;
ret = i2c_start(EXPANDER_ADDR | I2C_WRITE);
if (ret) goto stop;
ret = i2c_write(reg);
if (ret) goto stop;
ret = i2c_write(data);
stop:
i2c_stop();
return ret;
return i2c_writeReg(EXPANDER_ADDR, reg, &data, 1, I2C_TIMEOUT);
}

uint8_t expander_read(uint8_t reg, uint8_t *data)
{
if (expander_status == 0) {
return 0;
}
uint8_t ret;
ret = i2c_start(EXPANDER_ADDR | I2C_WRITE);
if (ret) goto stop;
ret = i2c_write(reg);
if (ret) goto stop;
ret = i2c_rep_start(EXPANDER_ADDR | I2C_READ);
if (ret) goto stop;
*data = i2c_readNak();
stop:
i2c_stop();
return ret;
return i2c_readReg(EXPANDER_ADDR, reg, data, 1, I2C_TIMEOUT);
}
178 changes: 0 additions & 178 deletions keyboards/ktec/ergodone/i2cmaster.h

This file was deleted.

18 changes: 9 additions & 9 deletions keyboards/ktec/ergodone/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ BOOTLOADER = caterina
#
CUSTOM_MATRIX = yes # Custom matrix file for the ErgoDone
UNICODE_ENABLE = yes # Unicode
BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
USB_6KRO_ENABLE = no # USB 6key Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
SWAP_HANDS_ENABLE = no # Disable Onehand
RGBLIGHT_ENABLE = no

# project specific files
QUANTUM_LIB_SRC += i2c_master.c
SRC = \
twimaster.c \
matrix.c \
expander.c \
matrix.c \
expander.c \

LAYOUTS = ergodox
Loading

0 comments on commit 7bc5402

Please sign in to comment.