2019-07-24 06:07:06 +08:00
|
|
|
// ******************** Prototypes ********************
|
|
|
|
typedef void (*board_init)(void);
|
2020-09-28 22:19:09 +08:00
|
|
|
typedef void (*board_enable_can_transceiver)(uint8_t transceiver, bool enabled);
|
|
|
|
typedef void (*board_enable_can_transceivers)(bool enabled);
|
2019-07-24 06:07:06 +08:00
|
|
|
typedef void (*board_set_led)(uint8_t color, bool enabled);
|
2020-08-27 06:37:50 +08:00
|
|
|
typedef void (*board_set_gps_mode)(uint8_t mode);
|
2019-07-24 06:07:06 +08:00
|
|
|
typedef void (*board_set_can_mode)(uint8_t mode);
|
|
|
|
typedef bool (*board_check_ignition)(void);
|
2019-10-26 07:22:42 +08:00
|
|
|
typedef uint32_t (*board_read_current)(void);
|
|
|
|
typedef void (*board_set_ir_power)(uint8_t percentage);
|
2022-08-18 11:43:49 +08:00
|
|
|
typedef void (*board_set_fan_enabled)(bool enabled);
|
2019-11-05 09:26:37 +08:00
|
|
|
typedef void (*board_set_phone_power)(bool enabled);
|
2020-08-17 21:04:01 +08:00
|
|
|
typedef void (*board_set_siren)(bool enabled);
|
2022-09-01 11:46:07 +08:00
|
|
|
typedef void (*board_board_tick)(bool ignition, bool usb_enum, bool heartbeat_seen);
|
2019-07-24 06:07:06 +08:00
|
|
|
|
|
|
|
struct board {
|
|
|
|
const char *board_type;
|
|
|
|
const harness_configuration *harness_config;
|
2021-07-03 09:25:35 +08:00
|
|
|
const bool has_gps;
|
|
|
|
const bool has_hw_gmlan;
|
|
|
|
const bool has_obd;
|
|
|
|
const bool has_lin;
|
2022-11-14 11:57:20 +08:00
|
|
|
const bool has_spi;
|
2022-09-17 12:56:48 +08:00
|
|
|
const bool has_canfd;
|
2022-02-10 07:36:37 +08:00
|
|
|
const bool has_rtc_battery;
|
2022-08-18 11:43:49 +08:00
|
|
|
const uint16_t fan_max_rpm;
|
2019-07-24 06:07:06 +08:00
|
|
|
board_init init;
|
2020-09-28 22:19:09 +08:00
|
|
|
board_enable_can_transceiver enable_can_transceiver;
|
|
|
|
board_enable_can_transceivers enable_can_transceivers;
|
2019-07-24 06:07:06 +08:00
|
|
|
board_set_led set_led;
|
2020-08-27 06:37:50 +08:00
|
|
|
board_set_gps_mode set_gps_mode;
|
2019-07-24 06:07:06 +08:00
|
|
|
board_set_can_mode set_can_mode;
|
|
|
|
board_check_ignition check_ignition;
|
2019-10-26 07:22:42 +08:00
|
|
|
board_read_current read_current;
|
|
|
|
board_set_ir_power set_ir_power;
|
2022-08-18 11:43:49 +08:00
|
|
|
board_set_fan_enabled set_fan_enabled;
|
2019-11-05 09:26:37 +08:00
|
|
|
board_set_phone_power set_phone_power;
|
2020-08-17 21:04:01 +08:00
|
|
|
board_set_siren set_siren;
|
2022-09-01 11:46:07 +08:00
|
|
|
board_board_tick board_tick;
|
2019-07-24 06:07:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// ******************* Definitions ********************
|
2019-08-29 03:57:42 +08:00
|
|
|
// These should match the enums in cereal/log.capnp and __init__.py
|
2019-07-24 06:07:06 +08:00
|
|
|
#define HW_TYPE_UNKNOWN 0U
|
|
|
|
#define HW_TYPE_WHITE_PANDA 1U
|
|
|
|
#define HW_TYPE_GREY_PANDA 2U
|
|
|
|
#define HW_TYPE_BLACK_PANDA 3U
|
|
|
|
#define HW_TYPE_PEDAL 4U
|
2019-10-26 07:22:42 +08:00
|
|
|
#define HW_TYPE_UNO 5U
|
2020-05-15 12:05:42 +08:00
|
|
|
#define HW_TYPE_DOS 6U
|
2021-08-03 11:26:15 +08:00
|
|
|
#define HW_TYPE_RED_PANDA 7U
|
2022-09-10 11:13:06 +08:00
|
|
|
#define HW_TYPE_RED_PANDA_V2 8U
|
2022-11-04 07:34:18 +08:00
|
|
|
#define HW_TYPE_TRES 9U
|
2019-07-24 06:07:06 +08:00
|
|
|
|
|
|
|
// LED colors
|
|
|
|
#define LED_RED 0U
|
|
|
|
#define LED_GREEN 1U
|
|
|
|
#define LED_BLUE 2U
|
|
|
|
|
2019-10-03 02:48:40 +08:00
|
|
|
// USB power modes (from cereal.log.health)
|
2019-10-05 01:48:17 +08:00
|
|
|
#define USB_POWER_NONE 0U
|
|
|
|
#define USB_POWER_CLIENT 1U
|
|
|
|
#define USB_POWER_CDP 2U
|
|
|
|
#define USB_POWER_DCP 3U
|
2019-07-24 06:07:06 +08:00
|
|
|
|
2020-08-27 06:37:50 +08:00
|
|
|
// GPS modes
|
|
|
|
#define GPS_DISABLED 0U
|
|
|
|
#define GPS_ENABLED 1U
|
|
|
|
#define GPS_BOOTMODE 2U
|
2019-07-24 06:07:06 +08:00
|
|
|
|
|
|
|
// CAN modes
|
|
|
|
#define CAN_MODE_NORMAL 0U
|
|
|
|
#define CAN_MODE_GMLAN_CAN2 1U
|
|
|
|
#define CAN_MODE_GMLAN_CAN3 2U
|
|
|
|
#define CAN_MODE_OBD_CAN2 3U
|