diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-11-11 15:35:57 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-11-11 15:35:57 +0100 |
commit | a7f63373bacfd36d438f11c38d5e54f48ec4f012 (patch) | |
tree | ea707c2e73faac850f00b7c0f8491b2fde8f9e2d | |
parent | a7a45b0e710dabb267859bf8794e19eefc173a7b (diff) | |
download | hourglass-a7f63373bacfd36d438f11c38d5e54f48ec4f012.tar.gz hourglass-a7f63373bacfd36d438f11c38d5e54f48ec4f012.tar.bz2 hourglass-a7f63373bacfd36d438f11c38d5e54f48ec4f012.zip |
pwm: Respect PB0/1’s value set by gyro
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | pwm.c | 9 |
2 files changed, 9 insertions, 1 deletions
@@ -36,6 +36,7 @@ int main () { uartInit (); gyroInit (); accelInit (); + /* pwm must be last, see pwm.c */ pwmInit (); set_sleep_mode (SLEEP_MODE_IDLE); @@ -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 () { |