aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorApexo2026-04-03 19:32:36 +0200
committerApexo2026-04-03 19:32:36 +0200
commit73106d1c66b0a172a3ec4b251a70cf119ae1dbdd (patch)
tree27c07b7afd9a436cb240ffabd222588c4a25cce3
parentavr32dd20 compat, onSleep hook (diff)
downloadavr8js-73106d1c66b0a172a3ec4b251a70cf119ae1dbdd.tar.gz
avr8js-73106d1c66b0a172a3ec4b251a70cf119ae1dbdd.tar.bz2
avr8js-73106d1c66b0a172a3ec4b251a70cf119ae1dbdd.zip
onBeforeInterrupt callbackavr32dd20
Diffstat (limited to '')
-rw-r--r--src/cpu/cpu.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cpu/cpu.ts b/src/cpu/cpu.ts
index 6da0fee..1237f0a 100644
--- a/src/cpu/cpu.ts
+++ b/src/cpu/cpu.ts
@@ -94,6 +94,12 @@ export class CPU {
};
/**
+ * This function is called before handling an interrupt. Useful for clearing sleep
+ * states.
+ */
+ onBeforeInterrupt = () => {};
+
+ /**
* Program counter
*/
pc: u32 = 0;
@@ -291,6 +297,7 @@ export class CPU {
const { nextInterrupt } = this;
if (this.interruptsEnabled && nextInterrupt >= 0) {
const interrupt = this.pendingInterrupts[nextInterrupt]!;
+ this.onBeforeInterrupt();
avrInterrupt(this, interrupt.address);
if (!interrupt.constant) {
this.clearInterrupt(interrupt);