STMicroelectronics STM32CubeG4 User Manual
광고
광고
UM2583
User manual
STM32CubeG4 STM32G474E-EVAL demonstration firmware
Introduction
STM32Cube is an STMicroelectronics original initiative to significantly improve designer's productivity by reducing development effort, time and cost. STM32Cube covers the whole STM32 portfolio.
STM32Cube includes:
• A set of user-friendly software development tools to cover project development from the conception to the realization, among which:
– STM32CubeMX , a graphical software configuration tool that allows the automatic generation of C initialization code using graphical wizards
– STM32CubeIDE , an all-in-one development tool with IP configuration, code generation, code compilation, and debug features
– STM32CubeProgrammer ( STM32CubeProg ), a programming tool available in graphical and command-line versions
– STM32CubeMonitor-Power ( STM32CubeMonPwr ), a monitoring tool to measure and help in the optimization of the power consumption of the MCU
– STM32CubeMonitor-UCPD ( STM32CubeMonUCPD ), a monitoring tool to measure and help in the configuration of
USB Type-C ™ and Power Delivery applications
• STM32Cube MCU & MPU Packages , comprehensive embedded-software platforms specific to each microcontroller and microprocessor series (such as STM32CubeG4 for the STM32G4 Series), which include:
– STM32Cube hardware abstraction layer (HAL), ensuring maximized portability across the STM32 portfolio
– STM32Cube low-layer APIs, ensuring the best performance and footprints with a high degree of user control over the
HW
– A consistent set of middleware components such as FAT file system, RTOS, USB Device, and USB Power Delivery
– All embedded software utilities with full sets of peripheral and applicative examples
• STM32Cube Expansion Packages , which contain embedded software components that complement the functionalities of the STM32Cube MCU & MPU Packages with:
– Middleware extensions and applicative layers
– Examples running on some specific STMicroelectronics development boards
The STM32CubeG4 demonstration firmware running on the STM32G474E-EVAL Evaluation board is built around the
STM32Cube hardware abstraction layer (HAL) and low-layer (LL) APIs, and board support package (BSP) components. It embeds several applications that demonstrate various features of the STM32G474QET6 device and exercise some peripherals of the STM32G474E-EVAL Evaluation board. These applications are:
• White LED application
• Mathematics application
• UCPD application
• Low-power application
• Image viewer application
• Audio application
• Calendar application
• Thermometer application
• File browser application
UM2583 - Rev 1 - June 2019
For further information contact your local STMicroelectronics sales office.
www.st.com
UM2583
STM32CubeG4 main features
1
Note:
STM32CubeG4 main features
STM32CubeG4 gathers, in a single package, all the generic embedded software components, required to develop an application on STM32G4 microcontrollers. In line with the STM32Cube initiative, this set of components is highly portable, not only to the STM32G4 Series but also to other STM32 series.
STM32CubeG4 is fully compatible with the STM32CubeMX code generator that allows the generation of initialization code.
The package includes a driver layer (HAL) proposing a set of abstraction services and a low-level hardware layer
(LL) proposing a set of register-level functions, together with an extensive set of examples running on
STMicroelectronics boards. HAL is available in open-source BSD license for user convenience.
•
•
The STM32CubeG4 MCU Package also contains a set of middleware components with the corresponding examples. They come in free user-friendly license terms:
• FAT file system based on open source FatFS solution
CMSIS-RTOS implementation with FreeRTOS ™ open source solution
•
USB PD Devices and Core libraries
USB Device library
Several applications and demonstrations implementing all these middleware components are also provided in the
STM32CubeG4 MCU Package.
The block diagram of STM32Cube is shown in
.
Figure 1. STM32CubeG4 firmware components
Evaluation boards
Discovery boards
Application level demonstrations
STM32 Nucleo boards
Dedicated boards
User application
Utilities
USB PD
Middleware level (1)
USB Device RTOS FAT file system
CMSIS
Utilities
Board Support Package (BSP)
HAL and LL APIs
(1) The set of middleware components depends on the product Series.
Low-layer APIs (LL)
Hardware abstraction layer APIs
(HAL)
The demonstration firmware for the STM32G474E-EVAL Evaluation board comes on top of the STM32CubeG4
MCU Package, which is based on a modular architecture allowing the reuse of software components separately in standalone applications. All modules are managed by the STM32Cube demonstration kernel, which allows the addition of new modules dynamically and access to the storage, graphical, and components common resources.
The demonstration firmware is built on the light kernel and services provided by the BSP as well as components based on the STM32Cube HAL It makes extensive use of the STM32G4 device capability to offer a wide scope of usages.
The STM32G4 microcontrollers are based on the Arm ® 32-bit Cortex ® -M4 processor.
Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
UM2583 - Rev 1 page 2/61
2
2.1
2.2
UM2583
Getting started with the demonstration
Getting started with the demonstration
Hardware requirements
•
•
The hardware requirements to start the demonstration are the following:
• One STM32G474E-EVAL Evaluation board (MB1397)
One microSD
™
card
One USB cable to power the STM32G474E-EVAL board from its ST-LINK USB
The STM32G474E-EVAL (MB1397) Evaluation board is connected to the host PC by means of the USB cable. It does not require any external power supply.
The demonstration displays icons that are stored on the microSD ™ card. The microSD ™ card must be loaded with several files ( *.bmp
, *.txt
, *.bin
) that are provided in the /Projects/STM32G474-EVAL/Demonstration s/Binary/SD_card firmware package directory.
Hardware settings
The STM32CubeG4 -based demonstration supports the STM32G474QET6 device and runs on the STM32G474E-
EVAL
Evaluation board from STMicroelectronics presented in Figure 2
.
Figure 2. STM32G474E-EVAL front view (MB1397)
UM2583 - Rev 1
The default jumper settings must be used to run the demonstration. Refer to
page 3/61
2.3
UM2583 microSD™ status microSD
™
status
The STM32G474E-EVAL board comes with a microSD ™ memory card pre-programmed with the image resources, text files and directory trees used by the demonstration FW. However, the user may load his own image files in the USER directory, assuming that file formats are supported by the demonstration ( *.bmp
).
Figure 3. microSD ™ card directory organization
Firmware binaries needed by the Demo application
User files
2.4
If the microSD ™ card is not correctly inserted or not well programmed, an error message is displayed.
Demonstration firmware
•
•
First, select the folder corresponding to the demonstration, then inspect the folder corresponding to the preferred toolchain (MDK-ARM, EWARM or SW4STM32 ):
•
Open the corresponding project
Rebuild all sources
Load the project image by means of the debugger
• Restart the Evaluation board (press reset button B3)
UM2583 - Rev 1 page 4/61
3
3.1
Demonstration firmware package
•
•
The demonstration targets the following objectives:
• Toolkit with low memory consumption
Independent modular applications with a high level of reuse
Basic menu navigation with the joystick
• Comprehensive STM32G4 functional coverage
Demonstration repository
shows the demonstration folder organization.
Figure 4. Demonstration folder organization
UM2583
Demonstration firmware package
UM2583 - Rev 1
The demonstration sources are located in the Projects folder of the STM32CubeG4 MCU Package for each supported board. The folder selected here is STM32G474E-EVAL for the Evaluation board.
The files making up the demonstration firmware are spread over the following sub-directories:
• Common : C source files implementing common services used by the demonstration firmware page 5/61
UM2583
Demonstration repository
•
•
•
•
•
Config : FatFS, HAL, BSP and demonstration kernel configuration files
Core : demonstration kernel implementation files
Demo : demonstration firmware
Modules :
SD_card : resource files (bitmaps) required by the demonstration firmware to be copied into the microSD ™ card
illustrates further the organization of the Modules folder, which contains one sub-folder for each elementary demonstration plus one for the main menu of the demonstration application, and Demo folder, which is dedicated to software development environments:
Figure 5. Demonstration module folder organization
UM2583 - Rev 1
•
•
•
•
•
•
•
•
The Modules folder contains the following sub-folders:
• main_app : main menu management
• audio : audio record and playback calendar : date, time and alarm setting filebrowser : navigation through a folder tree imagebrowser : bitmap images slide show lowpower : low-power modes math : signal filtering thermometer : temperature measurement ucpd : USB Power Delivery whiteled : LED control
The Demo folder contains the following sub-folders dedicated to software development environments:
• EWARM : IAR Embedded Workbench ™ page 6/61
3.2
UM2583
Demonstration architecture overview
•
•
MDK-ARM : Keil ® Microcontroller Development Kit
SW4STM32 : SW4STM32 , system workbench for STM32
Demonstration architecture overview
The top level software architecture of the STM32G474E-EVAL demonstration firmware is represented in
The software elements mentioned in this diagram are briefly depicted in dedicated sub-sections.
Figure 6. STM32G474E-EVAL demonstration firmware architecture
Demonstration level
Main
3.2.3
3.2.4
3.2.5
3.2.1
3.2.2
USB PD library
Middleware level
FreeRTOS™ FatFS
Kernel
HAL level
Hardware abstraction layer (HAL) Board support package (BSP)
Hardware component level
STM32G474QET6 Sensors
Hardware board level
STM32G474E-EVAL (MB1397)
Demonstrations
The application contains many demonstrations that are easily reusable, such as RTC calendar, FAT file system implementation on microSD ™ card, wave player and voice recorder using SAI and DMA peripherals, low-power modes, temperature sensor interfacing, and TFT LCD.
UCPD
The UCPD application consists in USB Type-C ™ connection/disconnection detection and USB Type-C ™ power contract negotiation. The UCPD demonstration is also capable of changing the power role. Protocol message exchanges can be displayed by means of the STM32CubeMonitor-UCPD tool ( STM32CubeMonUCPD ).
HAL level
The HAL level layer consists of the stm32g4xx_hal_ppp.c
HAL drivers together with the STM32G474E-EVAL board support package (BSP).
Kernel
The kernel is a suite of components providing high-level services to the applications in order to facilitate application module integration and execution.
•
Middleware
Middleware provides the following modules:
FreeRTOS: FreeRTOS ™ open-source solution. The UCPD application is based on FreeRTOS ™ .
UM2583 - Rev 1 page 7/61
UM2583
Microcontroler resources
3.3
3.3.1
3.3.1.1
•
•
FatFS: generic FAT file system module intended for small embedded systems. FatFS file control functions are used by the demonstration applications to get access to the files stored in the microSD ™ card.
USBPD: USB-PD software stack.
Microcontroler resources
Peripherals
The following sections detail which peripherals of the STM32G474QET6 microcontroller are used by the demonstrations.
Peripherals used by the main demonstration
Figure 7. STM32G474QET6 peripherals used by the main demonstration
STM32G474QET6
LCD microSD™ card
LEDs
USER button
Joystick
SPI
GPIO
DMA
TIM
RTC
PWR
SAI
HRTIM
COMP
DAC
WM8994
LED buck
I/O expander
STTS751
I2C
Legend: Component on MB895 Component on MB1397 MCU functional block
SPI
GPIO
SAI
COMP
RTC
DMA
HRTIM
Peripheral
Table 1. STM32G474QET6 peripherals used by the main demonstration
Usage description
Both LCD and microSD ™ card are controlled through SPI1. Read accesses to the microSD ™ card are performed to retrieve the bitmaps to display on the LCD screen. microSD ™ card is also read accessed by the audio playback application and write accessed by the audio record application.
Write accesses to the LCD are performed to display strings and bitmaps during demonstration execution.
GPIOs are used to toggle the LEDs when an error is detected during the demonstration.
Also the GPIO pins connected to the joystick and USER button are used to interact with the demonstration (menu navigation).
SAI is used for the audio data link with the WM8994 codec.
COMP is used to sense and limit the current of LEDbuck.
RTC peripheral is used by the calendar application to set the time, date and alarm.
It is also used by the power application to set the wakeup alarm.
DMA transfer are used to transfer audio samples from audio playback buffer to the DAC data register or to transfer audio sample from the ADC data register to the audio record buffer.
HRTIM is used to drive the LED buck.
UM2583 - Rev 1 page 8/61
UM2583
Microcontroler resources
PWR
Peripheral
I2C
Usage description
The PWR peripheral is used by the power application to enter power or standby mode. MCU exit low-power mode either by pressing the joystick selection key (mapped on WKUP1) or when the programmed RCT alarm expires.
I2C1 is used by the thermometer application to control the STTS751 component (digital temperature sensor).
3.3.1.2
Peripherals used by the UCPD demonstration
Figure 8. STM32G474QET6 peripherals used by the UCPD demonstration
LCD
Joystick
USB3.1 Port
Discharge
Source En
STM32G474QET6
SPI DMA ADC
TIM
UCPD
LPTIM
GPIO
V sense
USB Type-C™ Port DRP
Legend: Component on MB1352 Component on MB895 Component on MB1397 MCU functional block
SPI
GPIO
ADC
UCPD
DMA
LPTIM
Peripheral
Table 2. STM32G474QET6 peripherals used by the UCPD demonstration
Usage description
•
LCD is controlled through SPI1. Write accesses to the LCD are performed to display strings and bitmaps during the UCPD demonstration execution.
•
•
•
The GPIO pins connected to the joystick are used to interact with the UCPD demonstration, such as menu navigation:
One GPIO pin is used to detect USB3.1 cable connect/disconnect
One GPIO pin is used to enable the VBUS on the USB Type-C ™ port (DRP)
One GPIO pin is used to control the USB VBUS discharge mechanism on the USB Type-C ™ port (DRP)
ADC channel 9 is used to measure the voltage level on the VBUS line of the USB Type-C ™ port (DRP)
UCPD is used to manage the USB Type-C ™ communication over the USB Type-C ™ ports.
DMA is used for ADC conversions.
LPTIM1 is used to generate the PWM signal controlling the voltage level on the VBUS line of USB
Type-C ™ port 1 (when the duty cycle of the PWM signal is 0%, the VBUS voltage level is 15 V; when the duty cycle is 10%, the VBUS voltage level is 5 V).
3.3.2
Interrupts
shows all the external interrupts used by the demonstration.
UM2583 - Rev 1 page 9/61
UM2583
Microcontroler resources
Interrupt
Systick
EXTI line 0
EXTI line 13
DMA1_Channel3
DMA1_Channel4
DMA1_Channel5
DMA1_Channel6
DMA1_Channel7
DMA2_Channel1
DMA2_Channel2
RTC_TAMP_LSECSS
RTC_Alarm
HRTIM1_Master
UCPD1
USART1
Table 3. STM32G474QET6 demonstration interrupt usage
Delay management.
Usage description
IO Expander (Joystick, microSD ™ card).
User button.
Math CORDIC write.
Math CORDIC read.
Math FMAC with DMA In.
Math FMAC with DMA Out.
Math FMAC with DMA memory to memory.
SAI Audio output.
SAI Audio Input.
RTC tamper.
RTC alarm.
White LED burst period.
UCPD IT.
USB-PD trace Tx.
Main
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
UCPD
YES
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
3.3.3
Internal memory size
The system memory areas are used in the demonstration firmware as described in
.
Memory
Internal Flash
Internal SRAM1
Table 4. Internal memory configuration
Start address
0x0800 0000
0x2000 0000
Application
Demonstration firmware run code and constants.
Demonstration firmware data.
3.3.4
Note:
•
External memory organization
The STM32G474E-EVAL demonstration is based on the FatFS embedded free FAT file system. The file system is needed by the demonstration loader to retrieve the binary file to load in the Flash memory and read all media information from the on-board microSD ™ card memory. The microSD ™ memory card is organized in three subdirectories:
•
•
BIN : this directory contains the binary images of the main and UCPD demonstrations ( Legacy.bin
and Uc pd.bin
), built in relocate mode.
STFILES : this directory contains all the bitmaps required by the demonstration firmware.
USER : this is a user folder. The user may add his own files here to be played inside the demo menus
(pictures and .wav
files). This folder is used only by the file browser (refer to
Section 4.11 File browser application
), image viewer (refer to
Section 4.7 Image viewer application ), and wave player applications
(refer to
). This folder also contains the voice recorded wave file rec.wav
, which is created when the voice recording application is run.
The microSD ™ memory card provided with STM32G474E-EVAL is already programmed with the media files to run the demonstration. These files are also available within the demonstration firmware package in the Project s\STM32G474E-EVAL\Demonstrations\Binary\SD_card\ folder.
UM2583 - Rev 1 page 10/61
UM2583
Running the demonstration
4
4.1
4.1.1
Running the demonstration
Demonstration startup
Normal processing
After a board reset, the welcome screen is displayed and the STMicroelectronics logo appears on the LCD as illustrated in
.
Figure 9. Welcome screen
STM32G474E-EVAL
DEMONSTRATION
4.1.2
Error cases
If no card is detected, the demonstration does not start and the message shown in Figure 10
is displayed on the
LCD screen. The demonstration waits for the microSD ™ card insertion to proceed.
Figure 10. microSD ™ card detection error
Error popup
SD not present
…
Wait SD insertion
If the microSD ™ card does not contain appropriate icons and pictures for the demonstration, the message shown
is displayed on the LDC screen.
UM2583 - Rev 1 page 11/61
UM2583
Main menu
Figure 11. microSD ™ card content error
Error popup
Resource file missing
Please update
SD card content
4.2
Main menu
•
•
The main menu is displayed in the form of a set of icons. It shows all submenus on the same screen. Menu navigation is achieved by pressing the joystick keys:
UP, DOWN, LEFT or RIGHT key to browe among submenus
SEL to select and enter a submenu
When a submenu is selected, the submenu title, which is the name of the attached application, is mentioned at the top of the LCD display (refer to
Submenu title
Figure 12. Main menu
Calendar
Selected submenu
4.3
White LED
•
•
The white LED application demonstrates the possibility to drive LED brightness using various on-chip peripherals:
• The high-resolution timer (HRTIM) to drive LED with PWM
The fast digital-to-analog converter (DAC) coupled with HRTIM to generate sawtooth
The comparator (COMP)
•
•
For technical details, refer to
[4] , which has been written for the
32F3348DISCOVERY Discovery kit. The same techniques are in the white LED application used to avoid flickering:
•
Slope compensation
Dithering
High-brightness LED current regulation soft start
UM2583 - Rev 1 page 12/61
UM2583
White LED
Caution:
4.3.1
The main differences are:
• Instead of DMA, the white LED application takes advantage of STM32G474QET6 HRTIM capability to control internal DAC sawtooth signal generation.
•
60 steps are used to generated the sawtooth signal.
Signals on STM32G474E-EVAL are mapped as follows:
– HRTIM E channel 1 output on PC8 is used to drive the MOSFET (white LED)
– Fast DAC4 channel 2 is used to generate the sawtooth signal
– Sense-resistor voltage level is fed back to internal comparator COMP6 on PB11
For safety reasons, the maximum high-brightness LED forward current is limited by software to 250 mA, and an optical cube-shaped protection is placed over the LED. Do not override this current limitation and do not remove the optical protection while the LED is operating. These precautions must be taken due to the high luminous flux emitted by the high-brightness LED. Users must not expose their eyes to the LED direct light.
•
•
•
White LED submenu
The white LED submenu allows the selection among several demonstrations:
• Automatic dimming
Manual dimming
Flashing
Return to the main menu
Figure 13. White LED submenu
WhiteLed
Auto Dimming
Manual Dimming
Flashing
Return
4.3.2
Automatic dimming
The [ Auto Dimming ] option starts automatic white LED dimming: this mode scans the entire brightness range, up and down successively. Press any joystick key to return to the white LED submenu.
UM2583 - Rev 1 page 13/61
UM2583
White LED
Figure 14. White LED automatic dimming
Manual Dimming
Press up/down to
Increase / decrease
LED brightness
Other Joystick button to exit
4.3.3
Manual dimming
The [ Manual Dimming ] option starts manual control of the white LED brightness: press the UP or DOWN joystick keys to increase or decrease white LED brightness. Press any other joystick key to return to the white LED submenu.
Figure 15. White LED manual dimming
Manual Dimming
Press up/down to
Increase / decrease
LED brightness
Other Joystick button to exit
4.3.4
Flashing
The [ Flashing ] option starts manual control of the white LED brightness: the high-brightness LED is turned on with a 10 Hz frequency at full power (tON = 20 ms, tOFF = 80 ms). Press any joystick key to return to the white
LED submenu.
UM2583 - Rev 1 page 14/61
UM2583
Math
Figure 16. White LED flashing
Flashing
Press joystick to exit
4.4
Math
The Math application demonstrates the capabilities of the CORDIC and FMAC peripherals to compute trigonometric functions and filter signals, in order to offload the Cortex ® -M4 processor of the STM32G474QET6.
Figure 17. Math application submenu
Math
CORDIC (Trigo)
FMAC (Filtering)
Return
4.4.1
For technical details about the CORDIC and FMAC peripherals, refer to
CORDIC
The CORDIC application is accessed through the [ CORDIC (Trigo) ] option of the Math submenu.
It is possible to compute:
•
Sine and cosine in polling mode (1)
UM2583 - Rev 1 page 15/61
UM2583
Math
UM2583 - Rev 1
Figure 18. CORDIC sine and cosine (polling mode)
CORDIC
SIN+COS (Polling)
SIN+COS (DMA)
SQRT (Polling)
Time to complete
1517 cycles arm_math.h
11189 cycles
100 samples
UP/DOWN: Select – RIGHT: Quit
•
Sine and cosine in DMA mode (2)
Figure 19. CORDIC sine and cosine (DMA mode)
CORDIC
SIN+COS (Polling)
SIN+COS (DMA)
SQRT (Polling)
Time to complete
1517 cycles
0% cpu load arm_math.h
11189 cycles
100% cpu load
100 samples
UP/DOWN: Select – RIGHT: Quit
• Square root in polling mode
Figure 20. CORDIC sine and cosine (polling mode)
CORDIC
SIN+COS (Polling)
SIN+COS (DMA)
SQRT (Polling)
Time to complete
1 326 cycles arm_math.h
10 721 cycles
100 samples
UP/DOWN: Select – RIGHT: Quit
1. Sine plotted in pink and cosine plotted in purple.
page 16/61
UM2583
UCPD demonstration
4.4.2
4.5
2. Sine plotted in pink and cosine plotted in purple.
3. Square root plotted in pink.
The demonstration also compares the performance measured in number of cycles between the CORDIC peripheral and Arm ® mathematical library.
FMAC
The FMAC application is accessed through the [ FMAC (Filtering) ] option of the Math submenu.
It is possible to apply either a “FIR 51” filter or an “IIR 8” filter on the input signal, which is the sum of a 1 kHz sinusoid and of a 21 kHz sinusoid.. Both filters remove the 21 kHz sinusoid and keep the 1 kHz sinusoid (refer to
As the order of the FIR filter is greater than the one of the IIR, more samples are required to get the result and the filtered graph appears delayed.
The application also shows the gain in CPU load brought by the FMAC peripheral when compared to the Arm ® mathematical library.
Figure 21. FMAC FIR filtering
FMAC
FIR 51
IIR 8
FMAC (DMA)
0% cpu load arm_math.h
30% cpu load
500 kHz sampling
UP/DOWN: Select – RIGHT: Quit
Figure 22. FMAC IIR filtering
FMAC
FIR 51
IIR 8
FMAC (DMA)
0% cpu load arm_math.h
17% cpu load
500 kHz sampling
UP/DOWN: Select – RIGHT: Quit
UCPD demonstration
UM2583 - Rev 1 page 17/61
UM2583
UCPD demonstration
4.5.1
4.5.2
Warning
Running the UCPD demonstration may cause the power delivered to damage the device plugged onto the
STM32G474E-EVAL Evaluation board. STMicroelectronics may not be held responsible for all issues encountered.
Hardware checks
Before running the USB-PD demonstration, make sure that the configuration is correct (refer to
Check that the right firmware is programmed.
Figure 23. USB-PD firmware revision compatibility
P1 : DRP
USBPD Demo for
STM32G474E-EVAL
TRACE
VDM
FW: 192101-STACK:30250000
4.5.3
Emergency state
In case of power issue, the demonstration enters the emergency state:
Figure 24. USB-PD emergency state screen
P1 : DRP
CC1
POWER SUPPLY NOT AVAILABLE
Attach emc
4.5.4
To exit from this state, the user must check the power supply and reset firmware.
Overall presentation
Plug the USB Type-C ™ cable to a USB Type-C ™ device. The information on the LCD screen is presented as follows:
UM2583 - Rev 1 page 18/61
UM2583
UCPD demonstration
Information and command panel
Protocol debug information
Figure 25. USB-PD demonstration screen
Voltage and current displayed (when explicit contract is reached)
P1 : SNK
PD3 DFP CC2
5.03V 0.00A
Source capa : 3
UNCK DRD* USB EPW SUSP DRP*
5V 3.0A FIXED
9V 3.0A FIXED
15V 3.0A FIXED
attach emc request accepted
Explicit contract
Power role:
DRP = Dual Role Power
SRC = Source
SNK = Sink
PDx = stack revision used in the current contract
DFP/UFP = downstream/ upstream facing port
CCx = control channel line used
4.5.5
4.5.6
Navigation in the menus
•
•
The joystick is used to navigate in the different USBPD demonstration panels:
• LEFT / RIGHT: selects the information / command panels.
•
UP / DOWN: when possible, scrolls the information / action
SEL: executes the selected action
Blue USER button: exits the UCPD demonstration
Available panels
One command panel and several information panels are available.
Command panel
):
•
•
•
•
•
•
•
•
Hardware reset
Goto Min voltage
Get Source Capabilities
Get Sink Capabilities
Data Role Swap
Power Role Swap
Software reset
Get Extended capabilities
UM2583 - Rev 1 page 19/61
UM2583 - Rev 1
UM2583
UCPD demonstration
Figure 26. USB-PD - Available commands
P1: SRC
PD3 DFP CC2
5.03V 0.00A
Commands :
HARD RESET
GOTO MIN
GET SOURCE CAPA
GET SINK CAPA
attach emc request accepted
Explicit contract
Source capabilities / Sink capabilities
This information panel depends on the role of the port.
Figure 27 shows an example of source capabilities:
Figure 27. USB-PD - Source / sink capability
P1 : SNK
PD3 DFP CC2
5.03V 0.00A
Source capa : 3
UNCK DRD* USB EPW SUSP DRP
5V 3.0A FIXED
9V 3.0A FIXED
15V 3.0A FIXED
attach emc request accepted
Explicit contract
•
•
In this example, the source proposes 3 PDOs (Power Data Objects; refer to section 6.4.1
): 5 V, 9 V, and 15 V.
The Power Delivery available features are also displayed. A star ( * ) next to the capability indicates that the feature is supported among:
– UNCK: Unchunked message support
– DRD: Dual-Role Data (possibility to swap data role)
– USB: USB available
– EPW: Externally powered
– SUSP: USB Suspend Supported
– DRP: Dual-Role Power capability (possibility to change power role)
Presss the up and down joystick keys to reach a power profile and select the profile to send a power request as
illustrated by an example in Figure 28
.
page 20/61
UM2583 - Rev 1
UM2583
UCPD demonstration
Figure 28. USB-PD - Power profile selection
P1: SRC
PD3 DFP CC2
9.03V 0.00A
Source capa : 3
FRS DRD* USB EPW SUSP DRP
5V 3.0A FIXED
9V 3.0A FIXED
15V 3.0A FIXED
request sent request accepted
Explicit contract
•
•
•
•
Pressing the down key of the joystick once reaches the 9 V profile
Selecting the 9 V profile with the SEL button of the joystick sends a request to switch to 9 V from the port to the source
The debug info panel shows Request sent / Request accepted
The power switches to 9 V as indicated by the port current/voltage information line
Extended capabilities
Figure 29. USB-PB - Extended capabilities
P1 : SRC
PD3 DFP CC2
9.03V 0.00A
Extended capa :
VID:0x1
PID:0x2
F rev:0x1
H rev:0x2
attach request accepted
Explicit contract
•
•
•
•
•
VID: Vendor ID (given by USB-IF)
PID: Product ID (given by USB-IF)
XID: Value provided by the USB-IF assigned to the product
F rev: Firmware revision
H rev: Hardware version
Press the down key of the joystick to display more information, which is not shown in
•
•
•
V reg: the Voltage Regulation field contains bits covering Load Step Slew Rate and Magnitude.
Refer to section 7.1.12.1
in
Htime: the Holdup Time field must contain the source's holdup time.
Refer to section 7.1.12.2
in
Compliance: the Compliance field must contain the standards with which the source is compliant.
page 21/61
UM2583
Calendar application
4.6
4.6.1
•
•
•
•
•
•
•
•
Refer to section 7.1.12.3
in
Tcurre: the Touch Current field reports whether the source meets certain leakage current levels and if it has a ground pin
Peak1: the Peak Current field must contain the combinations of Peak Current that the source supports.
Refer to section 7.1.12.4
in
Peak2: Peak current 2
Peak3: Peak current 3
Ttemp: the Touch Temp field must report the IEC standard used to determine the surface temperature of the source's enclosure.
SRCin: the source input field must identify the possible inputs that provide power to the source. Some sources are only powered by a battery (such as in an automobile) rather than by the more common mains.
Nbbatt: the Batteries field must report the number of batteriesthat the source supports.
PDP: The source PDP field must report the source's rated PDP as defined in the PD3 specification.
Refer to table 10-2 in
Calendar application
The STM32G474QET6 features a real-time clock (RTC), which is an independent BCD timer/counter. The RTC provides a time-of-day clock/calendar, two programmable alarm interrupts, and a periodic programmable wakeup flag with interrupt capability.
Calendar submenu
The calendar submenu is used to select the date, time and alarm settings, or to return to the main menu.
Figure 30. Calendar submenu
Calendar
Date
Time
Alarm
Return
4.6.2
Date setting
The date setting submenu allows the user to set or see the current date, and get back to the calendar submenu.
UM2583 - Rev 1 page 22/61
UM2583
Calendar application
Set
Show
Return
Figure 31. Date submenu
Date
UM2583 - Rev 1
Setting the date is performed in three consecutive steps:
1.
Select the current year with the UP and DOWN joystick keys. The current year is displayed on right side of the upper line. Press the SEL joystick key when the desired year is reached.
Figure 32. Setting the year
NOVEMBER 2017
WEEK: 44 DAY: 306
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
UP/DOWN: Select Year
Sel: to set
2.
Select the month with the UP and DOWN joystick keys. The current month is displayed on the left side of the upper line. Press the SEL joystick key when the desired month is reached.
Figure 33. Setting the month
NOVEMBER 2017
WEEK: 44 DAY: 306
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
UP/DOWN: Select Month
Sel: to set
3.
Select the day number with the UP, DOWN, LEFT, and RIGHT joystick keys. The current selected date is framed. Press the SEL joystick key when the desired day is reached.
page 23/61
Figure 34. Setting the day
November 2017
WEEK: 46 DAY: 320
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
UP/DOWN/LEFT/RIGHT: Select Day
Sel: to set
The current date can be consulted through the [ Show ] option of the Date submenu.
Figure 35. Consulting the date
Date
Wed. 16.11.2017
UM2583
Calendar application
4.6.3
Time setting
The time setting submenu allows setting or consulting the current date, and getting back to the calendar submenu.
Figure 36. Time submenu
Time
Set
Show
Return
UM2583 - Rev 1
The time is set by selecting hours (in the 24-hour format), minutes, and seconds: page 24/61
UM2583
Calendar application
•
•
Use the LEFT or RIGHT joystick keys to switch among hours, minutes, and seconds. The current selection is highlighted in pink.
Press the DOWN or UP joystick keys to increase or decrease the selected number. Keep continuously pressing for incrementing or decrementing faster.
When the desired values are selected, press the SEL joystick key to set these as the current time.
Figure 37. Time setting
Time
19 :38:00
The current time can be consulted through the [ Show ] option of the Time submenu.
Figure 38. Consulting the time
Time
19:38:00
4.6.4
Alarm setting
The alarm setting submenu allows the user to set or disable the alarm, and get back to the calendar submenu.
UM2583 - Rev 1 page 25/61
UM2583 - Rev 1
UM2583
Calendar application
Set
Disable
Return
Figure 39. Alarm submenu
Alarm
The alarm is set by selecting hours (in the 24-hour format), minutes, and seconds:
• Use the LEFT or RIGHT joystick keys to switch among hours, minutes, and seconds. The current selection is highlighted in pink.
• Press the DOWN or UP joystick keys to increase or decrease the selected number. Keep continuously pressing for incrementing or decrementing faster.
When the desired values are selected, press the SEL joystick key to set the alarm accordingly.
Figure 40. Alarm setting
Alarm
19 :38:00
When the current time reaches the value set for the alarm, the alarm is triggered , making all LEDs blink alternatively for a few seconds. The alarm is configured to be triggered every day at the same time. If the user wants to disable it, he must do it manually through the disable option of the alarm submenu. Upon selection of the
[ Disable ] option, the alarm is disabled.
page 26/61
Figure 41. Alarm disable
Alarm
Alarm is disabled
UM2583
Image viewer application
4.7
4.8
4.8.1
Image viewer application
•
•
The image viewer submenu is used to demonstrate LCD control performance using the embedded SPI interface.
The application performs a slideshow of the bitmap files stored in the USER folder of the microSD ™ card. Only the .bmp
files having the following properties are considered:
Bit depth: 16 bits (RGB)
Size: 240×320
Press the RIGHT or LEFT keys of the joystick to display the next or previous bitmap in the list. Quit the application by pressing the DOWN key of the joystick and then return to the main menu.
Audio application
The audio application provides means to playback .wav
files and record voice using STM32G474QET6 SAI peripheral connected to the WM8994 external codec.
Connect the Micro or IN line to the CN23 connector, and the headphone or Output line to the CN26 connector.
Audio submenu
The audio submenu is used to select among the wave player or wave recorder applications.
Figure 42. Audio submenu
AUDIO
Wave player
Wave recorder
Return
4.8.2
Wave player
When the [ Wave Player ] menu option of the audio submenu is selected, the playlist is displayed on the LCD screen. The playlist consists in a listing the .wav
files in the USER folder of the microSD ™ card. The playlist size is limited to four titles.
UM2583 - Rev 1 page 27/61
UM2583 - Rev 1
UM2583
Audio application
Figure 43. Audio playlist
WAVE PLAYER
Title1.wav
Title2.wav
Title3.wav
SEL: Play – UP/DOWN: Select – RIGHT: Quit
Use the UP and DOWN keys of the joystick to browse among available titles. Press the SEL key of the joystick to
play the selected title. Figure 44
represents the aspect of the LCD screen when the wave file is being played.
Figure 44. Audio playing
WAVE PLAYER
Title1.wav
PLAYING
SEL: Play – UP/DOWN: Select – RIGHT: Quit
Pause the playback by pressing the SEL key of the joystick (press the SEL key again to resume playback). Press the DOWN key of the joystick to stop the playback (press the SELkey again restart playback from the beginning).
Figure 45 represents the aspect of the LCD screen when playback is paused.
Figure 45. Audio paused
WAVE PLAYER
Title1.wav
PAUSED
SEL: Play – UP/DOWN: Select – RIGHT: Quit page 28/61
UM2583
Audio application
Figure 46 represents the aspect of the LCD screen when playback is stopped.
Figure 46. Audio stopped
WAVE PLAYER
Title1.wav
Note:
4.8.3
STOPPED
SEL: Play – UP/DOWN: Select – RIGHT: Quit
The audio files provided within this package are based on free-music download from the danosongs.com
website.
Wave player implementation overview
Access to the selected wave file is done through the FatFS interface. Audio samples are transferred to the internal SRAM by blocks (512 bytes each) using the SPI interface. Audio samples go through a flip-flop buffer, meaning that one half of the buffer is fed by the SPI while the other half is read by the DMA to feed the SAI. The
SAI triggers the DAC conversions of the codec to generate the wave signal at the desired sample rate.
The wave player data path is shown in Figure 47
.
Figure 47. Wave player data path
CN28 SPI
Buffer1
Buffer2
DMA
SAI
Block
A data clock
Audio codec
& amplifier right left
CN26
STM32G474QE
STM32G474E-EVAL
Wave recorder
•
•
When the [ Wave Recorder ] option of the audio submenu is selected, the LCD displays the LCD audio record page (refer to
Figure 48 ). When recording is started, the
rec.wav
file is created in the USER folder of the microSD
™
card. If this file exists already, its content is erased and the file is considered as a new empty file.
The recorder audio file has the following properties:
• Sampling rate: 44100 samples/s
Channels: stereo (left = right)
Resolution: 16 bits/sample
UM2583 - Rev 1 page 29/61
UM2583 - Rev 1
UM2583
Audio application
Figure 48. Audio recorder start
WAVE recorder rec.wav
44100Hz
Mono
16 bits
‘SEL’ TO RECORD
Record properties
SEL: Start Rec – RIGHT: Quit
Start recording by pressing the SEL key of the joystick. The record duration is limited to 30 seconds. During the recording, the progress bar allows an estimation of the record time budget consumption:
Figure 49. Wave recording
WAVE recorder rec.wav
44100Hz
Mono
16 bits
RECORD ON GOING
SEL: Stop – RIGHT: Quit
Press the SEL key of the joystick to stop the recording (refer to
). Pressing the SEL key again starts a new recording.
Figure 50. Recording stopped
WAVE recorder rec.wav
44100Hz
Mono
16 bits
RECORD STOPPED
SEL: Restart Rec – RIGHT: Quit page 30/61
UM2583
Thermometer
4.9
Wave recorder implementation overview
The ADC is connected to the headphone through a microphone amplifier. The ADC converts the incoming audio stream into audio samples at a 44100 Hz rate. ADC conversions are triggered by the SAI in order to reach the target sample rate. Converted data go through a flip-flop buffer: one half of the buffer is fed by the DMA while the other half is copied to the rec.wav
file using the FatFS interface (the microSD ™ card is accessed through the
SPI). Audio samples are written to the recorded file by blocks (512 bytes each).
Figure 51. Wave recorder data path right
CN23 left
Audio codec
& amplifier data clock
SAI
Block
B
DMA
Buffer1
Buffer2
SPI CN28
STM32G474QE
STM32G474E-EVAL
Thermometer
The STM32G474QET6 microcontroller has four embedded I 2 C peripherals for connection to any device supporting the I 2 C protocol.
In this demonstration, the STTS751 I 2 C temperature sensor mounted on the STM32G474E-EVAL Evaluation board is used to capture the external temperature (-40°C to +125°C).
Select the [ Thermometer ] submenu of the demonstration menu by pressing the SEL push-button of the joystick.
The temperature value is displayed in Celsius and Fahrenheit degrees as shown in Figure 52
.
Figure 52. Temperature screen
Temperature
15 C
59 F
4.10
4.10.1
Press down to exit
Low-power mode application
The STM32G474QET6 microcontroller provides different operating modes in which the power consumption is reduced. The purpose of this menu is to show the behavior of the microcontroller in different low-power modes.
The Stop, Standby, and Sleep modes are used as examples.
Low-power mode submenu
The low-power mode submenu is used to select among low-power modes Stop, Sleep or Standby, or return to the main menu.
UM2583 - Rev 1 page 31/61
UM2583
Low-power mode application
Figure 53. Low-power submenu
STOP mode
Sleep mode
STANDBY mode
Return
Low power
4.10.2
Stop mode
The Stop mode submenu (refer to Figure 54
) allows the user to put the STM32G474QET6 in Stop mode with its low-power regulator on. It is possible to select between the EXTI (WFI) or RTC alarm (WFI) to exit from the Stop mode.
Figure 54. Stop mode submenu
Stop mode
EXTI pin
RTC Alarm
Return
Figure 55. Start Stop mode (EXTI)
STOP EXTI
Press JOY sel to start
Stop mode
UM2583 - Rev 1 page 32/61
UM2583 - Rev 1
Figure 56. Stop mode activated (EXTI)
STOP EXTI
Stop mode started
Press USER button to exit
Figure 57. Exit from Stop mode (EXTI)
LOW POWER
Exit from stop
UM2583
Low-power mode application
Figure 58. Start Stop mode (alarm)
STOP ALARM
Set delay time
00:00:
00
page 33/61
UM2583
Low-power mode application
Figure 59. Exit from Stop mode (alarm)
STOP Alarm
Stop mode started
Wait alarm to exit
4.10.3
Sleep mode
The Sleep mode submenu (refer to
Figure 60 ) allows the user to put the STM32G474QET6 in Sleep mode with its
low-power regulator on. It is possible to select between the EXTI (WFI) or RTC alarm (WFI) to exit from the Sleep mode.
Figure 60. Sleep mode submenu
Sleep mode
EXTI pin
RTC Alarm
Return
4.10.4
Standby mode
The Standby mode submenu allows the user to put the STM32G474QET6 in Standby mode. It is possible to select between the Wakeup pin or RTC alarm to exit from the Standby mode.
UM2583 - Rev 1 page 34/61
UM2583 - Rev 1
Figure 61. Standby mode
Wakeup pin
RTC Alarm
Return
Standby mode
UM2583
Low-power mode application
Figure 62. Standby mode entry (wake-up pin)
STANDBY WAKEUP
JOY sel will start
Standby mode
Figure 63. Standby mode exit (wake-up pin)
STANDBY WAKEUP
Press USER button to exit and reset page 35/61
UM2583
File browser application
Figure 64. Standby mode entry (alarm)
STANDBY Alarm
Set delay time
00:00:
00
Figure 65. Standby mode exit (alarm)
4.11
Standby mode started wait alarm to exit and reset
File browser application
The file browser application demonstrates the possibility to have access to the microSD ™ card file system through the FatFS interface. It can be used to navigate throuhg the USER folder of the microSD ™ card and display its contents and subfolders as shown in
UM2583 - Rev 1 page 36/61
UM2583
About application
4.12
Figure 66. File browser
Content of the directory Name of the directory
USER
Properties of the selected file/folder
Art of gard*
Image1.bmp
Image2.bmp
Image3.bmp
Image4.bmp
readme.txt
riding.wav
Dir1 file info name: art of gard.
fsize:
34MB fattrib:
0x20
Folder: sel enter/left go back
Press right: exit
•
•
Use the UP and DOWN keys of the joystick to selects an item. Press the SEL key of the joystick to enter a subdirectory. Press the LEFT key of the joystick to quit a sub-directory and go back to the parent directory.
When a file is selected, the following fields of the FatFS file information structure are displayed on the right side of the LCD screen:
• File name (only the first 12 characters are displayed)
File size (in bytes, Kbytes or Mbytes)
File attributes
About application
The About submenu shows the version and date of the STM32G474E-EVAL demonstration firmware. When the
About is selected, the message shown in Figure 67
is displayed on the LCD screen. Press the DOWN key to return to the main menu.
Figure 67. About submenu
STM32G474E-EVAL
Demonstration
Version 1.0.0
12 – April - 2019
MCD Application Team
COPYRIGHT 2019
STMicroelectronics
UM2583 - Rev 1 page 37/61
5
5.1
UM2583
Software architecture
Software architecture
Demonstration
The demonstration is a set of modules accessible through a main menu displayed on the LCD screen. At application startup, the system clock is configured at 170 MHz, and the file system, SD card, and LCD BSPs are initialized. If all the graphic resources (bitmap files) needed by the modules are present in the microSD ™ card, each module is declared to the kernel (registration step). From this point onward, the kernel handles menu navigation, whatever the menu level (root menu or module sub-menu), by managing an event loop. The user uses the joystick keys to move from one menu item to the other. When he presses the select joystick key from the main menu, the kernel launches the execution of the module. During module execution, the kernel forwards all joystick key related actions to the running module; it is then up to the module to decide what to do. Enabled
) and are used, as usual, to map the interrupt vector on the driver HAL driver, depending on the module requirement.
Storage initialization
Module registration
Start demo
Audio
Figure 68. Main demonstration software architecture block diagram
Message box
Progress bar k_demo
Kernel k_tools k_menu k_widgets k_module k_storage k_window
Module execution
User action notification
File system registration
Read access to bitmap files
Demonstration modules
Calendar
FileBrowser
Math UCPD
Thermometer
LowPower
WhiteLed
Joystick and USER button state
Middleware
FatFS USBPD
FreeRTOS
Text
Bitmaps
Drawings
Initialization control
IRQ handlers
Notifications
Reset/Standby flags
RCC
PWR
DMA
I2C
TIM
HAL
RTC
GPIO
HRTIM
SPI
SAI
FLASH
CORTEX
DAC
UCPD
SD and LCD initialization
Temperature sensor control
LCD screen updates
Daughter board ID
Temperature
Initialization control
Disk I/O driver API
EVAL
TSENSOR hx8347d wm8994
BSP
SD LCD
AUDIO PWR components stts751 mfxtm32vl152
The sequence diagram in
Figure 69 summarizes the application startup until the kernel takes the lead.
UM2583 - Rev 1 page 38/61
5.2
UM2583
UCPD demonstration
Application
Figure 69. Simplified application startup sequence diagram
Kernel Module
HAL init
System clock config kDemo_Start kDemo_Initialize
LCD init kStorage_Initialize
Display ST logo kModuleInit to add all the modules kStorage_Initialize
At this stage of the demonstration, the main menu is displayed and the kernel handles the menu navigation.
kMenu_Exit kModule_Execute(MODULE_MAIN_APP) kModule_Execute(MainMenu)
UCPD demonstration
is an RTOS task which receive events forwarded by DPM (Device Policy Manager). The events are mainly coming from the USBPD stack (such as attachment, detachment, and others). The demonstration manages the display of the related information on the screen by using the BSP interface. At application startup, the system clock is configured at 56 MHz. The USBPD application initializes the port as DRP, and the demo is ready to catch
DPM events. The user uses the USER button and joystick to navigate inside the menu and execute actions.
UM2583 - Rev 1 page 39/61
UM2583
Kernel API overview
Figure 70. UCPD demonstration software architecture block diagram
Demonstration level
DPM UCPD
USB PD core stack
Middleware level
RTOS
Driver level
USB PD Device
Hardware abstraction layer (HAL)
Board support package (BSP)
Low-layer drivers (LL)
Hardware component level
STM32G474QET6
Hardware board level
STM32G474E-EVAL (MB1397)
The sequence diagram in
Figure 71 summarizes the application processing of the UCPD application.
DPM
Figure 71. Application processing sequence diagram
Demo UCPD
USBPD
Core stack
USBPD
Device
BSP
Send USBPD message
Tamper or joystick event
Update screen display
USBPD message or
USB Type-C™ event
Core notifies the event
Forward event
Update screen display
User event
USBPD event
5.3
5.3.1
Kernel API overview k_demo
The function Kdemo_Start is executed by the application to launch modules scheduling and the kernel starts by running the module with ID=MODULE_MAIN_APP . To keep the kernel independent with the HW/SW, functions
UM2583 - Rev 1 page 40/61
UM2583
Kernel API overview kDemo_Initialization and kDemo_UnInitialization are defined on application side and called by kDemo_Start (see the application chapter for details about these functions).
kDemo_Initialization kDemo_UnInitialization kDemo_Start
Function
Table 5. k_demo API
Description
Initializes the demo (function defined on application side).
Initializes the demo (function defined on application side).
Starts the demo (Initialize, Run, UnInitialize, Exit).
5.3.2
k_menu
The module execution is started by a call to function kMenu_Execute . This kernel function handles navigation in the menu and the execution functionalities (by means of the structure t_menu defined inside the module).
Function kMenu_Init kMenu_EventHandler kMenu_Execute kMenu_Header kMenu_HandleSelection
Table 6. k_menu API
Description
Initializes the joystick.
GPIO event handler.
Function to execute a menu.
Function to display header information.
The function handles the navigation in the menu.
Figure 72 shows the execution flow for a menu.
UM2583 - Rev 1 page 41/61
UM2583
Kernel API overview
5.3.3
kModule_Exec
Figure 72. kMenu sequence diagram kMenu_Exec
Main menu
Switch menu type
TYPE_ICON
TYPE_TEXT
Display icon or text menu
Wait for user event
Execute mode functionality
User selection
TYPE_EXEC
Return module
SubMenu
Switch user sel
SEL_SUBMENU
Exec module SEL_MODULE
SEL_EXEC
Return current menu
SEL_EXIT
Return upper menu or exit the module
Execute mode functionality kMenu_HandleSelection
Handle menu navigation k_module
This kernel part centralizes information about all modules available inside demonstration firmware: function kModule_Init (defined on application side) registers all the modules present with the help of function kModule_Init (by means of the structure K_ModuleItem_Typedef defined inside the module).
kModule_Init
Function kModule_Add kModule_CheckRessource kModule_Execute
Table 7. k_module API
Description
Defined on application side.
Adds module inside the module list.
Checks the module resource.
Executes the module.
5.3.4
k_storage
The k_storage API handles only microSD ™ card storage and provides some services to simplify module development.
Function kStorage_Init
Table 8. k_storage API
Mounts the SD card file system.
Description
UM2583 - Rev 1 page 42/61
UM2583
Kernel API overview
Function kStorage_DeInit kStorage_GetStatus kStorage_GetDirectoryFiles kStorage_FileExist kStorage_GetFileInfo kStorage_OpenFileDrawBMP kStorage_OpenFileDrawPixel kStorage_GetExt kStorage_GetFree
Description
Unmounts the file system.
Returns SD card presence.
Returns the name of the file present inside a directory.
Checks if a file exists.
Returns file information.
Opens a .bmp
file and displays it (only files of 8 Kbytes max).
Opens a .bmp
file and displays it line by line.
Returns the file extension.
Gets free storage space.
5.3.5
k_window
The k_window API provides services to display a popup window without user event management (must be handled outside, for example inside the module).
Function kWindow_Popup kWindow_Error
Table 9. k_window API
Description
Displays a popup.
Displays a red popup with an error message.
5.3.6
k_widgets k_widgets provides a set of services allowing the creation of graphic objects to be displayed on the LCD screen.
Function kWidgets_ProgressBarCreate kWidgets_ProgressBarDestroy kWidgets_ProgressBarUpdate kWidgets_ProgressBarReset
Table 10. k_widgets API
Description
Creates and displays an empty progress bar object.
Destroys the progress bar object.
Updates the progress bar content.
Resets the progress bar content.
5.3.7
k_tools
The k_tools API provides tools for module development.
Function kTools_Buffercmp
Table 11. k_demo API
Description
Returns 0 if both buffers are identical.
UM2583 - Rev 1 page 43/61
5.4
5.5
5.6
FatFS API overview
The set of functions exposed by the FatFS file system interface is described in [5]
.
USBPD API overview
The set of functions exposed by the USB-PD interface is described in [6]
.
BSP API overview
The set of functions exposed by the BSP interface is described in [7]
.
UM2583
FatFS API overview
UM2583 - Rev 1 page 44/61
6
UM2583
Demonstration memory footprint
Demonstration memory footprint
•
•
Table 12 summarizes the RAM and Flash memory allocations for the demonstration:
• ro code is the number of bytes used in the read-only code memory rw code ro data
is the number of bytes used in the read-write code memory
is the number of bytes used in the read-only data memory
• rw data is the number of bytes used in the read-write data memory
Module
Core k_demo.o
k_menu.o
k_module.o
k_storage.o
k_widgets.o
k_window.o
Demo main.o
stm32g4xx_it.o
stm32g4xx_hal_msp.o
EWARM startup_stm32g474xx.o
Modules
Audio
app_audio.o
wave_player.o
wave_recorder.o
Calendar
app_calendar.o
FileBrowser
app_filesbrowser.o
ImageViewer
app_imagesbrowser.o
LowPower
app_lowpower.o
MainApp
app_main.o
Math
app_math.o
Table 12. Demonstration memory footprint ro code rw code
24
1032
112
736
216
244
1132
166
116
840
56
1916
1536
3280
1568
232
2964
544
4620
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ro data
160
92
-
-
-
-
-
560
88
52
620
857
176
-
-
-
-
-
rw data
220
629
-
-
-
-
48
-
-
-
8758
472
8
48
2586
2
2
321
582
UM2583 - Rev 1 page 45/61
UM2583 - Rev 1
UM2583
Demonstration memory footprint
Module
Thermometer
app_thermometer_LDR.o
UCPD
demo_application.o
app_ucpd.o
WhiteLed
app_whiteled.o
Drivers
BSP
Components
hx8347d.o
hx8347d_reg.o
mfxstm32l152.o
mfxstm32l152_reg.o
stts751.o
stts751_regs.o
wm8994.o
wm8994_reg.o
STM32G474E-EVAL
stm32g474e_eval.o
stm32g474e_eval_audio.o
stm32g474e_eval_bus.o
stm32g474e_eval_env_sensor.o
stm32g474e_eval_io.o
stm32g474e_eval_lcd.o
stm32g474e_eval_sd.o
stm32g474e_eval_usbpd_pwr.o
CMSIS
system_stm32g4xx.o
STM32G4xx_HAL_Drivers
stm32g4xx_hal.o
stm32g4xx_hal_comp.o
stm32g4xx_hal_cordic.o
stm32g4xx_hal_cortex.o
stm32g4xx_hal_dac.o
stm32g4xx_hal_dac_ex.o
stm32g4xx_hal_dma.o
stm32g4xx_hal_exti.o
ro code
1284
14724
196
2596 rw code
-
-
-
-
1192
2508
1618
320
726
974
2978
884
2632
24
2140
24
1204
24
3036
354
44
200
684
452
264
648
96
920
72
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ro data
92
220
20
218
19
-
-
-
-
44
4
-
58
-
57
-
25
-
35
-
10
-
-
-
-
6
-
-
rw data
102
825
12
384
56
764
2180
60
60
56
16
-
760
-
120
-
52
-
73
-
4
-
-
-
-
12
-
-
page 46/61
UM2583 - Rev 1
Module
stm32g4xx_hal_fmac.o
stm32g4xx_hal_gpio.o
stm32g4xx_hal_hrtim.o
stm32g4xx_hal_i2c.o
stm32g4xx_hal_i2c_ex.o
stm32g4xx_hal_opamp.o
stm32g4xx_hal_pwr.o
stm32g4xx_hal_pwr_ex.o
stm32g4xx_hal_rcc.o
stm32g4xx_hal_rcc_ex.o
stm32g4xx_hal_rtc.o
stm32g4xx_hal_sai.o
stm32g4xx_hal_spi.o
STM32G4xx_LL_Drivers
stm32g4xx_ll_dma.o
stm32g4xx_ll_rcc.o
stm32g4xx_ll_ucpd.o
stm32g4xx_ll_usart.o
Middleware
Fat FS
Core
diskio.o
ff.o
ff_gen_drv.o
Options
syscall.o
unicode.o
FreeRTOS
cmsis_os.o
queue.o
heap_4.o
list.o
port.o
portasm.o
task.o
USBPD
usbpd_cad_hw_if.o
usbpd_dpm_core.o
-
-
-
-
-
-
-
-
-
-
-
-
-
-
328
1328
432
144
516
176
1756
2244
708
120
7652
68
8
1128
UM2583
Demonstration memory footprint
682
168
552
1864
1764
1442
2002
1880 ro code
1796
720
3874
1424
134
140
492
98
308
-
-
-
-
-
-
-
rw code
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ro data
-
-
13
-
-
-
-
-
-
-
-
-
-
-
-
-
rw data
-
-
28
-
-
-
-
-
-
-
-
9524
-
12
-
280
12
92
-
204
16
-
-
-
-
-
-
6
-
-
-
72
-
-
-
-
page 47/61
UM2583 - Rev 1
UM2583
Demonstration memory footprint
Module
usbpd_dpm_user.o
usbpd_hw.o
usbpd_hw_if_it.o
usbpd_phy.o
usbpd_phy_hw_if.o
usbpd_pwr_hw_if.o
usbpd_pwr_if.o
usbpd_timersserver.o
usbpd_trace.o
usbpd_vdm_user.o
Others
basic_gui.o
sd_diskio.o
tracer_emb.o
tracer_emb_hw.o
USBPDCORE_PD3_FULL_CM4_wc32.a
dl7M_tlf.a
iar_cortexM4lf_math.a
m7M_tls.a
rt7M_tl.a
shb_l.a
Gaps
Linker created
Total
Total of all modules
1170
2488
1670
20
86
-
1192
136
266
888
25054
4742 ro code
2940
336
320
336
900
112
1124
656
262
1432
145462
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
rw code
-
-
-
-
-
0
2052
-
-
-
8
32
14835
20
-
-
-
68
-
-
-
36
25 ro data
4
-
-
-
-
20576
-
-
49152
-
-
-
140
1
1040
4
44
144
1
-
-
76
58 rw data
252
-
1
8
64
80268 page 48/61
UM2583
Advanced module description
7
7.1
7.1.1
7.1.2
7.1.2.1
Advanced module description
Module detailed description
A module is an autonomous application that runs directly from the launcher or from another module. The module contains two main parts:
• Module control: the kernel uses this part to handle input (user button) and output (display) to interact with the end-user
• Functional behavior: execution functions
Module control
A module is described by a simple structure named K_ModuleItem_Typedef . This structure provides a unique
ID, initialization and de-initialization functions, a function for checking resource application, and a main function as
.
kModuleId kModulePreExec kModuleExec
Field kModulePostExec
Table 13. K_ModuleItem_Typedef structure description kModuleRessouceCheck
Description
Unique ID module. This has to be defined inside the MODULES_INFO enumeration in the k_config.h
include file.
Function pointer used to initialize the low-layer driver, allocate memory or execute any specific action before module execution.
This function is optional.
Function pointer used to start the module main application. In the current kernel architecture, this function is used to call the kModuleExecute function that executes the module application based on the menu structure (refer to
This function is mandatory.
Function pointer used to de-initialize the low-layer driver, and release the resource allocation done inside kModulePreExec .
This function is optional.
Function pointer used to control if all required resources of the module are available. It is used for instance to check if a specific resource file is present on the microSD ™ card.
This function is optional.
Module menu description and graphical interface
The module menu is used to describe the module architecture and display.
tMenu structure
This structure is the main entry point used by function kModuleExecute to display the module MMI and execute the functionalities.
pszTitle psItems nItems nType
Table 14. tMenu structure description
Character string that contains the menu title to display.
Pointer on the menu description tMenuItem item (refer to
Number of entry inside above menu item data pointer.
Menu type. This parameter allows the kernel to distinguish what kind of menu is executed. Menu type is used to display icon menu ( TYPE_ICON ), basic text string
( TYPE_TEXT ), or only code execution ( TYPE_EXEC ).
UM2583 - Rev 1 page 49/61
UM2583
Module detailed description
7.1.2.2
7.1.2.3
line column
In case of icon display selection, number of icon lines.
In case of icon display selection, number of icon columns.
tMenuItem structure
This structure is used by the menu structure to describe all different items or sub-menus of the application module.
pszTitle x, y
SelType
ModuleId pfExecFunc pfActionFunc psSubMenu pIconPath
Field pIconSelectedPath
Table 15. tMenuItem structure description
Description
Character string that contains item title to display.
In case the menu is of the icon type, those numbers provide the icon position on the screen.
•
•
•
•
Item selection type. This field is one of following defined values:
SEL_EXEC : directly executes a functionality
SEL_SUBMENU : selects a sub-menu
SEL_EXIT : exits the current menu and returns to the previous menu or module
SEL_MODULE : executes a module
Corresponding Module ID
Function pointer to execute selected item.
Function pointer on a dedicated callback that is used to capture the user interface selection through joystick, button, or any other interface interrupt.
Pointer on a sub-menu item of tMenutype
Character string, which contains the icon name and path to be displayed
Character string, which contains alternative icon name and path to be displayed when the item is selected by the user.
Menu example
Figure 73 illustrates the basic example of a menu structure with the use of two modules:
•
•
The main module is built with two levels of menu and three functionalities. The level main is a TYPE_ICON menu, which may execute another App1 module with the SEL_MODULE property, execute function1 , or display a sub-menu with the SEL_SUBMENU property.
The sub-menu may execute functionsub1 , functionsub2 or go back to the main menu by means of
SEL_EXIT .
• The module App1 has a TYPE_TEXT context with 2 embedded functionalities: function1 and function2 .
UM2583 - Rev 1 page 50/61
UM2583
Adding a new module
Figure 73. Module menu architecture example
Module Main tMenuMain
TYPE_ICON tMenuItemMain
SEL_MODULE, MODULE_APP1
SEL_EXEC, function1
SEL_SUBMENU
Module App1 tMenuApp1
TYPE_TEXT tMenuSUB
TYPE_TEXT tMenuItemSub
SEL_EXEC, functionsub1
SEL_EXEC, functionsub2
SEL_EXIT tMenuItemMain
SEL_EXEC, function1
SEL_EXEC, function2
SEL_EXIT
7.1.3
7.2
•
Functionality
Functionality is describing module behavior from end-user point of view. Two cases are possible:
• Menu event that is executed when module is selected. The called function must respect the following prototype: void functionExec(void) .
This function is linked to the module context by function pointer pfExecFunc in the tMenuItem structure
(see above description). On function exit, the kernel returns to the previous menu state.
In many cases, functionality is stopped by a user event. As a consequence, the kernel offers the capability to return all possible events through a callback function with the following prototype: void functionSel(uint8_t sel) .
This function is linked to the module context by function pointer pfActionFunc in the tMenuItem structure
(see above description).
Adding a new module
Once the module appearance and functionality are defined and created, based on constraints described above, only the module is left to be added:
1.
Define the new module unique ID in file k_config.h
2.
The kModule_Add() function must be called in KDemo_Initialization() , with the module unique ID as parameter
3.
Modify the main module item description table, adding a dedicated line matching the new module description
( MainMenuItems in main_app.c
in our demonstration firmware)
4.
Add any possible resource file into the microSD ™ card as explained above
UM2583 - Rev 1 page 51/61
8
UM2583
Acronyms
Acronyms
document.
DRD
DRP
FIR
FMAC
HAL
HRTIM
IIR
Acronym
BSP
CC
CORDIC
DMA
DPM
LL
PID
RTOS
SAI
UCPD
USB-PD
USB PD
USBPD
VID
USB Power Delivery.
Vendor ID.
Table 16. Acronyms
Definition
Board support package.
Configuration channel.
Coordinate rotation digital computer.
Direct memory access.
Device policy manager.
Dual-Role Data.
Dual-Role Power.
Finite impulse response filter.
Filter math accelerator.
Hardware abstraction layer.
High-resolution timer
Infinite impulse response filter.
Low-layer drivers, low-layer API.
Product ID.
Real-time operating system.
Synchronous audio interface.
Name of the demonstration dedicated to USB Power Delivery with USB Type-C ™ .
UM2583 - Rev 1 page 52/61
9
UM2583
References
References
[3]
[4]
ID
[1]
[2]
[5]
[6]
[7]
[8]
Table 17. References
Description
USB-IF (2017). Universal Serial Bus Power Delivery Specification rev 3.0
.
•
•
Evaluation board with STM32G4xxQE MCU user manual (UM2514).
Getting started with the CORDIC accelerator on STM32G4 Series microntrollers
Digital filter implementation with the FMAC using STM32CubeG4 MCU Package
application note (AN5325)
application note (AN5305)
High brightness LED dimming using the STM32F334 Discovery kit application note (AN4885).
•
• Developing Applications on STM32Cube with FatFs user manual (UM1721)
Developing Applications on STM32Cube with RTOS user manual (UM1722)
Managing USB Power Delivery systems with STM32 microcontrollers user manual (UM2552).
Getting started with STM32CubeG4 for STM32G4 Series user manual (UM2492).
Description of STM32G4 HAL and low-layer drivers user manual (UM2570).
UM2583 - Rev 1 page 53/61
Revision history
Date
3-Jun-2019
Version
1
Table 18. Document revision history
Changes
Initial release.
UM2583
UM2583 - Rev 1 page 54/61
UM2583
Contents
Contents
UM2583 - Rev 1 page 55/61
UM2583
Contents
UM2583 - Rev 1 page 56/61
UM2583
Contents
UM2583 - Rev 1 page 57/61
UM2583
List of tables
List of tables
UM2583 - Rev 1 page 58/61
UM2583
List of figures
List of figures
UM2583 - Rev 1 page 59/61
UM2583
List of figures
UM2583 - Rev 1 page 60/61
UM2583
IMPORTANT NOTICE – PLEASE READ CAREFULLY
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Purchasers 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 any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, please refer to www.st.com/trademarks . All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2019 STMicroelectronics – All rights reserved
UM2583 - Rev 1 page 61/61
다운로드
광고