Greetings old friends - haven't been here in a while.
I've been playing with some KADE MiniArcades I've had for a while, and I decided to try re-purposing one as a Genesis controller to USB Keyboard encoder. My KADEs have ATMEGA32U2's in them (on a Minimus I think), and I've been coding in Atmel Studio and writing the firmware with Flip.
In any case, I finished the code to read the inputs from the Genesis controller (troubleshot and verified with an oscilloscope), but now I'm stuck on trying to output as a USB keyboard. I'm trying to adapt usb_keyboard.c and usb_keyboard.h from the Kade source code found on GitHub:
https://github.com/kadevice/KADE/tree/master/open%20software/firmwares/KADE%20miniArcade/sources/kade-genI noticed that they don't seem to support the ATMEGA32U2 though. To add it, I tried modifying the following section of keyboard.h:
#elif defined(__AVR_ATmega32U4__)
#define HW_CONFIG() (UHWCON = 0x01)
#define PLL_CONFIG() (PLLCSR = 0x12)
#define USB_CONFIG() (USBCON = ((1<<USBE)|(1<<OTGPADE)))
#define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
This is as far as I got:
#elif defined(__AVR_ATmega32U2__)
#define HW_CONFIG()
#define PLL_CONFIG() (PLLCSR = ((1<<PLLE)|(1<<PLLP0)))
#define USB_CONFIG() (USBCON = (1<<USBE))
#define USB_FREEZE() (USBCON = ((1<<USBE)|(1<<FRZCLK)))
Unlike some previous attempts, this does compile and run without crashing, and my PC recognizes it as a keyboard. The key presses sent to the PC
almost never work though. I think the problem is with the PLL divider as determined with PLL_CONFIG(). I don't really know though - by this point in the code I'm a bit out of my element.
Are any of the KADE devs still around to help with this? KADE used to run on the ATMEGA32U2, so is there some older, unreleased version of the code that supports it?
Thanks!