I would like to do a recap and add some info about the configuration of the tmk firmware for handling both the keyboard matrix and the trackpoint with a single teensy 2.0 (I have a 60% kb with 15x5 colxrows, so I have enough pins on the controller).
WiringFor the wiring you should see those resources, expecially the first one, as it shows various trackpoints versions and the RC filter you have to wire for the use with tmk firmware.
https://geekhack.org/index.php?topic=55 ... msg1291412http://sprintek.com/documents/datasheet ... asheet.pdfhttps://www.mikrocontroller.net/attachm ... tpm754.pdfFlashing the firmwareFirst of all you should not use the polling configuration but the interrupt or usart version, that because I saw a lot of ghosting like problems in the polling version, where keys where not detected if not pressed repeatedly or hold.
You should refer to the tmk onekey example for the configuration, see the config.h and Makefile
I will refer to the teensy 2 pinout
http://www.pjrc.com/teensy/pinout2a.png1) for the interrupt version you have to use any INTn or PCINTn pin for clock, and any pin for data, this should reflect the config and
initialization of the interrupt array on your config, for example say that you are using INT2 pin and pd5 for data, the config you have to change is like this: (this is not really tested as I'm not really sure of the initialization code)
- Code: Select all
/* PS/2 mouse interrupt version */
#ifdef PS2_USE_INT
/* uses INT2 for clock line(ATMega32U4) */
#define PS2_CLOCK_PORT PORTD
#define PS2_CLOCK_PIN PIND
#define PS2_CLOCK_DDR DDRD
#define PS2_CLOCK_BIT 2
#define PS2_DATA_PORT PORTD
#define PS2_DATA_PIN PIND
#define PS2_DATA_DDR DDRD
#define PS2_DATA_BIT 5
#define PS2_INT_INIT() do { \
EICRA |= ((1<<ISC21) | \
(0<<ISC20)); \
} while (0)
#define PS2_INT_ON() do { \
EIMSK |= (1<<INT2); \
} while (0)
#define PS2_INT_OFF() do { \
EIMSK &= ~(1<<INT2); \
} while (0)
#define PS2_INT_VECT INT2_vect
#endif
2) For the usart version you must use the PD5 (XCK) pin for the clock and PD2 (RXD1) for data, I'm using this config mode as presumably it should wake up less frequently the int handler.
- Code: Select all
/* PS/2 mouse USART version */
#ifdef PS2_USE_USART
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
/* XCK for clock line and RXD for data line */
#define PS2_CLOCK_PORT PORTD
#define PS2_CLOCK_PIN PIND
#define PS2_CLOCK_DDR DDRD
#define PS2_CLOCK_BIT 5
#define PS2_DATA_PORT PORTD
#define PS2_DATA_PIN PIND
#define PS2_DATA_DDR DDRD
#define PS2_DATA_BIT 2
/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
/* set DDR of CLOCK as input to be slave */
#define PS2_USART_INIT() do { \
PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
UCSR1C = ((1 << UMSEL10) | \
(3 << UPM10) | \
(0 << USBS1) | \
(3 << UCSZ10) | \
(0 << UCPOL1)); \
UCSR1A = 0; \
UBRR1H = 0; \
UBRR1L = 0; \
} while (0)
#define PS2_USART_RX_INT_ON() do { \
UCSR1B = ((1 << RXCIE1) | \
(1 << RXEN1)); \
} while (0)
#define PS2_USART_RX_POLL_ON() do { \
UCSR1B = (1 << RXEN1); \
} while (0)
#define PS2_USART_OFF() do { \
UCSR1C = 0; \
UCSR1B &= ~((1 << RXEN1) | \
(1 << TXEN1)); \
} while (0)
#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
#define PS2_USART_RX_DATA UDR1
#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
#define PS2_USART_RX_VECT USART1_RX_vect
#endif
#endif
#endif
3) the makefile should include
- Code: Select all
PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
#PS2_USE_BUSYWAIT = yes # uses primitive reference code
#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
PS2_MOUSE_DEBUG = no
With this on place you should be free to go.
