Skip to content

Commit 6d18be6

Browse files
Move Timer ISR handlers from timer_f1.c to timer.c to resolve linker issue in which some ISR's were not being linked even though they were being used
1 parent 3d51e8c commit 6d18be6

2 files changed

Lines changed: 106 additions & 89 deletions

File tree

STM32F1/cores/maple/libmaple/timer.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/******************************************************************************
23
* The MIT License
34
*
@@ -410,3 +411,102 @@ static void enable_bas_gen_irq(timer_dev *dev) {
410411
}
411412
nvic_irq_enable(irq_num);
412413
}
414+
415+
416+
/* Note.
417+
*
418+
* 2015/07/06 Roger Clark
419+
*
420+
* The IRQ handlers were initially in timer_f1.c however this seems to cause problems
421+
* in which the compiler / linker doesn't always link all the required handlers.
422+
* The work around was to move the handlers into this file
423+
*/
424+
425+
/*
426+
* IRQ handlers
427+
*
428+
* Defer to the timer_private dispatch API.
429+
*
430+
* FIXME: The names of these handlers are inaccurate since XL-density
431+
* devices came out. Update these to match the STM32F2 names, maybe
432+
* using some weak symbol magic to preserve backwards compatibility if
433+
* possible. Once that's done, we can just move the IRQ handlers into
434+
* the top-level libmaple/timer.c, and there will be no need for this
435+
* file.
436+
*/
437+
438+
void __irq_tim1_brk(void) {
439+
dispatch_adv_brk(TIMER1);
440+
#if STM32_HAVE_TIMER(9)
441+
dispatch_tim_9_12(TIMER9);
442+
#endif
443+
}
444+
445+
void __irq_tim1_up(void) {
446+
dispatch_adv_up(TIMER1);
447+
#if STM32_HAVE_TIMER(10)
448+
dispatch_tim_10_11_13_14(TIMER10);
449+
#endif
450+
}
451+
452+
void __irq_tim1_trg_com(void) {
453+
dispatch_adv_trg_com(TIMER1);
454+
#if STM32_HAVE_TIMER(11)
455+
dispatch_tim_10_11_13_14(TIMER11);
456+
#endif
457+
}
458+
459+
void __irq_tim1_cc(void) {
460+
dispatch_adv_cc(TIMER1);
461+
}
462+
463+
void __irq_tim2(void) {
464+
dispatch_general(TIMER2);
465+
}
466+
467+
void __irq_tim3(void) {
468+
dispatch_general(TIMER3);
469+
}
470+
471+
void __irq_tim4(void) {
472+
dispatch_general(TIMER4);
473+
}
474+
475+
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
476+
void __irq_tim5(void) {
477+
dispatch_general(TIMER5);
478+
}
479+
480+
void __irq_tim6(void) {
481+
dispatch_basic(TIMER6);
482+
}
483+
484+
void __irq_tim7(void) {
485+
dispatch_basic(TIMER7);
486+
}
487+
488+
void __irq_tim8_brk(void) {
489+
dispatch_adv_brk(TIMER8);
490+
#if STM32_HAVE_TIMER(12)
491+
dispatch_tim_9_12(TIMER12);
492+
#endif
493+
}
494+
495+
void __irq_tim8_up(void) {
496+
dispatch_adv_up(TIMER8);
497+
#if STM32_HAVE_TIMER(13)
498+
dispatch_tim_10_11_13_14(TIMER13);
499+
#endif
500+
}
501+
502+
void __irq_tim8_trg_com(void) {
503+
dispatch_adv_trg_com(TIMER8);
504+
#if STM32_HAVE_TIMER(14)
505+
dispatch_tim_10_11_13_14(TIMER14);
506+
#endif
507+
}
508+
509+
void __irq_tim8_cc(void) {
510+
dispatch_adv_cc(TIMER8);
511+
}
512+
#endif /* defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) */

STM32F1/cores/maple/libmaple/timer_f1.c

Lines changed: 6 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -30,95 +30,12 @@
3030
* @brief STM32F1 timer.
3131
*/
3232

33-
#include <libmaple/timer.h>
34-
#include <libmaple/stm32.h>
35-
#include "timer_private.h"
36-
3733
/*
38-
* IRQ handlers
39-
*
40-
* Defer to the timer_private dispatch API.
41-
*
42-
* FIXME: The names of these handlers are inaccurate since XL-density
43-
* devices came out. Update these to match the STM32F2 names, maybe
44-
* using some weak symbol magic to preserve backwards compatibility if
45-
* possible. Once that's done, we can just move the IRQ handlers into
46-
* the top-level libmaple/timer.c, and there will be no need for this
47-
* file.
34+
* 2015/07/06
35+
* Note. The IRQ handlers which were initially in this file have been moved to timer.c
36+
* to resolve a linker issue in where some IRQ handlers were not being linked even though
37+
* they were being used.
38+
* This file has been retains for historical reasons, but can be moved at some time in the future
39+
* when full testing of the code in the new location has been completed.
4840
*/
4941

50-
void __irq_tim1_brk(void) {
51-
dispatch_adv_brk(TIMER1);
52-
#if STM32_HAVE_TIMER(9)
53-
dispatch_tim_9_12(TIMER9);
54-
#endif
55-
}
56-
57-
void __irq_tim1_up(void) {
58-
dispatch_adv_up(TIMER1);
59-
#if STM32_HAVE_TIMER(10)
60-
dispatch_tim_10_11_13_14(TIMER10);
61-
#endif
62-
}
63-
64-
void __irq_tim1_trg_com(void) {
65-
dispatch_adv_trg_com(TIMER1);
66-
#if STM32_HAVE_TIMER(11)
67-
dispatch_tim_10_11_13_14(TIMER11);
68-
#endif
69-
}
70-
71-
void __irq_tim1_cc(void) {
72-
dispatch_adv_cc(TIMER1);
73-
}
74-
75-
void __irq_tim2(void) {
76-
dispatch_general(TIMER2);
77-
}
78-
79-
void __irq_tim3(void) {
80-
dispatch_general(TIMER3);
81-
}
82-
83-
void __irq_tim4(void) {
84-
dispatch_general(TIMER4);
85-
}
86-
87-
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
88-
void __irq_tim5(void) {
89-
dispatch_general(TIMER5);
90-
}
91-
92-
void __irq_tim6(void) {
93-
dispatch_basic(TIMER6);
94-
}
95-
96-
void __irq_tim7(void) {
97-
dispatch_basic(TIMER7);
98-
}
99-
100-
void __irq_tim8_brk(void) {
101-
dispatch_adv_brk(TIMER8);
102-
#if STM32_HAVE_TIMER(12)
103-
dispatch_tim_9_12(TIMER12);
104-
#endif
105-
}
106-
107-
void __irq_tim8_up(void) {
108-
dispatch_adv_up(TIMER8);
109-
#if STM32_HAVE_TIMER(13)
110-
dispatch_tim_10_11_13_14(TIMER13);
111-
#endif
112-
}
113-
114-
void __irq_tim8_trg_com(void) {
115-
dispatch_adv_trg_com(TIMER8);
116-
#if STM32_HAVE_TIMER(14)
117-
dispatch_tim_10_11_13_14(TIMER14);
118-
#endif
119-
}
120-
121-
void __irq_tim8_cc(void) {
122-
dispatch_adv_cc(TIMER8);
123-
}
124-
#endif /* defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) */

0 commit comments

Comments
 (0)