Reimplement SLOT_ID_TO_UHK_MODULE_DRIVER_ID as UhkModuleSlaveDriver_SlotIdToDriverId and UHK_MODULE_DRIVER_ID_TO_SLOT_ID as UhkModuleSlaveDriver_DriverIdToSlotId

This commit is contained in:
László Monda
2019-06-11 00:42:32 +02:00
parent 4486f607da
commit 95003cf55d
4 changed files with 16 additions and 4 deletions

View File

@@ -9,6 +9,17 @@
#include "key_states.h"
uhk_module_state_t UhkModuleStates[UHK_MODULE_MAX_COUNT];
uint8_t UhkModuleSlaveDriver_SlotIdToDriverId(uint8_t slotId)
{
return slotId-1;
}
uint8_t UhkModuleSlaveDriver_DriverIdToSlotId(uint8_t uhkModuleDriverId)
{
return uhkModuleDriverId+1;
}
static uint8_t keyStatesBuffer[MAX_KEY_COUNT_PER_MODULE];
static i2c_message_t txMessage;

View File

@@ -11,8 +11,6 @@
#define UHK_MODULE_MAX_COUNT 3
#define MAX_PWM_BRIGHTNESS 0x64
#define SLOT_ID_TO_UHK_MODULE_DRIVER_ID(slotId) ((slotId)-1)
#define UHK_MODULE_DRIVER_ID_TO_SLOT_ID(uhkModuleDriverId) ((uhkModuleDriverId)+1)
// Typedefs:
@@ -96,6 +94,9 @@
// Functions:
uint8_t UhkModuleSlaveDriver_SlotIdToDriverId(uint8_t slotId);
uint8_t UhkModuleSlaveDriver_DriverIdToSlotId(uint8_t uhkModuleDriverId);
void UhkModuleSlaveDriver_Init(uint8_t uhkModuleDriverId);
status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId);
void UhkModuleSlaveDriver_Disconnect(uint8_t uhkModuleDriverId);

View File

@@ -15,7 +15,7 @@ void UsbCommand_GetModuleProperty()
module_property_id_t modulePropertyId = GetUsbRxBufferUint8(2);
switch (modulePropertyId) {
case ModulePropertyId_VersionNumbers: {
uint8_t moduleDriverId = SLOT_ID_TO_UHK_MODULE_DRIVER_ID(slotId);
uint8_t moduleDriverId = UhkModuleSlaveDriver_SlotIdToDriverId(slotId);
uhk_module_state_t *moduleState = UhkModuleStates + moduleDriverId;
GenericHidOutBuffer[1] = moduleState->moduleId;
memcpy(GenericHidOutBuffer + 2, &moduleState->moduleProtocolVersion, sizeof(version_t));

View File

@@ -12,6 +12,6 @@ void UsbCommand_JumpToModuleBootloader(void)
return;
}
uint8_t uhkModuleDriverId = SLOT_ID_TO_UHK_MODULE_DRIVER_ID(slotId);
uint8_t uhkModuleDriverId = UhkModuleSlaveDriver_SlotIdToDriverId(slotId);
UhkModuleStates[uhkModuleDriverId].phase = UhkModulePhase_JumpToBootloader;
}