mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-27 00:42:05 +08:00
876256a268
9881e6118 Panda for Mazda (#165) 9a15d2f5b fix version newline a8ed7d219 add subaru outback/legacy to subaru safety (#259) bdeb1c953 mazda is #12 14ea4d2e0 merge safety gm in a single file bf1ef875e Add GM passive safety mode (#266) c131fffae fix canflash for pedal (#267) 3397b1527 only allow bootloader entry on debug builds d68356b92 Honda Nidec: fwd stock AEB (#257) 6f532c6d5 Black panda Jenkins (#256) d68508c79 Gpio race condition fix (#263) d69d05fc0 Fixed pedal not initializing (#262) 36067e01c Honda safety: fixed incorrect brake decoding. Due to the specific limit of 255, this change does not affect the safety behavior git-subtree-dir: panda git-subtree-split: 9881e61184ad0417e9e080767f09585a9c777621
65 lines
2.0 KiB
C
65 lines
2.0 KiB
C
// ///////////////////////////////////////////////////////////// //
|
|
// Hardware abstraction layer for all different supported boards //
|
|
// ///////////////////////////////////////////////////////////// //
|
|
#include "board_declarations.h"
|
|
#include "boards/common.h"
|
|
|
|
// ///// Board definition and detection ///// //
|
|
#include "drivers/harness.h"
|
|
#ifdef PANDA
|
|
#include "boards/white.h"
|
|
#include "boards/grey.h"
|
|
#include "boards/black.h"
|
|
#else
|
|
#include "boards/pedal.h"
|
|
#endif
|
|
|
|
void detect_board_type(void) {
|
|
#ifdef PANDA
|
|
// SPI lines floating: white (TODO: is this reliable?)
|
|
if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){
|
|
hw_type = HW_TYPE_WHITE_PANDA;
|
|
current_board = &board_white;
|
|
} else if(detect_with_pull(GPIOA, 13, PULL_DOWN)) { // Rev AB deprecated, so no pullup means black. In REV C, A13 is pulled up to 5V with a 10K
|
|
hw_type = HW_TYPE_GREY_PANDA;
|
|
current_board = &board_grey;
|
|
} else {
|
|
hw_type = HW_TYPE_BLACK_PANDA;
|
|
current_board = &board_black;
|
|
}
|
|
#else
|
|
#ifdef PEDAL
|
|
hw_type = HW_TYPE_PEDAL;
|
|
current_board = &board_pedal;
|
|
#else
|
|
hw_type = HW_TYPE_UNKNOWN;
|
|
puts("Hardware type is UNKNOWN!\n");
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
|
|
// ///// Configuration detection ///// //
|
|
bool has_external_debug_serial = 0;
|
|
bool is_entering_bootmode = 0;
|
|
|
|
void detect_configuration(void) {
|
|
// detect if external serial debugging is present
|
|
has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN);
|
|
|
|
#ifdef PANDA
|
|
if(hw_type == HW_TYPE_WHITE_PANDA) {
|
|
// check if the ESP is trying to put me in boot mode
|
|
is_entering_bootmode = !detect_with_pull(GPIOB, 0, PULL_UP);
|
|
} else {
|
|
is_entering_bootmode = 0;
|
|
}
|
|
#else
|
|
is_entering_bootmode = 0;
|
|
#endif
|
|
}
|
|
|
|
// ///// Board functions ///// //
|
|
bool board_has_gps(void) {
|
|
return ((hw_type == HW_TYPE_GREY_PANDA) || (hw_type == HW_TYPE_BLACK_PANDA));
|
|
} |