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.