aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorchrysn2012-10-18 17:30:18 +0200
committerchrysn2012-10-18 17:33:20 +0200
commitae832b4ee87f2cf94b29f790bc04d7b570109919 (patch)
treee8849afc004ca47bbdd4c641af1a1716daa87c23 /scripts
parent5ceb377a378203c80580fbe5160000fca998b635 (diff)
split irq.yaml output in nvic.h and vector_nvic.h
the weak pragmas need to be used in the very compilation unit where their target is defined, requiring another dispatch
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/irq2nvic_h29
1 files changed, 23 insertions, 6 deletions
diff --git a/scripts/irq2nvic_h b/scripts/irq2nvic_h
index 9346e9b..fc5e571 100755
--- a/scripts/irq2nvic_h
+++ b/scripts/irq2nvic_h
@@ -29,7 +29,7 @@ method to achive the same thing with C preprocessor is known to the author.
import sys
import yaml
-template = '''\
+template_nvic_h = '''\
/* This file is part of the libopencm3 project.
*
* It was generated by the irq2nvic_h script.
@@ -38,6 +38,8 @@ template = '''\
#ifndef {includeguard}
#define {includeguard}
+#include <libopencm3/cm3/nvic.h>
+
/** @defgroup CM3_nvic_defines_{partname_doxygen} User interrupts for {partname_humanreadable}
@ingroup CM3_nvic_defines
@@ -60,6 +62,19 @@ template = '''\
/**@}}*/
+#endif /* {includeguard} */
+'''
+
+template_vector_nvic_h = '''\
+/* This file is part of the libopencm3 project.
+ *
+ * It was generated by the irq2nvic_h script.
+ *
+ * This part needs to get included in the compilation unit where
+ * blocking_handler gets defined due to the way #pragma works.
+ */
+
+
/** @defgroup CM3_nvic_isrpragmas_{partname_doxygen} User interrupt service routines (ISR) defaults for {partname_humanreadable}
@ingroup CM3_nvic_isrpragmas
@@ -76,11 +91,9 @@ template = '''\
#define IRQ_HANDLERS \\
{vectortableinitialization}
-
-#endif /* {includeguard} */
'''
-def convert(infile, outfile):
+def convert(infile, outfile_nvic, outfile_vectornvic):
data = yaml.load(infile)
irq2name = list(enumerate(data['irqs']) if isinstance(data['irqs'], list) else data['irqs'].items())
@@ -96,10 +109,14 @@ def convert(infile, outfile):
data['isrpragmas'] = "\n".join('#pragma weak %s_isr = blocking_handler'%name.lower() for name in irqnames)
data['vectortableinitialization'] = ', \\\n '.join('[NVIC_%s_IRQ] = %s_isr'%(name.upper(), name.lower()) for name in irqnames)
- outfile.write(template.format(**data))
+ outfile_nvic.write(template_nvic_h.format(**data))
+ # FIXME: the vector_nvic.h file could just as well be a vector_nvic.c file
+ # in lib/, but that'd spread this mechanism over the whole library; just
+ # needs some thingking over
+ outfile_vectornvic.write(template_vector_nvic_h.format(**data))
def main():
- convert(open('irq.yaml'), open('nvic.h', 'w'))
+ convert(open('irq.yaml'), open('nvic.h', 'w'), open('vector_nvic.h', 'w'))
if __name__ == "__main__":
main()