summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-09-18 14:26:18 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-09-18 14:50:20 -0400
commit9baec592172efc3e21d93c7b0807fdffe2646ade (patch)
tree0da40230fd41daf00e19b3b049e9533020c54edc
parent5ff4a88374986f3e74dd17f2c17b8532c88debb1 (diff)
downloadSensor-Watch-9baec592172efc3e21d93c7b0807fdffe2646ade.tar.gz
Sensor-Watch-9baec592172efc3e21d93c7b0807fdffe2646ade.tar.bz2
Sensor-Watch-9baec592172efc3e21d93c7b0807fdffe2646ade.zip
support common anode LEDs
-rw-r--r--watch-library/watch/watch_private.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/watch-library/watch/watch_private.c b/watch-library/watch/watch_private.c
index d3da5426..bdf6b78a 100644
--- a/watch-library/watch/watch_private.c
+++ b/watch-library/watch/watch_private.c
@@ -88,6 +88,11 @@ void _watch_enable_tcc() {
// period (i.e. a square wave with a 50% duty cycle).
// * LEDs on CC[2] and CC[3] can be set to any value from 0 (off) to PER (fully on).
hri_tcc_write_WAVE_reg(TCC0, TCC_WAVE_WAVEGEN_NPWM);
+ #ifdef WATCH_INVERT_LED_POLARITY
+ // This is here for the dev board, which uses a common anode LED (instead of common cathode like the actual watch).
+ hri_tcc_set_WAVE_reg(TCC0, (1 << (TCC_WAVE_POL0_Pos + WATCH_RED_TCC_CHANNEL)) |
+ (1 << (TCC_WAVE_POL0_Pos + WATCH_GREEN_TCC_CHANNEL)));
+ #endif
// The buzzer will set the period depending on the tone it wants to play, but we have to set some period here to
// get the LED working. Almost any period will do, tho it should be below 20000 (i.e. 50 Hz) to avoid flickering.
hri_tcc_write_PER_reg(TCC0, 4096);