Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a52df9da7e | ||
|
|
28f98f179a | ||
|
|
5798f9e4fb | ||
|
|
4fe5ce45ac | ||
|
|
a212c254a9 | ||
|
|
235e18d706 | ||
|
|
7c91f8f6d1 | ||
|
|
c8cfe53136 | ||
|
|
f1f47ece14 | ||
|
|
a0dba2fa66 | ||
|
|
0f34b01189 | ||
|
|
5a449ad5c5 |
@@ -5,6 +5,14 @@ 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.
|
||||||
|
|
||||||
|
## [6.0.0] - 2017-12-12
|
||||||
|
|
||||||
|
Data Model: 4.0.0 (unchanged) | USB Protocol: 3.0.0 (major bump) | Slave Protocol: 3.0.0 (unchanged)
|
||||||
|
|
||||||
|
- Change the value of almost every USB protocol commands because there were unused intervals between them. `USBPROTOCOL:MAJOR`
|
||||||
|
- Disable LED display icons by default.
|
||||||
|
- Update LED brightness levels upon applying the configuration.
|
||||||
|
|
||||||
## [5.0.1] - 2017-12-09
|
## [5.0.1] - 2017-12-09
|
||||||
|
|
||||||
Data Model: 4.0.0 (unchanged) | USB Protocol: 2.0.0 (unchanged) | Slave Protocol: 3.0.0 (unchanged)
|
Data Model: 4.0.0 (unchanged) | USB Protocol: 2.0.0 (unchanged) | Slave Protocol: 3.0.0 (unchanged)
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ config_buffer_t ValidatedUserConfigBuffer = { validatedUserConfig };
|
|||||||
|
|
||||||
bool ParserRunDry;
|
bool ParserRunDry;
|
||||||
|
|
||||||
|
bool IsConfigBufferIdValid(config_buffer_id_t configBufferId)
|
||||||
|
{
|
||||||
|
return ConfigBufferId_HardwareConfig <= configBufferId && configBufferId <= ConfigBufferId_ValidatedUserConfig;
|
||||||
|
}
|
||||||
|
|
||||||
config_buffer_t* ConfigBufferIdToConfigBuffer(config_buffer_id_t configBufferId)
|
config_buffer_t* ConfigBufferIdToConfigBuffer(config_buffer_id_t configBufferId)
|
||||||
{
|
{
|
||||||
switch (configBufferId) {
|
switch (configBufferId) {
|
||||||
@@ -25,3 +30,16 @@ config_buffer_t* ConfigBufferIdToConfigBuffer(config_buffer_id_t configBufferId)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t ConfigBufferIdToBufferSize(config_buffer_id_t configBufferId)
|
||||||
|
{
|
||||||
|
switch (configBufferId) {
|
||||||
|
case ConfigBufferId_HardwareConfig:
|
||||||
|
return HARDWARE_CONFIG_SIZE;
|
||||||
|
case ConfigBufferId_StagingUserConfig:
|
||||||
|
case ConfigBufferId_ValidatedUserConfig:
|
||||||
|
return USER_CONFIG_SIZE;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
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);
|
||||||
|
uint16_t ConfigBufferIdToBufferSize(config_buffer_id_t configBufferId);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include "config_globals.h"
|
#include "config_globals.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "usb_report_updater.h"
|
#include "usb_report_updater.h"
|
||||||
|
#include "led_display.h"
|
||||||
|
#include "slave_scheduler.h"
|
||||||
|
#include "slave_drivers/is31fl3731_driver.h"
|
||||||
|
|
||||||
static parser_error_t parseModuleConfiguration(config_buffer_t *buffer)
|
static parser_error_t parseModuleConfiguration(config_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
@@ -59,10 +62,6 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
uint8_t alphanumericSegmentsBrightness = ReadUInt8(buffer);
|
uint8_t alphanumericSegmentsBrightness = ReadUInt8(buffer);
|
||||||
uint8_t keyBacklightBrightness = ReadUInt8(buffer);
|
uint8_t keyBacklightBrightness = ReadUInt8(buffer);
|
||||||
|
|
||||||
(void)iconsAndLayerTextsBrightness;
|
|
||||||
(void)alphanumericSegmentsBrightness;
|
|
||||||
(void)keyBacklightBrightness;
|
|
||||||
|
|
||||||
// Mouse kinetic properties
|
// Mouse kinetic properties
|
||||||
|
|
||||||
uint8_t mouseMoveInitialSpeed = ReadUInt8(buffer);
|
uint8_t mouseMoveInitialSpeed = ReadUInt8(buffer);
|
||||||
@@ -138,6 +137,16 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
if (!ParserRunDry) {
|
if (!ParserRunDry) {
|
||||||
DoubleTapSwitchLayerTimeout = doubleTapSwitchLayerTimeout;
|
DoubleTapSwitchLayerTimeout = doubleTapSwitchLayerTimeout;
|
||||||
|
|
||||||
|
// Update LED brightnesses and reinitialize LED drivers
|
||||||
|
|
||||||
|
IconsAndLayerTextsBrightness = iconsAndLayerTextsBrightness;
|
||||||
|
AlphanumericSegmentsBrightness = alphanumericSegmentsBrightness;
|
||||||
|
KeyBacklightBrightness = keyBacklightBrightness;
|
||||||
|
Slaves[SlaveId_LeftLedDriver].isConnected = false;
|
||||||
|
Slaves[SlaveId_RightLedDriver].isConnected = false;
|
||||||
|
|
||||||
|
// Update mouse key speeds
|
||||||
|
|
||||||
MouseMoveState.initialSpeed = mouseMoveInitialSpeed;
|
MouseMoveState.initialSpeed = mouseMoveInitialSpeed;
|
||||||
MouseMoveState.acceleration = mouseMoveAcceleration;
|
MouseMoveState.acceleration = mouseMoveAcceleration;
|
||||||
MouseMoveState.deceleratedSpeed = mouseMoveDeceleratedSpeed;
|
MouseMoveState.deceleratedSpeed = mouseMoveDeceleratedSpeed;
|
||||||
@@ -150,6 +159,8 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
MouseScrollState.baseSpeed = mouseScrollBaseSpeed;
|
MouseScrollState.baseSpeed = mouseScrollBaseSpeed;
|
||||||
MouseScrollState.acceleratedSpeed = mouseScrollAcceleratedSpeed;
|
MouseScrollState.acceleratedSpeed = mouseScrollAcceleratedSpeed;
|
||||||
|
|
||||||
|
// Update counts
|
||||||
|
|
||||||
AllKeymapsCount = keymapCount;
|
AllKeymapsCount = keymapCount;
|
||||||
AllMacrosCount = macroCount;
|
AllMacrosCount = macroCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,3 +125,8 @@ status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t
|
|||||||
IsEepromBusy = LastEepromTransferStatus == kStatus_Success;
|
IsEepromBusy = LastEepromTransferStatus == kStatus_Success;
|
||||||
return LastEepromTransferStatus;
|
return LastEepromTransferStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsEepromOperationValid(eeprom_operation_t operation)
|
||||||
|
{
|
||||||
|
return operation == EepromOperation_Read || operation == EepromOperation_Write;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,5 +31,6 @@
|
|||||||
|
|
||||||
void EEPROM_Init(void);
|
void EEPROM_Init(void);
|
||||||
status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t config_buffer_id, void (*successCallback));
|
status_t EEPROM_LaunchTransfer(eeprom_operation_t operation, config_buffer_id_t config_buffer_id, void (*successCallback));
|
||||||
|
bool IsEepromOperationValid(eeprom_operation_t operation);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
#include "layer.h"
|
#include "layer.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
|
||||||
|
uint8_t IconsAndLayerTextsBrightness = 0xff;
|
||||||
|
uint8_t AlphanumericSegmentsBrightness = 0xff;
|
||||||
|
|
||||||
static const uint16_t capitalLetterToSegmentSet[] = {
|
static const uint16_t capitalLetterToSegmentSet[] = {
|
||||||
0b0000000011110111,
|
0b0000000011110111,
|
||||||
0b0001001010001111,
|
0b0001001010001111,
|
||||||
@@ -69,13 +72,13 @@ void LedDisplay_SetText(uint8_t length, const char* text)
|
|||||||
allSegmentSets |= characterToSegmentSet(text[0]);
|
allSegmentSets |= characterToSegmentSet(text[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
LedDriverValues[LedDriverId_Left][11] = allSegmentSets & 0b00000001 ? LED_BRIGHTNESS_LEVEL : 0;
|
LedDriverValues[LedDriverId_Left][11] = allSegmentSets & 0b00000001 ? AlphanumericSegmentsBrightness : 0;
|
||||||
LedDriverValues[LedDriverId_Left][12] = allSegmentSets & 0b00000010 ? LED_BRIGHTNESS_LEVEL : 0;
|
LedDriverValues[LedDriverId_Left][12] = allSegmentSets & 0b00000010 ? AlphanumericSegmentsBrightness : 0;
|
||||||
allSegmentSets >>= 2;
|
allSegmentSets >>= 2;
|
||||||
|
|
||||||
for (uint8_t i = 24; i <= 136; i += 16) {
|
for (uint8_t i = 24; i <= 136; i += 16) {
|
||||||
for (uint8_t j = 0; j < 5; j++) {
|
for (uint8_t j = 0; j < 5; j++) {
|
||||||
LedDriverValues[LedDriverId_Left][i + j] = allSegmentSets & 1 << j ? LED_BRIGHTNESS_LEVEL : 0;
|
LedDriverValues[LedDriverId_Left][i + j] = allSegmentSets & 1 << j ? AlphanumericSegmentsBrightness : 0;
|
||||||
}
|
}
|
||||||
allSegmentSets >>= 5;
|
allSegmentSets >>= 5;
|
||||||
}
|
}
|
||||||
@@ -94,11 +97,11 @@ void LedDisplay_SetLayer(uint8_t layerId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (layerId >= LayerId_Mod && layerId <= LayerId_Mouse) {
|
if (layerId >= LayerId_Mod && layerId <= LayerId_Mouse) {
|
||||||
LedDriverValues[LedDriverId_Left][16 * layerId - 3] = LED_BRIGHTNESS_LEVEL;
|
LedDriverValues[LedDriverId_Left][16 * layerId - 3] = IconsAndLayerTextsBrightness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled)
|
void LedDisplay_SetIcon(led_display_icon_t icon, bool isEnabled)
|
||||||
{
|
{
|
||||||
LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? LED_BRIGHTNESS_LEVEL : 0;
|
LedDriverValues[LedDriverId_Left][8 + icon] = isEnabled ? IconsAndLayerTextsBrightness : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
LedDisplayIcon_Adaptive,
|
LedDisplayIcon_Adaptive,
|
||||||
} led_display_icon_t;
|
} led_display_icon_t;
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
extern uint8_t IconsAndLayerTextsBrightness;
|
||||||
|
extern uint8_t AlphanumericSegmentsBrightness;
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void LedDisplay_SetText(uint8_t length, const char* text);
|
void LedDisplay_SetText(uint8_t length, const char* text);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "slave_scheduler.h"
|
#include "slave_scheduler.h"
|
||||||
#include "led_display.h"
|
#include "led_display.h"
|
||||||
|
|
||||||
|
uint8_t KeyBacklightBrightness = 0xff;
|
||||||
uint8_t LedDriverValues[LED_DRIVER_MAX_COUNT][LED_DRIVER_LED_COUNT];
|
uint8_t LedDriverValues[LED_DRIVER_MAX_COUNT][LED_DRIVER_LED_COUNT];
|
||||||
|
|
||||||
static led_driver_state_t ledDriverStates[LED_DRIVER_MAX_COUNT] = {
|
static led_driver_state_t ledDriverStates[LED_DRIVER_MAX_COUNT] = {
|
||||||
@@ -70,8 +71,14 @@ void LedSlaveDriver_Init(uint8_t ledDriverId)
|
|||||||
led_driver_state_t *currentLedDriverState = ledDriverStates + ledDriverId;
|
led_driver_state_t *currentLedDriverState = ledDriverStates + ledDriverId;
|
||||||
currentLedDriverState->phase = LedDriverPhase_SetFunctionFrame;
|
currentLedDriverState->phase = LedDriverPhase_SetFunctionFrame;
|
||||||
currentLedDriverState->ledIndex = 0;
|
currentLedDriverState->ledIndex = 0;
|
||||||
memset(LedDriverValues[ledDriverId], LED_BRIGHTNESS_LEVEL, LED_DRIVER_LED_COUNT);
|
memset(LedDriverValues[ledDriverId], KeyBacklightBrightness, LED_DRIVER_LED_COUNT);
|
||||||
|
|
||||||
|
if (ledDriverId == LedDriverId_Left) {
|
||||||
|
LedDisplay_SetIcon(LedDisplayIcon_CapsLock, false);
|
||||||
|
LedDisplay_SetIcon(LedDisplayIcon_Agent, false);
|
||||||
|
LedDisplay_SetIcon(LedDisplayIcon_Adaptive, false);
|
||||||
LedDisplay_SetCurrentKeymapText();
|
LedDisplay_SetCurrentKeymapText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t LedSlaveDriver_Update(uint8_t ledDriverId)
|
status_t LedSlaveDriver_Update(uint8_t ledDriverId)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#define LED_CONTROL_REGISTERS_COMMAND_LENGTH 19
|
#define LED_CONTROL_REGISTERS_COMMAND_LENGTH 19
|
||||||
#define PMW_REGISTER_UPDATE_CHUNK_SIZE 8
|
#define PMW_REGISTER_UPDATE_CHUNK_SIZE 8
|
||||||
#define PWM_REGISTER_BUFFER_LENGTH (1 + PMW_REGISTER_UPDATE_CHUNK_SIZE)
|
#define PWM_REGISTER_BUFFER_LENGTH (1 + PMW_REGISTER_UPDATE_CHUNK_SIZE)
|
||||||
#define LED_BRIGHTNESS_LEVEL 0xff
|
|
||||||
|
|
||||||
#define IS_ISO true
|
#define IS_ISO true
|
||||||
#define ISO_KEY_LED_DRIVER_ID LedDriverId_Left
|
#define ISO_KEY_LED_DRIVER_ID LedDriverId_Left
|
||||||
@@ -45,6 +44,7 @@
|
|||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
|
extern uint8_t KeyBacklightBrightness;
|
||||||
extern uint8_t LedDriverValues[LED_DRIVER_MAX_COUNT][LED_DRIVER_LED_COUNT];
|
extern uint8_t LedDriverValues[LED_DRIVER_MAX_COUNT][LED_DRIVER_LED_COUNT];
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|||||||
25
right/src/usb_commands/usb_command_launch_eeprom_transfer.c
Normal file
25
right/src/usb_commands/usb_command_launch_eeprom_transfer.c
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "fsl_common.h"
|
||||||
|
#include "usb_commands/usb_command_launch_eeprom_transfer.h"
|
||||||
|
#include "usb_protocol_handler.h"
|
||||||
|
#include "eeprom.h"
|
||||||
|
#include "config_parser/config_globals.h"
|
||||||
|
|
||||||
|
void UsbCommand_LaunchEepromTransfer(void)
|
||||||
|
{
|
||||||
|
eeprom_operation_t eepromOperation = GetUsbRxBufferUint8(1);
|
||||||
|
config_buffer_id_t configBufferId = GetUsbRxBufferUint8(2);
|
||||||
|
|
||||||
|
if (!IsEepromOperationValid(eepromOperation)) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_LaunchEepromTransfer_InvalidEepromOperation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsConfigBufferIdValid(configBufferId)) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_LaunchEepromTransfer_InvalidConfigBufferId);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t status = EEPROM_LaunchTransfer(eepromOperation, configBufferId, NULL);
|
||||||
|
if (status != kStatus_Success) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_LaunchEepromTransfer_TransferError);
|
||||||
|
SetUsbTxBufferUint32(1, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
right/src/usb_commands/usb_command_launch_eeprom_transfer.h
Normal file
16
right/src/usb_commands/usb_command_launch_eeprom_transfer.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_H__
|
||||||
|
#define __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_H__
|
||||||
|
|
||||||
|
// Typedef
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UsbStatusCode_LaunchEepromTransfer_InvalidEepromOperation = 2,
|
||||||
|
UsbStatusCode_LaunchEepromTransfer_InvalidConfigBufferId = 3,
|
||||||
|
UsbStatusCode_LaunchEepromTransfer_TransferError = 4,
|
||||||
|
} usb_status_code_launch_eeprom_transfer_t;
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
void UsbCommand_LaunchEepromTransfer(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#include "fsl_common.h"
|
|
||||||
#include "usb_commands/usb_command_launch_eeprom_transfer_legacy.h"
|
|
||||||
#include "usb_protocol_handler.h"
|
|
||||||
#include "eeprom.h"
|
|
||||||
|
|
||||||
void UsbCommand_LaunchEepromTransferLegacy(void)
|
|
||||||
{
|
|
||||||
uint8_t legacyEepromTransferId = GetUsbRxBufferUint8(1);
|
|
||||||
switch (legacyEepromTransferId) {
|
|
||||||
case 0:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_HardwareConfig, NULL);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Write, ConfigBufferId_HardwareConfig, NULL);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Read, ConfigBufferId_ValidatedUserConfig, NULL);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
EEPROM_LaunchTransfer(EepromOperation_Write, ConfigBufferId_ValidatedUserConfig, NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_LEGACY_H__
|
|
||||||
#define __USB_COMMAND_LAUNCH_EEPROM_TRANSFER_LEGACY_H__
|
|
||||||
|
|
||||||
// Functions:
|
|
||||||
|
|
||||||
void UsbCommand_LaunchEepromTransferLegacy(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -3,23 +3,28 @@
|
|||||||
#include "usb_protocol_handler.h"
|
#include "usb_protocol_handler.h"
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
|
|
||||||
void UsbCommand_ReadConfig(bool isHardware)
|
void UsbCommand_ReadConfig()
|
||||||
{
|
{
|
||||||
uint8_t length = GetUsbRxBufferUint8(1);
|
config_buffer_id_t configBufferId = GetUsbRxBufferUint8(1);
|
||||||
uint16_t offset = GetUsbRxBufferUint16(2);
|
uint8_t length = GetUsbRxBufferUint8(2);
|
||||||
|
uint16_t offset = GetUsbRxBufferUint16(3);
|
||||||
|
|
||||||
|
if (!IsConfigBufferIdValid(configBufferId)) {
|
||||||
|
SetUsbTxBufferUint8(0, UsbStatusCode_ReadConfig_InvalidConfigBufferId);
|
||||||
|
}
|
||||||
|
|
||||||
if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH - USB_STATUS_CODE_SIZE) {
|
if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH - USB_STATUS_CODE_SIZE) {
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_ReadConfig_LengthTooLarge);
|
SetUsbTxBufferUint8(0, UsbStatusCode_ReadConfig_LengthTooLarge);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buffer = isHardware ? HardwareConfigBuffer.buffer : ValidatedUserConfigBuffer.buffer;
|
config_buffer_t *buffer = ConfigBufferIdToConfigBuffer(configBufferId);
|
||||||
uint16_t bufferLength = isHardware ? HARDWARE_CONFIG_SIZE : USER_CONFIG_SIZE;
|
uint16_t bufferLength = ConfigBufferIdToBufferSize(configBufferId);
|
||||||
|
|
||||||
if (offset + length > bufferLength) {
|
if (offset + length > bufferLength) {
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_ReadConfig_BufferOutOfBounds);
|
SetUsbTxBufferUint8(0, UsbStatusCode_ReadConfig_BufferOutOfBounds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(GenericHidOutBuffer + USB_STATUS_CODE_SIZE, buffer + offset, length);
|
memcpy(GenericHidOutBuffer + USB_STATUS_CODE_SIZE, buffer->buffer + offset, length);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void UsbCommand_ReadConfig(bool isHardware);
|
void UsbCommand_ReadConfig();
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UsbStatusCode_ReadConfig_LengthTooLarge = 2,
|
UsbStatusCode_ReadConfig_InvalidConfigBufferId = 2,
|
||||||
UsbStatusCode_ReadConfig_BufferOutOfBounds = 3,
|
UsbStatusCode_ReadConfig_LengthTooLarge = 3,
|
||||||
|
UsbStatusCode_ReadConfig_BufferOutOfBounds = 4,
|
||||||
} usb_status_code_read_config_t;
|
} usb_status_code_read_config_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "usb_protocol_handler.h"
|
#include "usb_protocol_handler.h"
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
|
|
||||||
void UsbCommand_WriteConfig(bool isHardware)
|
void UsbCommand_WriteConfig(config_buffer_id_t configBufferId)
|
||||||
{
|
{
|
||||||
uint8_t length = GetUsbRxBufferUint8(1);
|
uint8_t length = GetUsbRxBufferUint8(1);
|
||||||
uint16_t offset = GetUsbRxBufferUint16(2);
|
uint16_t offset = GetUsbRxBufferUint16(2);
|
||||||
@@ -14,8 +14,8 @@ void UsbCommand_WriteConfig(bool isHardware)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buffer = isHardware ? HardwareConfigBuffer.buffer : StagingUserConfigBuffer.buffer;
|
uint8_t *buffer = ConfigBufferIdToConfigBuffer(configBufferId)->buffer;
|
||||||
uint16_t bufferLength = isHardware ? HARDWARE_CONFIG_SIZE : USER_CONFIG_SIZE;
|
uint16_t bufferLength = ConfigBufferIdToBufferSize(configBufferId);
|
||||||
|
|
||||||
if (offset + length > bufferLength) {
|
if (offset + length > bufferLength) {
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_WriteConfig_BufferOutOfBounds);
|
SetUsbTxBufferUint8(0, UsbStatusCode_WriteConfig_BufferOutOfBounds);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef __USB_COMMAND_WRITE_CONFIG_H__
|
#ifndef __USB_COMMAND_WRITE_CONFIG_H__
|
||||||
#define __USB_COMMAND_WRITE_CONFIG_H__
|
#define __USB_COMMAND_WRITE_CONFIG_H__
|
||||||
|
|
||||||
// Functions:
|
// Includes:
|
||||||
|
|
||||||
void UsbCommand_WriteConfig(bool isHardware);
|
#include "config_parser/config_globals.h"
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
@@ -12,4 +12,8 @@
|
|||||||
UsbStatusCode_WriteConfig_BufferOutOfBounds = 3,
|
UsbStatusCode_WriteConfig_BufferOutOfBounds = 3,
|
||||||
} usb_status_code_write_config_t;
|
} usb_status_code_write_config_t;
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
void UsbCommand_WriteConfig(config_buffer_id_t configBufferId);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "usb_commands/usb_command_apply_config.h"
|
#include "usb_commands/usb_command_apply_config.h"
|
||||||
#include "usb_commands/usb_command_set_led_pwm_brightness.h"
|
#include "usb_commands/usb_command_set_led_pwm_brightness.h"
|
||||||
#include "usb_commands/usb_command_get_adc_value.h"
|
#include "usb_commands/usb_command_get_adc_value.h"
|
||||||
#include "usb_commands/usb_command_launch_eeprom_transfer_legacy.h"
|
#include "usb_commands/usb_command_launch_eeprom_transfer.h"
|
||||||
#include "usb_commands/usb_command_read_config.h"
|
#include "usb_commands/usb_command_read_config.h"
|
||||||
#include "usb_commands/usb_command_get_keyboard_state.h"
|
#include "usb_commands/usb_command_get_keyboard_state.h"
|
||||||
#include "usb_commands/usb_command_get_debug_buffer.h"
|
#include "usb_commands/usb_command_get_debug_buffer.h"
|
||||||
@@ -25,45 +25,42 @@ void UsbProtocolHandler(void)
|
|||||||
case UsbCommandId_Reenumerate:
|
case UsbCommandId_Reenumerate:
|
||||||
UsbCommand_Reenumerate();
|
UsbCommand_Reenumerate();
|
||||||
break;
|
break;
|
||||||
case UsbCommandId_SetTestLed:
|
|
||||||
UsbCommand_SetTestLed();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_WriteUserConfig:
|
|
||||||
UsbCommand_WriteConfig(false);
|
|
||||||
break;
|
|
||||||
case UsbCommandId_ApplyConfig:
|
|
||||||
UsbCommand_ApplyConfig();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_SetLedPwmBrightness:
|
|
||||||
UsbCommand_SetLedPwmBrightness();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_GetAdcValue:
|
|
||||||
UsbCommand_GetAdcValue();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_LaunchEepromTransferLegacy:
|
|
||||||
UsbCommand_LaunchEepromTransferLegacy();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_ReadHardwareConfig:
|
|
||||||
UsbCommand_ReadConfig(true);
|
|
||||||
break;
|
|
||||||
case UsbCommandId_WriteHardwareConfig:
|
|
||||||
UsbCommand_WriteConfig(true);
|
|
||||||
break;
|
|
||||||
case UsbCommandId_ReadUserConfig:
|
|
||||||
UsbCommand_ReadConfig(false);
|
|
||||||
break;
|
|
||||||
case UsbCommandId_GetKeyboardState:
|
|
||||||
UsbCommand_GetKeyboardState();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_GetDebugBuffer:
|
|
||||||
UsbCommand_GetDebugBuffer();
|
|
||||||
break;
|
|
||||||
case UsbCommandId_JumpToModuleBootloader:
|
case UsbCommandId_JumpToModuleBootloader:
|
||||||
UsbCommand_JumpToModuleBootloader();
|
UsbCommand_JumpToModuleBootloader();
|
||||||
break;
|
break;
|
||||||
case UsbCommandId_SendKbootCommandToModule:
|
case UsbCommandId_SendKbootCommandToModule:
|
||||||
UsbCommand_SendKbootCommandToModule();
|
UsbCommand_SendKbootCommandToModule();
|
||||||
break;
|
break;
|
||||||
|
case UsbCommandId_ReadConfig:
|
||||||
|
UsbCommand_ReadConfig();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_WriteHardwareConfig:
|
||||||
|
UsbCommand_WriteConfig(ConfigBufferId_HardwareConfig);
|
||||||
|
break;
|
||||||
|
case UsbCommandId_WriteStagingUserConfig:
|
||||||
|
UsbCommand_WriteConfig(ConfigBufferId_StagingUserConfig);
|
||||||
|
break;
|
||||||
|
case UsbCommandId_ApplyConfig:
|
||||||
|
UsbCommand_ApplyConfig();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_LaunchEepromTransfer:
|
||||||
|
UsbCommand_LaunchEepromTransfer();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_GetDeviceState:
|
||||||
|
UsbCommand_GetKeyboardState();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_SetTestLed:
|
||||||
|
UsbCommand_SetTestLed();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_GetDebugBuffer:
|
||||||
|
UsbCommand_GetDebugBuffer();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_GetAdcValue:
|
||||||
|
UsbCommand_GetAdcValue();
|
||||||
|
break;
|
||||||
|
case UsbCommandId_SetLedPwmBrightness:
|
||||||
|
UsbCommand_SetLedPwmBrightness();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
|
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -14,20 +14,22 @@
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UsbCommandId_GetProperty = 0x00,
|
UsbCommandId_GetProperty = 0x00,
|
||||||
|
|
||||||
UsbCommandId_Reenumerate = 0x01,
|
UsbCommandId_Reenumerate = 0x01,
|
||||||
UsbCommandId_SetTestLed = 0x02,
|
UsbCommandId_JumpToModuleBootloader = 0x02,
|
||||||
UsbCommandId_WriteUserConfig = 0x08,
|
UsbCommandId_SendKbootCommandToModule = 0x03,
|
||||||
UsbCommandId_ApplyConfig = 0x09,
|
|
||||||
UsbCommandId_SetLedPwmBrightness = 0x0A,
|
UsbCommandId_ReadConfig = 0x04,
|
||||||
UsbCommandId_GetAdcValue = 0x0B,
|
UsbCommandId_WriteHardwareConfig = 0x05,
|
||||||
UsbCommandId_LaunchEepromTransferLegacy = 0x0C,
|
UsbCommandId_WriteStagingUserConfig = 0x06,
|
||||||
UsbCommandId_ReadHardwareConfig = 0x0D,
|
UsbCommandId_ApplyConfig = 0x07,
|
||||||
UsbCommandId_WriteHardwareConfig = 0x0E,
|
UsbCommandId_LaunchEepromTransfer = 0x08,
|
||||||
UsbCommandId_ReadUserConfig = 0x0F,
|
|
||||||
UsbCommandId_GetKeyboardState = 0x10,
|
UsbCommandId_GetDeviceState = 0x09,
|
||||||
UsbCommandId_GetDebugBuffer = 0x11,
|
UsbCommandId_SetTestLed = 0x0a,
|
||||||
UsbCommandId_JumpToModuleBootloader = 0x12,
|
UsbCommandId_GetDebugBuffer = 0x0b,
|
||||||
UsbCommandId_SendKbootCommandToModule = 0x13,
|
UsbCommandId_GetAdcValue = 0x0c,
|
||||||
|
UsbCommandId_SetLedPwmBrightness = 0x0d,
|
||||||
} usb_command_id_t;
|
} usb_command_id_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
"commander": "^2.11.0",
|
"commander": "^2.11.0",
|
||||||
"shelljs": "^0.7.8"
|
"shelljs": "^0.7.8"
|
||||||
},
|
},
|
||||||
"version": "5.0.1",
|
"version": "6.0.0",
|
||||||
"dataModelVersion": "4.0.0",
|
"dataModelVersion": "4.0.0",
|
||||||
"usbProtocolVersion": "2.0.0",
|
"usbProtocolVersion": "3.0.0",
|
||||||
"slaveProtocolVersion": "3.0.0",
|
"slaveProtocolVersion": "3.0.0",
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user