Convert macros for controlling test LEDs to functions
This commit is contained in:
@@ -21,7 +21,7 @@ void RunWatchdog(void)
|
||||
cntr++;
|
||||
if (cntr==100) { /* we get called from KEY_SCANNER_HANDLER() which runs at 1ms, thus scaling down by 100 here to get 100 ms period */
|
||||
cntr=0;
|
||||
TEST_LED_TOGGLE();
|
||||
TestLed_Toggle();
|
||||
I2cWatchdog_WatchCounter++;
|
||||
|
||||
if (I2cWatchdog_WatchCounter>10) { /* do not check within the first 1000 ms, as I2C might not be running yet */
|
||||
|
||||
@@ -42,7 +42,7 @@ void SlaveRxHandler(void)
|
||||
case SlaveCommand_SetTestLed:
|
||||
TxMessage.length = 0;
|
||||
bool isLedOn = RxMessage.data[1];
|
||||
TEST_LED_SET(isLedOn);
|
||||
TestLed_Set(isLedOn);
|
||||
break;
|
||||
case SlaveCommand_SetLedPwmBrightness:
|
||||
TxMessage.length = 0;
|
||||
|
||||
@@ -6,5 +6,5 @@ extern void TestLed_Init(void)
|
||||
CLOCK_EnableClock(TEST_LED_CLOCK);
|
||||
PORT_SetPinMux(TEST_LED_PORT, TEST_LED_PIN, kPORT_MuxAsGpio);
|
||||
GPIO_PinInit(TEST_LED_GPIO, TEST_LED_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0});
|
||||
TEST_LED_ON();
|
||||
TestLed_On();
|
||||
}
|
||||
|
||||
@@ -15,10 +15,21 @@
|
||||
#define TEST_LED_CLOCK kCLOCK_PortB
|
||||
#define TEST_LED_PIN 13
|
||||
|
||||
#define TEST_LED_ON() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||
#define TEST_LED_OFF() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_PIN, (state))
|
||||
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||
static inline void TestLed_On(void) {
|
||||
GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN);
|
||||
}
|
||||
|
||||
static inline void TestLed_Off(void) {
|
||||
GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN);
|
||||
}
|
||||
|
||||
static inline void TestLed_Set(bool state) {
|
||||
GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_PIN, state);
|
||||
}
|
||||
|
||||
static inline void TestLed_Toggle(void) {
|
||||
GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN);
|
||||
}
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
void PIT_KEY_DEBOUNCER_HANDLER(void)
|
||||
{
|
||||
TEST_LED_TOGGLE();
|
||||
TestLed_Toggle();
|
||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
|
||||
|
||||
@@ -6,5 +6,5 @@ void TestLed_Init(void)
|
||||
CLOCK_EnableClock(TEST_LED_CLOCK);
|
||||
PORT_SetPinMux(TEST_LED_GPIO_PORT, TEST_LED_GPIO_PIN, kPORT_MuxAsGpio);
|
||||
GPIO_PinInit(TEST_LED_GPIO, TEST_LED_GPIO_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
||||
TEST_LED_ON();
|
||||
TestLed_On();
|
||||
}
|
||||
|
||||
@@ -15,10 +15,25 @@
|
||||
#define TEST_LED_CLOCK kCLOCK_PortD
|
||||
#define TEST_LED_GPIO_PIN 7U
|
||||
|
||||
#define TEST_LED_ON() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
#define TEST_LED_OFF() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
#define TEST_LED_SET(state) GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_GPIO_PIN, (state))
|
||||
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
static inline void TestLed_On(void)
|
||||
{
|
||||
GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN);
|
||||
}
|
||||
|
||||
static inline void TestLed_Off(void)
|
||||
{
|
||||
GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN);
|
||||
}
|
||||
|
||||
static inline void TestLed_Set(bool state)
|
||||
{
|
||||
GPIO_WritePinOutput(TEST_LED_GPIO, TEST_LED_GPIO_PIN, state);
|
||||
}
|
||||
|
||||
static inline void TestLed_Toggle(void)
|
||||
{
|
||||
GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN);
|
||||
}
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
void UsbCommand_SetTestLed(void)
|
||||
{
|
||||
bool isTestLedOn = GetUsbRxBufferUint8(1);
|
||||
TEST_LED_SET(isTestLedOn);
|
||||
TestLed_Set(isTestLedOn);
|
||||
UhkModuleStates[UhkModuleDriverId_LeftKeyboardHalf].sourceVars.isTestLedOn = isTestLedOn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user