use generalized libopencm3 functions in cmsis
This commit is contained in:
@@ -99,7 +99,19 @@ template_vector_nvic_c = '''\
|
||||
{vectortableinitialization}
|
||||
'''
|
||||
|
||||
def convert(infile, outfile_nvic, outfile_vectornvic):
|
||||
template_cmsis_h = '''\
|
||||
/* This file is part of the libopencm3 project.
|
||||
*
|
||||
* It was generated by the irq2nvic_h script.
|
||||
*
|
||||
* These definitions bend every interrupt handler that is defined CMSIS style
|
||||
* to the weak symbol exported by libopenmc3.
|
||||
*/
|
||||
|
||||
{cmsisbends}
|
||||
'''
|
||||
|
||||
def convert(infile, outfile_nvic, outfile_vectornvic, outfile_cmsis):
|
||||
data = yaml.load(infile)
|
||||
|
||||
irq2name = list(enumerate(data['irqs']) if isinstance(data['irqs'], list) else data['irqs'].items())
|
||||
@@ -114,9 +126,11 @@ def convert(infile, outfile_nvic, outfile_vectornvic):
|
||||
data['isrprototypes'] = "\n".join('void WEAK %s_isr(void);'%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['cmsisbends'] = "\n".join("#define %s_IRQHandler %s_isr"%(name.upper(), name.lower()) for name in irqnames)
|
||||
|
||||
outfile_nvic.write(template_nvic_h.format(**data))
|
||||
outfile_vectornvic.write(template_vector_nvic_c.format(**data))
|
||||
outfile_cmsis.write(template_cmsis_h.format(**data))
|
||||
|
||||
def makeparentdir(filename):
|
||||
try:
|
||||
@@ -131,11 +145,13 @@ def main():
|
||||
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')
|
||||
cmsis = infile.replace('irq.yaml', 'irqhandlers.h').replace('/libopencm3/', '/libopencmsis/')
|
||||
|
||||
makeparentdir(nvic_h)
|
||||
makeparentdir(vector_nvic_c)
|
||||
makeparentdir(cmsis)
|
||||
|
||||
convert(open(infile), open(nvic_h, 'w'), open(vector_nvic_c, 'w'))
|
||||
convert(open(infile), open(nvic_h, 'w'), open(vector_nvic_c, 'w'), open(cmsis, 'w'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user