Skip to content

Commit

Permalink
Added update_buzzer() functionality and function call
Browse files Browse the repository at this point in the history
  • Loading branch information
ejramas committed Apr 1, 2024
1 parent b0924fc commit a95a51a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions projects/centre_console/inc/cc_hw_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
#define BATT_DISP8 \
{ .port = GPIO_PORT_A, .pin = 8 }

// Buzzer
#define FAULT_BUZZ \
{ .port = GPIO_PORT_B, .pin = 7 }

// All displays
#define ALL_DISPLAYS \
{ \
Expand Down
1 change: 1 addition & 0 deletions projects/centre_console/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void run_medium_cycle() {
update_indicators(notif);
monitor_cruise_control();
fsm_run_cycle(drive);
update_buzzer();
wait_tasks(1);

update_drive_output(notif);
Expand Down
17 changes: 13 additions & 4 deletions projects/centre_console/src/update_dashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "centre_console_getters.h"
#include "centre_console_setters.h"
#include "drive_fsm.h"
#include "gpio.h"
#include "pca9555_gpio_expander.h"
#include "pwm.h"
#include "seg_display.h"

// Multiplication factor to convert CAN drive output velocity (cm/s) to kph
Expand Down Expand Up @@ -172,10 +174,12 @@ void update_drive_output(uint32_t notif) {
}

void update_buzzer() {
if (get_battery_status_fault() && (1 << 15)) {
// set PB7 PMW high
} else if ((get_battery_status_fault() && (1 << 14))) {
// set PB7 PMW low
if (get_battery_status_fault() & (1 << 15)) {
pmw_set_dc(PWM_TIMER_4, 100);
} else if ((get_battery_status_fault() & (1 << 14))) {
pmw_set_dc(PWM_TIMER_4, 50);
} else {
pmw_set_dc(PWM_TIMER_4, 0);
}
}

Expand All @@ -189,5 +193,10 @@ StatusCode dashboard_init(void) {
}
seg_displays_init(&all_displays);
pca9555_gpio_set_state(&s_output_leds[REGEN_LED], PCA9555_GPIO_STATE_HIGH);

gpio_init_();
gpio_init_pin(&FAULT_BUZZ, GPIO_ALTFN_PUSH_PULL, GPIO_STATE_HIGH);
pwm_init(PWM_TIMER_4, 40);

return STATUS_CODE_OK;
}

0 comments on commit a95a51a

Please sign in to comment.