cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f072 joystick

Afonso Marques
Associate
Posted on March 16, 2018 at 13:11

Hi,

Please forgive as I am new to STM32 devices and tools.

I was suggested to use a STM32 F0 Discovery dev kit (STM32F072RBT6) in order to develop a very simple application: a custom made 3 axles joystick (x,y and throttle).

I have installed STM32CubeMX, SystemWorkbench for STM32 (SW4STM32) and followed all the steps without any problem until the point of creating a Custom HID Class.

1. How do I compile just to check that everything is OK so far? (it should be after all everything was automated)

2. I found a joystick descriptor (please see below) which, I think, fits the purpose. How do I use, configure, insert, edit, etc the current one either on CubeMX or SW4?

3. Is there a demo somewhere that I can look at?

Thanks in advance.

-x-x-x-x-x-

Joystick descriptor:

USAGE_PAGE (Generic Desktop)    05 01

LOGICAL_MINIMUM (0)    15 00

USAGE (Joystick)    09 04

COLLECTION (Application)    A1 01

  USAGE_PAGE (Simulation Controls)    05 02

  USAGE (Throttle)    09 BB

  LOGICAL_MINIMUM (-127)    15 81

  LOGICAL_MAXIMUM (127)    25 7F

  REPORT_SIZE (8)    75 08

  REPORT_COUNT (1)    95 01

  INPUT (Data,Var,Abs)    81 02

  USAGE_PAGE (Generic Desktop)    05 01

  USAGE (Pointer)    09 01

  COLLECTION (Physical)    A1 00

    USAGE (X)    09 30

    USAGE (Y)    09 31

    REPORT_COUNT (2)    95 02

    INPUT (Data,Var,Abs)    81 02

  END_COLLECTION    C0

  USAGE (Hat switch)    09 39

  LOGICAL_MINIMUM (0)    15 00

  LOGICAL_MAXIMUM (3)    25 03

  PHYSICAL_MINIMUM (0)    35 00

  PHYSICAL_MAXIMUM (270)    46 0E 01

  UNIT (Eng Rot:Angular Pos)    65 14

  REPORT_SIZE (4)    75 04

  REPORT_COUNT (1)    95 01

  INPUT (Data,Var,Abs)    81 02

  USAGE_PAGE (Button)    05 09

  USAGE_MINIMUM (Button 1)    19 01

  USAGE_MAXIMUM (Button 4)    29 04

  LOGICAL_MINIMUM (0)    15 00

  LOGICAL_MAXIMUM (1)    25 01

  REPORT_SIZE (1)    75 01

  REPORT_COUNT (4)    95 04

  UNIT_EXPONENT (0)    55 00

  UNIT (None)    65 00

  INPUT (Data,Var,Abs)    81 02

END_COLLECTION    C0

https://community.st.com/tags♯/?tags=joystick

‌

https://community.st.com/tags♯/?tags=stm32f072%20discovery

‌

https://community.st.com/tags♯/?tags=!stm32f072%20!usb%20!custom_hid

‌

#stm32f072-discovery #!stm32f072-!usb-!custom_hid #joystick
3 REPLIES 3
Andrew Neil
Evangelist III
Posted on March 16, 2018 at 14:10

I am new to STM32 devices and tools.

Do you have experience with any other microcontroller(s)? With programming in general?

creating a Custom USB Class is not a beginner project!

Getting Started with

STM32 devices and tools:

https://community.st.com/0D50X00009XkWltSAF

Afonso Marques
Associate
Posted on March 16, 2018 at 14:19

I've programming for the last 15 years at least but this is my first time with USB.

:(

I've been working monstly with ATMega, PIC and SiLabs EFM8, and back in the old days Z8, Z8000 and MC68000.

Posted on March 18, 2018 at 16:14

creating a Custom USB Class is not a beginner project!

Creating an interface for the ST-provided Custom HID class is entirely different from creating a custom USB device class.

In some of the Cube repository's projects exists the CustomHID_Standalone project (example path: STM32Cube_FW_F7_V1.9.0\Projects\STM32756G_EVAL\Applications\USB_Device\CustomHID_Standalone), which can help getting started. I suggest looking at the class code first to see what definitions are needed in usbd_conf.h, then you can implement the interface loosely based on usbd_customhid_if.c.

I'm not an advocate of the STM32 libraries as they are full of poor design choices, but for this purpose it might serve well. In case you need to create a composite device later on, or just need a better USB device stack, I can recommend

https://github.com/IntergatedCircuits/USBDevice

.