aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2014-11-11 15:35:57 +0100
committerLars-Dominik Braun <lars@6xq.net>2014-11-11 15:35:57 +0100
commita7f63373bacfd36d438f11c38d5e54f48ec4f012 (patch)
treeea707c2e73faac850f00b7c0f8491b2fde8f9e2d
parenta7a45b0e710dabb267859bf8794e19eefc173a7b (diff)
downloadhourglass-a7f63373bacfd36d438f11c38d5e54f48ec4f012.tar.gz
hourglass-a7f63373bacfd36d438f11c38d5e54f48ec4f012.tar.bz2
hourglass-a7f63373bacfd36d438f11c38d5e54f48ec4f012.zip
pwm: Respect PB0/1’s value set by gyro
-rw-r--r--main.c1
-rw-r--r--pwm.c9
2 files changed, 9 insertions, 1 deletions
diff --git a/main.c b/main.c
index a69a045..51255bf 100644
--- a/main.c
+++ b/main.c
@@ -36,6 +36,7 @@ int main () {
uartInit ();
gyroInit ();
accelInit ();
+ /* pwm must be last, see pwm.c */
pwmInit ();
set_sleep_mode (SLEEP_MODE_IDLE);
diff --git a/pwm.c b/pwm.c
index 944720e..49045b4 100644
--- a/pwm.c
+++ b/pwm.c
@@ -59,7 +59,14 @@ void pwmInit () {
DDRB |= (1 << PB6) | (1 << PB7);
/* set led3,led4,led5,led6 to output */
DDRD |= (1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5);
- memset (pwmvalue, 0, sizeof (pwmvalue));
+
+ /* gyro uses pb1, get its setup; this function must be called after gyro setup */
+ const uint8_t pbdef = PORTB;
+ const uint8_t pddef = PORTD;
+ for (uint8_t i = 0; i < PWM_MAX_BRIGHTNESS; i++) {
+ pwmvalue[i][0] = pbdef;
+ pwmvalue[i][1] = pddef;
+ }
}
void pwmStart () {