Expose variables via USB
This commit is contained in:
21
right/src/usb_commands/usb_command_get_variable.c
Normal file
21
right/src/usb_commands/usb_command_get_variable.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "usb_protocol_handler.h"
|
||||
#include "usb_commands/usb_command_get_variable.h"
|
||||
#include "key_matrix.h"
|
||||
|
||||
void UsbCommand_GetVariable(void)
|
||||
{
|
||||
usb_variable_id_t variableId = GetUsbRxBufferUint8(1);
|
||||
|
||||
switch (variableId) {
|
||||
case UsbVariable_TestMode:
|
||||
break;
|
||||
case UsbVariable_TestUsbStack:
|
||||
break;
|
||||
case UsbVariable_DebounceTimePress:
|
||||
SetUsbTxBufferUint8(1, DebounceTimePress);
|
||||
break;
|
||||
case UsbVariable_DebounceTimeRelease:
|
||||
SetUsbTxBufferUint8(1, DebounceTimeRelease);
|
||||
break;
|
||||
}
|
||||
}
|
||||
8
right/src/usb_commands/usb_command_get_variable.h
Normal file
8
right/src/usb_commands/usb_command_get_variable.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __USB_COMMAND_GET_VARIABLE_H__
|
||||
#define __USB_COMMAND_GET_VARIABLE_H__
|
||||
|
||||
// Functions:
|
||||
|
||||
void UsbCommand_GetVariable(void);
|
||||
|
||||
#endif
|
||||
21
right/src/usb_commands/usb_command_set_variable.c
Normal file
21
right/src/usb_commands/usb_command_set_variable.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "usb_protocol_handler.h"
|
||||
#include "usb_commands/usb_command_set_variable.h"
|
||||
#include "key_matrix.h"
|
||||
|
||||
void UsbCommand_SetVariable(void)
|
||||
{
|
||||
usb_variable_id_t variableId = GetUsbRxBufferUint8(1);
|
||||
|
||||
switch (variableId) {
|
||||
case UsbVariable_TestMode:
|
||||
break;
|
||||
case UsbVariable_TestUsbStack:
|
||||
break;
|
||||
case UsbVariable_DebounceTimePress:
|
||||
DebounceTimePress = GetUsbRxBufferUint8(2);
|
||||
break;
|
||||
case UsbVariable_DebounceTimeRelease:
|
||||
DebounceTimeRelease = GetUsbRxBufferUint8(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
8
right/src/usb_commands/usb_command_set_variable.h
Normal file
8
right/src/usb_commands/usb_command_set_variable.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __USB_COMMAND_SET_VARIABLE_H__
|
||||
#define __USB_COMMAND_SET_VARIABLE_H__
|
||||
|
||||
// Functions:
|
||||
|
||||
void UsbCommand_SetVariable(void);
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "usb_commands/usb_command_get_slave_i2c_errors.h"
|
||||
#include "usb_commands/usb_command_set_i2c_baud_rate.h"
|
||||
#include "usb_commands/usb_command_switch_keymap.h"
|
||||
#include "usb_commands/usb_command_get_variable.h"
|
||||
#include "usb_commands/usb_command_set_variable.h"
|
||||
|
||||
void UsbProtocolHandler(void)
|
||||
{
|
||||
@@ -77,6 +79,12 @@ void UsbProtocolHandler(void)
|
||||
case UsbCommandId_SwitchKeymap:
|
||||
UsbCommand_SwitchKeymap();
|
||||
break;
|
||||
case UsbCommandId_GetVariable:
|
||||
UsbCommand_GetVariable();
|
||||
break;
|
||||
case UsbCommandId_SetVariable:
|
||||
UsbCommand_SetVariable();
|
||||
break;
|
||||
default:
|
||||
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
|
||||
break;
|
||||
|
||||
@@ -34,8 +34,17 @@
|
||||
UsbCommandId_GetSlaveI2cErrors = 0x0f,
|
||||
UsbCommandId_SetI2cBaudRate = 0x10,
|
||||
UsbCommandId_SwitchKeymap = 0x11,
|
||||
UsbCommandId_GetVariable = 0x12,
|
||||
UsbCommandId_SetVariable = 0x13,
|
||||
} usb_command_id_t;
|
||||
|
||||
typedef enum {
|
||||
UsbVariable_TestMode,
|
||||
UsbVariable_TestUsbStack,
|
||||
UsbVariable_DebounceTimePress,
|
||||
UsbVariable_DebounceTimeRelease
|
||||
} usb_variable_id_t;
|
||||
|
||||
typedef enum {
|
||||
UsbStatusCode_Success = 0,
|
||||
UsbStatusCode_InvalidCommand = 1,
|
||||
|
||||
Reference in New Issue
Block a user