Conversation
6aec3bf to
47caf95
Compare
board/boards/body.h
Outdated
There was a problem hiding this comment.
you shouldn't need this one. this is for pandas
board/body/boards/motor_control.h
Outdated
| // M1 drive: PB8 -> TIM16_CH1, PB9 -> TIM17_CH1, PE2/PE3 enables | ||
| // M2 drive: PA2 -> TIM15_CH1, PA3 -> TIM15_CH2, PE8/PE9 enables | ||
|
|
||
| #ifndef MOTOR_PWM_TIMER_CLOCK_HZ |
There was a problem hiding this comment.
what's up with all the ifndef??
board/body/boards/motor_control.h
Outdated
| #define MOTOR_SPEED_CONTROL_UPDATE_PERIOD_US 1000U | ||
| #endif | ||
|
|
||
| #define MOTOR_CONTROL_UNUSED __attribute__((unused)) |
adeebshihadeh
left a comment
There was a problem hiding this comment.
Let's clean this up and get it merged as clean base FW that just runs on the body board, then we can add the rest of the functionality in smaller followup PRs.
board/body/boards/board_body.h
Outdated
| void board_body_init_bootloader(void) { | ||
| } | ||
|
|
||
| void board_body_tick(void) { | ||
| } |
There was a problem hiding this comment.
remove all these things that are unused. the board struct isn't the same as panda's so you don't have to populate all these unused fields
board/body/boards/board_body.h
Outdated
| // Body board: PD0 (RX), PD1 (TX) | ||
| set_gpio_pullup(GPIOD, 0, PULL_NONE); | ||
| set_gpio_alternate(GPIOD, 0, GPIO_AF9_FDCAN1); |
board/body/boards/board_body.h
Outdated
| uint32_t board_body_read_voltage_mV(void) { | ||
| return 0U; | ||
| } | ||
|
|
||
| uint32_t board_body_read_current_mA(void) { | ||
| return 0U; | ||
| } |
|
|
||
| // ******************* Definitions ******************** | ||
| #define HW_TYPE_UNKNOWN 0U | ||
| #define HW_TYPE_BODY 0xB0U |
There was a problem hiding this comment.
i like the b prefix. let's call it 0xb1 or 0xb2 though?
There was a problem hiding this comment.
we should pull out all these common ones between panda, jungle, and body. but we can do that in a followup
board/stm32h7/peripherals.h
Outdated
| // Body board: PD0 (RX), PD1 (TX) | ||
| set_gpio_pullup(GPIOD, 0, PULL_NONE); | ||
| set_gpio_alternate(GPIOD, 0, GPIO_AF9_FDCAN1); | ||
|
|
||
| set_gpio_pullup(GPIOD, 1, PULL_NONE); | ||
| set_gpio_alternate(GPIOD, 1, GPIO_AF9_FDCAN1); |
There was a problem hiding this comment.
can you do this in the board init?
board/body/boards/board_body.h
Outdated
| void board_body_set_can_mode(uint8_t mode) { | ||
| if (mode == CAN_MODE_NORMAL) { |
There was a problem hiding this comment.
doesn't need (or have) modes
board/body/__init__.py
Outdated
| # ****************** Motor Control ***************** | ||
|
|
||
| def motor_set_speed(self, motor: int, speed: int) -> None: | ||
| assert motor in (1, 2), "motor must be 1 or 2" |
There was a problem hiding this comment.
we should make nice enums for the motors. like which one is 1 and 2?
board/body/boards/motor_encoder.h
Outdated
There was a problem hiding this comment.
this should go up one level. the boards/ folder is for different body motherboards
board/body/boards/motor_control.h
Outdated
| const uint8_t led_pin[3]; | ||
| const uint8_t led_pwm_channels[3]; // leave at 0 to disable PWM | ||
| board_init init; | ||
| board_init_bootloader init_bootloader; |
There was a problem hiding this comment.
this is unused, along with a bunch of other stuff
There was a problem hiding this comment.
compile errors if we remove init_bootloader and led driver requires pwm channels to be declared. removed all other unused
|
@rexblade21 This is pretty close, but there's still a decent amount to trim here. Before requesting another review, I recommend talking to an LLM about the PR, e.g. "Do you see any way we can simplify parts of this diff?" |
| .led_GPIO = {GPIOC, GPIOC, GPIOC}, | ||
| .led_pin = {7, 7, 7}, |
There was a problem hiding this comment.
this is confusing but i assume done to maintain compatibility with panda? if so, leave a comment
also, do we only have a single color LED?
There was a problem hiding this comment.
yes to maintain compatibility with led driver. and yes
given that its just a single blinking heartbeat led, we don't really have to use the led driver?
board/body/boards/board_body.h
Outdated
| .led_pin = {7, 7, 7}, | ||
| .init = board_body_init, | ||
| .enable_can_transceiver = board_body_enable_can_transceiver, | ||
| .has_spi = false, |
|
|
||
| // ******************** Prototypes ******************** | ||
| typedef void (*board_init)(void); | ||
| typedef void (*board_init_bootloader)(void); |
There was a problem hiding this comment.
./board/early_init.h: In function 'early_initialization':
./board/early_init.h:56:3: error: implicit declaration of function 'detect_board_type' [-Werror=implicit-function-declaration]
56 | detect_board_type();
seems to be required for early_init. moving to board_body.h
board/body/can.h
Outdated
| if (!body_can_bus_ready(bus)) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
does this matter? don't we just recover anyway? or is this to prevent bus off such that we don't need to recover?
board/drivers/fdcan.h
Outdated
|
|
||
| safety_rx_invalid += safety_rx_hook(&to_push) ? 0U : 1U; | ||
| #ifdef PANDA_BODY | ||
| body_can_safety_rx(&to_push); |
There was a problem hiding this comment.
this should just be safety_rx_hook
|
You need to ignore the body for the MISRA mutation tests: https://github.com/commaai/panda/actions/runs/18775663943/job/53570424244?pr=2291 |
* motors * can * cleanup unused stuff * initial clean * more clean * remove integral and derivative clamps, revert pwm driver to original * remove integral and derivative clamps, revert pwm driver to original * remove integral and derivative clamps, revert pwm driver to original * dont need this for now * clean * fix can rx and can version error * ignore body for misra mutation test * fix bus recovery, remove body rx hook
* spi debug (commaai#2292) Co-authored-by: Comma Device <device@comma.ai> * Add comma body firmware (commaai#2291) * motors * can * cleanup unused stuff * initial clean * more clean * remove integral and derivative clamps, revert pwm driver to original * remove integral and derivative clamps, revert pwm driver to original * remove integral and derivative clamps, revert pwm driver to original * dont need this for now * clean * fix can rx and can version error * ignore body for misra mutation test * fix bus recovery, remove body rx hook * SocketPanda improvements (commaai#2297) * SocketPanda improvements * implement timeouts * Fix mcu_type for deprecated pandas (commaai#2296) * skip 1024 samples to settle, around 22ms (commaai#2295) * skip 1024 samples to settle, around 22ms * smaller diff * Fix mcu_type in jungle (commaai#2300) should fix jungle * Cuatro siren (commaai#2294) * Fix siren * fix MISRA * remove MISRA suppression * disable amp * fix rebase mistake * fix fault * diff audio * misra --------- Co-authored-by: Comma Device <device@comma.ai> * add double buffer for microphone (commaai#2299) * add double buffer for microphone * comment * fix size check * Revert `mcu_type` changes (commaai#2303) * Revert "Fix mcu_type for deprecated pandas (commaai#2296)" This reverts commit 6c9064c. * Revert "Fix mcu_type in jungle (commaai#2300)" This reverts commit 1e8fa51. * it's just unsupported * cleanup fan scripts * garbage collect always-true condition check (commaai#2305) garbage collect dead code * CI: use tags for cppcheck update cppcheck doesn't always create a release for each tag * lil more * Adjust `gitversion` handling to include null terminator in length calculations. (commaai#2309) Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * fix up fan HITL test (commaai#2317) * fix up fan HITL test * cleanup * times two * even simpler * append * one more... * speed it up now * oops * Build everything before jungle recover (commaai#2316) * make sure everything is built, including the bootloader * also for flash * Align delay and compensate (commaai#2318) * align delay and compensate * empty * rm -rf drivers/spi/; kernel driver isn't needed * [bot] Update cppcheck to 2.19.1 (commaai#2254) * [bot] Update cppcheck to 2.19.1 * update coverage table --------- Co-authored-by: Vehicle Researcher <user@comma.ai> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * Revert "[bot] Update cppcheck to 2.19.1 (commaai#2254)" This reverts commit ae769db. * remove mcu_type (commaai#2324) * remove mcu_type from Panda, it's redundant since all supported devices are H7 * revert disable automatic CAN-FD switching H7 check * revert original can no longer be flashed error * assert, assert, assert * normal reset is fine * fix usb connect on macos (commaai#2326) fix claim on macos * Revert "remove mcu_type (commaai#2324)" This reverts commit 8922b48. * remove mcu_type (commaai#2327) * remove mcu_type from Panda, it's redundant since all supported devices are H7 * revert disable automatic CAN-FD switching H7 check * revert original can no longer be flashed error * assert, assert, assert * normal reset is fine * remove assert from recover * update pyproject.toml: include panda.python and panda.board (commaai#2328) * improve HITL robustness (commaai#2333) * windows: fix fcntl import (commaai#2329) * windows: fix fcntl import * fix indentation * add windows ci * make sure CI catches import error * Revert "make sure CI catches import error" This reverts commit b18043a. --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Comma Device <device@comma.ai> Co-authored-by: Jason Huang <91160588+rexblade21@users.noreply.github.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Igor Biletski <briskspirit@users.noreply.github.com> Co-authored-by: Robbe Derks <robbe.derks@gmail.com> Co-authored-by: Jason Young <46612682+jyoung8607@users.noreply.github.com> Co-authored-by: downquark7 <mail2emn@gmail.com> Co-authored-by: commaci-public <60409688+commaci-public@users.noreply.github.com> Co-authored-by: Vehicle Researcher <user@comma.ai> Co-authored-by: Andi Radulescu <andi.radulescu@gmail.com>
No description provided.