summaryrefslogtreecommitdiff
path: root/src/peripherals/avrdx-adc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/peripherals/avrdx-adc.ts')
-rw-r--r--src/peripherals/avrdx-adc.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/peripherals/avrdx-adc.ts b/src/peripherals/avrdx-adc.ts
index ed49ce6..716c4c7 100644
--- a/src/peripherals/avrdx-adc.ts
+++ b/src/peripherals/avrdx-adc.ts
@@ -3,6 +3,7 @@
import type { CPU, AVRInterruptConfig } from 'avr8js/cpu/cpu';
import type { AVRDxVREF } from './avrdx-vref';
+import { SMODE_IDLE_gc, type AVRDxSLPCTRL } from './avrdx-slpctrl';
const CTRLA = 0x0000;
const CTRLB = 0x0001;
@@ -72,7 +73,7 @@ export class AVRDxADC {
private readonly resrdyIrq: AVRInterruptConfig;
- constructor(private cpu: CPU, private base: number, resrdyIrqNo: number, private vref: AVRDxVREF) {
+ constructor(private cpu: CPU, private base: number, resrdyIrqNo: number, private vref: AVRDxVREF, private slpctrl: AVRDxSLPCTRL) {
this.resrdyIrq = {
address: resrdyIrqNo * 2, // vector 26, word addr 0x34
flagRegister: base + INTFLAGS,
@@ -117,6 +118,10 @@ export class AVRDxADC {
// RES registers - read only (but firmware can read them)
cpu.writeHooks[base + RESL] = () => true; // ignore writes
cpu.writeHooks[base + RESH] = () => true;
+
+ slpctrl.onSleep((mode) => {
+ if (mode !== SMODE_IDLE_gc) this.stop();
+ });
}
private stop() {
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.