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
This commit is contained in:
parent
5ceb377a37
commit
ae832b4ee8
@ -15,6 +15,5 @@
|
|||||||
# warning"no chipset defined; user interrupts are disabled"
|
# warning"no chipset defined; user interrupts are disabled"
|
||||||
|
|
||||||
#define NVIC_IRQ_COUNT 0
|
#define NVIC_IRQ_COUNT 0
|
||||||
#define IRQ_HANDLERS
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
/* load optional platform dependent initialization routines */
|
/* load optional platform dependent initialization routines */
|
||||||
#include "../dispatch/vector.c"
|
#include "../dispatch/vector.c"
|
||||||
|
/* load the weak symbols for IRQ_HANDLERS */
|
||||||
|
#include <libopencm3/dispatch/vector_nvic.h>
|
||||||
|
|
||||||
#define WEAK __attribute__ ((weak))
|
#define WEAK __attribute__ ((weak))
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ method to achive the same thing with C preprocessor is known to the author.
|
|||||||
import sys
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
template = '''\
|
template_nvic_h = '''\
|
||||||
/* This file is part of the libopencm3 project.
|
/* This file is part of the libopencm3 project.
|
||||||
*
|
*
|
||||||
* It was generated by the irq2nvic_h script.
|
* It was generated by the irq2nvic_h script.
|
||||||
@ -38,6 +38,8 @@ template = '''\
|
|||||||
#ifndef {includeguard}
|
#ifndef {includeguard}
|
||||||
#define {includeguard}
|
#define {includeguard}
|
||||||
|
|
||||||
|
#include <libopencm3/cm3/nvic.h>
|
||||||
|
|
||||||
/** @defgroup CM3_nvic_defines_{partname_doxygen} User interrupts for {partname_humanreadable}
|
/** @defgroup CM3_nvic_defines_{partname_doxygen} User interrupts for {partname_humanreadable}
|
||||||
@ingroup CM3_nvic_defines
|
@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}
|
/** @defgroup CM3_nvic_isrpragmas_{partname_doxygen} User interrupt service routines (ISR) defaults for {partname_humanreadable}
|
||||||
@ingroup CM3_nvic_isrpragmas
|
@ingroup CM3_nvic_isrpragmas
|
||||||
|
|
||||||
@ -76,11 +91,9 @@ template = '''\
|
|||||||
|
|
||||||
#define IRQ_HANDLERS \\
|
#define IRQ_HANDLERS \\
|
||||||
{vectortableinitialization}
|
{vectortableinitialization}
|
||||||
|
|
||||||
#endif /* {includeguard} */
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def convert(infile, outfile):
|
def convert(infile, outfile_nvic, outfile_vectornvic):
|
||||||
data = yaml.load(infile)
|
data = yaml.load(infile)
|
||||||
|
|
||||||
irq2name = list(enumerate(data['irqs']) if isinstance(data['irqs'], list) else data['irqs'].items())
|
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['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)
|
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():
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user