Make the BlackBerry trackball work in one direction.
This commit is contained in:
19
keycluster/src/blackberry_trackball.c
Normal file
19
keycluster/src/blackberry_trackball.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "fsl_gpio.h"
|
||||||
|
#include "fsl_port.h"
|
||||||
|
#include "blackberry_trackball.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BLACKBERRY_TRACKBALL_IRQ_HANDLER(void)
|
||||||
|
{
|
||||||
|
GPIO_ClearPinsInterruptFlags(BLACKBERRY_TRACKBALL_LEFT_GPIO, 1U << BLACKBERRY_TRACKBALL_LEFT_PIN);
|
||||||
|
BlackBerryTrackball_PointerDelta.x++;
|
||||||
|
}
|
||||||
26
keycluster/src/blackberry_trackball.h
Normal file
26
keycluster/src/blackberry_trackball.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef __BLACKBERRY_TRACKBALL_H__
|
||||||
|
#define __BLACKBERRY_TRACKBALL_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include "slave_protocol.h"
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define BLACKBERRY_TRACKBALL_LEFT_PORT PORTB
|
||||||
|
#define BLACKBERRY_TRACKBALL_LEFT_GPIO GPIOB
|
||||||
|
#define BLACKBERRY_TRACKBALL_LEFT_IRQ PORTB_IRQn
|
||||||
|
#define BLACKBERRY_TRACKBALL_LEFT_CLOCK kCLOCK_PortB
|
||||||
|
#define BLACKBERRY_TRACKBALL_LEFT_PIN 6
|
||||||
|
|
||||||
|
#define BLACKBERRY_TRACKBALL_IRQ_HANDLER PORTB_IRQHandler
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
extern pointer_delta_t BlackBerryTrackball_PointerDelta;
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
void BlackberryTrackball_Init(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "i2c_watchdog.h"
|
#include "i2c_watchdog.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "blackberry_trackball.h"
|
||||||
|
|
||||||
i2c_slave_config_t slaveConfig;
|
i2c_slave_config_t slaveConfig;
|
||||||
i2c_slave_handle_t slaveHandle;
|
i2c_slave_handle_t slaveHandle;
|
||||||
@@ -86,4 +87,5 @@ void InitPeripherals(void)
|
|||||||
TestLed_Init();
|
TestLed_Init();
|
||||||
LedPwm_Init();
|
LedPwm_Init();
|
||||||
initI2c();
|
initI2c();
|
||||||
|
BlackberryTrackball_Init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "bootloader.h"
|
#include "bootloader.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "versions.h"
|
#include "versions.h"
|
||||||
|
#include "blackberry_trackball.h"
|
||||||
|
|
||||||
i2c_message_t RxMessage;
|
i2c_message_t RxMessage;
|
||||||
i2c_message_t TxMessage;
|
i2c_message_t TxMessage;
|
||||||
@@ -97,8 +98,10 @@ void SlaveTxHandler(void)
|
|||||||
uint8_t messageLength = BOOL_BYTES_TO_BITS_COUNT(MODULE_KEY_COUNT);
|
uint8_t messageLength = BOOL_BYTES_TO_BITS_COUNT(MODULE_KEY_COUNT);
|
||||||
if (MODULE_POINTER_COUNT) {
|
if (MODULE_POINTER_COUNT) {
|
||||||
pointer_delta_t *pointerDelta = (pointer_delta_t*)(TxMessage.data + messageLength);
|
pointer_delta_t *pointerDelta = (pointer_delta_t*)(TxMessage.data + messageLength);
|
||||||
pointerDelta->x = 0;
|
pointerDelta->x = BlackBerryTrackball_PointerDelta.x;
|
||||||
pointerDelta->y = 0;
|
pointerDelta->y = BlackBerryTrackball_PointerDelta.y;
|
||||||
|
BlackBerryTrackball_PointerDelta.x = 0;
|
||||||
|
BlackBerryTrackball_PointerDelta.y = 0;
|
||||||
if (keyMatrix.keyStates[0]) {
|
if (keyMatrix.keyStates[0]) {
|
||||||
pointerDelta->x = 1;
|
pointerDelta->x = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user