integrate irq2nvic_h script in buildprocess
This commit is contained in:
8
Makefile
8
Makefile
@@ -39,7 +39,13 @@ all: build
|
|||||||
|
|
||||||
build: lib examples
|
build: lib examples
|
||||||
|
|
||||||
lib:
|
generatedheaders:
|
||||||
|
@printf " UPDATING HEADERS\n"
|
||||||
|
$(Q)for yamlfile in `find -name 'irq.yaml'`; do \
|
||||||
|
./scripts/irq2nvic_h $$yamlfile ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
lib: generatedheaders
|
||||||
$(Q)for i in $(addprefix $@/,$(TARGETS)); do \
|
$(Q)for i in $(addprefix $@/,$(TARGETS)); do \
|
||||||
if [ -d $$i ]; then \
|
if [ -d $$i ]; then \
|
||||||
printf " BUILD $$i\n"; \
|
printf " BUILD $$i\n"; \
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
nvic.h: irq.yaml
|
|
||||||
./irq2nvic_h
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
/* 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 */
|
/* load the weak symbols for IRQ_HANDLERS */
|
||||||
#include <libopencm3/dispatch/vector_nvic.h>
|
#include "../dispatch/vector_nvic.c"
|
||||||
|
|
||||||
#define WEAK __attribute__ ((weak))
|
#define WEAK __attribute__ ((weak))
|
||||||
|
|
||||||
|
|||||||
19
lib/dispatch/vector_nvic.c
Normal file
19
lib/dispatch/vector_nvic.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#if defined(STM32F1)
|
||||||
|
# include "../stm32/f1/vector_nvic.c"
|
||||||
|
#elif defined(STM32F2)
|
||||||
|
# include "../stm32/f2/vector_nvic.c"
|
||||||
|
#elif defined(STM32F4)
|
||||||
|
# include "../stm32/f4/vector_nvic.c"
|
||||||
|
|
||||||
|
#elif defined(TINYGECKO)
|
||||||
|
# include "../efm32/tinygecko/vector_nvic.c"
|
||||||
|
|
||||||
|
#elif defined(LPC43XX)
|
||||||
|
# include "../lpc43xx/vector_nvic.c"
|
||||||
|
|
||||||
|
#else
|
||||||
|
# warning"no chipset defined; user interrupts are disabled"
|
||||||
|
|
||||||
|
#define IRQ_HANDLERS
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -65,7 +65,7 @@ template_nvic_h = '''\
|
|||||||
#endif /* {includeguard} */
|
#endif /* {includeguard} */
|
||||||
'''
|
'''
|
||||||
|
|
||||||
template_vector_nvic_h = '''\
|
template_vector_nvic_c = '''\
|
||||||
/* 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.
|
||||||
@@ -110,13 +110,15 @@ def convert(infile, outfile_nvic, outfile_vectornvic):
|
|||||||
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_nvic.write(template_nvic_h.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
|
outfile_vectornvic.write(template_vector_nvic_c.format(**data))
|
||||||
# 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'), open('vector_nvic.h', 'w'))
|
infile = sys.argv[1]
|
||||||
|
if not infile.startswith('./include/libopencm3/') or not infile.endswith('/irq.yaml'):
|
||||||
|
raise ValueError("Arguent must match ./include/libopencm3/**/irq.yaml")
|
||||||
|
nvic_h = infile.replace('irq.yaml', 'nvic.h')
|
||||||
|
vector_nvic_c = infile.replace('./include/libopencm3/', './lib/').replace('irq.yaml', 'vector_nvic.c')
|
||||||
|
convert(open(infile), open(nvic_h, 'w'), open(vector_nvic_c, 'w'))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user