Code Monkey home page Code Monkey logo

stm32g4xx_usb_cdc's Introduction

stm32g4xx_usb_cdc

This repo contains a STM32G474 USB CDC example implementation, combined with Jan Breuer's SCPI parser library v2 allowing you to build your own STM32G4xx based scientific instruments.

The STM will present a Serial device, running the SCPI parser.

The STM will present a Serial device, running a SCPI parser.

A query speed test can be performed by running testscripts/speedtest.py, performances up to 70ms/100 requests have been seen.

query speed test

Working example instruments

Lucys Wireless Charging SMU

Jana Maries Mini-TDR

Folder structure

  • usb_cdc_g4/ : Universal CDC implementation for STM32G4xx, include this folder + changes to the Makefile
  • libscpi/ : Jan Breuer's awesome SCPI parser library v2
  • Inc/ : Contains the header files, please note Inc/scpi-def.h
  • Src/ : Contains the source files, please note Src/scpi-def.c and Src/scpi-com.c
  • testscripts/ : Contains some python test scripts and example software

How to use the CDC-library for your own project

  • Copy usb_cdc_g4/ and its contents to your project folder.

  • Add the following lines to your Makefile.

C_SOURCES += \
usb_cdc_g4/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \
usb_cdc_g4/STM32_USB_Device_Library/Core/Src/usbd_core.c \
usb_cdc_g4/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
usb_cdc_g4/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usb.c \
usb_cdc_g4/Src/usbd_cdc_if.c \
usb_cdc_g4/Src/usb_device.c \
usb_cdc_g4/Src/usbd_conf.c \
usb_cdc_g4/Src/usbd_it.c \
usb_cdc_g4/Src/usbd_desc.c

C_INCLUDES +=  \
-Iusb_cdc_g4/STM32_USB_Device_Library/Class/CDC/Inc \
-Iusb_cdc_g4/STM32_USB_Device_Library/Core/Inc \
-Iusb_cdc_g4/Inc
  • Add the following to your global variables if needed.
extern uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
extern uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
extern uint8_t is_new_data_ready;
extern uint16_t new_data_length;
  • Call the USB init
MX_USB_PCD_Init();
MX_USB_Device_Init();
  • Received Data is present within main.c though the earlier added global variables, e.g.:
if (is_new_data_ready) {
  SCPI_Input(&scpi_context, UserRxBufferFS, new_data_length);
  is_new_data_ready = 0;
}
  • Data can be transmitted via:
CDC_Transmit_FS(data, length);

stm32g4xx_usb_cdc's People

Contributors

flybysun avatar jana-marie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

stm32g4xx_usb_cdc's Issues

What is the IDE for this project?

Hi Henrik,

I saw the cubeMX file in your project.
I was trying to import your project into SMT32CubeIDE, but it not compatible.
May you tell me what is IDE that you used?

Thanks
Phuoc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.