Files
panda-meb/board/body/boards/board_body.h
Jason Huang 7c0c1d956b Body v2: Hoverboard Motors (#2308)
* body

* hoverboard motors

* pass test

* body ignition exception and remove used comms

Co-authored-by: rexblade21 <zkhuang4968@gmail.com>

* send extra empty message to distinguish fingerprint

* can.h body v2 put safety hook = 1

* change v2 extra id to 0x396

* fix mirsa style error

* move ignition exception to seperate bus 2 if statement

* silence heartbeat siren on body

* turn ignition off on switch repress

* 0x250 interception in panda fw

* send extra body data, same as v1 body

* cleanup data passing for more predictable inputs and lower rpm deadband

* remove extra downscaling

* change v2 fingerprint from 0x002 to 0x222

* clean up, bus 0 ignition exception and trq mode

* keep in SPD mode for now

* remove comment

* clean

* apply suggestions

---------

Co-authored-by: stefpi <19478336+stefpi@users.noreply.github.com>
2026-04-08 09:17:01 -07:00

46 lines
1.7 KiB
C

#include "board/body/boards/board_declarations.h"
void board_body_init(void) {
// Initialize CAN pins
set_gpio_pullup(CAN_RX_PORT, CAN_RX_PIN, PULL_NONE);
set_gpio_alternate(CAN_RX_PORT, CAN_RX_PIN, GPIO_AF9_FDCAN1);
set_gpio_pullup(CAN_TX_PORT, CAN_TX_PIN, PULL_NONE);
set_gpio_alternate(CAN_TX_PORT, CAN_TX_PIN, GPIO_AF9_FDCAN1);
// Initialize button input (PC15)
set_gpio_mode(IGNITION_SW_PORT, IGNITION_SW_PIN, MODE_INPUT);
SYSCFG->EXTICR[3] &= ~(SYSCFG_EXTICR4_EXTI15);
SYSCFG->EXTICR[3] |= SYSCFG_EXTICR4_EXTI15_PC;
EXTI->PR1 = (1U << 15);
EXTI->RTSR1 |= (1U << 15);
EXTI->FTSR1 |= (1U << 15);
EXTI->IMR1 |= (1U << 15);
// Initialize barrel jack detection input (PC13)
set_gpio_pullup(CHARGING_DETECT_PORT, CHARGING_DETECT_PIN, PULL_UP);
set_gpio_mode(CHARGING_DETECT_PORT, CHARGING_DETECT_PIN, MODE_INPUT);
SYSCFG->EXTICR[3] &= ~(SYSCFG_EXTICR4_EXTI13);
SYSCFG->EXTICR[3] |= SYSCFG_EXTICR4_EXTI13_PC;
EXTI->PR1 = (1U << 13);
EXTI->RTSR1 |= (1U << 13);
EXTI->FTSR1 |= (1U << 13);
EXTI->IMR1 |= (1U << 13);
// Initialize and turn on mici power
set_gpio_mode(OBDC_POWER_ON_PORT, OBDC_POWER_ON_PIN, MODE_OUTPUT);
set_gpio_output(OBDC_POWER_ON_PORT, OBDC_POWER_ON_PIN, 1);
// Initialize and turn off gpu power
set_gpio_mode(GPU_POWER_ON_PORT, GPU_POWER_ON_PIN, MODE_OUTPUT);
set_gpio_output(GPU_POWER_ON_PORT, GPU_POWER_ON_PIN, 0);
// Initialize and turn off ignition output
set_gpio_mode(OBDC_IGNITION_ON_PORT, OBDC_IGNITION_ON_PIN, MODE_OUTPUT);
set_gpio_output(OBDC_IGNITION_ON_PORT, OBDC_IGNITION_ON_PIN, 0);
}
board board_body = {
.led_GPIO = {GPIOA, GPIOA, GPIOA},
.led_pin = {10, 10, 10},
.init = board_body_init,
};