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
-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);
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.