Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d21fe30139 | ||
|
|
224d9eae42 | ||
|
|
cdfabaec42 | ||
|
|
ff99c2e734 | ||
|
|
6d356114a8 | ||
|
|
3041132959 | ||
|
|
2877773cac | ||
|
|
b1cbeefa28 | ||
|
|
65006cc376 | ||
|
|
fc01b29823 | ||
|
|
462595ef03 | ||
|
|
b0d85795f4 | ||
|
|
2c91ef51db | ||
|
|
a54e7ac0a8 | ||
|
|
64f54c268b | ||
|
|
d889d51a7d | ||
|
|
b284e9fa58 | ||
|
|
1a0da7971a | ||
|
|
53a82a5f57 | ||
|
|
10985abcdb | ||
|
|
e60a282742 | ||
|
|
a691b16ebe | ||
|
|
c38114648a | ||
|
|
3fc4419f4f | ||
|
|
033bdf6491 | ||
|
|
18e3ba9558 | ||
|
|
3fb552cc55 | ||
|
|
d093c84fb4 | ||
|
|
95d7197394 | ||
|
|
989774ced9 | ||
|
|
0e29276a56 | ||
|
|
5b90d78518 | ||
|
|
d2eb4b43c7 | ||
|
|
a545324693 | ||
|
|
27b02c32b5 |
39
CHANGELOG.md
39
CHANGELOG.md
@@ -5,6 +5,45 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
|
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
|
||||||
|
|
||||||
|
## [8.3.2] - 2018-06-27
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Make the debouncer debounce not only on key presses but also on key releases, and change the debounce interval from 100ms to the suggested 5ms of MX switches.
|
||||||
|
- Revert the Windows related commits of firmware 8.3.1 because they introduced a nondeterministic bug that made USB hang.
|
||||||
|
- Add base layer key mappings for the left and right add-ons for testing purposes.
|
||||||
|
|
||||||
|
## [8.3.1] - 2018-06-07
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Fix media key repetition bug on Windows.
|
||||||
|
- Fix bug that made Windows unable to sleep when the UHK was plugged in.
|
||||||
|
- Fix bug that made Chrome Remote Desktop blocked from interacting on Windows.
|
||||||
|
- Fix bug that made locked layers not release. This bug was introduced in the previous release.
|
||||||
|
|
||||||
|
## [8.3.0] - 2018-06-03
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.**1.0** | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Make the config parser handle switch layer actions with hold on double tap disabled. `USERCONFIG:MINOR`
|
||||||
|
- Set key debounce timeout from 80ms to 100ms. This should further reduce key chattering.
|
||||||
|
|
||||||
|
## [8.2.5] - 2018-05-27
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Now really fix the bug that made the hardware and user configuration not load from the EEPROM on some hosts right after firmware update.
|
||||||
|
|
||||||
|
## [8.2.4] - 2018-05-21
|
||||||
|
|
||||||
|
Device Protocol: 4.3.**1** | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Fix the bug that made the hardware and user configuration not load from the EEPROM on some hosts right after firmware update.
|
||||||
|
- Set the signature of the hardware config to "FTY" in the RAM when the keyboard is in factory reset mode, allowing Agent to be aware of the factory reset state. `DEVICEPROTOCOL:PATCH`
|
||||||
|
- Load the hardware and user configuration from the EEPROM even in factory reset mode.
|
||||||
|
- Set key debounce timeout from 60ms to 80ms. This should further reduce key chattering.
|
||||||
|
|
||||||
## [8.2.3] - 2018-05-15
|
## [8.2.3] - 2018-05-15
|
||||||
|
|
||||||
Device Protocol: 4.3.0 | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
Device Protocol: 4.3.0 | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
||||||
|
|||||||
Submodule lib/agent updated: e294727ac5...81a83994ab
@@ -11,6 +11,8 @@ config_buffer_t HardwareConfigBuffer = { hardwareConfig };
|
|||||||
config_buffer_t StagingUserConfigBuffer = { stagingUserConfig };
|
config_buffer_t StagingUserConfigBuffer = { stagingUserConfig };
|
||||||
config_buffer_t ValidatedUserConfigBuffer = { validatedUserConfig };
|
config_buffer_t ValidatedUserConfigBuffer = { validatedUserConfig };
|
||||||
|
|
||||||
|
hardware_config_t *HardwareConfig = (hardware_config_t*)hardwareConfig;
|
||||||
|
|
||||||
bool ParserRunDry;
|
bool ParserRunDry;
|
||||||
|
|
||||||
bool IsConfigBufferIdValid(config_buffer_id_t configBufferId)
|
bool IsConfigBufferIdValid(config_buffer_id_t configBufferId)
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include "fsl_common.h"
|
#include "fsl_common.h"
|
||||||
#include "basic_types.h"
|
#include "basic_types.h"
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define HARDWARE_CONFIG_SIGNATURE_LENGTH 3
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -14,6 +18,19 @@
|
|||||||
ConfigBufferId_ValidatedUserConfig,
|
ConfigBufferId_ValidatedUserConfig,
|
||||||
} config_buffer_id_t;
|
} config_buffer_id_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t signatureLength;
|
||||||
|
char signature[HARDWARE_CONFIG_SIGNATURE_LENGTH];
|
||||||
|
uint8_t majorVersion;
|
||||||
|
uint8_t minorVersion;
|
||||||
|
uint8_t patchVersion;
|
||||||
|
uint8_t brandId;
|
||||||
|
uint8_t deviceId;
|
||||||
|
uint32_t uniqueId;
|
||||||
|
bool isVendorModeOn;
|
||||||
|
bool isIso;
|
||||||
|
} hardware_config_t;
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern bool ParserRunDry;
|
extern bool ParserRunDry;
|
||||||
@@ -21,8 +38,9 @@
|
|||||||
extern config_buffer_t HardwareConfigBuffer;
|
extern config_buffer_t HardwareConfigBuffer;
|
||||||
extern config_buffer_t StagingUserConfigBuffer;
|
extern config_buffer_t StagingUserConfigBuffer;
|
||||||
extern config_buffer_t ValidatedUserConfigBuffer;
|
extern config_buffer_t ValidatedUserConfigBuffer;
|
||||||
|
extern hardware_config_t *HardwareConfig;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
bool IsConfigBufferIdValid(config_buffer_id_t configBufferId);
|
bool IsConfigBufferIdValid(config_buffer_id_t configBufferId);
|
||||||
config_buffer_t* ConfigBufferIdToConfigBuffer(config_buffer_id_t configBufferId);
|
config_buffer_t* ConfigBufferIdToConfigBuffer(config_buffer_id_t configBufferId);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyS
|
|||||||
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buffer_t *buffer)
|
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
uint8_t layer = ReadUInt8(buffer) + 1;
|
uint8_t layer = ReadUInt8(buffer) + 1;
|
||||||
uint8_t mode = ReadBool(buffer) ? SwitchLayerMode_Toggle : SwitchLayerMode_HoldAndDoubleTapToggle;
|
switch_layer_mode_t mode = ReadUInt8(buffer);
|
||||||
|
|
||||||
KeyAction->type = KeyActionType_SwitchLayer;
|
KeyAction->type = KeyActionType_SwitchLayer;
|
||||||
KeyAction->switchLayer.layer = layer;
|
KeyAction->switchLayer.layer = layer;
|
||||||
|
|||||||
@@ -35,10 +35,12 @@
|
|||||||
#define I2C_EEPROM_BUS_BAUD_RATE 1000000 // 1 Mhz is the maximum speed of the EEPROM.
|
#define I2C_EEPROM_BUS_BAUD_RATE 1000000 // 1 Mhz is the maximum speed of the EEPROM.
|
||||||
#define I2C_EEPROM_BUS_MUX kPORT_MuxAlt2
|
#define I2C_EEPROM_BUS_MUX kPORT_MuxAlt2
|
||||||
|
|
||||||
|
#define I2C_EEPROM_BUS_SDA_GPIO GPIOC
|
||||||
#define I2C_EEPROM_BUS_SDA_PORT PORTC
|
#define I2C_EEPROM_BUS_SDA_PORT PORTC
|
||||||
#define I2C_EEPROM_BUS_SDA_CLOCK kCLOCK_PortC
|
#define I2C_EEPROM_BUS_SDA_CLOCK kCLOCK_PortC
|
||||||
#define I2C_EEPROM_BUS_SDA_PIN 11
|
#define I2C_EEPROM_BUS_SDA_PIN 11
|
||||||
|
|
||||||
|
#define I2C_EEPROM_BUS_SCL_GPIO GPIOC
|
||||||
#define I2C_EEPROM_BUS_SCL_PORT PORTC
|
#define I2C_EEPROM_BUS_SCL_PORT PORTC
|
||||||
#define I2C_EEPROM_BUS_SCL_CLOCK kCLOCK_PortC
|
#define I2C_EEPROM_BUS_SCL_CLOCK kCLOCK_PortC
|
||||||
#define I2C_EEPROM_BUS_SCL_PIN 10
|
#define I2C_EEPROM_BUS_SCL_PIN 10
|
||||||
|
|||||||
@@ -21,6 +21,38 @@ bool IsBusPalOn;
|
|||||||
volatile uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_NORMAL_BAUD_RATE;
|
volatile uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_NORMAL_BAUD_RATE;
|
||||||
volatile uint32_t I2cMainBusActualBaudRateBps;
|
volatile uint32_t I2cMainBusActualBaudRateBps;
|
||||||
|
|
||||||
|
static i2c_bus_t i2cMainBus = {
|
||||||
|
.baseAddr = I2C_MAIN_BUS_BASEADDR,
|
||||||
|
.clockSrc = I2C_MAIN_BUS_CLK_SRC,
|
||||||
|
.mux = I2C_MAIN_BUS_MUX,
|
||||||
|
|
||||||
|
.sdaClock = I2C_MAIN_BUS_SDA_CLOCK,
|
||||||
|
.sdaGpio = I2C_MAIN_BUS_SDA_GPIO,
|
||||||
|
.sdaPort = I2C_MAIN_BUS_SDA_PORT,
|
||||||
|
.sdaPin = I2C_MAIN_BUS_SDA_PIN,
|
||||||
|
|
||||||
|
.sclClock = I2C_MAIN_BUS_SCL_CLOCK,
|
||||||
|
.sclGpio = I2C_MAIN_BUS_SCL_GPIO,
|
||||||
|
.sclPort = I2C_MAIN_BUS_SCL_PORT,
|
||||||
|
.sclPin = I2C_MAIN_BUS_SCL_PIN,
|
||||||
|
};
|
||||||
|
|
||||||
|
static i2c_bus_t i2cEepromBus = {
|
||||||
|
.baseAddr = I2C_EEPROM_BUS_BASEADDR,
|
||||||
|
.clockSrc = I2C_EEPROM_BUS_CLK_SRC,
|
||||||
|
.mux = I2C_EEPROM_BUS_MUX,
|
||||||
|
|
||||||
|
.sdaClock = I2C_EEPROM_BUS_SDA_CLOCK,
|
||||||
|
.sdaGpio = I2C_EEPROM_BUS_SDA_GPIO,
|
||||||
|
.sdaPort = I2C_EEPROM_BUS_SDA_PORT,
|
||||||
|
.sdaPin = I2C_EEPROM_BUS_SDA_PIN,
|
||||||
|
|
||||||
|
.sclClock = I2C_EEPROM_BUS_SCL_CLOCK,
|
||||||
|
.sclGpio = I2C_EEPROM_BUS_SCL_GPIO,
|
||||||
|
.sclPort = I2C_EEPROM_BUS_SCL_PORT,
|
||||||
|
.sclPin = I2C_EEPROM_BUS_SCL_PIN,
|
||||||
|
};
|
||||||
|
|
||||||
static void initBusPalState(void) {
|
static void initBusPalState(void) {
|
||||||
IsBusPalOn = Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal;
|
IsBusPalOn = Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal;
|
||||||
if (IsBusPalOn) {
|
if (IsBusPalOn) {
|
||||||
@@ -32,12 +64,12 @@ static void initBusPalState(void) {
|
|||||||
static void initInterruptPriorities(void)
|
static void initInterruptPriorities(void)
|
||||||
{
|
{
|
||||||
NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1);
|
NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1);
|
||||||
NVIC_SetPriority(PIT_TIMER_IRQ_ID, 2);
|
NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 0);
|
||||||
NVIC_SetPriority(PIT_KEY_SCANNER_IRQ_ID, 3);
|
NVIC_SetPriority(PIT_TIMER_IRQ_ID, 3);
|
||||||
NVIC_SetPriority(PIT_KEY_DEBOUNCER_IRQ_ID, 3);
|
NVIC_SetPriority(PIT_KEY_SCANNER_IRQ_ID, 4);
|
||||||
NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 3);
|
NVIC_SetPriority(PIT_KEY_DEBOUNCER_IRQ_ID, 4);
|
||||||
NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 3);
|
NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 4);
|
||||||
NVIC_SetPriority(USB_IRQ_ID, 3);
|
NVIC_SetPriority(USB_IRQ_ID, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delay(void)
|
static void delay(void)
|
||||||
@@ -45,91 +77,73 @@ static void delay(void)
|
|||||||
for (volatile uint32_t i=0; i<62; i++);
|
for (volatile uint32_t i=0; i<62; i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recoverI2c(void)
|
static void recoverI2cBus(i2c_bus_t *i2cBus)
|
||||||
{
|
{
|
||||||
PORT_SetPinMux(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SDA_PIN, kPORT_MuxAsGpio);
|
PORT_SetPinMux(i2cBus->sdaPort, i2cBus->sdaPin, kPORT_MuxAsGpio);
|
||||||
PORT_SetPinMux(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SCL_PIN, kPORT_MuxAsGpio);
|
PORT_SetPinMux(i2cBus->sclPort, i2cBus->sclPin, kPORT_MuxAsGpio);
|
||||||
GPIO_PinInit(I2C_MAIN_BUS_SCL_GPIO, I2C_MAIN_BUS_SCL_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
GPIO_PinInit(i2cBus->sclGpio, i2cBus->sclPin, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
||||||
|
|
||||||
bool isOn = true;
|
bool isOn = true;
|
||||||
for (int i=0; i<20; i++) {
|
for (int i=0; i<20; i++) {
|
||||||
GPIO_PinInit(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, &(gpio_pin_config_t){kGPIO_DigitalInput});
|
GPIO_PinInit(i2cBus->sdaGpio, i2cBus->sdaPin, &(gpio_pin_config_t){kGPIO_DigitalInput});
|
||||||
bool isSdaHigh = GPIO_ReadPinInput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN);
|
bool isSdaHigh = GPIO_ReadPinInput(i2cBus->sdaGpio, i2cBus->sdaPin);
|
||||||
GPIO_PinInit(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
GPIO_PinInit(i2cBus->sdaGpio, i2cBus->sdaPin, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
||||||
|
|
||||||
if (isSdaHigh) {
|
if (isSdaHigh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SCL_GPIO, I2C_MAIN_BUS_SCL_PIN, isOn);
|
GPIO_WritePinOutput(i2cBus->sclGpio, i2cBus->sclPin, isOn);
|
||||||
delay();
|
delay();
|
||||||
isOn = !isOn;
|
isOn = !isOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, 0);
|
GPIO_WritePinOutput(i2cBus->sdaGpio, i2cBus->sdaPin, 0);
|
||||||
delay();
|
delay();
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SCL_GPIO, I2C_MAIN_BUS_SCL_PIN, 1);
|
GPIO_WritePinOutput(i2cBus->sclGpio, i2cBus->sclPin, 1);
|
||||||
delay();
|
delay();
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, 1);
|
GPIO_WritePinOutput(i2cBus->sdaGpio, i2cBus->sdaPin, 1);
|
||||||
delay();
|
delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initI2cMainBus(void)
|
static void initI2cBus(i2c_bus_t *i2cBus)
|
||||||
{
|
{
|
||||||
CLOCK_EnableClock(I2C_MAIN_BUS_SDA_CLOCK);
|
CLOCK_EnableClock(i2cBus->sdaClock);
|
||||||
CLOCK_EnableClock(I2C_MAIN_BUS_SCL_CLOCK);
|
CLOCK_EnableClock(i2cBus->sclClock);
|
||||||
|
|
||||||
recoverI2c();
|
recoverI2cBus(i2cBus);
|
||||||
|
|
||||||
port_pin_config_t pinConfig = {
|
port_pin_config_t pinConfig = {
|
||||||
.pullSelect = kPORT_PullUp,
|
.pullSelect = kPORT_PullUp,
|
||||||
.openDrainEnable = kPORT_OpenDrainEnable,
|
.openDrainEnable = kPORT_OpenDrainEnable,
|
||||||
.mux = I2C_MAIN_BUS_MUX,
|
.mux = i2cBus->mux,
|
||||||
};
|
};
|
||||||
|
|
||||||
PORT_SetPinConfig(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SDA_PIN, &pinConfig);
|
PORT_SetPinConfig(i2cBus->sdaPort, i2cBus->sdaPin, &pinConfig);
|
||||||
PORT_SetPinConfig(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SCL_PIN, &pinConfig);
|
PORT_SetPinConfig(i2cBus->sclPort, i2cBus->sclPin, &pinConfig);
|
||||||
|
|
||||||
i2c_master_config_t masterConfig;
|
i2c_master_config_t masterConfig;
|
||||||
I2C_MasterGetDefaultConfig(&masterConfig);
|
I2C_MasterGetDefaultConfig(&masterConfig);
|
||||||
masterConfig.baudRate_Bps = I2cMainBusRequestedBaudRateBps;
|
masterConfig.baudRate_Bps = i2cBus == &i2cMainBus ? I2cMainBusRequestedBaudRateBps : I2C_EEPROM_BUS_BAUD_RATE;
|
||||||
uint32_t sourceClock = CLOCK_GetFreq(I2C_MAIN_BUS_CLK_SRC);
|
uint32_t sourceClock = CLOCK_GetFreq(i2cBus->clockSrc);
|
||||||
I2C_MasterInit(I2C_MAIN_BUS_BASEADDR, &masterConfig, sourceClock);
|
I2C_MasterInit(i2cBus->baseAddr, &masterConfig, sourceClock);
|
||||||
I2cMainBusActualBaudRateBps = I2C_ActualBaudRate;
|
|
||||||
|
if (i2cBus == &i2cMainBus) {
|
||||||
|
I2cMainBusActualBaudRateBps = I2C_ActualBaudRate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReinitI2cMainBus(void)
|
void ReinitI2cMainBus(void)
|
||||||
{
|
{
|
||||||
I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR);
|
I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR);
|
||||||
initI2cMainBus();
|
initI2cBus(&i2cMainBus);
|
||||||
InitSlaveScheduler();
|
InitSlaveScheduler();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initI2cEepromBus(void)
|
|
||||||
{
|
|
||||||
port_pin_config_t pinConfig = {
|
|
||||||
.pullSelect = kPORT_PullUp,
|
|
||||||
.openDrainEnable = kPORT_OpenDrainEnable,
|
|
||||||
.mux = I2C_EEPROM_BUS_MUX,
|
|
||||||
};
|
|
||||||
|
|
||||||
CLOCK_EnableClock(I2C_EEPROM_BUS_SDA_CLOCK);
|
|
||||||
CLOCK_EnableClock(I2C_EEPROM_BUS_SCL_CLOCK);
|
|
||||||
|
|
||||||
PORT_SetPinConfig(I2C_EEPROM_BUS_SDA_PORT, I2C_EEPROM_BUS_SDA_PIN, &pinConfig);
|
|
||||||
PORT_SetPinConfig(I2C_EEPROM_BUS_SCL_PORT, I2C_EEPROM_BUS_SCL_PIN, &pinConfig);
|
|
||||||
|
|
||||||
i2c_master_config_t masterConfig;
|
|
||||||
I2C_MasterGetDefaultConfig(&masterConfig);
|
|
||||||
masterConfig.baudRate_Bps = I2C_EEPROM_BUS_BAUD_RATE;
|
|
||||||
uint32_t sourceClock = CLOCK_GetFreq(I2C_EEPROM_BUS_CLK_SRC);
|
|
||||||
I2C_MasterInit(I2C_EEPROM_BUS_BASEADDR, &masterConfig, sourceClock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void initI2c(void)
|
static void initI2c(void)
|
||||||
{
|
{
|
||||||
initI2cMainBus();
|
initI2cBus(&i2cMainBus);
|
||||||
initI2cEepromBus();
|
initI2cBus(&i2cEepromBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitPeripherals(void)
|
void InitPeripherals(void)
|
||||||
|
|||||||
@@ -1,10 +1,28 @@
|
|||||||
#ifndef __INIT_PERIPHERALS_H__
|
#ifndef __INIT_PERIPHERALS_H__
|
||||||
#define __INIT_PERIPHERALS_H__
|
#define __INIT_PERIPHERALS_H__
|
||||||
|
|
||||||
// Includes
|
// Includes:
|
||||||
|
|
||||||
#include "fsl_common.h"
|
#include "fsl_common.h"
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
clock_name_t clockSrc;
|
||||||
|
I2C_Type *baseAddr;
|
||||||
|
uint16_t mux;
|
||||||
|
|
||||||
|
clock_ip_name_t sdaClock;
|
||||||
|
GPIO_Type *sdaGpio;
|
||||||
|
PORT_Type *sdaPort;
|
||||||
|
uint32_t sdaPin;
|
||||||
|
|
||||||
|
clock_ip_name_t sclClock;
|
||||||
|
GPIO_Type *sclGpio;
|
||||||
|
PORT_Type *sclPort;
|
||||||
|
uint32_t sclPin;
|
||||||
|
} i2c_bus_t;
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern bool IsBusPalOn;
|
extern bool IsBusPalOn;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
} keystroke_type_t;
|
} keystroke_type_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SwitchLayerMode_Hold,
|
|
||||||
SwitchLayerMode_HoldAndDoubleTapToggle,
|
SwitchLayerMode_HoldAndDoubleTapToggle,
|
||||||
SwitchLayerMode_Toggle,
|
SwitchLayerMode_Toggle,
|
||||||
|
SwitchLayerMode_Hold,
|
||||||
} switch_layer_mode_t;
|
} switch_layer_mode_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ void PIT_KEY_DEBOUNCER_HANDLER(void)
|
|||||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||||
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
|
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
|
||||||
if (*debounceCounter < 0xff) {
|
if (*debounceCounter) {
|
||||||
(*debounceCounter)++;
|
--(*debounceCounter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
|
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
|
||||||
#define KEY_DEBOUNCER_TIMEOUT_MSEC 60
|
#define KEY_DEBOUNCER_TIMEOUT_MSEC 5
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,102 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
|||||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_V }},
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_V }},
|
||||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_B }},
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_B }},
|
||||||
|
|
||||||
|
// Row 5
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_CONTROL }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }},
|
||||||
|
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }},
|
||||||
|
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod }},
|
||||||
|
{ .type = KeyActionType_None },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Left module
|
||||||
|
{
|
||||||
|
// Row 1
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_1_AND_EXCLAMATION }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_2_AND_AT }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_3_AND_HASHMARK }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_4_AND_DOLLAR }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_5_AND_PERCENTAGE }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_6_AND_CARET }},
|
||||||
|
|
||||||
|
// Row 2
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_TAB }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Q }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_W }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_E }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_R }},
|
||||||
|
{ .type = KeyActionType_None },
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_T }},
|
||||||
|
|
||||||
|
// Row 3
|
||||||
|
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mouse }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_A }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_S }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_D }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F }},
|
||||||
|
{ .type = KeyActionType_None },
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_G }},
|
||||||
|
|
||||||
|
// Row 4
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_SHIFT }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Z }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_X }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_C }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_V }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_B }},
|
||||||
|
|
||||||
|
// Row 5
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_CONTROL }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }},
|
||||||
|
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }},
|
||||||
|
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod }},
|
||||||
|
{ .type = KeyActionType_None },
|
||||||
|
},
|
||||||
|
|
||||||
|
// Right module
|
||||||
|
{
|
||||||
|
// Row 1
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_1_AND_EXCLAMATION }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_2_AND_AT }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_3_AND_HASHMARK }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_4_AND_DOLLAR }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_5_AND_PERCENTAGE }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_6_AND_CARET }},
|
||||||
|
|
||||||
|
// Row 2
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_TAB }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Q }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_W }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_E }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_R }},
|
||||||
|
{ .type = KeyActionType_None },
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_T }},
|
||||||
|
|
||||||
|
// Row 3
|
||||||
|
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mouse }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_A }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_S }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_D }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F }},
|
||||||
|
{ .type = KeyActionType_None },
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_G }},
|
||||||
|
|
||||||
|
// Row 4
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_SHIFT }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Z }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_X }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_C }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_V }},
|
||||||
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_B }},
|
||||||
|
|
||||||
// Row 5
|
// Row 5
|
||||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_CONTROL }},
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_CONTROL }},
|
||||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }},
|
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }},
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
|
||||||
static bool heldLayers[LAYER_COUNT];
|
static bool heldLayers[LAYER_COUNT];
|
||||||
static switch_layer_mode_t pressedLayers[LAYER_COUNT];
|
static bool toggledLayers[LAYER_COUNT];
|
||||||
|
|
||||||
void updateLayerStates(void)
|
void updateLayerStates(void)
|
||||||
{
|
{
|
||||||
memset(heldLayers, false, LAYER_COUNT);
|
memset(heldLayers, false, LAYER_COUNT);
|
||||||
memset(pressedLayers, false, LAYER_COUNT);
|
memset(toggledLayers, false, LAYER_COUNT);
|
||||||
|
|
||||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||||
@@ -20,9 +20,8 @@ void updateLayerStates(void)
|
|||||||
if (action.type == KeyActionType_SwitchLayer) {
|
if (action.type == KeyActionType_SwitchLayer) {
|
||||||
if (action.switchLayer.mode != SwitchLayerMode_Toggle) {
|
if (action.switchLayer.mode != SwitchLayerMode_Toggle) {
|
||||||
heldLayers[action.switchLayer.layer] = true;
|
heldLayers[action.switchLayer.layer] = true;
|
||||||
}
|
} else if (!keyState->previous) {
|
||||||
if (action.switchLayer.mode != SwitchLayerMode_Hold && !keyState->previous && keyState->current) {
|
toggledLayers[action.switchLayer.layer] = true;
|
||||||
pressedLayers[action.switchLayer.layer] = action.switchLayer.mode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,11 +39,11 @@ layer_id_t GetActiveLayer()
|
|||||||
// Handle toggled layers
|
// Handle toggled layers
|
||||||
|
|
||||||
for (layer_id_t layerId=LayerId_Mod; layerId<=LayerId_Mouse; layerId++) {
|
for (layer_id_t layerId=LayerId_Mod; layerId<=LayerId_Mouse; layerId++) {
|
||||||
if (pressedLayers[layerId]) {
|
if (toggledLayers[layerId]) {
|
||||||
if (ToggledLayer == layerId) {
|
if (ToggledLayer == layerId) {
|
||||||
ToggledLayer = LayerId_Base;
|
ToggledLayer = LayerId_Base;
|
||||||
break;
|
break;
|
||||||
} else if (ToggledLayer == LayerId_Base && pressedLayers[layerId] == SwitchLayerMode_Toggle) {
|
} else if (ToggledLayer == LayerId_Base && toggledLayers[layerId] == SwitchLayerMode_Toggle) {
|
||||||
ToggledLayer = layerId;
|
ToggledLayer = layerId;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
uint8_t IconsAndLayerTextsBrightness = 0xff;
|
uint8_t IconsAndLayerTextsBrightness = 0xff;
|
||||||
uint8_t AlphanumericSegmentsBrightness = 0xff;
|
uint8_t AlphanumericSegmentsBrightness = 0xff;
|
||||||
bool ledIconStates[LedDisplayIcon_Last];
|
bool ledIconStates[LedDisplayIcon_Last];
|
||||||
|
char LedDisplay_DebugString[] = " ";
|
||||||
|
|
||||||
static const uint16_t capitalLetterToSegmentMap[] = {
|
static const uint16_t capitalLetterToSegmentMap[] = {
|
||||||
0b0000000011110111,
|
0b0000000011110111,
|
||||||
@@ -116,8 +117,12 @@ void LedDisplay_UpdateIcons(void)
|
|||||||
|
|
||||||
void LedDisplay_UpdateText(void)
|
void LedDisplay_UpdateText(void)
|
||||||
{
|
{
|
||||||
|
#if LED_DISPLAY_DEBUG_MODE == 0
|
||||||
keymap_reference_t *currentKeymap = AllKeymaps + CurrentKeymapIndex;
|
keymap_reference_t *currentKeymap = AllKeymaps + CurrentKeymapIndex;
|
||||||
LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation);
|
LedDisplay_SetText(currentKeymap->abbreviationLen, currentKeymap->abbreviation);
|
||||||
|
#else
|
||||||
|
LedDisplay_SetText(strlen(LedDisplay_DebugString), LedDisplay_DebugString);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LedDisplay_UpdateAll(void)
|
void LedDisplay_UpdateAll(void)
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "layer.h"
|
#include "layer.h"
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define LED_DISPLAY_DEBUG_MODE 0
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -20,6 +24,7 @@
|
|||||||
|
|
||||||
extern uint8_t IconsAndLayerTextsBrightness;
|
extern uint8_t IconsAndLayerTextsBrightness;
|
||||||
extern uint8_t AlphanumericSegmentsBrightness;
|
extern uint8_t AlphanumericSegmentsBrightness;
|
||||||
|
extern char LedDisplay_DebugString[];
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "key_scanner.h"
|
#include "key_scanner.h"
|
||||||
#include "usb_commands/usb_command_apply_config.h"
|
#include "usb_commands/usb_command_apply_config.h"
|
||||||
#include "peripherals/reset_button.h"
|
#include "peripherals/reset_button.h"
|
||||||
|
#include "config_parser/config_globals.h"
|
||||||
#include "usb_report_updater.h"
|
#include "usb_report_updater.h"
|
||||||
|
|
||||||
static bool IsEepromInitialized = false;
|
static bool IsEepromInitialized = false;
|
||||||
@@ -21,6 +22,10 @@ static void userConfigurationReadFinished(void)
|
|||||||
|
|
||||||
static void hardwareConfigurationReadFinished(void)
|
static void hardwareConfigurationReadFinished(void)
|
||||||
{
|
{
|
||||||
|
if (IsFactoryResetModeEnabled) {
|
||||||
|
HardwareConfig->signatureLength = HARDWARE_CONFIG_SIGNATURE_LENGTH;
|
||||||
|
strncpy(HardwareConfig->signature, "FTY", HARDWARE_CONFIG_SIGNATURE_LENGTH);
|
||||||
|
}
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_StagingUserConfig, userConfigurationReadFinished);
|
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_StagingUserConfig, userConfigurationReadFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,9 +34,9 @@ int main(void)
|
|||||||
InitClock();
|
InitClock();
|
||||||
InitPeripherals();
|
InitPeripherals();
|
||||||
|
|
||||||
if (!RESET_BUTTON_IS_PRESSED) {
|
IsFactoryResetModeEnabled = RESET_BUTTON_IS_PRESSED;
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_HardwareConfig, hardwareConfigurationReadFinished);
|
|
||||||
}
|
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_HardwareConfig, hardwareConfigurationReadFinished);
|
||||||
|
|
||||||
if (IsBusPalOn) {
|
if (IsBusPalOn) {
|
||||||
init_hardware();
|
init_hardware();
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "fsl_port.h"
|
#include "fsl_port.h"
|
||||||
#include "bootloader/wormhole.h"
|
#include "bootloader/wormhole.h"
|
||||||
|
|
||||||
|
bool IsFactoryResetModeEnabled = false;
|
||||||
|
|
||||||
void RESET_BUTTON_IRQ_HANDLER(void)
|
void RESET_BUTTON_IRQ_HANDLER(void)
|
||||||
{
|
{
|
||||||
Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER;
|
Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER;
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
#define RESET_BUTTON_IS_PRESSED !GPIO_ReadPinInput(RESET_BUTTON_GPIO, RESET_BUTTON_PIN)
|
#define RESET_BUTTON_IS_PRESSED !GPIO_ReadPinInput(RESET_BUTTON_GPIO, RESET_BUTTON_PIN)
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
extern bool IsFactoryResetModeEnabled;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void InitResetButton(void);
|
void InitResetButton(void);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "usb_commands/usb_command_apply_config.h"
|
#include "usb_commands/usb_command_apply_config.h"
|
||||||
#include "config_parser/config_globals.h"
|
#include "config_parser/config_globals.h"
|
||||||
#include "config_parser/parse_config.h"
|
#include "config_parser/parse_config.h"
|
||||||
|
#include "peripherals/reset_button.h"
|
||||||
#include "usb_protocol_handler.h"
|
#include "usb_protocol_handler.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
|
||||||
@@ -35,6 +36,10 @@ void UsbCommand_ApplyConfig(void)
|
|||||||
ValidatedUserConfigBuffer.buffer = StagingUserConfigBuffer.buffer;
|
ValidatedUserConfigBuffer.buffer = StagingUserConfigBuffer.buffer;
|
||||||
StagingUserConfigBuffer.buffer = temp;
|
StagingUserConfigBuffer.buffer = temp;
|
||||||
|
|
||||||
|
if (IsFactoryResetModeEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ParserRunDry = false;
|
ParserRunDry = false;
|
||||||
ValidatedUserConfigBuffer.offset = 0;
|
ValidatedUserConfigBuffer.offset = 0;
|
||||||
parseConfigStatus = ParseConfig(&ValidatedUserConfigBuffer);
|
parseConfigStatus = ParseConfig(&ValidatedUserConfigBuffer);
|
||||||
|
|||||||
@@ -191,23 +191,56 @@ static void processMouseActions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static layer_id_t previousLayer = LayerId_Base;
|
static layer_id_t previousLayer = LayerId_Base;
|
||||||
|
|
||||||
|
static void handleSwitchLayerAction(key_state_t *keyState, key_action_t *action)
|
||||||
|
{
|
||||||
|
static key_state_t *doubleTapSwitchLayerKey;
|
||||||
|
static uint32_t doubleTapSwitchLayerStartTime;
|
||||||
|
static uint32_t doubleTapSwitchLayerTriggerTime;
|
||||||
|
static bool isLayerDoubleTapToggled;
|
||||||
|
|
||||||
|
if (doubleTapSwitchLayerKey && doubleTapSwitchLayerKey != keyState && !keyState->previous) {
|
||||||
|
doubleTapSwitchLayerKey = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keyState->previous && isLayerDoubleTapToggled && ToggledLayer == action->switchLayer.layer) {
|
||||||
|
ToggledLayer = LayerId_Base;
|
||||||
|
isLayerDoubleTapToggled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action->type != KeyActionType_SwitchLayer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyState->previous && doubleTapSwitchLayerKey == keyState &&
|
||||||
|
Timer_GetElapsedTime(&doubleTapSwitchLayerTriggerTime) > DoubleTapSwitchLayerReleaseTimeout)
|
||||||
|
{
|
||||||
|
ToggledLayer = LayerId_Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
||||||
|
if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
||||||
|
ToggledLayer = action->switchLayer.layer;
|
||||||
|
isLayerDoubleTapToggled = true;
|
||||||
|
doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime();
|
||||||
|
} else {
|
||||||
|
doubleTapSwitchLayerKey = keyState;
|
||||||
|
}
|
||||||
|
doubleTapSwitchLayerStartTime = Timer_GetCurrentTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t basicScancodeIndex = 0;
|
static uint8_t basicScancodeIndex = 0;
|
||||||
static uint8_t mediaScancodeIndex = 0;
|
static uint8_t mediaScancodeIndex = 0;
|
||||||
static uint8_t systemScancodeIndex = 0;
|
static uint8_t systemScancodeIndex = 0;
|
||||||
|
|
||||||
static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||||
{
|
{
|
||||||
static key_state_t *doubleTapSwitchLayerKey;
|
|
||||||
static uint32_t doubleTapSwitchLayerStartTime;
|
|
||||||
static uint32_t doubleTapSwitchLayerTriggerTime;
|
|
||||||
|
|
||||||
if (keyState->suppressed) {
|
if (keyState->suppressed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doubleTapSwitchLayerKey && doubleTapSwitchLayerKey != keyState && !keyState->previous) {
|
handleSwitchLayerAction(keyState, action);
|
||||||
doubleTapSwitchLayerKey = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (action->type) {
|
switch (action->type) {
|
||||||
case KeyActionType_Keystroke:
|
case KeyActionType_Keystroke:
|
||||||
@@ -238,21 +271,7 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
|||||||
activeMouseStates[action->mouseAction] = true;
|
activeMouseStates[action->mouseAction] = true;
|
||||||
break;
|
break;
|
||||||
case KeyActionType_SwitchLayer:
|
case KeyActionType_SwitchLayer:
|
||||||
if (keyState->previous && doubleTapSwitchLayerKey == keyState &&
|
// Handled by handleSwitchLayerAction()
|
||||||
Timer_GetElapsedTime(&doubleTapSwitchLayerTriggerTime) > DoubleTapSwitchLayerReleaseTimeout)
|
|
||||||
{
|
|
||||||
ToggledLayer = LayerId_Base;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
|
||||||
if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
|
||||||
ToggledLayer = action->switchLayer.layer;
|
|
||||||
doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime();
|
|
||||||
} else {
|
|
||||||
doubleTapSwitchLayerKey = keyState;
|
|
||||||
}
|
|
||||||
doubleTapSwitchLayerStartTime = Timer_GetCurrentTime();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case KeyActionType_SwitchKeymap:
|
case KeyActionType_SwitchKeymap:
|
||||||
if (!keyState->previous) {
|
if (!keyState->previous) {
|
||||||
@@ -305,10 +324,10 @@ static void updateActiveUsbReports(void)
|
|||||||
key_state_t *keyState = &KeyStates[slotId][keyId];
|
key_state_t *keyState = &KeyStates[slotId][keyId];
|
||||||
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
|
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
|
||||||
|
|
||||||
if (keyState->debounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) {
|
if (keyState->debounceCounter) {
|
||||||
keyState->current = keyState->previous;
|
keyState->current = keyState->previous;
|
||||||
} else if (!keyState->previous && keyState->current) {
|
} else if (keyState->previous != keyState->current) {
|
||||||
keyState->debounceCounter = 0;
|
keyState->debounceCounter = KEY_DEBOUNCER_TIMEOUT_MSEC + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyState->current) {
|
if (keyState->current) {
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
"commander": "^2.11.0",
|
"commander": "^2.11.0",
|
||||||
"shelljs": "^0.7.8"
|
"shelljs": "^0.7.8"
|
||||||
},
|
},
|
||||||
"firmwareVersion": "8.2.3",
|
"firmwareVersion": "8.3.2",
|
||||||
"deviceProtocolVersion": "4.3.0",
|
"deviceProtocolVersion": "4.3.1",
|
||||||
"moduleProtocolVersion": "4.0.0",
|
"moduleProtocolVersion": "4.0.0",
|
||||||
"userConfigVersion": "4.0.0",
|
"userConfigVersion": "4.1.0",
|
||||||
"hardwareConfigVersion": "1.0.0",
|
"hardwareConfigVersion": "1.0.0",
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,19 +19,19 @@
|
|||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
#define FIRMWARE_MAJOR_VERSION 8
|
#define FIRMWARE_MAJOR_VERSION 8
|
||||||
#define FIRMWARE_MINOR_VERSION 2
|
#define FIRMWARE_MINOR_VERSION 3
|
||||||
#define FIRMWARE_PATCH_VERSION 3
|
#define FIRMWARE_PATCH_VERSION 2
|
||||||
|
|
||||||
#define DEVICE_PROTOCOL_MAJOR_VERSION 4
|
#define DEVICE_PROTOCOL_MAJOR_VERSION 4
|
||||||
#define DEVICE_PROTOCOL_MINOR_VERSION 3
|
#define DEVICE_PROTOCOL_MINOR_VERSION 3
|
||||||
#define DEVICE_PROTOCOL_PATCH_VERSION 0
|
#define DEVICE_PROTOCOL_PATCH_VERSION 1
|
||||||
|
|
||||||
#define MODULE_PROTOCOL_MAJOR_VERSION 4
|
#define MODULE_PROTOCOL_MAJOR_VERSION 4
|
||||||
#define MODULE_PROTOCOL_MINOR_VERSION 0
|
#define MODULE_PROTOCOL_MINOR_VERSION 0
|
||||||
#define MODULE_PROTOCOL_PATCH_VERSION 0
|
#define MODULE_PROTOCOL_PATCH_VERSION 0
|
||||||
|
|
||||||
#define USER_CONFIG_MAJOR_VERSION 4
|
#define USER_CONFIG_MAJOR_VERSION 4
|
||||||
#define USER_CONFIG_MINOR_VERSION 0
|
#define USER_CONFIG_MINOR_VERSION 1
|
||||||
#define USER_CONFIG_PATCH_VERSION 0
|
#define USER_CONFIG_PATCH_VERSION 0
|
||||||
|
|
||||||
#define HARDWARE_CONFIG_MAJOR_VERSION 1
|
#define HARDWARE_CONFIG_MAJOR_VERSION 1
|
||||||
|
|||||||
Reference in New Issue
Block a user