6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Jun 04, 2024 3:57 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Nov 25, 2023 11:47 pm 
Offline

Joined: Tue Sep 26, 2023 11:09 am
Posts: 51
i'm working thru a breadboard 6502 tutorial and thought i'd take a detour into learning about mechanical keyboards... So I built a nullbits tidbit keypad as a hex keypad.

The keypad runs on an rp2040 mcu (avr arch) with QMK software for keyboard customization.
It lets you type hex digits directly as well as arbitrary ascii characters using a meta key (bottom left) followed by two hex digits. e.g. meta + 2 + 0 generates a space character. It'll have other QMK config with different typing modes but that's unimportant here.

Anyway, I'd like to hook it up to send ascii to the 65c02 using a 65c22. The rp2040 gives me a breakout for vcc/gnd/clk/sda and QMK already seems to offer various drivers (i2c, spi, uart, serial/bitbang) - see https://docs.qmk.fm/#/hardware_drivers - so it seems like i have a lot of ingredients. At worst I could ditch QMK and write custom code for the mcu but that would mean managing the keyboard directly which would be nice to avoid.

Wondered if anyone had been down a similar path with suggestions for the best/easiest approach?


Attachments:
IMG_4522.jpg
IMG_4522.jpg [ 1.22 MiB | Viewed 1722 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 27, 2023 12:30 am 
Offline
User avatar

Joined: Fri Feb 17, 2023 11:59 pm
Posts: 163
Location: Lviv, Ukraine
AFAIK, QMK is primarily targeted to send keypress data through USB HID. I'm not sure if it supports, say, sending key codes through UART/i2c out of the box.

Nevertheless, you can easily override the key processing handler in your keymap code to send key codes through i2c, for instance. There are some existing functions in QMK for performing i2c transactions. You can then use 65c22 with a shift register mode to read serial messages into its internal buffer, and it can generate an interrupt for you once the key code is received. Beware of the shift register bug though though! (Search forums for "6522 bug" or check Garth's primer on 6522.)

Alternatively, instead of using i2c, you can just bit-bang the data from QMK into 65c22's shift register, since i2c feels like an overkill here. This will give you more control over the data that you're sending - e.g. make/break byte, various flags, etc. And in case QMK has SPI functions - you can use them to avoid doing manual bit-banging! SPI works great with shift registers, and you'll only need 2 signal lines: CLK & MOSI (it makes sense to treat keyboard as master here IMO). This won't be "true" SPI and it will be unidirectional, but to me it looks like an efficient solution.
I myself would probably go this route (bitbang or half-SPI) since it seems fun, and I love reinventing the wheel. :)

_________________
/Andrew

deck65 - 6502 slab with screen and keyboard | ПК-88 - SBC based on KM1810VM88 (Ukrainian i8088 clone) | leo80 - simple Z80 SBC
nice65 - 6502 assembly linter | My parts, footprints & 3D models for KiCad/FreeCAD


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 30, 2023 1:13 pm 
Offline

Joined: Tue Sep 26, 2023 11:09 am
Posts: 51
Amazing, thanks, just the kind of advice I was looking for!

I switched from QMK to KMK which is similar but python w/ interactive repl makes it much easier to tinker with. I have most of the configuration done as a standard USB keyboard and shouldn't be hard to add some direct output mode. there is the keycode <> ascii translation nuance to deal with also.

I naively thought i2c and spi would both play nice with 6522 but i have no practical experience so great to know where to start.

i'm of the same mind about reinventing the wheel - it's all new to me anyway and imho the best way to learn.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: