Setting up Arduino UNO with Joystick demo project.

80 views
Skip to first unread message

Enthused Dragon

unread,
Jul 30, 2018, 8:14:18 AM7/30/18
to LUFA Library Support List
Hi guys,

I'm busy wiring up a custom controller for my PC that has two joysticks, a thruster and 12 buttons.

I've got a Arduino UNO I want to wire everything to but I'm having trouble compiling the LUFA Joystick Demo.

I've made the changes to the makefile:
MCU          = atmega16u2
ARCH         = AVR8
BOARD        = UNO
F_CPU        = 16000000Enter code here...

Then I received errors stating that there are no Buttons.h or Joystick.h files in the Boards/UNO/ directory.
I copied the two files over from the Boards/USBKEY and then it found the files but I'm getting the following errors now.

 [INFO]    : Begin compilation of project "Joystick"...

avr-gcc.exe (AVR_8_bit_GNU_Toolchain_3.6.1_1750) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 [GCC]     : Compiling C file "Joystick.c"
avr-gcc -c -pipe -gdwarf-2 -g2 -mmcu=atmega16u2 -fshort-enums -fno-inline-small-functions -fpack-struct -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections -I. -DARCH=ARCH_AVR8 -DF_CPU=16000000UL -mrelax -fno-jump-tables -x c -Os -std=gnu99 -Wstrict-prototypes -DUSE_LUFA_CONFIG_HEADER -IConfig/ -I. -I../../../../LUFA/.. -DARCH=ARCH_AVR8 -DBOARD=BOARD_UNO -DF_USB=16000000UL  -MMD -MP -MF obj/Joystick.d Joystick.c -o obj/Joystick.o
In file included from ../../../../LUFA/../LUFA/Drivers/Board/Joystick.h:114:0,
                 from Joystick.h:49,
                 from Joystick.c:37:
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h: In function 'Joystick_Init':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:100:5: error: 'DDRE' undeclared (first use in this function)
     DDRE  &= ~JOY_EMASK;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:100:5: note: each undeclared identifier is reported only once for each function it appears in
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:103:5: error: 'PORTE' undeclared (first use in this function)
     PORTE |=  JOY_EMASK;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h: In function 'Joystick_Disable':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:109:5: error: 'DDRE' undeclared (first use in this function)
     DDRE  &= ~JOY_EMASK;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:112:5: error: 'PORTE' undeclared (first use in this function)
     PORTE &= ~JOY_EMASK;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h: In function 'Joystick_GetStatus':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:118:56: error: 'PINE' undeclared (first use in this function)
     return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT));
                                                        ^
In file included from ../../../../LUFA/../LUFA/Drivers/Board/Buttons.h:102:0,
                 from Joystick.h:51,
                 from Joystick.c:37:
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h: In function 'Buttons_Init':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h:78:5: error: 'DDRE' undeclared (first use in this function)
     DDRE  &= ~BUTTONS_BUTTON1;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h:79:5: error: 'PORTE' undeclared (first use in this function)
     PORTE |=  BUTTONS_BUTTON1;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h: In function 'Buttons_Disable':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h:84:5: error: 'DDRE' undeclared (first use in this function)
     DDRE  &= ~BUTTONS_BUTTON1;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h:85:5: error: 'PORTE' undeclared (first use in this function)
     PORTE &= ~BUTTONS_BUTTON1;
     ^
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h: In function 'Buttons_GetStatus':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h:91:14: error: 'PINE' undeclared (first use in this function)
     return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
              ^
In file included from ../../../../LUFA/../LUFA/Drivers/Board/Joystick.h:114:0,
                 from Joystick.h:49,
                 from Joystick.c:37:
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h: In function 'Joystick_GetStatus':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Joystick.h:119:4: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
In file included from ../../../../LUFA/../LUFA/Drivers/Board/Buttons.h:102:0,
                 from Joystick.h:51,
                 from Joystick.c:37:
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h: In function 'Buttons_GetStatus':
../../../../LUFA/../LUFA/Drivers/Board/AVR8/UNO/Buttons.h:92:4: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
make: *** [obj/Joystick.o] Error 1

If anyone has an idea of what I'm missing or doing wrong, I'd appreciate that.

Don Davis

unread,
Jul 31, 2018, 10:47:58 AM7/31/18
to lufa-s...@googlegroups.com
James,

Did you figure this out yet? DDRE (the data direction register for port E) doesn't exist on the 16u2. The usb key uses a 128 pin chip which has many more resources including port E. You need to make a Joystick.h that matches the UNO and your particular hardware. FWIW, if you switched over to the Leonardo, or the M0 based arduinos, the current core has perfectly workable HID implementations that you can use until you get up to speed on whatever you were expecting LUFA to do. 

Cheers,

D
--
You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lufa-support...@googlegroups.com.
To post to this group, send email to lufa-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/lufa-support.
For more options, visit https://groups.google.com/d/optout.

Enthused Dragon

unread,
Aug 1, 2018, 3:38:02 AM8/1/18
to LUFA Library Support List
Hey,

Thanks, I only had the UNO available to me at the moment.
I managed to do what I wanted using Hoodloader2. :)
Reply all
Reply to author
Forward
0 new messages