Teensy with TMK firmware in composite mode

obones

11 Dec 2015, 17:40

Hello all,

As I'm trying to find some use to a dead laptop sitting around here, I came up with the idea to use it as a KVM for a server.
With the help of a dedicated controller board, I got the original LCD to display the server image via a standard VGA connection.
But now, I'm moving on to the keyboard and trackpad on it. Looking at the various parts on the motherboard, I discovered the following details:

The keyboard has a set of rows and columns connected to a specialized chip that talks directly to the CPU via the internal bus (National Semiconductor DS012932)
The trackpad uses a 5V chipset that outputs a PS/2 signal that is connected to the same specialized chip.

Clearly, I can't scavenge this chip but doing searches on the web, I stumbled across the use of a Teensy++ 2.0 board with the TMK keyboard firmware collection. It appears to be quite versatile and I believe it could be the solution for me because the homepage for the project on GitHub mentions "PS/2 mouse support as composite device"

However, I could not confirm this would indeed working fine, mostly because I could not find any configuration examples for such a situation.

Would any of you have any hints as to what I should be looking at?

Thanks a lot for your answers.

User avatar
Ray

15 Dec 2015, 18:25

Wow, no replies to this one?

The software side of this would be pretty easy, as your laptop board has some kind of default layout and you are not looking for fancy stuff.
The PS/2 mouse support is easy to figure out with a quick read through the makefiles. That is, if you have some skills in C and have seen code for microcontrollers. If not, feel free to ask the specific question again.
In Makefile, look out for

Code: Select all

PS2_MOUSE_ENABLE = yes
PS2_USE_USART = yes
and in config.h for

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
I am pretty sure you need to change this for the teensy++. I am copy-pasting out of context, but this can tell you where to look at.

The hardware side is a bit more complicated. You need to figure out the matrix. This is easy to do, but takes quite some time.
You probably need connections from flatflex to the teensy. I haven't seen this around here before, but can be done without black wizardry for sure.

From there on, follow the “How to build your very own keyboard firmware” thread

obones

16 Dec 2015, 10:43

Thanks for the reply.

Thanks for the indications in the source, it will help me get started.
I have programmed some PIC microcontrollers in the past, so I'm not in foreign land here.

I have looked up the pinout for the Teensy++ and the USART is located on the same port, so it should work fine. I may need to adjust the #if defined clause, but that's no big deal.

Thanks for using the FlatFlex word, it allowed me to narrow down my search for connectors matching what's coming out of the keyboard and the touchpad. I now need to measure the pitch for both, shouldn't be too hard.

And you are right, what's gonna take lots of time is finding the right assignments for the matrix. But a bit of breadboarding with leds should make this easier.

Finally, thanks for the heads up on the other thread, I read it quickly and it seems it contains all I will need when I have the hardware part sorted out.

Once again, thanks for your detailed answer.

obones

30 Dec 2015, 16:46

Hello again,

I have received my Teensy++ board and it's working just fine and because I'm still waiting for the flatflex connectors, I decided to start working on the software part.
I made a fork of TMK's github project here: https://github.com/obones/tmk_keyboard/ ... sario_2710

I followed the tutorial from the other thread and I get a compiled firmware.
However, reading carefully the various comments in the code, I'm wondering if I have the rows and columns count rights.
I mean, here is the documentation for the PC87570 chip that was used on the motherboard to drive the keyboard:
KBSIN(7–0)Input Pull Up-SchmidtInternal Keyboard input scan lines
KBSOUT(15–0)Output Open DrainInternal Keyboard output scan lines
So the chip has 16 output lines that get pulled low when selecting, unconnected (hi-z) when not, and 8 input lines that are pulled up by an internal resistor.

Now, when I go into matrix.c, there is the init_cols method with this comment:

Code: Select all

Input with pull-up(DDR:0, PORT:1)
and inside the two row functions there are these comments:

Code: Select all

Hi-Z(DDR:0, PORT:0) to unselect
Output low(DDR:1, PORT:0) to select
The wording is clearly similar to the documentation for the PC87570 chip but unless I'm grossly mistaken, the comments in the TMK firmware suggest that this keyboard has 16 rows and 8 columns. Basically, it's as if it is a transposed version of a common keyboard matrix where the number of rows is smaller than the number of columns.

I haven't found out the physical key assignment yet because I'm still waiting for the flatflex connector, but do you think I'm correct in assuming that I should configure TMK to have 16 rows and 8 columns?

User avatar
Ray

30 Dec 2015, 17:06

My best guess is your keyboard matrix has no diodes or other directional stuff built in. Just a plain matrix that fights ghosting with a matrix-layout that minimizes ghosting for typical usage. And maybe some firmware that's clever when collisions occur.

If my assumtion is true, you don't need to care about which side of the matrix is input and which is output or which direction the current flows.
Also on the firmware side I don't think TMKs anti ghosting is doing fancy stuff that would be optimized for specific matrices. At least I haven't heard about it.

obones

01 Feb 2016, 11:02

I finally received the missing parts, and you were definitely right, there are no diodes or anything else in the keyboard. So I was able to figure out assignments and am now moving to the next step.

Thanks for your help.

Post Reply

Return to “Workshop”