From ea38721fc33720fcf09c5f778e91e70d20bdc5ab Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 8 Jul 2012 08:32:03 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4430 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/gencfg/lib/liblicense.ftl | 58 +++++++++++++++++++++ tools/gencfg/lib/libutils.ftl | 109 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 tools/gencfg/lib/liblicense.ftl create mode 100644 tools/gencfg/lib/libutils.ftl (limited to 'tools/gencfg/lib') diff --git a/tools/gencfg/lib/liblicense.ftl b/tools/gencfg/lib/liblicense.ftl new file mode 100644 index 000000000..18581ee29 --- /dev/null +++ b/tools/gencfg/lib/liblicense.ftl @@ -0,0 +1,58 @@ +[#ftl] +[#-- + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + --] + +[#-- + -- Emits the ChibiOS/RT standard license exception text. + -- The license exception text is indented by 4 spaces. + --] +[#macro EmitLicenseExceptionAsText] + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +[/#macro] + +[#-- + -- Emits the ChibiOS/RT standard license text. + -- The license text is indented by 4 spaces. + --] +[#macro EmitLicenseAsText] + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +[/#macro] diff --git a/tools/gencfg/lib/libutils.ftl b/tools/gencfg/lib/libutils.ftl new file mode 100644 index 000000000..03b0622a3 --- /dev/null +++ b/tools/gencfg/lib/libutils.ftl @@ -0,0 +1,109 @@ +[#ftl] +[#-- + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + --] + +[#-- + -- Returns the trimmed text "s" making sure it is terminated by a dot. + -- The empty string is always returned as an empty string, the dot is not + -- added. + --] +[#function WithDot s] + [#local s = s?trim /] + [#if s == ""] + [#return s /] + [/#if] + [#if s?ends_with(".")] + [#return s /] + [/#if] + [#return s + "." /] +[/#function] + +[#-- + -- Returns the trimmed text "s" making sure it is not terminated by a dot. + --] +[#function WithoutDot s] + [#local s = s?trim /] + [#if s?ends_with(".")] + [#return s?substring(0, s?length - 2) /] + [/#if] + [#return s /] +[/#function] + +[#-- + -- Returns the trimmed text "s" making sure it is terminated by a dot if the + -- text is composed of multiple phrases, if the text is composed of a single + -- phrase then makes sure it is *not* terminated by a dot. + -- A phrase is recognized by the pattern ". " into the text. + -- The empty string is always returned as an empty string, the dot is never + -- added. + --] +[#function IntelligentDot s] + [#local s = s?trim /] + [#if s?contains(". ")] + [#return WithDot(s) /] + [/#if] + [#return WithoutDot(s) /] +[/#function] + +[#-- + -- Formats a text string in a sequence of strings no longer than "len" (first + -- line) or "lenn" (subsequent lines). + -- White spaces are normalized between words, sequences of white spaces become + -- a single space. + --] +[#function StringToText len1 lenn s] + [#local words=s?word_list /] + [#local line="" /] + [#local lines=[] /] + [#list words as word] + [#if lines?size == 0] + [#local len = len1 /] + [#else] + [#local len = lenn /] + [/#if] + [#if (line?length + word?length + 1 > len)] + [#local lines = lines + [line?trim] /] + [#local line = word + " " /] + [#else] + [#local line = line + word + " " /] + [/#if] + [/#list] + [#if line != ""] + [#local lines = lines + [line?trim] /] + [/#if] + [#return lines /] +[/#function] + +[#-- + -- Emits a string "s" as a formatted text, the first line is prefixed by the + -- "p1" parameter, subsequent lines are prefixed by the "pn" paramenter. + -- Emitted lines are no longer than the "len" parameter. + -- White spaces are normalized between words. + --] +[#macro FormatStringAsText p1 pn s len] + [#local lines = StringToText(len - p1?length, len - pn?length, s) /] + [#list lines as line] + [#if line_index == 0] +${p1}${line} + [#else] +${pn}${line} + [/#if] + [/#list] +[/#macro] -- cgit v1.2.3 From 5521ecc4fb61cda3cad92de5f0505c873b6abb99 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 10 Jul 2012 18:47:54 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4455 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/gencfg/lib/libcode.ftl | 261 ++++++++++++++++++++++++++++++++++++++ tools/gencfg/lib/libstm32f4xx.ftl | 34 +++++ 2 files changed, 295 insertions(+) create mode 100644 tools/gencfg/lib/libcode.ftl create mode 100644 tools/gencfg/lib/libstm32f4xx.ftl (limited to 'tools/gencfg/lib') diff --git a/tools/gencfg/lib/libcode.ftl b/tools/gencfg/lib/libcode.ftl new file mode 100644 index 000000000..8147e02c4 --- /dev/null +++ b/tools/gencfg/lib/libcode.ftl @@ -0,0 +1,261 @@ +[#ftl] +[#-- + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + --] + +<#-- + -- Coding style global settings. + --> +[#assign indentation = " " /] +[#assign fields_align = 24 /] +[#assign define_value_align = 36 /] +[#assign comments_align = 48 /] +[#assign boundary = 80 /] + +[#-- + -- This macro generates a brief description in DoxyGen format. + --] +[#macro EmitDoxygenBrief brief=[]] + [#if brief[0]??] +[@utils.FormatStringAsText " * @brief " + " * " + utils.WithDot(brief[0]?cap_first) + boundary /] + [/#if] +[/#macro] + +[#-- + -- This macro generates a detailed description in DoxyGen format. + --] +[#macro EmitDoxygenDetails details=[]] + [#if details[0]??] +[@utils.FormatStringAsText " * @details " + " * " + utils.WithDot(details[0]?cap_first) + boundary /] + [/#if] +[/#macro] + +[#-- + -- This macro generates the parameters description in DoxyGen format. + --] +[#macro EmitDoxygenParams params=[]] + [#list params as param] + [#local name = (param.@name[0]!"no-name")?trim /] + [#local brief = (param.@brief[0]!"")?trim /] + [#local dir = (param.@dir[0]!"boh")?trim?lower_case /] + [#if dir == "in"] +[@utils.FormatStringAsText " * @param[in] " + " * " + utils.IntelligentDot(name + " " + brief?uncap_first) + boundary /] + [#elseif dir == "out"] +[@utils.FormatStringAsText " * @param[out] " + " * " + utils.IntelligentDot(name + " " + brief?uncap_first) + boundary /] + [#elseif dir == "both"] +[@utils.FormatStringAsText " * @param[in,out] " + " * " + utils.IntelligentDot(name + " " + brief?uncap_first) + boundary /] + [#elseif dir == "boh"] +[@utils.FormatStringAsText " * @param " + " * " + utils.IntelligentDot(name + " " + brief?uncap_first) + boundary /] + [/#if] + [/#list] +[/#macro] + +[#-- + -- This macro generates a return description followed by a retval list + -- in DoxyGen format. + --] +[#macro EmitDoxygenReturn return=[]] + [#if return[0]?? && ((return[0].@type[0]!"void")?trim != "void")] + [#local brief = (return[0].@brief[0]!"")?trim /] + [#if brief != ""] +[@utils.FormatStringAsText " * @return " + " * " + utils.WithDot(brief?cap_first) + boundary /] + [/#if] + [#list return[0].value as value] + [#local label = (value.@name[0]!"no-val")?trim /] + [#local brief = (value.@brief[0]!"")?trim /] +[@utils.FormatStringAsText " * @retval " + " * " + utils.WithDot(label + " " + brief?uncap_first) + boundary /] + [/#list] + [/#if] +[/#macro] + +[#-- + -- This macro generates the inner function code (if present). + --] +[#macro EmitCode code=[]] + [#if function.code[0]?? && (function.code[0]?trim != "")] +${indentation}${function.code[0]?trim} + [/#if] +[/#macro] + +[#-- + -- Returns true if the module exports some functions. + --] +[#function HasPublicFunctions module=[]] + [#local flag = false /] + [#list module.function as function] + [#if (function.@visibility[0]!"private") == "public"] + [#local flag = true /] + [/#if] + [/#list] + [#return flag /] +[/#function] + +[#-- + -- Returns true if the module has static functions. + --] +[#function HasPrivateFunctions module=[]] + [#local flag = false /] + [#list module.function as function] + [#if (function.@visibility[0]!"private") == "private"] + [#local flag = true /] + [/#if] + [/#list] + [#return flag /] +[/#function] + +[#-- + -- This macro generates a function prototype from an XML "function" + -- node passed as parameter. + -- @note Does not generate the final EOL. + --] +[#macro GeneratePrototype function={}] + [#if function.return?? && function.return[0]??] + [#local rettype = (function.return[0].@type[0]!"void")?trim /] + [#else] + [#local rettype = "void" /] + [/#if] + [#local name = (function.@name[0]!"no-name")?trim /] + [#local visibility = (function.@visibility[0]!"private")?trim /] + [#if function.param?? && function.param[0]??] + [#-- If the function has parameters then generates the parameters list --] + [#local l1 = rettype + " " + name + "(" /] + [#if visibility == "private"] + [#local l1 = "static " + l1 /] + [/#if] + [#local ln = ""?right_pad(l1?length) /] + [#list function.param as param] + [#local type = (param.@type[0]!"no-type")?trim /] + [#if type?contains("$")] + [#local pstring = type?replace("$", (param.@name[0]!"no-name")?trim) /] + [#else] + [#local pstring = type + " " + (param.@name[0]!"no-name")?trim /] + [/#if] + [#local dir = (param.@dir[0]!"boh")?trim?lower_case /] + [#if dir == "in"] + [#local pstring = "const " + pstring /] + [/#if] + [#if param_index == 0] + [#local line = l1 + pstring /] + [#else] + [#if (line + ", " + pstring + " ")?length > boundary] +${line + ","} + [#local line = ln + pstring /] + [#else] + [#local line = line + ", " + pstring /] + [/#if] + [/#if] + [/#list] +${line + ")"}[#rt] + [#else] +${rettype + " " + name}(void)[#rt] + [/#if] +[/#macro] + +[#-- + -- This macro generates a function (and its Doxygen documentation) + -- from an XML "function" node passed as parameter. + --] +[#macro GenerateFunction function={}] +/** +[@EmitDoxygenBrief function.@brief /] +[@EmitDoxygenDetails function.details /] +[@EmitDoxygenParams function.param /] +[@EmitDoxygenReturn function.return /] + * + * @note --Implementer notes here (or remove the tag)-- + * @bug --Known problems please here (or remove the tag)-- + * @todo --Implement this function (then remove the tag)-- + */ +[@GeneratePrototype function /] { + [#if function.code[0]??] + [#-- Makes sure to undef the do_code macro --] + [#assign inline = "[#ftl][#macro do_code function][/#macro]"?interpret /] +[@inline /] + [#-- Interprets the code within the code element --] + [#assign inline = function.code[0]?interpret /] +[@inline /] +[@do_code function /] + [#else] + +${indentation}/* ${function.@name[0]!"no-name"}() Implementation here! */ + [/#if] +} +[/#macro] + +[#-- + -- Generates the implementations for the private functions in the specified + -- module. + --] +[#macro GeneratePrivateFunctionsImplementations module] + [#list module.function as function] + [#if (function.@visibility[0]!"private") == "private"] +[@code.GenerateFunction function /] + + [/#if] + [/#list] +[/#macro] + +[#-- + -- Generates the prototypes of the public functions in the specified + -- module. + --] +[#macro GeneratePublicFunctionsPrototypes indentation module] + [#list module.function as function] + [#if (function.@visibility[0]!"private")?trim == "public"] +${indentation}[@code.GeneratePrototype function /]; + [/#if] + [/#list] +[/#macro] + +[#-- + -- Generates the implementations for the public functions in the specified + -- module. + --] +[#macro GeneratePublicFunctionsImplementations module] + [#list module.function as function] + [#if (function.@visibility[0]!"private") == "public"] +[@code.GenerateFunction function /] + + [/#if] + [/#list] +[/#macro] diff --git a/tools/gencfg/lib/libstm32f4xx.ftl b/tools/gencfg/lib/libstm32f4xx.ftl new file mode 100644 index 000000000..f6df3a771 --- /dev/null +++ b/tools/gencfg/lib/libstm32f4xx.ftl @@ -0,0 +1,34 @@ +[#ftl] +[#-- + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + --] + +[#-- + -- Emits the ChibiOS/RT standard license exception text. + -- The license exception text is indented by 4 spaces. + --] +[#macro EmitADCConfig config] + [#local cfg_name = config.@name[0]?string /] +/* ADC Config.*/ +/** +[@code.EmitDoxygenBrief config.@brief /] +[@code.EmitDoxygenDetails config.details /] + */ +const ADCConfig ${cfg_name} = {0}; +[/#macro] -- cgit v1.2.3 From f9f6c4db2df5174acdbd79959ff6ea3e07fd0de6 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 10 Jul 2012 19:23:29 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4456 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/gencfg/lib/libstm32f4xx.ftl | 1 - 1 file changed, 1 deletion(-) (limited to 'tools/gencfg/lib') diff --git a/tools/gencfg/lib/libstm32f4xx.ftl b/tools/gencfg/lib/libstm32f4xx.ftl index f6df3a771..47b0659e3 100644 --- a/tools/gencfg/lib/libstm32f4xx.ftl +++ b/tools/gencfg/lib/libstm32f4xx.ftl @@ -25,7 +25,6 @@ --] [#macro EmitADCConfig config] [#local cfg_name = config.@name[0]?string /] -/* ADC Config.*/ /** [@code.EmitDoxygenBrief config.@brief /] [@code.EmitDoxygenDetails config.details /] -- cgit v1.2.3 From dbfb5a1f70e69a3f412f2a69f528bf398633c10f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 10 Jul 2012 20:08:46 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4457 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/gencfg/lib/libstm32f4xx.ftl | 55 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'tools/gencfg/lib') diff --git a/tools/gencfg/lib/libstm32f4xx.ftl b/tools/gencfg/lib/libstm32f4xx.ftl index 47b0659e3..9ede34c2c 100644 --- a/tools/gencfg/lib/libstm32f4xx.ftl +++ b/tools/gencfg/lib/libstm32f4xx.ftl @@ -20,14 +20,61 @@ --] [#-- - -- Emits the ChibiOS/RT standard license exception text. - -- The license exception text is indented by 4 spaces. + -- Emits the STM32F4xx ADC driver constant configuration structures. --] [#macro EmitADCConfig config] [#local cfg_name = config.@name[0]?string /] /** -[@code.EmitDoxygenBrief config.@brief /] -[@code.EmitDoxygenDetails config.details /] + [@code.EmitDoxygenBrief config.@brief /] + [@code.EmitDoxygenDetails config.details /] */ const ADCConfig ${cfg_name} = {0}; + + [#list config.groups.group as group] + [#local grpcfg_name = group.@name[0]?string /] +/** + [@code.EmitDoxygenBrief group.@brief /] + [@code.EmitDoxygenDetails group.details /] + */ +const ADCGroupConfig ${grpcfg_name} = { + /* Circular conversion flag.*/ + ${group.@circular[0]?string?upper_case}, + /* Number of channels sampled in the conversion group.*/ + ${group.channels_sequence.channel?size}, + /* End of conversion callback or NULL.*/ + [#if group.@conversion_callback[0]?string?trim == ""] + NULL, + [#else] + ${group.@conversion_callback[0]?string?trim}, + [/#if] + /* Error callback or NULL.*/ + [#if group.@error_callback[0]?string?trim == ""] + NULL, + [#else] + ${group.@error_callback[0]?string?trim}, + [/#if] +}; + [/#list] +[/#macro] + +[#-- + -- Emits the STM32F4xx ADC driver configuration external declarations. + --] +[#macro EmitADCConfigExtern config] + [#local cfg_name = config.@name[0]?string /] + [#list config.groups.group as group] + [#local grpcfg_name = group.@name[0]?string /] + [#-- Only emits the comment if there is at least a callback defined.--] + /* ADC configuration "${cfg_name}".*/ + extern const ADCConfig ${cfg_name}; + /* ADC conversion group "${grpcfg_name}".*/ + extern const ADCGroupConfig ${grpcfg_name}; + [#if group.@conversion_callback[0]?string?trim != ""] + void ${group.@conversion_callback[0]?string?trim}(ADCDriver *, adcsample_t *, size_t); + [/#if] + [#if group.@error_callback[0]?string?trim != ""] + void ${group.@error_callback[0]?string?trim}(ADCDriver *, adcerror_t); + [/#if] + + [/#list] [/#macro] -- cgit v1.2.3 From 2ab5ce68ba6f7913fe63b2905f8065327d769b79 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 11 Jul 2012 11:59:23 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4458 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/gencfg/lib/libstm32f4xx.ftl | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'tools/gencfg/lib') diff --git a/tools/gencfg/lib/libstm32f4xx.ftl b/tools/gencfg/lib/libstm32f4xx.ftl index 9ede34c2c..2a541606d 100644 --- a/tools/gencfg/lib/libstm32f4xx.ftl +++ b/tools/gencfg/lib/libstm32f4xx.ftl @@ -53,6 +53,76 @@ const ADCGroupConfig ${grpcfg_name} = { [#else] ${group.@error_callback[0]?string?trim}, [/#if] + /* CR1 register initialization value.*/ + [#local resolution = group.@resolution[0]?word_list[0]?number /] + [#local cr1 = "ADC_CR1_RESOLUTION_N(" + resolution?string + ")" /] + [#local discnum = group.@discontinuous_number[0]?word_list[0]?number /] + [#local cr1 = cr1 + " | ADC_CR1_DISCNUM_N(" + (discnum - 1)?string + ")" /] + [#if group.@discontinuous_mode[0]?string == "true"] + [#local cr1 = cr1 + " | ADC_CR1_DISCEN" /] + [/#if] + ${cr1}, + /* CR2 register initialization value.*/ + [#local exten = group.@trigger_mode[0]?word_list[0]?number /] + [#local cr2 = "ADC_CR1_EXTEN_N(" + exten?string + ")" /] + [#local extsel = group.@trigger_source[0]?word_list[0]?number /] + [#local cr2 = cr2 + " | ADC_CR1_EXSEL_N(" + extsel?string + ")" /] + [#if group.@alignment[0]?word_list[0]?number != 0] + [#local cr2 = cr2 + " | ADC_CR2_ALIGN" /] + [/#if] + ${cr2}, + /* Channels sample time settings.*/ + [#local smpr1 = "" /] + [#local smpr2 = "" /] + [#list group.sample_time.* as input] + [#local sinput = input?node_name] + [#if input_index < 9] + [#local smpr2 = smpr2 + "ADC_SMPR2_SMP_" + input?node_name + + "(" + input?string + ") | " /] + [#elseif input_index == 9] + [#local smpr2 = smpr2 + "ADC_SMPR2_SMP_" + input?node_name + + "(" + input?string + ")," /] + [#elseif input_index < 18] + [#local smpr1 = smpr1 + "ADC_SMPR1_SMP_" + input?node_name + + "(" + input?string + ") | " /] + [#else] + [#local smpr1 = smpr1 + "ADC_SMPR1_SMP_" + input?node_name + + "(" + input?string + ")," /] + [/#if] + [/#list] + [@utils.FormatStringAsText " " " " smpr1 80 /] + [@utils.FormatStringAsText " " " " smpr2 80 /] + /* Channels sequence.*/ + [#local sqr1 = "ADC_SQR1_NUM_CH(" + group.channels_sequence?size + ")" /] + [#local sqr2 = "" /] + [#local sqr3 = "" /] + [#list group.channels_sequence.channel as channel] + [#if channel_index <= 5] + [#local sqr3 = sqr3 + "ADC_SQR3_SQ" + (channel_index + 1) + + "_N(" + channel + ")" /] + [#if channel_has_next && channel_index < 5] + [#local sqr3 = sqr3 + " | " /] + [/#if] + [#elseif channel_index <= 11] + [#local sqr2 = sqr2 + "ADC_SQR2_SQ" + (channel_index + 1) + + "_N(" + channel + ")" /] + [#if channel_has_next && channel_index < 11] + [#local sqr2 = sqr2 + " | " /] + [/#if] + [#else] + [#local sqr1 = sqr1 + " | ADC_SQR2_SQ" + (channel_index + 1) + + "_N(" + channel + ")" /] + [/#if] + [/#list] + [#-- SQR2 could be empty.--] + [#if sqr2 == ""] + [#local sqr2 = "0" /] + [/#if] + [#local sqr1 = sqr1 + "," /] + [#local sqr2 = sqr2 + "," /] + [@utils.FormatStringAsText " " " " sqr1 80 /] + [@utils.FormatStringAsText " " " " sqr2 80 /] + [@utils.FormatStringAsText " " " " sqr3 80 /] }; [/#list] [/#macro] -- cgit v1.2.3 From ab4703c491d8cbc4848d43902857adcfb8768a87 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 12 Jul 2012 14:02:44 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4463 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- tools/gencfg/lib/libcode.ftl | 67 +++++++++++++++++++++++++++++++++++---- tools/gencfg/lib/libstm32f4xx.ftl | 50 +++++++++++++---------------- 2 files changed, 83 insertions(+), 34 deletions(-) (limited to 'tools/gencfg/lib') diff --git a/tools/gencfg/lib/libcode.ftl b/tools/gencfg/lib/libcode.ftl index 8147e02c4..45b94a320 100644 --- a/tools/gencfg/lib/libcode.ftl +++ b/tools/gencfg/lib/libcode.ftl @@ -31,11 +31,11 @@ [#-- -- This macro generates a brief description in DoxyGen format. --] -[#macro EmitDoxygenBrief brief=[]] - [#if brief[0]??] +[#macro EmitDoxygenBrief object=[]] + [#if object.brief[0]??] [@utils.FormatStringAsText " * @brief " " * " - utils.WithDot(brief[0]?cap_first) + utils.WithDot(object.brief[0]?cap_first) boundary /] [/#if] [/#macro] @@ -43,15 +43,70 @@ [#-- -- This macro generates a detailed description in DoxyGen format. --] -[#macro EmitDoxygenDetails details=[]] - [#if details[0]??] +[#macro EmitDoxygenDetails object=[]] + [#if object.details[0]??] [@utils.FormatStringAsText " * @details " " * " - utils.WithDot(details[0]?cap_first) + utils.WithDot(object.details[0]?cap_first) boundary /] [/#if] [/#macro] +[#-- + -- This macro generates a notes list in DoxyGen format. + --] +[#macro EmitDoxygenNotes object=[]] + [#list object.* as note] + [#if note?node_name == "note"] + [@utils.FormatStringAsText " * @note " + " * " + utils.WithDot(note[0]?cap_first) + boundary /] + [/#if] + [/#list] +[/#macro] + +[#-- + -- This macro generates a pre-requisites list in DoxyGen format. + --] +[#macro EmitDoxygenPrerequisites object=[]] + [#list object.* as pre] + [#if pre?node_name == "pre"] + [@utils.FormatStringAsText " * @pre " + " * " + utils.WithDot(pre[0]?cap_first) + boundary /] + [/#if] + [/#list] +[/#macro] + +[#-- + -- This macro generates a post-requisites list in DoxyGen format. + --] +[#macro EmitDoxygenPostrequisites object=[]] + [#list object.* as post] + [#if post?node_name == "post"] + [@utils.FormatStringAsText " * @post " + " * " + utils.WithDot(post[0]?cap_first) + boundary /] + [/#if] + [/#list] +[/#macro] + +[#-- + -- This macro generates a complete Doxygen documentation comment. + --] +[#macro EmitDoxygenDocumentationComment object=[]] +/** + [@code.EmitDoxygenBrief object /] + [@code.EmitDoxygenDetails object /] + [@code.EmitDoxygenPrerequisites object /] + [@code.EmitDoxygenPostrequisites object /] + [@code.EmitDoxygenNotes object /] + */ +[/#macro] + [#-- -- This macro generates the parameters description in DoxyGen format. --] diff --git a/tools/gencfg/lib/libstm32f4xx.ftl b/tools/gencfg/lib/libstm32f4xx.ftl index 2a541606d..81b8f987c 100644 --- a/tools/gencfg/lib/libstm32f4xx.ftl +++ b/tools/gencfg/lib/libstm32f4xx.ftl @@ -23,51 +23,45 @@ -- Emits the STM32F4xx ADC driver constant configuration structures. --] [#macro EmitADCConfig config] - [#local cfg_name = config.@name[0]?string /] -/** - [@code.EmitDoxygenBrief config.@brief /] - [@code.EmitDoxygenDetails config.details /] - */ + [#local cfg_name = config.name[0]?string /] + [@code.EmitDoxygenDocumentationComment config /] const ADCConfig ${cfg_name} = {0}; [#list config.groups.group as group] - [#local grpcfg_name = group.@name[0]?string /] -/** - [@code.EmitDoxygenBrief group.@brief /] - [@code.EmitDoxygenDetails group.details /] - */ + [#local grpcfg_name = group.name[0]?string /] + [@code.EmitDoxygenDocumentationComment group /] const ADCGroupConfig ${grpcfg_name} = { /* Circular conversion flag.*/ - ${group.@circular[0]?string?upper_case}, + ${group.circular[0]?string?upper_case}, /* Number of channels sampled in the conversion group.*/ ${group.channels_sequence.channel?size}, /* End of conversion callback or NULL.*/ - [#if group.@conversion_callback[0]?string?trim == ""] + [#if group.conv_callback[0]?string?trim == ""] NULL, [#else] - ${group.@conversion_callback[0]?string?trim}, + ${group.conv_callback[0]?string?trim}, [/#if] /* Error callback or NULL.*/ - [#if group.@error_callback[0]?string?trim == ""] + [#if group.error_callback[0]?string?trim == ""] NULL, [#else] - ${group.@error_callback[0]?string?trim}, + ${group.error_callback[0]?string?trim}, [/#if] /* CR1 register initialization value.*/ - [#local resolution = group.@resolution[0]?word_list[0]?number /] + [#local resolution = group.resolution[0]?word_list[0]?number /] [#local cr1 = "ADC_CR1_RESOLUTION_N(" + resolution?string + ")" /] - [#local discnum = group.@discontinuous_number[0]?word_list[0]?number /] - [#local cr1 = cr1 + " | ADC_CR1_DISCNUM_N(" + (discnum - 1)?string + ")" /] - [#if group.@discontinuous_mode[0]?string == "true"] + [#local disc = group.discontinuous[0]?word_list[0]?number /] + [#if disc > 0] [#local cr1 = cr1 + " | ADC_CR1_DISCEN" /] + [#local cr1 = cr1 + " | ADC_CR1_DISCNUM_N(" + (disc - 1)?string + ")" /] [/#if] ${cr1}, /* CR2 register initialization value.*/ - [#local exten = group.@trigger_mode[0]?word_list[0]?number /] + [#local exten = group.trigger_mode[0]?word_list[0]?number /] [#local cr2 = "ADC_CR1_EXTEN_N(" + exten?string + ")" /] - [#local extsel = group.@trigger_source[0]?word_list[0]?number /] + [#local extsel = group.trigger_source[0]?word_list[0]?number /] [#local cr2 = cr2 + " | ADC_CR1_EXSEL_N(" + extsel?string + ")" /] - [#if group.@alignment[0]?word_list[0]?number != 0] + [#if group.alignment[0]?word_list[0]?number != 0] [#local cr2 = cr2 + " | ADC_CR2_ALIGN" /] [/#if] ${cr2}, @@ -131,19 +125,19 @@ const ADCGroupConfig ${grpcfg_name} = { -- Emits the STM32F4xx ADC driver configuration external declarations. --] [#macro EmitADCConfigExtern config] - [#local cfg_name = config.@name[0]?string /] + [#local cfg_name = config.name[0]?string /] [#list config.groups.group as group] - [#local grpcfg_name = group.@name[0]?string /] + [#local grpcfg_name = group.name[0]?string /] [#-- Only emits the comment if there is at least a callback defined.--] /* ADC configuration "${cfg_name}".*/ extern const ADCConfig ${cfg_name}; /* ADC conversion group "${grpcfg_name}".*/ extern const ADCGroupConfig ${grpcfg_name}; - [#if group.@conversion_callback[0]?string?trim != ""] - void ${group.@conversion_callback[0]?string?trim}(ADCDriver *, adcsample_t *, size_t); + [#if group.conv_callback[0]?string?trim != ""] + void ${group.conv_callback[0]?string?trim}(ADCDriver *, adcsample_t *, size_t); [/#if] - [#if group.@error_callback[0]?string?trim != ""] - void ${group.@error_callback[0]?string?trim}(ADCDriver *, adcerror_t); + [#if group.error_callback[0]?string?trim != ""] + void ${group.error_callback[0]?string?trim}(ADCDriver *, adcerror_t); [/#if] [/#list] -- cgit v1.2.3