Skip to content

Commit

Permalink
avr: fix default handler in interrupt vector
Browse files Browse the repository at this point in the history
Apparently the target of a weak symbol must be defined in the same file
as where it is used as a weak symbol.

https://www.avrfreaks.net/forum/using-weak-custom-vector-table#comment-745922
  • Loading branch information
aykevl committed Sep 24, 2018
1 parent fd6dda5 commit ddd4a39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 0 additions & 10 deletions targets/avr.S
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ init_data_end:
; need to jump.


; This is the default handler for interrupts, if triggered but not defined.
; Sleep inside so that an accidentally triggered interrupt won't drain the
; battery of a battery-powered device.
.section .text.__vector_default
.global __vector_default
__vector_default:
sleep
rjmp __vector_default


; The only thing this WDT handler really does is disable itself, to get out of
; sleep mode.
.section .text.__vector_WDT
Expand Down
9 changes: 9 additions & 0 deletions tools/gen-device-avr.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ def writeAsm(outdir, device):
; Automatically generated file. DO NOT EDIT.
; Generated by gen-device-avr.py from {file}, see {descriptorSource}
; This is the default handler for interrupts, if triggered but not defined.
; Sleep inside so that an accidentally triggered interrupt won't drain the
; battery of a battery-powered device.
.section .text.__vector_default
.global __vector_default
__vector_default:
sleep
rjmp __vector_default
; Avoid the need for repeated .weak and .set instructions.
.macro IRQ handler
.weak \\handler
Expand Down

0 comments on commit ddd4a39

Please sign in to comment.