From e4c592d9cfb2740678862865498d545bf8160e12 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 8 Jul 2012 12:05:39 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4434 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- .../boards/stm32f4xx/datamodel/stm32f4board.xml | 292 ++++++++++----------- .../boards/stm32f4xx/templates/board.h.ftl | 61 ++++- .../schema/common/stm32/stm32_gpiov2_port.xsd | 2 +- 3 files changed, 202 insertions(+), 153 deletions(-) diff --git a/tools/gencfg/processors/boards/stm32f4xx/datamodel/stm32f4board.xml b/tools/gencfg/processors/boards/stm32f4xx/datamodel/stm32f4board.xml index 343d3ea85..bd5e1bdb0 100644 --- a/tools/gencfg/processors/boards/stm32f4xx/datamodel/stm32f4board.xml +++ b/tools/gencfg/processors/boards/stm32f4xx/datamodel/stm32f4board.xml @@ -14,115 +14,115 @@ @@ -131,112 +131,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -245,112 +245,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -359,112 +359,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -473,112 +473,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -587,112 +587,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -701,112 +701,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -815,112 +815,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> @@ -929,112 +929,112 @@ ID="" Type="PushPull" Speed="Minimum" - Resistor="None" + Resistor="Floating" Mode="Input" Alternate="0" /> diff --git a/tools/gencfg/processors/boards/stm32f4xx/templates/board.h.ftl b/tools/gencfg/processors/boards/stm32f4xx/templates/board.h.ftl index d0253cfcd..cb46a90d8 100644 --- a/tools/gencfg/processors/boards/stm32f4xx/templates/board.h.ftl +++ b/tools/gencfg/processors/boards/stm32f4xx/templates/board.h.ftl @@ -37,13 +37,13 @@ * Board identifier. */ #define BOARD_${doc1.board.@BoardID[0]} -#define BOARD_NAME "${doc1.board.@name[0]}" +#define BOARD_NAME "${doc1.board.@name[0]}" [#if doc1.board.@BoardPHYID[0]??] /* * Ethernet PHY type. */ -#define BOARD_PHY_ID ${doc1.board.@BoardPHYID[0]} +#define BOARD_PHY_ID ${doc1.board.@BoardPHYID[0]} [#if doc1.board.@BoardPHYType[0]?string == "RMII"] #define BOARD_PHY_RMII [/#if] @@ -59,11 +59,11 @@ [/#if] */ #if !defined(STM32_LSECLK) -#define STM32_LSECLK ${doc1.board.@LSEFrequency[0]} +#define STM32_LSECLK ${doc1.board.@LSEFrequency[0]} #endif #if !defined(STM32_HSECLK) -#define STM32_HSECLK ${doc1.board.@HSEFrequency[0]} +#define STM32_HSECLK ${doc1.board.@HSEFrequency[0]} #endif [#if doc1.board.@HSEBypass[0]?string == "true"] @@ -74,7 +74,7 @@ * Board voltages. * Required for performance limits calculation. */ -#define STM32_VDD ${doc1.board.@VDD[0]} +#define STM32_VDD ${doc1.board.@VDD[0]} /* * MCU type as defined in the ST header file stm32f4xx.h. @@ -84,17 +84,66 @@ /* * IO pins assignments. */ +[#list doc1.board.ports.* as port] + [#assign pinidx = 0 /] + [#list port.* as pin] + [#assign name = pin.@ID[0]?string?trim /] + [#if name?length == 0] + [#assign name = pin?node_name?upper_case /] + [/#if] +#define ${(port?node_name + "_" + name)?right_pad(27, " ")} ${pinidx?string} + [#assign pinidx = pinidx + 1 /] + [/#list] + +[/#list] +/* + * I/O ports initial setup, this configuration is established soon after reset + * in the initialization code. + * Please refer to the STM32 Reference Manual for details. + */ +#define PIN_MODE_INPUT(n) (0U << ((n) * 2)) +#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2)) +#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2)) +#define PIN_MODE_ANALOG(n) (3U << ((n) * 2)) +#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) +#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) +#define PIN_OSPEED_2M(n) (0U << ((n) * 2)) +#define PIN_OSPEED_25M(n) (1U << ((n) * 2)) +#define PIN_OSPEED_50M(n) (2U << ((n) * 2)) +#define PIN_OSPEED_100M(n) (3U << ((n) * 2)) +#define PIN_PUDR_FLOATING(n) (0U << ((n) * 2)) +#define PIN_PUDR_PULLUP(n) (1U << ((n) * 2)) +#define PIN_PUDR_PULLDOWN(n) (2U << ((n) * 2)) +#define PIN_AFIO_AF(n, v) ((v##U) << ((n % 8) * 4)) [#list doc1.board.ports.* as port] +/* + * ${port?node_name} setup: + * [#assign pinidx = 0 /] [#list port.* as pin] [#assign name = pin.@ID[0]?string?trim /] [#if name?length == 0] [#assign name = pin?node_name?upper_case /] [/#if] -#define ${(port?node_name + "_" + name)?right_pad(23, " ")} ${pinidx?string} + [#assign mode = pin.@Mode[0] /] + [#assign type = pin.@Type[0] /] + [#assign resistor = pin.@Resistor[0] /] + [#assign speed = pin.@Speed[0] /] + [#assign alternate = pin.@Alternate[0] /] + [#if mode == "Input"] + [#assign desc = mode + " " + resistor /] + [#elseif mode == "Output"] + [#assign desc = mode + " " + type + " " + speed /] + [#elseif mode == "Alternate"] + [#assign desc = mode + " " + alternate /] + [#else] + [#assign desc = "Analog" /] + [/#if] + * P${(port?node_name[4..] + pinidx?string)?right_pad(3, " ")} - ${name?right_pad(26, " ")}(${desc?lower_case}). [#assign pinidx = pinidx + 1 /] [/#list] + */ [/#list] diff --git a/tools/gencfg/schema/common/stm32/stm32_gpiov2_port.xsd b/tools/gencfg/schema/common/stm32/stm32_gpiov2_port.xsd index dbefc05d3..b363b0006 100644 --- a/tools/gencfg/schema/common/stm32/stm32_gpiov2_port.xsd +++ b/tools/gencfg/schema/common/stm32/stm32_gpiov2_port.xsd @@ -82,7 +82,7 @@ - + -- cgit v1.2.3