2024-09-17 05:07:21 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2019-07-24 06:07:06 +08:00
|
|
|
// ******************** Prototypes ********************
|
2023-11-09 14:54:55 +08:00
|
|
|
typedef enum {
|
|
|
|
BOOT_STANDBY,
|
|
|
|
BOOT_BOOTKICK,
|
2023-11-10 10:01:46 +08:00
|
|
|
BOOT_RESET,
|
2023-11-09 14:54:55 +08:00
|
|
|
} BootState;
|
|
|
|
|
2019-07-24 06:07:06 +08:00
|
|
|
typedef void (*board_init)(void);
|
2023-08-07 03:29:54 +08:00
|
|
|
typedef void (*board_init_bootloader)(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);
|
|
|
|
typedef void (*board_set_can_mode)(uint8_t mode);
|
|
|
|
typedef bool (*board_check_ignition)(void);
|
2024-02-16 05:49:06 +08:00
|
|
|
typedef uint32_t (*board_read_voltage_mV)(void);
|
|
|
|
typedef uint32_t (*board_read_current_mA)(void);
|
2019-10-26 07:22:42 +08:00
|
|
|
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);
|
2020-08-17 21:04:01 +08:00
|
|
|
typedef void (*board_set_siren)(bool enabled);
|
2023-11-09 14:54:55 +08:00
|
|
|
typedef void (*board_set_bootkick)(BootState state);
|
2023-02-08 23:01:14 +08:00
|
|
|
typedef bool (*board_read_som_gpio)(void);
|
2024-11-13 23:09:13 +08:00
|
|
|
typedef void (*board_set_amp_enabled)(bool enabled);
|
2019-07-24 06:07:06 +08:00
|
|
|
|
|
|
|
struct board {
|
2024-03-25 03:38:25 +08:00
|
|
|
harness_configuration *harness_config;
|
2021-07-03 09:25:35 +08:00
|
|
|
const bool has_obd;
|
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-08-18 11:43:49 +08:00
|
|
|
const uint16_t fan_max_rpm;
|
2023-05-04 19:22:01 +08:00
|
|
|
const uint16_t avdd_mV;
|
2023-03-16 21:15:43 +08:00
|
|
|
const bool fan_stall_recovery;
|
|
|
|
const uint8_t fan_enable_cooldown_time;
|
2024-08-19 08:43:27 +08:00
|
|
|
const uint8_t fan_max_pwm;
|
2019-07-24 06:07:06 +08:00
|
|
|
board_init init;
|
2023-08-07 03:29:54 +08:00
|
|
|
board_init_bootloader init_bootloader;
|
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;
|
|
|
|
board_set_can_mode set_can_mode;
|
|
|
|
board_check_ignition check_ignition;
|
2024-02-16 05:49:06 +08:00
|
|
|
board_read_voltage_mV read_voltage_mV;
|
|
|
|
board_read_current_mA read_current_mA;
|
2019-10-26 07:22:42 +08:00
|
|
|
board_set_ir_power set_ir_power;
|
2022-08-18 11:43:49 +08:00
|
|
|
board_set_fan_enabled set_fan_enabled;
|
2020-08-17 21:04:01 +08:00
|
|
|
board_set_siren set_siren;
|
2023-11-09 14:54:55 +08:00
|
|
|
board_set_bootkick set_bootkick;
|
2023-02-08 23:01:14 +08:00
|
|
|
board_read_som_gpio read_som_gpio;
|
2024-11-13 23:09:13 +08:00
|
|
|
board_set_amp_enabled set_amp_enabled;
|
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
|
2024-01-25 05:07:47 +08:00
|
|
|
#define HW_TYPE_CUATRO 10U
|
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
|
|
|
|
|
|
|
// CAN modes
|
|
|
|
#define CAN_MODE_NORMAL 0U
|
2024-03-22 04:56:36 +08:00
|
|
|
#define CAN_MODE_OBD_CAN2 1U
|
2024-09-17 05:07:21 +08:00
|
|
|
|
|
|
|
extern struct board board_black;
|
|
|
|
extern struct board board_dos;
|
|
|
|
extern struct board board_uno;
|
|
|
|
extern struct board board_tres;
|
|
|
|
extern struct board board_grey;
|
|
|
|
extern struct board board_white;
|
|
|
|
extern struct board board_cuatro;
|
|
|
|
extern struct board board_red;
|