FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    C ++ detailed use guide under RT-THREAD in STM32 platform

     

    This article describes how to use C ++ on the STM32 platform equipped with the RT-Thread system, including C ++ configuration and application. And give the code example of verification on the STM32F411 Nucleo development board. Hardware platform This article is based on the integration of the STM32F411 Nucleo development board, which gives the specific application example code of C ++. Since the RT-THREAD is applied to the API versatility, these code is not limited to the specific hardware platform, and the user can easily transplant it to others. on the platform. STM32F411 Nucleo is a development board based on the ARM Cortex-M4 kernel, the highest frequency is 100MHz, and the development board has a rich on-board resource, and the chip performance of STM32F411RE can be fully utilized. The STM32F411re is known from the STM32F4 series belonging to the sales list, which is well known that F4 is the "light luxury" series of STM32 main performance and digital signal processing. "Luxury" in F4 as a Cortex-M4 (DSP + FPU) MCU, optional 180MHz frequency, 2M flash / 384KB RAM, CHROM-ART accelerator, MPI-DSI interface, extending to 125 degrees operating temperature, DFSDM Digital filters and a variety of common audio (SAI), connect (Ethernet, Camera, USB), control (CAN, UART, I2C), storage (FMC, 2/4/8 BITS SPI, SDMMC) peripherals. "Light" is "relaxed" in the price, the size "lightweight" (less than 3mm * 3mm package), the power consumption "slight". How to use C ++ on STM32 Ready to work 1, download the RT-THREAD source code 2, download the ENV tool 3, enter the RT-Thread \ BSP \ STM32F411-St-Nucleo directory, check if the BSP RTCONFIG.PY file and the sconstruct file support C ++ configuration, check the support of C ++ in the RTConfig.py file as shown below, check the SCONSTRUCT file C ++ support Open C ++ support: Open the ENV tool, enter MenuConfig in the ENV command line, enter the configuration interface, use the MenuConfig tool (learning how to use) configuration project. Select RT-THREAD Components in the MenuConfig configuration interface ---. 1882. C ++ Features ---. 1882. Support C ++ Features, as shown in the figure: Compilation Project: Scons - Target = MDK5 1. Generate the MDK5 project, replace the main.cpp with the sample code to replace main.c in the BSP and re-join the project, as shown in the figure: Compile, download the program, enters the HELP command in the terminal to see Test_CPP has been added successfully. Run C ++ program: In the terminal input Test_CPP operation, as shown below. Call of C ++ global object constructor In the implementation of the global object constructor, in the implementation of the global object constructor, in the CRT_INIT.C file in the RT-THREAD \ Components \ CPLUSPLUS directory, the system is initialized, in a specific BSP directory, the connection script The file link.lds is assigned a segment for the C ++ global constructor, so that the C ++ global object constructs the function link to be stored in the specified segment. As shown below: In the CPLUSPLUS_SYSTEM_INIT function, the constructor of the global object is then linked into the segment assigned to the link script file, and the RT-Thread component automatically initializes the macro INIT_COMPONENT_EXPORT, so when the link, the C ++ global object constructor The resulting target file is linked to the segment of __ctors_start__and __ctors_end__. The segment part of the C ++ global constructor is allocated in the link script: 1PROVIDE (__ctors_start__=.); 2keep (* (sort (.init_Array. *))))))) 3keep (* (. Init_Array)) 4Provide (__ctors_end__=.); __ctors_start__Assign the starting address of the C ++ global constructor segment, __ctors_end__assigns the end address of the C ++ global constructor segment, so the global constructor is linked to the segment address assigned here when the system is initialized. RT-THREAD C ++ abnormal instructions Similarly, in the link script file link.lds, the segment address is also assigned to C ++: 1 __exidx_start =.; 2 arm.exidx: 3 { 4 * (. Arm.exidx * .gnu.linkonce.Armexidx. *) 5_sidata =. 6} > CODE 7 __exidx_end =. __exidx_start assigns the start address of the C ++ exception, and __exidx_end assigns the end address of the C ++ exception. When an exception is generated, it is assigned to the specified segment address. Here is a C ++ except for zero extraction and capture as an example: 1 # include 2 3 #define min_value (1e-4) 4 # DEFINE IS_DOUBLE_ZERO (D) (ABS (D) < Min_value) 5 6 Double Div_Func (Double X, Double Y) 7 { 8 IF (is_double_zero (y)) 9 { 10 throw y; / * throw exception * / 11} 12 13 RETURN X / Y; 14} 15 16 void throw_exceptions (void * args) 17 { 18 TRY 19 { 20 div_func (6, 3); 21 RT_KPrintf ("there is no err \ n"); 22 Div_Func (4, 0); / * CREATE EXCEPTION * / 23 RT_KPRINTF ("You CAN Run Here? \ N"); twenty four } 25 catch (double) / * catch exception * / 26 { 27 RT_KPrintf ("Error of Dividing Zero \ N"); 28} 29} 30 31 msh_cmd_export (throw_exceptions, throw cpp exception); The Div_FUNC function will throw an exception when the zero except occurs, and this exception will be captured in the throw_exceptions function. Download the code and enter the throw_exceptions in the terminal. The result is shown below. By this step, how to use C ++ introduction on the STM32 platform equipped with the RT-Thread system.

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us