Skip to content

Commit

Permalink
Ensure buzzer data does not go out of scope
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgecrw committed Oct 27, 2023
1 parent b4ab5a4 commit f8d6366
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions software/firmware/src/peripherals/src/buzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@

// Static Global Variables ---------------------------------------------------------------------------------------------

static const uint16_t unplugged_frequencies[] = { 1760, 1, 1320, 1, 1110, 1, 880, 0 };
static const uint16_t unplugged_durations[] = { 100, 10, 100, 10, 100, 10, 100 };
static const uint16_t plugged_frequencies[] = { 880, 1, 1110, 1, 1320, 1, 1760, 0 };
static const uint16_t plugged_durations[] = { 100, 10, 100, 10, 100, 10, 100 };
static const uint16_t invalid_rtc_frequencies[] = { 760, 1, 760, 0 };
static const uint16_t invalid_rtc_durations[] = { 100, 100, 400 };
static const uint16_t error_frequencies[] = { 880, 1, 587, 0 };
static const uint16_t error_durations[] = { 300, 100, 500 };
static const uint16_t locator_frequencies[] = { 1047, 1, 1047, 830, 1, 880, 698, 0 };
static const uint16_t locator_durations[] = { 100, 100, 100, 100, 100, 100, 200 };

static am_hal_timer_config_t timer_config;
static volatile const uint16_t *current_frequency, *current_duration;
static volatile uint32_t interrupt_counter_index, interrupt_counter_max;
Expand Down Expand Up @@ -124,8 +135,6 @@ void buzzer_deinit(void)

void buzzer_indicate_plugged_in(void)
{
const uint16_t plugged_frequencies[] = { 880, 1, 1110, 1, 1320, 1, 1760, 0 };
const uint16_t plugged_durations[] = { 100, 10, 100, 10, 100, 10, 100 };
if (!current_frequency)
{
current_frequency = plugged_frequencies;
Expand All @@ -136,8 +145,6 @@ void buzzer_indicate_plugged_in(void)

void buzzer_indicate_unplugged(void)
{
const uint16_t unplugged_frequencies[] = { 1760, 1, 1320, 1, 1110, 1, 880, 0 };
const uint16_t unplugged_durations[] = { 100, 10, 100, 10, 100, 10, 100 };
if (!current_frequency)
{
current_frequency = unplugged_frequencies;
Expand All @@ -148,8 +155,6 @@ void buzzer_indicate_unplugged(void)

void buzzer_indicate_invalid_rtc_time(void)
{
const uint16_t invalid_rtc_frequencies[] = { 760, 1, 760, 0 };
const uint16_t invalid_rtc_durations[] = { 100, 100, 400 };
if (!current_frequency)
{
current_frequency = invalid_rtc_frequencies;
Expand All @@ -160,8 +165,6 @@ void buzzer_indicate_invalid_rtc_time(void)

void buzzer_indicate_error(void)
{
const uint16_t error_frequencies[] = { 880, 1, 587, 0 };
const uint16_t error_durations[] = { 300, 100, 500 };
if (!current_frequency)
{
current_frequency = error_frequencies;
Expand All @@ -172,8 +175,6 @@ void buzzer_indicate_error(void)

void buzzer_indicate_location(void)
{
const uint16_t locator_frequencies[] = { 1047, 1, 1047, 830, 1, 880, 698, 0 };
const uint16_t locator_durations[] = { 100, 100, 100, 100, 100, 100, 200 };
if (!current_frequency)
{
current_frequency = locator_frequencies;
Expand Down

0 comments on commit f8d6366

Please sign in to comment.