Simplify GETPC()
This commit is contained in:
parent
6ce7792045
commit
f25bddce35
@ -990,7 +990,7 @@ void __attribute__((noinline)) serial_dump_and_reset(dump_crash_reason reason)
|
|||||||
|
|
||||||
// sample SP/PC
|
// sample SP/PC
|
||||||
sp = SP;
|
sp = SP;
|
||||||
GETPC(&pc);
|
pc = GETPC();
|
||||||
|
|
||||||
// extend WDT long enough to allow writing the entire stream
|
// extend WDT long enough to allow writing the entire stream
|
||||||
wdt_enable(WDTO_8S);
|
wdt_enable(WDTO_8S);
|
||||||
|
@ -1,24 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
#ifdef __AVR_ATmega2560__
|
#ifdef __AVR_ATmega2560__
|
||||||
|
|
||||||
// return the current PC (on AVRs with 22bit PC)
|
// return the current PC (on AVRs with 22bit PC)
|
||||||
static inline void GETPC(uint32_t* v)
|
FORCE_INLINE __uint24 GETPC(void)
|
||||||
{
|
{
|
||||||
uint8_t a, b, c;
|
__uint24 ret;
|
||||||
asm
|
asm (
|
||||||
(
|
|
||||||
"rcall .\n"
|
"rcall .\n"
|
||||||
"pop %2\n"
|
"pop %A0\n"
|
||||||
"pop %1\n"
|
"pop %B0\n"
|
||||||
"pop %0\n"
|
"pop %C0\n"
|
||||||
: "=r" (a), "=r" (b), "=r" (c)
|
: "=&r" (ret)
|
||||||
);
|
);
|
||||||
((uint8_t*)v)[0] = a;
|
return ret;
|
||||||
((uint8_t*)v)[1] = b;
|
|
||||||
((uint8_t*)v)[2] = c;
|
|
||||||
((uint8_t*)v)[3] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,7 +59,7 @@ static void __attribute__((noinline)) xfdump_dump_core(dump_header_t& hdr, uint3
|
|||||||
|
|
||||||
// sample SP/PC
|
// sample SP/PC
|
||||||
hdr.sp = SP;
|
hdr.sp = SP;
|
||||||
GETPC(&hdr.pc);
|
hdr.pc = GETPC();
|
||||||
|
|
||||||
// write header
|
// write header
|
||||||
static_assert(sizeof(hdr) <= 256, "header is larger than a single page write");
|
static_assert(sizeof(hdr) <= 256, "header is larger than a single page write");
|
||||||
|
Loading…
Reference in New Issue
Block a user