aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-07-30 20:15:06 -0600
committerSelene ToyKeeper2019-07-30 20:15:06 -0600
commit775a114098b9db17fe52ddff5ed080e0b24e5a38 (patch)
tree60553b7ee6ff68a454c69b7ed5409f5ce7008e5a
parentadded an early version of Emisar D1S v2 hwdef and cfg files (diff)
downloadanduril-775a114098b9db17fe52ddff5ed080e0b24e5a38.tar.gz
anduril-775a114098b9db17fe52ddff5ed080e0b24e5a38.tar.bz2
anduril-775a114098b9db17fe52ddff5ed080e0b24e5a38.zip
fsm-ramping: turn opamp chip on and off automatically based on ramp level
-rw-r--r--hwdef-Emisar_D1Sv2.h3
-rw-r--r--spaghetti-monster/fsm-ramping.c9
2 files changed, 11 insertions, 1 deletions
diff --git a/hwdef-Emisar_D1Sv2.h b/hwdef-Emisar_D1Sv2.h
index c51e827..6895e73 100644
--- a/hwdef-Emisar_D1Sv2.h
+++ b/hwdef-Emisar_D1Sv2.h
@@ -51,7 +51,8 @@
#define PWM1_PIN PB3 // pin 16, Opamp reference
#define PWM1_LVL OCR1A // OCR1A is the output compare register for PB3
-#define LED_ENABLE_PIN PB0 // pin 19, Opamp power
+#define LED_ENABLE_PIN PB0 // pin 19, Opamp power
+#define LED_ENABLE_PORT PORTB // control port for PB0
//#define PWM2_PIN PB0 // pin 19, Opamp power
// FIXME:
//#define PWM2_LVL OCR1B // OCR1B is the output compare register for PB1
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index 69e20bc..52a7246 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -65,9 +65,18 @@ void set_level(uint8_t level) {
#if PWM_CHANNELS >= 4
PWM4_LVL = 0;
#endif
+ // disable the power channel, if relevant
+ #ifdef LED_ENABLE_PIN
+ LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN);
+ #endif
} else {
level --;
+ // enable the power channel, if relevant
+ #ifdef LED_ENABLE_PIN
+ LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN);
+ #endif
+
#ifdef USE_TINT_RAMPING
// calculate actual PWM levels based on a single-channel ramp
// and a global tint value
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.