Make bidirectional communication work between the keyboard halves. Make the set test LED USB command set the test LED of the left half, too.

This commit is contained in:
László Monda
2016-10-19 19:39:00 +02:00
parent 1286d9cfc3
commit 7a6e5523fb
9 changed files with 167 additions and 37 deletions

View File

@@ -0,0 +1,40 @@
#include "bridge_protocol_handler.h"
#include "test_led.h"
#include "main.h"
#include "i2c_addresses.h"
#include "i2c.h"
void SetError(uint8_t error);
void SetGenericError();
void SetResponseByte(uint8_t response);
void SetError(uint8_t error) {
BridgeTxBuffer[0] = error;
}
void SetGenericError()
{
SetError(PROTOCOL_RESPONSE_GENERIC_ERROR);
}
// Set a single byte as the response.
void SetResponseByte(uint8_t response)
{
BridgeTxBuffer[1] = response;
}
void BridgeProtocolHandler()
{
uint8_t commandId = BridgeRxBuffer[0];
switch (commandId) {
case BRIDGE_COMMAND_GET_KEY_STATES:
BridgeTxSize = KEYBOARD_MATRIX_COLS_NUM*KEYBOARD_MATRIX_ROWS_NUM;
memcpy(BridgeTxBuffer, keyMatrix.keyStates, BridgeTxSize);
break;
case BRIDGE_COMMAND_SET_LED:
TEST_LED_OFF();
BridgeTxSize = 0;
TEST_LED_SET(BridgeRxBuffer[1]);
break;
}
}