Browse Source

add possibility to change buzzer freq (original contrib by fertito)

master-old
Marc 13 years ago
parent
commit
b52996b126
  1. 4
      driver/buzzer.c
  2. 4
      driver/buzzer.h

4
driver/buzzer.c

@ -82,6 +82,8 @@ void reset_buzzer(void)
{
sBuzzer.time = 0;
sBuzzer.state = BUZZER_OFF;
sBuzzer.steps = BUZZER_TIMER_STEPS;
}
// *************************************************************************************************
@ -107,7 +109,7 @@ void start_buzzer(u8 cycles, u16 on_time, u16 off_time)
TA1CTL = TACLR | MC_1 | TASSEL__ACLK;
// Set PWM frequency
TA1CCR0 = BUZZER_TIMER_STEPS;
TA1CCR0 = sBuzzer.steps;
// Enable IRQ, set output mode "toggle"
TA1CCTL0 = OUTMOD_4;

4
driver/buzzer.h

@ -87,6 +87,10 @@ struct buzzer
// Current buzzer output state
u8 state;
// Current steps (~freq)
u8 steps;
};
extern struct buzzer sBuzzer;

Loading…
Cancel
Save