forked from UltimateHackingKeyboard/firmware
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:UltimateHackingKeyboard/firmware
# Conflicts: # README.md
- Loading branch information
Showing
20 changed files
with
144 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,50 @@ | ||
#include "fsl_gpio.h" | ||
#include "fsl_port.h" | ||
#include "blackberry_trackball.h" | ||
#include "test_led.h" | ||
|
||
pointer_delta_t BlackBerryTrackball_PointerDelta; | ||
|
||
void BlackberryTrackball_Init(void) | ||
{ | ||
CLOCK_EnableClock(BLACKBERRY_TRACKBALL_LEFT_CLOCK); | ||
PORT_SetPinMux(BLACKBERRY_TRACKBALL_LEFT_PORT, BLACKBERRY_TRACKBALL_LEFT_PIN, kPORT_MuxAsGpio); | ||
PORT_SetPinInterruptConfig(BLACKBERRY_TRACKBALL_LEFT_PORT, BLACKBERRY_TRACKBALL_LEFT_PIN, kPORT_InterruptEitherEdge); | ||
NVIC_EnableIRQ(BLACKBERRY_TRACKBALL_LEFT_IRQ); | ||
|
||
CLOCK_EnableClock(BLACKBERRY_TRACKBALL_RIGHT_CLOCK); | ||
PORT_SetPinMux(BLACKBERRY_TRACKBALL_RIGHT_PORT, BLACKBERRY_TRACKBALL_RIGHT_PIN, kPORT_MuxAsGpio); | ||
PORT_SetPinInterruptConfig(BLACKBERRY_TRACKBALL_RIGHT_PORT, BLACKBERRY_TRACKBALL_RIGHT_PIN, kPORT_InterruptEitherEdge); | ||
NVIC_EnableIRQ(BLACKBERRY_TRACKBALL_RIGHT_IRQ); | ||
|
||
CLOCK_EnableClock(BLACKBERRY_TRACKBALL_UP_CLOCK); | ||
PORT_SetPinMux(BLACKBERRY_TRACKBALL_UP_PORT, BLACKBERRY_TRACKBALL_UP_PIN, kPORT_MuxAsGpio); | ||
PORT_SetPinInterruptConfig(BLACKBERRY_TRACKBALL_UP_PORT, BLACKBERRY_TRACKBALL_UP_PIN, kPORT_InterruptEitherEdge); | ||
NVIC_EnableIRQ(BLACKBERRY_TRACKBALL_UP_IRQ); | ||
|
||
CLOCK_EnableClock(BLACKBERRY_TRACKBALL_DOWN_CLOCK); | ||
PORT_SetPinMux(BLACKBERRY_TRACKBALL_DOWN_PORT, BLACKBERRY_TRACKBALL_DOWN_PIN, kPORT_MuxAsGpio); | ||
PORT_SetPinInterruptConfig(BLACKBERRY_TRACKBALL_DOWN_PORT, BLACKBERRY_TRACKBALL_DOWN_PIN, kPORT_InterruptEitherEdge); | ||
NVIC_EnableIRQ(BLACKBERRY_TRACKBALL_DOWN_IRQ); | ||
} | ||
|
||
void handleTrackball(void) | ||
{ | ||
if (PORT_GetPinsInterruptFlags(BLACKBERRY_TRACKBALL_LEFT_PORT) & (1 << BLACKBERRY_TRACKBALL_LEFT_PIN)) { | ||
BlackBerryTrackball_PointerDelta.x++; | ||
GPIO_ClearPinsInterruptFlags(BLACKBERRY_TRACKBALL_LEFT_GPIO, 1U << BLACKBERRY_TRACKBALL_LEFT_PIN); | ||
} | ||
bool oldLeft, oldRight, oldUp, oldDown; | ||
|
||
if (PORT_GetPinsInterruptFlags(BLACKBERRY_TRACKBALL_RIGHT_PORT) & (1 << BLACKBERRY_TRACKBALL_RIGHT_PIN)) { | ||
void BlackberryTrackball_Update(void) | ||
{ | ||
uint8_t newLeft = GPIO_ReadPinInput(BLACKBERRY_TRACKBALL_LEFT_GPIO, BLACKBERRY_TRACKBALL_LEFT_PIN); | ||
if (oldLeft != newLeft) { | ||
BlackBerryTrackball_PointerDelta.x--; | ||
GPIO_ClearPinsInterruptFlags(BLACKBERRY_TRACKBALL_RIGHT_GPIO, 1U << BLACKBERRY_TRACKBALL_RIGHT_PIN); | ||
oldLeft = newLeft; | ||
} | ||
|
||
if (PORT_GetPinsInterruptFlags(BLACKBERRY_TRACKBALL_UP_PORT) & (1 << BLACKBERRY_TRACKBALL_UP_PIN)) { | ||
BlackBerryTrackball_PointerDelta.y++; | ||
GPIO_ClearPinsInterruptFlags(BLACKBERRY_TRACKBALL_UP_GPIO, 1U << BLACKBERRY_TRACKBALL_UP_PIN); | ||
uint8_t newRight = GPIO_ReadPinInput(BLACKBERRY_TRACKBALL_RIGHT_GPIO, BLACKBERRY_TRACKBALL_RIGHT_PIN); | ||
if (oldRight != newRight) { | ||
BlackBerryTrackball_PointerDelta.x++; | ||
oldRight = newRight; | ||
} | ||
|
||
if (PORT_GetPinsInterruptFlags(BLACKBERRY_TRACKBALL_DOWN_PORT) & (1 << BLACKBERRY_TRACKBALL_DOWN_PIN)) { | ||
uint8_t newUp = GPIO_ReadPinInput(BLACKBERRY_TRACKBALL_UP_GPIO, BLACKBERRY_TRACKBALL_UP_PIN); | ||
if (oldUp != newUp) { | ||
BlackBerryTrackball_PointerDelta.y--; | ||
GPIO_ClearPinsInterruptFlags(BLACKBERRY_TRACKBALL_DOWN_GPIO, 1U << BLACKBERRY_TRACKBALL_DOWN_PIN); | ||
oldUp = newUp; | ||
} | ||
} | ||
|
||
void BLACKBERRY_TRACKBALL_IRQ_HANDLER1(void) | ||
{ | ||
handleTrackball(); | ||
} | ||
|
||
void BLACKBERRY_TRACKBALL_IRQ_HANDLER2(void) | ||
{ | ||
handleTrackball(); | ||
uint8_t newDown = GPIO_ReadPinInput(BLACKBERRY_TRACKBALL_DOWN_GPIO, BLACKBERRY_TRACKBALL_DOWN_PIN); | ||
if (oldDown != newDown) { | ||
BlackBerryTrackball_PointerDelta.y++; | ||
oldDown = newDown; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "fsl_gpio.h" | ||
#include "key_vector.h" | ||
|
||
void KeyVector_Init(key_vector_t *keyVector) | ||
{ | ||
for (key_vector_pin_t *item = keyVector->items; item < keyVector->items + keyVector->itemNum; item++) { | ||
CLOCK_EnableClock(item->clock); | ||
PORT_SetPinConfig(item->port, item->pin, | ||
&(port_pin_config_t){.pullSelect=kPORT_PullUp, .mux=kPORT_MuxAsGpio}); | ||
GPIO_PinInit(item->gpio, item->pin, &(gpio_pin_config_t){kGPIO_DigitalInput}); | ||
} | ||
} | ||
|
||
void KeyVector_Scan(key_vector_t *keyVector) | ||
{ | ||
uint8_t *keyState = keyVector->keyStates; | ||
for (key_vector_pin_t *item = keyVector->items; item < keyVector->items + keyVector->itemNum; item++) { | ||
*(keyState++) = !GPIO_ReadPinInput(item->gpio, item->pin); | ||
} | ||
} |
Oops, something went wrong.