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
Diffstat (limited to '')
-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