2012-07-10 18:47:54 +00:00
|
|
|
[#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 <http://www.gnu.org/licenses/>.
|
|
|
|
--]
|
|
|
|
|
|
|
|
[#--
|
2012-07-10 20:08:46 +00:00
|
|
|
-- Emits the STM32F4xx ADC driver constant configuration structures.
|
2012-07-10 18:47:54 +00:00
|
|
|
--]
|
|
|
|
[#macro EmitADCConfig config]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local cfg_name = config.name[0]?string /]
|
|
|
|
[@code.EmitDoxygenDocumentationComment config /]
|
2012-07-10 18:47:54 +00:00
|
|
|
const ADCConfig ${cfg_name} = {0};
|
2012-07-10 20:08:46 +00:00
|
|
|
|
|
|
|
[#list config.groups.group as group]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local grpcfg_name = group.name[0]?string /]
|
|
|
|
[@code.EmitDoxygenDocumentationComment group /]
|
2012-07-10 20:08:46 +00:00
|
|
|
const ADCGroupConfig ${grpcfg_name} = {
|
|
|
|
/* Circular conversion flag.*/
|
2012-07-12 14:02:44 +00:00
|
|
|
${group.circular[0]?string?upper_case},
|
2012-07-10 20:08:46 +00:00
|
|
|
/* Number of channels sampled in the conversion group.*/
|
|
|
|
${group.channels_sequence.channel?size},
|
|
|
|
/* End of conversion callback or NULL.*/
|
2012-07-12 14:02:44 +00:00
|
|
|
[#if group.conv_callback[0]?string?trim == ""]
|
2012-07-10 20:08:46 +00:00
|
|
|
NULL,
|
|
|
|
[#else]
|
2012-07-12 14:02:44 +00:00
|
|
|
${group.conv_callback[0]?string?trim},
|
2012-07-10 20:08:46 +00:00
|
|
|
[/#if]
|
|
|
|
/* Error callback or NULL.*/
|
2012-07-12 14:02:44 +00:00
|
|
|
[#if group.error_callback[0]?string?trim == ""]
|
2012-07-10 20:08:46 +00:00
|
|
|
NULL,
|
|
|
|
[#else]
|
2012-07-12 14:02:44 +00:00
|
|
|
${group.error_callback[0]?string?trim},
|
2012-07-10 20:08:46 +00:00
|
|
|
[/#if]
|
2012-07-11 11:59:23 +00:00
|
|
|
/* CR1 register initialization value.*/
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local resolution = group.resolution[0]?word_list[0]?number /]
|
2012-07-11 11:59:23 +00:00
|
|
|
[#local cr1 = "ADC_CR1_RESOLUTION_N(" + resolution?string + ")" /]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local disc = group.discontinuous[0]?word_list[0]?number /]
|
|
|
|
[#if disc > 0]
|
2012-07-11 11:59:23 +00:00
|
|
|
[#local cr1 = cr1 + " | ADC_CR1_DISCEN" /]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local cr1 = cr1 + " | ADC_CR1_DISCNUM_N(" + (disc - 1)?string + ")" /]
|
2012-07-11 11:59:23 +00:00
|
|
|
[/#if]
|
|
|
|
${cr1},
|
|
|
|
/* CR2 register initialization value.*/
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local exten = group.trigger_mode[0]?word_list[0]?number /]
|
2012-07-11 11:59:23 +00:00
|
|
|
[#local cr2 = "ADC_CR1_EXTEN_N(" + exten?string + ")" /]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local extsel = group.trigger_source[0]?word_list[0]?number /]
|
2012-07-11 11:59:23 +00:00
|
|
|
[#local cr2 = cr2 + " | ADC_CR1_EXSEL_N(" + extsel?string + ")" /]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#if group.alignment[0]?word_list[0]?number != 0]
|
2012-07-11 11:59:23 +00:00
|
|
|
[#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 /]
|
2012-07-10 20:08:46 +00:00
|
|
|
};
|
|
|
|
[/#list]
|
|
|
|
[/#macro]
|
|
|
|
|
|
|
|
[#--
|
|
|
|
-- Emits the STM32F4xx ADC driver configuration external declarations.
|
|
|
|
--]
|
|
|
|
[#macro EmitADCConfigExtern config]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local cfg_name = config.name[0]?string /]
|
2012-07-10 20:08:46 +00:00
|
|
|
[#list config.groups.group as group]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#local grpcfg_name = group.name[0]?string /]
|
2012-07-10 20:08:46 +00:00
|
|
|
[#-- 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};
|
2012-07-12 14:02:44 +00:00
|
|
|
[#if group.conv_callback[0]?string?trim != ""]
|
|
|
|
void ${group.conv_callback[0]?string?trim}(ADCDriver *, adcsample_t *, size_t);
|
2012-07-10 20:08:46 +00:00
|
|
|
[/#if]
|
2012-07-12 14:02:44 +00:00
|
|
|
[#if group.error_callback[0]?string?trim != ""]
|
|
|
|
void ${group.error_callback[0]?string?trim}(ADCDriver *, adcerror_t);
|
2012-07-10 20:08:46 +00:00
|
|
|
[/#if]
|
|
|
|
|
|
|
|
[/#list]
|
2012-07-10 18:47:54 +00:00
|
|
|
[/#macro]
|