Skip to content

Commit

Permalink
finish esp/gps removal (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored Aug 6, 2023
1 parent d2d207b commit c66b98b
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 644 deletions.
43 changes: 10 additions & 33 deletions board/boards/black.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,10 @@ void black_set_led(uint8_t color, bool enabled) {
}
}

void black_set_gps_load_switch(bool enabled) {
set_gpio_output(GPIOC, 12, enabled);
}

void black_set_usb_load_switch(bool enabled) {
set_gpio_output(GPIOB, 1, !enabled);
}

void black_set_gps_mode(uint8_t mode) {
switch (mode) {
case GPS_DISABLED:
// GPS OFF
set_gpio_output(GPIOC, 12, 0);
set_gpio_output(GPIOC, 5, 0);
break;
case GPS_ENABLED:
// GPS ON
set_gpio_output(GPIOC, 12, 1);
set_gpio_output(GPIOC, 5, 1);
break;
case GPS_BOOTMODE:
set_gpio_output(GPIOC, 12, 1);
set_gpio_output(GPIOC, 5, 0);
break;
default:
print("Invalid GPS mode\n");
break;
}
}

void black_set_can_mode(uint8_t mode){
switch (mode) {
case CAN_MODE_NORMAL:
Expand Down Expand Up @@ -124,8 +98,9 @@ void black_init(void) {
set_gpio_mode(GPIOC, 0, MODE_ANALOG);
set_gpio_mode(GPIOC, 3, MODE_ANALOG);

// Set default state of GPS
current_board->set_gps_mode(GPS_ENABLED);
// GPS OFF
set_gpio_output(GPIOC, 5, 0);
set_gpio_output(GPIOC, 12, 0);

// C10: OBD_SBU1_RELAY (harness relay driving output)
// C11: OBD_SBU2_RELAY (harness relay driving output)
Expand All @@ -136,9 +111,6 @@ void black_init(void) {
set_gpio_output(GPIOC, 10, 1);
set_gpio_output(GPIOC, 11, 1);

// Turn on GPS load switch.
black_set_gps_load_switch(true);

// Turn on USB load switch.
black_set_usb_load_switch(true);

Expand All @@ -165,6 +137,12 @@ void black_init(void) {
}
}

void black_init_bootloader(void) {
// GPS OFF
set_gpio_output(GPIOC, 5, 0);
set_gpio_output(GPIOC, 12, 0);
}

const harness_configuration black_harness_config = {
.has_harness = true,
.GPIO_SBU1 = GPIOC,
Expand All @@ -183,7 +161,6 @@ const board board_black = {
.board_type = "Black",
.board_tick = unused_board_tick,
.harness_config = &black_harness_config,
.has_gps = true,
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
Expand All @@ -195,10 +172,10 @@ const board board_black = {
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 0U,
.init = black_init,
.init_bootloader = black_init_bootloader,
.enable_can_transceiver = black_enable_can_transceiver,
.enable_can_transceivers = black_enable_can_transceivers,
.set_led = black_set_led,
.set_gps_mode = black_set_gps_mode,
.set_can_mode = black_set_can_mode,
.check_ignition = black_check_ignition,
.read_current = unused_read_current,
Expand Down
10 changes: 2 additions & 8 deletions board/boards/board_declarations.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// ******************** Prototypes ********************
typedef void (*board_init)(void);
typedef void (*board_init_bootloader)(void);
typedef void (*board_enable_can_transceiver)(uint8_t transceiver, bool enabled);
typedef void (*board_enable_can_transceivers)(bool enabled);
typedef void (*board_set_led)(uint8_t color, bool enabled);
typedef void (*board_set_gps_mode)(uint8_t mode);
typedef void (*board_set_can_mode)(uint8_t mode);
typedef bool (*board_check_ignition)(void);
typedef uint32_t (*board_read_current)(void);
Expand All @@ -17,7 +17,6 @@ typedef bool (*board_read_som_gpio)(void);
struct board {
const char *board_type;
const harness_configuration *harness_config;
const bool has_gps;
const bool has_hw_gmlan;
const bool has_obd;
const bool has_lin;
Expand All @@ -29,10 +28,10 @@ struct board {
const bool fan_stall_recovery;
const uint8_t fan_enable_cooldown_time;
board_init init;
board_init_bootloader init_bootloader;
board_enable_can_transceiver enable_can_transceiver;
board_enable_can_transceivers enable_can_transceivers;
board_set_led set_led;
board_set_gps_mode set_gps_mode;
board_set_can_mode set_can_mode;
board_check_ignition check_ignition;
board_read_current read_current;
Expand Down Expand Up @@ -68,11 +67,6 @@ struct board {
#define USB_POWER_CDP 2U
#define USB_POWER_DCP 3U

// GPS modes
#define GPS_DISABLED 0U
#define GPS_ENABLED 1U
#define GPS_BOOTMODE 2U

// CAN modes
#define CAN_MODE_NORMAL 0U
#define CAN_MODE_GMLAN_CAN2 1U
Expand Down
3 changes: 1 addition & 2 deletions board/boards/dos.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ const board board_dos = {
.board_type = "Dos",
.board_tick = dos_board_tick,
.harness_config = &dos_harness_config,
.has_gps = false,
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
Expand All @@ -222,10 +221,10 @@ const board board_dos = {
.fan_stall_recovery = true,
.fan_enable_cooldown_time = 3U,
.init = dos_init,
.init_bootloader = unused_init_bootloader,
.enable_can_transceiver = dos_enable_can_transceiver,
.enable_can_transceivers = dos_enable_can_transceivers,
.set_led = dos_set_led,
.set_gps_mode = unused_set_gps_mode,
.set_can_mode = dos_set_can_mode,
.check_ignition = dos_check_ignition,
.read_current = unused_read_current,
Expand Down
34 changes: 2 additions & 32 deletions board/boards/grey.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,10 @@

// Most hardware functionality is similar to white panda

void grey_init(void) {
white_grey_common_init();

// Set default state of GPS
current_board->set_gps_mode(GPS_ENABLED);
}

void grey_set_gps_mode(uint8_t mode) {
switch (mode) {
case GPS_DISABLED:
// GPS OFF
set_gpio_output(GPIOC, 14, 0);
set_gpio_output(GPIOC, 5, 0);
break;
case GPS_ENABLED:
// GPS ON
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 1);
break;
case GPS_BOOTMODE:
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 0);
break;
default:
print("Invalid ESP/GPS mode\n");
break;
}
}

const board board_grey = {
.board_type = "Grey",
.board_tick = unused_board_tick,
.harness_config = &white_harness_config,
.has_gps = true,
.has_hw_gmlan = true,
.has_obd = false,
.has_lin = true,
Expand All @@ -48,11 +18,11 @@ const board board_grey = {
.avdd_mV = 3300U,
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 0U,
.init = grey_init,
.init = white_grey_init,
.init_bootloader = white_grey_init_bootloader,
.enable_can_transceiver = white_enable_can_transceiver,
.enable_can_transceivers = white_enable_can_transceivers,
.set_led = white_set_led,
.set_gps_mode = grey_set_gps_mode,
.set_can_mode = white_set_can_mode,
.check_ignition = white_check_ignition,
.read_current = white_read_current,
Expand Down
8 changes: 1 addition & 7 deletions board/boards/pedal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ void pedal_set_led(uint8_t color, bool enabled) {
}
}

void pedal_set_gps_mode(uint8_t mode) {
UNUSED(mode);
print("Trying to set ESP/GPS mode on pedal. This is not supported.\n");
}

void pedal_set_can_mode(uint8_t mode){
switch (mode) {
case CAN_MODE_NORMAL:
Expand Down Expand Up @@ -75,7 +70,6 @@ const board board_pedal = {
.board_type = "Pedal",
.board_tick = unused_board_tick,
.harness_config = &pedal_harness_config,
.has_gps = false,
.has_hw_gmlan = false,
.has_obd = false,
.has_lin = false,
Expand All @@ -87,10 +81,10 @@ const board board_pedal = {
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 0U,
.init = pedal_init,
.init_bootloader = unused_init_bootloader,
.enable_can_transceiver = pedal_enable_can_transceiver,
.enable_can_transceivers = pedal_enable_can_transceivers,
.set_led = pedal_set_led,
.set_gps_mode = pedal_set_gps_mode,
.set_can_mode = pedal_set_can_mode,
.check_ignition = pedal_check_ignition,
.read_current = unused_read_current,
Expand Down
3 changes: 1 addition & 2 deletions board/boards/red.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ const board board_red = {
.board_type = "Red",
.board_tick = unused_board_tick,
.harness_config = &red_harness_config,
.has_gps = false,
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
Expand All @@ -182,10 +181,10 @@ const board board_red = {
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 0U,
.init = red_init,
.init_bootloader = unused_init_bootloader,
.enable_can_transceiver = red_enable_can_transceiver,
.enable_can_transceivers = red_enable_can_transceivers,
.set_led = red_set_led,
.set_gps_mode = unused_set_gps_mode,
.set_can_mode = red_set_can_mode,
.check_ignition = red_check_ignition,
.read_current = unused_read_current,
Expand Down
3 changes: 1 addition & 2 deletions board/boards/red_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const board board_red_v2 = {
.board_type = "Red_v2",
.board_tick = unused_board_tick,
.harness_config = &red_chiplet_harness_config,
.has_gps = false,
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
Expand All @@ -26,10 +25,10 @@ const board board_red_v2 = {
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 0U,
.init = red_panda_v2_init,
.init_bootloader = unused_init_bootloader,
.enable_can_transceiver = red_chiplet_enable_can_transceiver,
.enable_can_transceivers = red_chiplet_enable_can_transceivers,
.set_led = red_set_led,
.set_gps_mode = unused_set_gps_mode,
.set_can_mode = red_set_can_mode,
.check_ignition = red_check_ignition,
.read_current = unused_read_current,
Expand Down
3 changes: 1 addition & 2 deletions board/boards/tres.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const board board_tres = {
.board_type = "Tres",
.board_tick = tres_board_tick,
.harness_config = &red_chiplet_harness_config,
.has_gps = false,
.has_hw_gmlan = false,
.has_obd = true,
.has_lin = false,
Expand All @@ -101,10 +100,10 @@ const board board_tres = {
.fan_stall_recovery = false,
.fan_enable_cooldown_time = 3U,
.init = tres_init,
.init_bootloader = unused_init_bootloader,
.enable_can_transceiver = red_chiplet_enable_can_transceiver,
.enable_can_transceivers = red_chiplet_enable_can_transceivers,
.set_led = red_set_led,
.set_gps_mode = unused_set_gps_mode,
.set_can_mode = red_set_can_mode,
.check_ignition = red_check_ignition,
.read_current = unused_read_current,
Expand Down
Loading

0 comments on commit c66b98b

Please sign in to comment.