Skip to main content
Visitor II
July 14, 2020
Solved

How to use stm32f103 as usb hid (Assembly language) ? I want to learn everything about usb hid protocol...

  • July 14, 2020
  • 3 replies
  • 2868 views

Thanks for your replies,already.

    This topic has been closed for replies.
    Best answer by DeeDee

    As predecesors says: It makes (almost) no sense to study USB (or any other protocols) from assembly language for specific CPU/microcontroller. But If you really want this:

    I'm using gcc suite for building of projects, and there is a tool/binary named objdump, which is able disasembly of binary target and part of Makefile looks like:

    #######################################
    # binaries
    #######################################
    BINPATH = /opt/arm-tools/arm-none-eabi/bin
    PREFIX = arm-none-eabi-
    CC = $(BINPATH)/$(PREFIX)gcc
    AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp
    CP = $(BINPATH)/$(PREFIX)objcopy
    AR = $(BINPATH)/$(PREFIX)ar
    SZ = $(BINPATH)/$(PREFIX)size
    OBJDUMP = $(BINPATH)/$(PREFIX)objdump
    HEX = $(CP) -O ihex
    BIN = $(CP) -O binary -S
     
    ...
     
    $(BUILD_DIR)/$(TARGET).uasm: $(BUILD_DIR)/$(TARGET).elf Makefile.linux
    	$(OBJDUMP) -d $(BUILD_DIR)/$(TARGET).elf > $@

    And result looks like (this is non related to USB_HID but USB_CDC/Serial Comm port)

    08004380 <MX_USB_DEVICE_Init>:
     8004380:	b510 	push	{r4, lr}
     8004382:	4c09 	ldr	r4, [pc, #36]	; (80043a8 <MX_USB_DEVICE_Init+0x28>)
     8004384:	2200 	movs	r2, #0
     8004386:	4909 	ldr	r1, [pc, #36]	; (80043ac <MX_USB_DEVICE_Init+0x2c>)
     8004388:	4620 	mov	r0, r4
     800438a:	f004 fe1c 	bl	8008fc6 <USBD_Init>
     800438e:	4908 	ldr	r1, [pc, #32]	; (80043b0 <MX_USB_DEVICE_Init+0x30>)
     8004390:	4620 	mov	r0, r4
     8004392:	f004 fe2d 	bl	8008ff0 <USBD_RegisterClass>
     8004396:	4620 	mov	r0, r4
     8004398:	4906 	ldr	r1, [pc, #24]	; (80043b4 <MX_USB_DEVICE_Init+0x34>)
     800439a:	f004 fc40 	bl	8008c1e <USBD_CDC_RegisterInterface>
     800439e:	4620 	mov	r0, r4
     80043a0:	e8bd 4010 	ldmia.w	sp!, {r4, lr}
     80043a4:	f004 be2b 	b.w	8008ffe <USBD_Start>

    3 replies

    Super User
    July 14, 2020

    coding USB in assembly language seems like a bad choice. There are usb examples in the cube repositories.

    YAY.1Author
    Visitor II
    July 14, 2020

    Thanks for your opinon.

    i know but i want to do with assembly language because i want to learn everything about usb hid.

    Just i need, hid signature with assembly language for windows.

    Graduate II
    July 14, 2020

    Ok, so what's stopping you reviewing the register level implementation, docs on HID classes (irrespective of the STM32), the C code, or disassembly thereof, and then coding in whatever language you want.

    The learning here can be done via "doing" rather than "showing"

    The mechanics of the hardware, interrupts and descriptors really isn't going to be any different.

    YAY.1Author
    Visitor II
    July 14, 2020

    0693W000001srSUQAY.pngJust i could not do this , How can i do this with assembly language ?

    YAY.1Author
    Visitor II
    July 15, 2020

    https://stm32f4-discovery.net/2014/09/library-34-stm32f4-usb-hid-device/

    I will try to make this library with assembly language.

    Super User
    July 15, 2020
    I'd recommend becoming very familiar with http://www.usbmadesimple.co.uk/
    YAY.1Author
    Visitor II
    July 18, 2020

    I have a question about c language stm32f103 hid mouse project.

    How can i holding mouse button ?