background image

UM2546 Rev 1

17/30

UM2546

Software description

29

The file "stm32g0xx_it.c" is also part of the application and is used, as usual, to map the 
interrupt vector on the driver HAL driver, depending on the module requirement (for debug 
trace, and joystick management)

Main demonstration functionalities are in the file demo_disco.c.

          

5.2 Application 

overview

Depending on the door position (GPIO DOOR_SENSE_PIN: PC8), two different sub-
applications may be executed.

In the spy case, USBPD stack is not launched. INA230 is used to know which CC line is 
selected for communication, and then decode the messages on it.

In the standalone mode, the full USBPD stack is running.

Table 5. Main applications functions description 

Functions (demo_disco.c) 

Description

DEMO_Manage_spy

This is the main spy function. It gets the VBUS voltage 
and current from the INA230, and gets the voltage level of 
both CC lines. If the message queue has some messages 
to process, Display_add_spymsg is called

DEMO_Manage_event

Main function for standalone mode.

Display_add_spymsg

Function goal is to fill the USB PD data structures with the 
information received from the CC lines. These structures 
are then used by the application, to feed the G0 disco 
information display.

DEMO_SPY_Handler

This function is called on any UCPD event thanks to an 
interrupt. It posts the USBPD protocol message seen from 
the CC lines to a queue. Later, the application reads this 
queue and decode the protocol messages. We don’t 
decode the message under interrupt state, to be ready as 
soon as possible to see the next messages on the CC 
lines.

DEMO_InitBSP

Initialise the LCD, and the voltage monitoring of VBUS 
and CC lines.

Check_cc_attachement

Used in case of spy mode: to detect which CC line is used 
for power delivery protocol exchanges.

DEMO_PostMMIMessage

Function that posts the joystick press event in a 
FreeRTOS queue, thanks to 
HAL_GPIO_EXTI_Rising_Callback function.

*_menu_nav

Function that is used to manage the joystick up and down 
press to navigate into a specific menu (source power 
profiles, sink power profiles, extended capabilities, 
command…)

*_menu_exec

Function that executes the selected specific action (select 
power profile, command…)

Intialize_RX_processing

Configures the UCPD IP (DMA, Interrupts) to be ready to 
capture UCPD messages.

Содержание STM32G071B-DISCO

Страница 1: ...ery kit may be executed in two different modes depending on the position of the switch standalone sink mode or spy mode The spy mode does not use the USBPD stack In this mode the protocol information...

Страница 2: ...l description 12 2 1 Demo startup 12 2 1 1 Normal processing 12 2 2 UCPD demonstration 12 2 2 1 Mode selection 12 2 2 2 LED indications 12 3 Hardware settings 14 3 1 STM32G071B DISCO board 14 4 Softwa...

Страница 3: ...UM2546 Rev 1 3 30 UM2546 Contents 3 5 2 5 Dynamic memory use 25 5 3 Middlewares 25 5 3 1 USB PD 25 5 3 2 FreeRTOS 25 6 Footprint 26 7 Acronyms 27 8 Table of references 28 Revision history 29...

Страница 4: ...e 2 STM32G071RBT demonstration interrupts usage 10 Table 3 LED assignation 13 Table 4 Main application functions description 16 Table 5 Main applications functions description 17 Table 6 Code example...

Страница 5: ...ation pull down 18 Figure 13 Menu sequence in spy mode 19 Figure 14 Menu sequence in standalone sink mode 20 Figure 15 Welcome screen 20 Figure 16 Attach screen 20 Figure 17 PD capability screen 20 Fi...

Страница 6: ...ehensive G0 functional coverage 1 1 Demonstration package Figure 2 shows the demonstration folder organization Figure 2 Demonstration folder organization The demonstration sources are located in the P...

Страница 7: ...WARM IAR embedded workbench MDK ARM Keil Microcontroller Development Kit SW4STM32 System workbench for STM32 1 2 Demonstration architecture overview The top level software architecture of the STM32G07...

Страница 8: ...disconnection detection and Type C power contract negotiation 1 2 2 HAL level HAL level layer consists in the stm32g0xx HAL drivers together with the STM32G071B DISCO board support package BSP 1 2 3 M...

Страница 9: ...sed by the UCPD demonstration 06Y 9 0LFUR 86 FRQQHFWRU PEHGGHG 67 1 9 670 0LFURFRQWUROOHU SLQ 86 5 H WHQVLRQ FRQQHFWRU SLQ 3 2 FRQQHFWRU SLQ 3 2 FRQQHFWRU XUUHQW 3RZHU 0RQLWRU XUUHQW 3RZHU 0RQLWRU XUU...

Страница 10: ...O pins connected to the joystick are used to interact with the UCPD demonstration e g menu navigation One GPIO pin is used to detect the door position Several GPIOs are used to drive some indication L...

Страница 11: ...errupt mode rising edge EXTI line 1 Joystick LEFT interrupt mode rising edge EXTI line 13 Tamper interrupt mode rising edge DMA1 Channel1 DAC ADC conversions completion ADC1_COMP ADC analog watchdogs...

Страница 12: ...STM32G071B DISCO is powered from the micro USB after a board reset at demo startup the welcome screen is displayed 2 2 UCPD demonstration 2 2 1 Mode selection Depending on the position of the switch t...

Страница 13: ...Table 3 LED assignation Reference Color Name Function LD1 Green POWER 5V 5V present onto the board LD4 Orange SINK mode Attached to a power source LD5 Orange SOURCE mode Attached to a device as sourc...

Страница 14: ...f using the VBUS when connected to a type C Source For detailed information on the hardware part please check STM32G0 Discovery kit for USB Type C and Power Delivery user manual UM2401 3 1 STM32G071B...

Страница 15: ...thods 4 2 1 Using Binary file To program demonstration s binary image into the internal Flash memory the user may exercise STM32G071B DISCO_USBPD_Analyzer hex file thanks to ST Link Utility or STM32Cu...

Страница 16: ...ializing all the HW SW Table below provides a description of all the actions performed by the different functions in main c Table 4 Main application functions description Functions Main c Description...

Страница 17: ...on goal is to fill the USB PD data structures with the information received from the CC lines These structures are then used by the application to feed the G0 disco information display DEMO_SPY_Handle...

Страница 18: ...and T5 MOSFETs are turned ON Door is open RD56 5K1 Ohms is ignored needed only for standalone mode to be seen as a sink and CC1 and CC2 pins are connected from the G0 UCPD IP Figure 12 CC lines isola...

Страница 19: ...ce So dead battery indication may be provided and Rd resistors on the CC1 line must be shown This is why when the door is closed the T5 MOSFET is enabled and RD_CC1 signal is driven so that the resist...

Страница 20: ...e this screen is visible Figure 16 Attach screen Whenever a VBUS is present on the type C cable this information is displayed Then depending on the source capabilities seen dual role information may b...

Страница 21: ...p Figure 21 Data role screen This screen will indicate if the connected source device supports data role swap Figure 22 Display Port screen only standalone mode If the source is capable of using the s...

Страница 22: ...tion may be triggered here on a distant sink profile Figure 26 Action screen only standalone mode On this screen the user may execute the displayed commands using the joystick center to select He may...

Страница 23: ...UM2546 Rev 1 23 30 UM2546 Software description 29 Figure 28 STM32CubeMonitor USB Type C PD tool debug trace selection Figure 29 STM32G0 top and bottom view of Discovery board MB1378...

Страница 24: ...1 The user gets such a screen Figure 30 Trace example When the G0 disco application is used in standalone sink mode the full STM32CubeMonitor USB Type C PD tool application GUI may be used to issue so...

Страница 25: ...ment user manual UM2468 5 2 5 Dynamic memory use The demonstration is currently using CSTACK 0x300 HEAP 0x800 5 3 Middlewares 5 3 1 USB PD In this application the USBPD stack used is delivered as a li...

Страница 26: ...only code memory Byte Read only data Byte Read write data memory Byte STM32CubeMonitor USB Type C PD tool responder GUI 7682 540 Demo Application 13596 2345 842 Policy Engine PE 20320 16 20 Stack Prot...

Страница 27: ...s Table 8 Table of acronyms Acronym CC Configuration channel USB PD USB Power Delivery GUI Graphical User Interface UCPD PC monitor application PD Power Delivery DRP Dual Role Power FRS Fast Role Swap...

Страница 28: ...Table of references UM2546 28 30 UM2546 Rev 1 8 Table of references References USB IF 2017 Universal Serial Bus Power Delivery Specification rev 3 0 USB IF...

Страница 29: ...UM2546 Rev 1 29 30 UM2546 Revision history 29 Revision history Table 9 Document revision history Date Revision Changes 20 Feb 2019 1 Initial version...

Страница 30: ...rs are solely responsible for the choice selection and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products No license express or implied to a...

Отзывы: