关于cubesuite的code generator的使用,同工程多次生成代码的问题;
因为有时候我们最先使用
code generator进行io口功能配置的时候,不一定配置得比较合理,所以有时候需要进行更改配置;在code generator的使用中发现,多次使用code generator进行Generate Code配置生成代码是可以不覆盖之前的用户代码的,最近使用的时候发现的,这里给不是很熟悉的朋友介绍一下~~
下面是之前的一段代码
r_cg_main.c
- /***********************************************************************************************************************
- * DISCLAIMER
- * This software is supplied by Renesas Electronics Corporation and is only
- * intended for use with Renesas products. No other uses are authorized. This
- * software is owned by Renesas Electronics Corporation and is protected under
- * all applicable laws, including copyright laws.
- * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
- * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
- * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
- * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
- * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
- * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
- * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
- * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- * Renesas reserves the right, without notice, to make changes to this software
- * and to discontinue the availability of this software. By using this software,
- * you agree to the additional terms and conditions found by accessing the
- * following link:
- * http://www.renesas.com/disclaimer
- *
- * Copyright (C) 2012, 2013 Renesas Electronics Corporation. All rights reserved.
- ***********************************************************************************************************************/
- /***********************************************************************************************************************
- * File Name : r_cg_main.c
- * Version : Code Generator for RL78/R7F0C8021 V1.02.00.01 [25 Dec 2013]
- * Device(s) : R7F0C8021
- * Tool-Chain : CA78K0R
- * Description : This file implements main function.
- * Creation Date: 2014-10-05
- ***********************************************************************************************************************/
- /***********************************************************************************************************************
- Pragma directive
- ***********************************************************************************************************************/
- /* Start user code for pragma. Do not edit comment generated here */
- /* End user code. Do not edit comment generated here */
- /***********************************************************************************************************************
- Includes
- ***********************************************************************************************************************/
- #include "r_cg_macrodriver.h"
- #include "r_cg_cgc.h"
- #include "r_cg_port.h"
- #include "r_cg_wdt.h"
- /* Start user code for include. Do not edit comment generated here */
- /* End user code. Do not edit comment generated here */
- #include "r_cg_userdefine.h"
- /***********************************************************************************************************************
- Global variables and functions
- ***********************************************************************************************************************/
- /* Start user code for global. Do not edit comment generated here */
- int a,b,c;
- /* End user code. Do not edit comment generated here */
- void R_MAIN_UserInit(void);
- /***********************************************************************************************************************
- * Function Name: main
- * Description : This function implements main function.
- * Arguments : None
- * Return Value : None
- ***********************************************************************************************************************/
- void main(void)
- {
- R_MAIN_UserInit();
- /* Start user code. Do not edit comment generated here */
- while (1U)
- {
- //io设置为低电平
- P0.3=0;
- P0.4=0;
- for(a=100;a>0;a--)//延时函数
- {
- for(b=100;b>0;b--)
- for(c=100;c>0;c--);
- }
- //io设置为高电平
- P0.3=1;
- P0.4=1;
- for(a=100;a>0;a--)//延时函数
- {
- for(b=100;b>0;b--)
- for(c=100;c>0;c--);
- }
- }
- /* End user code. Do not edit comment generated here */
- }
- /***********************************************************************************************************************
- * Function Name: R_MAIN_UserInit
- * Description : This function adds user code before implementing main function.
- * Arguments : None
- * Return Value : None
- ***********************************************************************************************************************/
- void R_MAIN_UserInit(void)
- {
- /* Start user code. Do not edit comment generated here */
- EI();
- /* End user code. Do not edit comment generated here */
- }
- /* Start user code for adding. Do not edit comment generated here */
- /* End user code. Do not edit comment generated here */
在自动生成的代码中有很多地方有类似注释:
/* Start user code 。。。。。。. Do not edit comment generated here */
这里可以添加用户代码~~~
/* End user code. Do not edit comment generated here */这段文字是说明,这里添加的用户代码在生成代码的时候将不会被覆盖,就是说你无论使用多少次code generator的Generate Code这两行注释的内部代码都不会改变。
这里特别说明一下,代码放在上面注释之外再次使用Generate Code生成代码时是会被清除的,如果不再使用Generate Code生成代码则没有影响。
并且这里不可以通过复制自行增加相同注释而达到同样的保护效果。
其实对于芯片来说功能相对简单,使用
code generator来进行配置是相当简便的,功能也很完善。对于项目开发也完全够用,使大家可以专注于项目本身的代码构建。