aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Hart2021-08-20 09:48:04 -0500
committerGabriel Hart2021-08-20 09:48:04 -0500
commit02d197fdf6d6294e3aeb392f427c5acc3a0c475d (patch)
treed40717830cd78f1c6f7fbeb4e07ba5d1c087463a
parentAdjusted more Sofirn SP10 config values (party strobe, candle amp, max_1x7135) (diff)
downloadanduril-02d197fdf6d6294e3aeb392f427c5acc3a0c475d.tar.gz
anduril-02d197fdf6d6294e3aeb392f427c5acc3a0c475d.tar.bz2
anduril-02d197fdf6d6294e3aeb392f427c5acc3a0c475d.zip
from Tom E, support PB4 for any of the 3 PWM channels
-rw-r--r--spaghetti-monster/fsm-main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c
index f3c319c..2015563 100644
--- a/spaghetti-monster/fsm-main.c
+++ b/spaghetti-monster/fsm-main.c
@@ -46,17 +46,28 @@ static inline void hw_setup() {
DDRB |= (1 << PWM1_PIN);
TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...)
TCCR0A = PHASE;
+ #if (PWM1_PIN == PB4) // Second PWM counter is ... weird
+ TCCR1 = _BV (CS10);
+ GTCCR = _BV (COM1B1) | _BV (PWM1B);
+ OCR1C = 255; // Set ceiling value to maximum
+ #endif
#endif
#if PWM_CHANNELS >= 2
DDRB |= (1 << PWM2_PIN);
+ #if (PWM2_PIN == PB4) // Second PWM counter is ... weird
+ TCCR1 = _BV (CS10);
+ GTCCR = _BV (COM1B1) | _BV (PWM1B);
+ OCR1C = 255; // Set ceiling value to maximum
+ #endif
#endif
#if PWM_CHANNELS >= 3
- // Second PWM counter is ... weird
DDRB |= (1 << PWM3_PIN);
+ #if (PWM3_PIN == PB4) // Second PWM counter is ... weird
TCCR1 = _BV (CS10);
GTCCR = _BV (COM1B1) | _BV (PWM1B);
OCR1C = 255; // Set ceiling value to maximum
#endif
+ #endif
#if PWM_CHANNELS >= 4
// 4th PWM channel is ... not actually supported in hardware :(
DDRB |= (1 << PWM4_PIN);
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.