Go Down

Topic: ps2x library with esp32 -> problem with avr (Read 725 times) previous topic - next topic

_butch_

Hi all,

I am trying to use esp32 with ps2x library (https://github.com/madsci1016/Arduino-PS2X).
I want to read the gamepad and transmit the data via BLE to an arduino micro or nano which I plan to use with HM11 or HM10 as receiver to control RC cars.

When using esp32 with ps2x library, it links some avr libraries which seems to be incompatible or unavailable for esp32.

Any Idea how I can proceed or does anyone know an other good library to read out a wired ps2 controller which is compatible with esp32?

Thanks, Andreas

pylon

Quote
When using esp32 with ps2x library, it links some avr libraries which seems to be incompatible or unavailable for esp32.
I cannot find any specific AVR library to be included. It has an include for an AVR header file ("avr/io.h") in PS2X_lib.cpp, but you can safely delete that line as the include is done in the PS2X_lib.h file already if the AVR platform is used. What other libraries is missing on your platform?

_butch_

sorry for my late reply. I did not receive a notification of your response.

I am programming in sloeber.
I tried your hint and removed the avr include. I removed in .cpp and in .h

Now I get following error during building:

'Starting combiner'
"F:\Arduino\sloeber_4.2\/arduinoPlugin/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-gcc" -nostdlib "-LF:\Arduino\sloeber_4.2\/arduinoPlugin/packages/esp32/hardware/esp32/1.0.0/tools/sdk/lib" "-LF:\Arduino\sloeber_4.2\/arduinoPlugin/packages/esp32/hardware/esp32/1.0.0/tools/sdk/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception -Wl,--start-group    .\sloeber.ino.cpp.o  .\libraries\PS2X_lib_ESP32\PS2X_lib.cpp.o   "F:/Arduino/workspace_git/arduino_eclipse_workspace/esp32_ps2x_test1/Release/arduino.ar" -lgcc -lopenssl -lbtdm_app -lfatfs -lwps -lcoexist -lwear_levelling -lesp_http_client -lhal -lnewlib -ldriver -lbootloader_support -lpp -lmesh -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lapp_trace -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lcxx -lxtensa-debug-module -lmdns -lvfs -lsoc -lcore -lsdmmc -lcoap -ltcpip_adapter -lc_nano -lesp-tls -lrtc -lspi_flash -lwpa2 -lesp32 -lapp_update -lnghttp -lspiffs -lespnow -lnvs_flash -lesp_adc_cal -llog -lsmartconfig_ack -lexpat -lm -lc -lheap -lmbedtls -llwip -lnet80211 -lpthread -ljson -lstdc++ -Wl,--end-group -Wl,-EL -o "F:/Arduino/workspace_git/arduino_eclipse_workspace/esp32_ps2x_test1/Release/esp32_ps2x_test1.elf" F:/Arduino/workspace_git/arduino_eclipse_workspace/esp32_ps2x_test1/Release/arduino.ar
F:\Arduino\sloeber_4.2\/arduinoPlugin/packages/esp32/hardware/esp32/1.0.0/tools/sdk/lib\libbtdm_app.a(arch_main.o):(.bss+0x4): multiple definition of `error'
.\sloeber.ino.cpp.o:(.bss.error+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

pylon

Try to compile with the Arduino IDE. If you still get errors there, post your complete code and post links to the used libraries.

JNA81685

#4
Feb 11, 2019, 09:56 pm Last Edit: Feb 11, 2019, 10:02 pm by JNA81685
Hello, I am hoping someone can help me -- I am having issues using the PS2X_lib and ESP32 -
I downloaded the ps2x_lib from: https://github.com/madsci1016/Arduino-PS2X

I am trying to port this ROV project (http://techmonkeybusiness.com/rov-control-sketches-fourth-edition.html) which I built and had working with an Arduino Nano to 2 NodeMCU ESP32-S because I need the extra memory and processing power to add an external pressure sensor, MPU9250, PID control, and an on-screen display via mavlink and minimOSD.

For more simplified testing I reverted back to the original sketch from techmonkeybusiness:(http://techmonkeybusiness.com/rov-control-sketches-fourth-edition.html) -- code is at the bottom of his page.

As instructed above I commented out the AVR/IO.h references in the ps2x_lib.h and ps2x_lib.cpp files but I am stilll getting the following error messages:

Arduino: 1.8.5 (Mac OS X), Board: "NodeMCU-32S, 80MHz, 921600"

/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'byte PS2X::config_gamepad(uint32_t, uint32_t, uint32_t, uint32_t, bool, bool)':
PS2X_lib.cpp:185: error: '_clk_lport_set' was not declared in this scope
  _clk_lport_set = portOutputRegister(lport) + 2;
  ^
PS2X_lib.cpp:186: error: '_clk_lport_clr' was not declared in this scope
  _clk_lport_clr = portOutputRegister(lport) + 1;
  ^
PS2X_lib.cpp:190: error: '_cmd_lport_set' was not declared in this scope
  _cmd_lport_set = portOutputRegister(lport) + 2;
  ^
PS2X_lib.cpp:191: error: '_cmd_lport_clr' was not declared in this scope
  _cmd_lport_clr = portOutputRegister(lport) + 1;
  ^
PS2X_lib.cpp:195: error: '_att_lport_set' was not declared in this scope
  _att_lport_set = portOutputRegister(lport) + 2;
  ^
PS2X_lib.cpp:196: error: '_att_lport_clr' was not declared in this scope
  _att_lport_clr = portOutputRegister(lport) + 1;
  ^
PS2X_lib.cpp:199: error: '_dat_lport' was not declared in this scope
  _dat_lport = portInputRegister(digitalPinToPort(dat));
  ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'void PS2X::CLK_SET()':
PS2X_lib.cpp:440: error: '_clk_lport_set' was not declared in this scope
  *_clk_lport_set |= _clk_mask;
   ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'void PS2X::CLK_CLR()':
PS2X_lib.cpp:444: error: '_clk_lport_clr' was not declared in this scope
  *_clk_lport_clr |= _clk_mask;
   ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'void PS2X::CMD_SET()':
PS2X_lib.cpp:448: error: '_cmd_lport_set' was not declared in this scope
  *_cmd_lport_set |= _cmd_mask;
   ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'void PS2X::CMD_CLR()':
PS2X_lib.cpp:452: error: '_cmd_lport_clr' was not declared in this scope
  *_cmd_lport_clr |= _cmd_mask;
   ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'void PS2X::ATT_SET()':
PS2X_lib.cpp:456: error: '_att_lport_set' was not declared in this scope
  *_att_lport_set |= _att_mask;
   ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'void PS2X::ATT_CLR()':
PS2X_lib.cpp:460: error: '_att_lport_clr' was not declared in this scope
  *_att_lport_clr |= _att_mask;
   ^
/var/folders/1l/fvhdppfn553965nv3tkhpsv40000gn/T/arduino_build_65421/sketch/PS2X_lib.cpp: In member function 'bool PS2X::DAT_CHK()':
PS2X_lib.cpp:464: error: '_dat_lport' was not declared in this scope
  return (*_dat_lport & _dat_mask) ? true : false;
           ^
/Users/Jonathan/Documents/Arduino/libraries/PS2X_lib/PS2X_lib.cpp: In member function 'unsigned char PS2X::_gamepad_shiftinout(char)':
PS2X_lib.cpp:62: error: 'SREG' was not declared in this scope
    uint8_t old_sreg = SREG;        // *** KJE *** save away the current state of interrupts
                       ^
/Users/Jonathan/Documents/Arduino/libraries/PS2X_lib/PS2X_lib.cpp: In member function 'void PS2X::read_gamepad(boolean, byte)':
PS2X_lib.cpp:93: error: 'SREG' was not declared in this scope
   uint8_t old_sreg = SREG;        // *** KJE **** save away the current state of interrupts - *** *** KJE *** ***
                      ^
/Users/Jonathan/Documents/Arduino/libraries/PS2X_lib/PS2X_lib.cpp: In member function 'byte PS2X::config_gamepad(uint8_t, uint8_t, uint8_t, uint8_t, bool, bool)':
PS2X_lib.cpp:159: error: 'SREG' was not declared in this scope
    uint8_t old_sreg = SREG;        // *** KJE *** save away the current state of interrupts
                       ^
PS2X_lib.cpp:163: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
  _clk_oreg = portOutputRegister(digitalPinToPort(clk));
            ^
PS2X_lib.cpp:165: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
  _cmd_oreg = portOutputRegister(digitalPinToPort(cmd));
            ^
PS2X_lib.cpp:167: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
  _att_oreg = portOutputRegister(digitalPinToPort(att));
            ^
PS2X_lib.cpp:169: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
  _dat_ireg = portInputRegister(digitalPinToPort(dat));
            ^
/Users/Jonathan/Documents/Arduino/libraries/PS2X_lib/PS2X_lib.cpp: In member function 'void PS2X::sendCommandString(byte*, byte)':
PS2X_lib.cpp:263: error: 'SREG' was not declared in this scope
    uint8_t old_sreg = SREG;        // *** KJE *** save away the current state of interrupts

pylon

It seems that the ESP32 platform doesn't support direct port readings. Convert the button reads into digitalRead()s which every Arduino IDE core must support.

Go Up