Comfort System Design-function module generation template-description, system design function module

Source: Internet
Author: User
Tags alphanumeric characters

Comfort System Design-function module generation template-description, system design function module

1. Custom templates

In the IAR system, edit-> code templates can edit and use custom templates.

Generate each function module by generating an H file and a C file

2. Module files

######################################## ######################################## #### This is an example file for defining your own code templates. #### The syntax for defining a code template is: ### TEMPLATE <template name>, <field> [= default value], <field>... #### The template name, the fields and their default values shocould be defined # within quotes if they contain non-alphanumeric characters. # U Se "&" in front of a letter in the template name to make the letter become # a shortcut, which means that you can use ALT + <letter> to select the template # or jump to the field in the dialog box. # Use ">" in the template to organize the template names in submenus. ######################################## ######################################## ### TEMPLATE "& Statement> & if" if (% c) {}# TEMPLATE & Sta Tement> & for, "& End Value" = 10, & Variable = ifor (int % 2 = 0; % 2 <% 1; ++ % 2) {% c} # TEMPLATE & Statement> & optimize, & optimize # pragma optimize = % 1 # TEMPLATE & initialize ate> & class, "Class & name", & Description = --, & Created = "$ DATE $, by $ USER_NAME $" // ********************* // CLASS: % 1 // DESCRIPTION: // % 2 // CREATED: % 3 // FILE: $ FILE_FNAME $ // class % 1 {public: % 1 ();~ % 1 (); % c };# TEMPLATE & effecate> & class, "Class & name", & Description = --, & Created = "$ DATE $, by $ USER_NAME $ "// ******************* // CLASS: % 1 // DESCRIPTION: // % 2 /// CREATED: % 3 /// FILE: $ FILE_FNAME $ // class % 1 {public: % 1 ();~ % 1 (); % c };# TEMPLATE & effecate> & Task, "Task & name", & Description = -- Task_RET_E % task_temp (uint32 para1, uint32 para2, void * pt); const Task_S g_st % 1 Task [] = {MSG_ID_TEMPLATE_DEFAULT, "task_temp ", % worker task_temp}/*** @ brief message processing *** % 2 * @ param * para1 parameter 1, para2 parameter 2 pt parameter pointer Pass * @ retval bool-true message processed false message not processed */Task_RET_E % task_temp (uint32 para1, uint32 para2, void * pt) {}# TEMPLATE & effecate> & Funtion ," Funtion & name ", & Description = --, & Para, & ret/*** @ brief % 2 ** @ param ** @ retval void */% 4% 1 (% 3) {return ;}# TEMPLATE & File> & file_h, "& file name", & Description = --, & Created = "$ DATE $, by $ USER_NAME $ "/********************************** **************************************** * ****** File Name: % 1.h * Description: % 2 * Created: % 3 ************************************** ******************************* **************************************** **************************************** * ******** // * Define to prevent recursive injection into sequence */# ifndef __% limit h # define __% limit h # ifdef _ cplusplus extern "C "{ # endif/* Includes ------------------------------------------------------------------ */# include "stm32f3xx_hal.h" # include "datatype. h "# include" osal. h "/* USER CODE BEGI N primary des * // * user code end primary des * // * user code begin Private defines * // * user code end Private defines * // * user code begin Prototypes */extern const osalFnx_S g_st % 1 OsalFn; /* user code end Prototypes */# ifdef _ cplusplus} # endif/* _ % 1_H *//***@}*//***** * ******************* (C) COPYRIGHT Chongqingfuzik ***** end of file *****/# TEMPLATE & File> & file_c, "& file name", & Created = "$ DATE $, $ USER_NAME $ "/*********************************** **************************************** * ***** @ file % 1.c * @ created: % 2 * @ brief ***** ================================ ========================================================== ========###### % 1 specific features #####================== ========================================================== ================================ [...] ##### How to use this file ######========================= ==== ========================================================== ========== [...] **************************************** ***************************************/ /* Includes ------------------------------------------------------------------ */# include "% 1.h" # include" msg_def.h "# include" trace. h "# define _ use _ % define Module # ifdef _ use _ % define module/* Private typedef ------------------------------------------------------- * // * Priv Ate define variable * // * Private macro variable * // * Private variables variable * // * Private function prototypes ------------------------------------------------- */void % invalid Init (void ); void % consumer start (void); void % consumer tick (void); void % consumer process (void); void % 1 _ Process_1s (void); void % define process_1min (void); BOOL % merge trace (void); RESP_E % merge debug (const uint8 * in); BOOL % Merge (Msg_Id_E msg, uint32 para1, uint32 para2, void * pt); uint16 % 1_Trace_Pwr (void);/* Exported functions -------------------------------------------------------- */const OsalFnx_S g_st % 1 OsalFn = {% uninstall init, % restart start, % uninstall tick, % Worker Process, % worker process_1s, % worker process_1min, % worker debug, % worker message_dea L, % 1_Trace_Pwr }; /** =================================================== ========================================================== ###### Initialization and de-initialization functions ######================ ========================================================== ================== [...] * // *** @ brief module initialization ** @ param ** @ retval */void % initialize Init (void) {Trace_Stack (% initialize init );} /*** @ brief module starts running ** @ param ** @ retval */void % restart start (void) {Tra Ce_Stack (% restart start);}/*** @ brief 10 ms interrupt processing, processing real-time tasks ** @ param ** @ retval */void % effectick (void) {Trace_Stack (% effectick);}/*** @ brief 10 ms process processing, processing non-real-time tasks ** @ param ** @ retval */void % completed process (void) {Trace_Stack (% Worker Process);}/*** @ brief 1 s process processing, processing non-real-time tasks ** @ param ** @ retval */void % 1_Process_1s (void) {Trace_Stack (% worker process_1s);}/*** @ brief 1min process processing, processing non-real-time tasks ** @ param ** @ retval */void % worker process_1mi N (void) {Trace_Stack (% 1_Process_1min);}/*** @ brief debugging interface ** @ param in the string to be processed ** @ retval processing result, parameter RESP_E */RESP_E % release debug (const uint8 * in) {Trace_Stack (% release Debug); return RESP_NULL ;} /*** @ brief message processing *** @ param msg Message id * para1 parameter 1, para2 parameter 2 pt parameter pointer Pass * @ retval bool-true message processed false message not processed */BOOL % handle message_deal (Msg_Id_E msg, uint32 para1, uint32 para2, void * pt) {if (! Msg_Id_IsValid (msg) {return FALSE;} Trace_Stack (% optional message_deal); return TRUE ;} /*** @ brief power management *** @ param *** @ retval uint16-the time when the STOP mode is disabled, with a single order of 10 ms */uint16% 1_Trace_Pwr (void) {Trace_Stack (% trace_pwr); return 0 ;} # endif/* % 1_MODULE_ENABLED *//***@}*//***@}*//*************** * ******** (C) COPYRIGHT STMicroelectronics ***** end of file ****/

3. Modules

1. Include the template header file in msg_def.c

2. In

const FileModoule_S g_stFileModoule[Modoule_ID_MAX+1]={    {Modoule_ID_NULL,NULL,NULL},    {Modoule_ID_TRACE,"trace",&g_stTraceOsalFn},    {Modoule_ID_HWDPT,"hwdpt",&g_sthwdptOsalFn},     {Modoule_ID_MAX,NULL,NULL}};

Associated module ID, name, and call function struct

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.