1
0
mirror of https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter synced 2024-11-11 11:45:04 -05:00
Arduino-USB-HID-RetroJoysti.../C64_joystick_atmelstudio/README.md

66 lines
2.4 KiB
Markdown
Raw Normal View History

2019-02-13 16:13:27 -05:00
## Firmware/flashing
- Install Arduino IDE
- Download firmware: https://github.com/mcgurk/Arduino-USB-HID-RetroJoystickAdapter/raw/master/C64_joystick_atmelstudio/CLASS_JOYSTICK1.hex
- Connect RST to GND couple of times to get Arduino Pro Micro to programming mode (notice that com-port is different in programming mode in Windows)
- Flash firmware
```
& "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude" -C"C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -p m32u4 -c avr109 -P COM5 -b 57600 -U flash:w:CLASS_JOYSTICK1.hex:i
```
## Muistiinpanoja
2019-02-13 16:11:06 -05:00
```
13.2.2019:
Koko ATmega32U4 tuntuu puuttuvan...
Löytyy kyllä kun tekee uuden projektin...
Examplet puuttuu kaikki...
Tools->Extensions and Updates...->Lufa
Nyt löytyy.
Lufa->New Example Project->FourWalledCubicle - Dean Camera->Joystick HID Device Demo (Class Driver APIs) - AVR8 Architecture
Project->Properties->Change Device...->ATmega32U4 (rutkuttaa jotain, mutta suostuu silti)
Tools->External tools
Title:
Arduino_via_bootloader
command:
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude.exe
Arguments:
-C"C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega32u4 -cavr109 -PCOM5 -b57600 -D -Uflash:w:"$(BinDir)\$(TargetName).hex":i
Use Output window
Pari kertaa GND->RST, sitten Tools->Arduino_via_bootloader
C:\Users\lehti\Documents\Atmel Studio\7.0\CLASS_JOYSTICK1\CLASS_JOYSTICK1\Debug\CLASS_JOYSTICK1.hex
Tulee "LUFA Joystick Demo", 2 nappia ja kolme axista (X,Y,Z).
Näkyy Device managerissa "HID-compliant game controller".
0x03EB, 0x2043, Atmel Corp., LUFA Joystick Demo Application.
VID/PID ja "LUFA Joystick Demo": Descriptors.c
suuntien ja nappien määrä ehkä structissa: Joystick.h
Ja myös: src/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h (HID_DESCRIPTOR_JOYSTICK)
Pois: HID_RI_USAGE(8, 0x32)
Muokkaa: HID_RI_REPORT_COUNT(8, 3) -> 2
Koodi: Joystick.c
GitHub-integraation vois tehdä external tools:lla.
PB6,2,3,1
PB5,4
```
## Joystick.c
SetupHardware (before USB_INIT();):
```
DDRB = 0x0; //PORTB=input
PORTB = 0xff; //PORTB=pullup
```
CALLBACK_HID_Device_CreateHIDReport (before report size):
```
if (!(in & (1 << 6))) JoystickReport->Y = -100;
if (!(in & (1 << 2))) JoystickReport->Y = 100;
if (!(in & (1 << 3))) JoystickReport->X = -100;
if (!(in & (1 << 1))) JoystickReport->X = 100;
if (!(in & (1 << 5))) JoystickReport->Button |= (1 << 0);
if (!(in & (1 << 4))) JoystickReport->Button |= (1 << 1);
```