Browse Source

boards: chronos: convert buzzer to use xtimer

dev/timer
Kaspar Schleiser 8 years ago
parent
commit
b0892c781f
  1. 6
      boards/chronos/drivers/buzzer.c
  2. 4
      boards/chronos/drivers/include/buzzer.h

6
boards/chronos/drivers/buzzer.c

@ -26,9 +26,9 @@
#include <cc430f6137.h>
#include "buzzer.h"
#include "hwtimer.h"
#include "xtimer.h"
void buzzer_beep(uint8_t pitch, uint16_t duration)
void buzzer_beep(uint8_t pitch, uint32_t duration)
{
// Reset TA1R, set up mode, TA1 runs from 32768Hz ACLK
TA1CTL = TACLR | MC_1 | TASSEL__ACLK;
@ -42,7 +42,7 @@ void buzzer_beep(uint8_t pitch, uint16_t duration)
// Allow buzzer PWM output on P2.7
P2SEL |= BIT7;
hwtimer_wait(duration);
xtimer_usleep(duration);
// Stop PWM timer
TA1CTL &= ~(BIT4 | BIT5);

4
boards/chronos/drivers/include/buzzer.h

@ -9,11 +9,13 @@
#ifndef BUZZER_H_
#define BUZZER_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
void buzzer_beep(uint8_t pitch, uint16_t duration);
void buzzer_beep(uint8_t pitch, uint32_t duration);
#ifdef __cplusplus
}

Loading…
Cancel
Save