45#include <ti/drivers/PIN.h>
46#include <ti/drivers/Power.h>
47#include <ti/drivers/power/PowerCC26XX.h>
48#include <ti/drivers/pin/PINCC26XX.h>
49#include <ti/drivers/timer/GPTimerCC26XX.h>
57#error "Board file doesn't define pin Board_BUZZER"
59#define BUZZER_PIN Board_BUZZER
61static const PIN_Config pin_table[] = {
62 BUZZER_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW,
66static PIN_State pin_state;
67static PIN_Handle pin_handle;
69static GPTimerCC26XX_Handle gpt_handle;
72static volatile bool is_running;
81 GPTimerCC26XX_Params gpt_params;
82 GPTimerCC26XX_Params_init(&gpt_params);
84 gpt_params.width = GPT_CONFIG_16BIT;
85 gpt_params.mode = GPT_MODE_PWM;
86 gpt_params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
88 gpt_handle = GPTimerCC26XX_open(Board_GPTIMER0A, &gpt_params);
120 pin_handle = PIN_open(&pin_state, pin_table);
125 Power_setDependency(PowerCC26XX_XOSC_HF);
127 PINCC26XX_setMux(pin_handle, BUZZER_PIN, GPT_PIN_0A);
130 GPTimerCC26XX_Value load_value = (48 * 1000 * 1000) / freq;
132 GPTimerCC26XX_setLoadValue(gpt_handle, load_value);
133 GPTimerCC26XX_setMatchValue(gpt_handle, load_value / 2);
134 GPTimerCC26XX_start(gpt_handle);
151 Power_releaseDependency(PowerCC26XX_XOSC_HF);
153 GPTimerCC26XX_stop(gpt_handle);
155 PIN_close(pin_handle);
bool buzzer_running()
Retrieve the buzzer state.
void buzzer_stop()
Stop the buzzer.
void buzzer_init()
Initialise the buzzer.
void buzzer_start(int freq)
Start the buzzer.
Header file for the Sensortag Buzzer.