diff --git a/right/src/usb_commands/usb_command_get_variable.c b/right/src/usb_commands/usb_command_get_variable.c new file mode 100644 index 0000000..5f910a5 --- /dev/null +++ b/right/src/usb_commands/usb_command_get_variable.c @@ -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; + } +} diff --git a/right/src/usb_commands/usb_command_get_variable.h b/right/src/usb_commands/usb_command_get_variable.h new file mode 100644 index 0000000..5e5992a --- /dev/null +++ b/right/src/usb_commands/usb_command_get_variable.h @@ -0,0 +1,8 @@ +#ifndef __USB_COMMAND_GET_VARIABLE_H__ +#define __USB_COMMAND_GET_VARIABLE_H__ + +// Functions: + + void UsbCommand_GetVariable(void); + +#endif diff --git a/right/src/usb_commands/usb_command_set_variable.c b/right/src/usb_commands/usb_command_set_variable.c new file mode 100644 index 0000000..be71c3a --- /dev/null +++ b/right/src/usb_commands/usb_command_set_variable.c @@ -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; + } +} diff --git a/right/src/usb_commands/usb_command_set_variable.h b/right/src/usb_commands/usb_command_set_variable.h new file mode 100644 index 0000000..e9b6121 --- /dev/null +++ b/right/src/usb_commands/usb_command_set_variable.h @@ -0,0 +1,8 @@ +#ifndef __USB_COMMAND_SET_VARIABLE_H__ +#define __USB_COMMAND_SET_VARIABLE_H__ + +// Functions: + + void UsbCommand_SetVariable(void); + +#endif diff --git a/right/src/usb_protocol_handler.c b/right/src/usb_protocol_handler.c index 20b23ed..80da518 100644 --- a/right/src/usb_protocol_handler.c +++ b/right/src/usb_protocol_handler.c @@ -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; diff --git a/right/src/usb_protocol_handler.h b/right/src/usb_protocol_handler.h index 7f48f29..a417bfa 100644 --- a/right/src/usb_protocol_handler.h +++ b/right/src/usb_protocol_handler.h @@ -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,