You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					74 lines
				
				2.4 KiB
			
		
		
			
		
	
	
					74 lines
				
				2.4 KiB
			| 
								 
											6 years ago
										 
									 | 
							
								// ******************** Prototypes ********************
							 | 
						||
| 
								 | 
							
								typedef void (*board_init)(void);
							 | 
						||
| 
								 | 
							
								typedef void (*board_enable_can_transciever)(uint8_t transciever, bool enabled);
							 | 
						||
| 
								 | 
							
								typedef void (*board_enable_can_transcievers)(bool enabled);
							 | 
						||
| 
								 | 
							
								typedef void (*board_set_led)(uint8_t color, bool enabled);
							 | 
						||
| 
								 | 
							
								typedef void (*board_set_usb_power_mode)(uint8_t mode);
							 | 
						||
| 
								 | 
							
								typedef void (*board_set_esp_gps_mode)(uint8_t mode);
							 | 
						||
| 
								 | 
							
								typedef void (*board_set_can_mode)(uint8_t mode);
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								typedef void (*board_usb_power_mode_tick)(uint32_t uptime);
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								typedef bool (*board_check_ignition)(void);
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								typedef uint32_t (*board_read_current)(void);
							 | 
						||
| 
								 | 
							
								typedef void (*board_set_ir_power)(uint8_t percentage);
							 | 
						||
| 
								 | 
							
								typedef void (*board_set_fan_power)(uint8_t percentage);
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								typedef void (*board_set_phone_power)(bool enabled);
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								struct board {
							 | 
						||
| 
								 | 
							
								  const char *board_type;
							 | 
						||
| 
								 | 
							
								  const harness_configuration *harness_config;
							 | 
						||
| 
								 | 
							
								  board_init init;
							 | 
						||
| 
								 | 
							
								  board_enable_can_transciever enable_can_transciever;
							 | 
						||
| 
								 | 
							
								  board_enable_can_transcievers enable_can_transcievers;
							 | 
						||
| 
								 | 
							
								  board_set_led set_led;
							 | 
						||
| 
								 | 
							
								  board_set_usb_power_mode set_usb_power_mode;
							 | 
						||
| 
								 | 
							
								  board_set_esp_gps_mode set_esp_gps_mode;
							 | 
						||
| 
								 | 
							
								  board_set_can_mode set_can_mode;
							 | 
						||
| 
								 | 
							
								  board_usb_power_mode_tick usb_power_mode_tick;
							 | 
						||
| 
								 | 
							
								  board_check_ignition check_ignition;
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  board_read_current read_current;
							 | 
						||
| 
								 | 
							
								  board_set_ir_power set_ir_power;
							 | 
						||
| 
								 | 
							
								  board_set_fan_power set_fan_power;
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  board_set_phone_power set_phone_power;
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// ******************* Definitions ********************
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								// These should match the enums in cereal/log.capnp and __init__.py
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								#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
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								#define HW_TYPE_UNO 5U
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								// LED colors
							 | 
						||
| 
								 | 
							
								#define LED_RED 0U
							 | 
						||
| 
								 | 
							
								#define LED_GREEN 1U
							 | 
						||
| 
								 | 
							
								#define LED_BLUE 2U
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								// USB power modes (from cereal.log.health)
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								#define USB_POWER_NONE 0U
							 | 
						||
| 
								 | 
							
								#define USB_POWER_CLIENT 1U
							 | 
						||
| 
								 | 
							
								#define USB_POWER_CDP 2U
							 | 
						||
| 
								 | 
							
								#define USB_POWER_DCP 3U
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// ESP modes
							 | 
						||
| 
								 | 
							
								#define ESP_GPS_DISABLED 0U
							 | 
						||
| 
								 | 
							
								#define ESP_GPS_ENABLED 1U
							 | 
						||
| 
								 | 
							
								#define ESP_GPS_BOOTMODE 2U
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// 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
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// ********************* Globals **********************
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								uint8_t usb_power_mode = USB_POWER_NONE;
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								// ************ Board function prototypes *************
							 | 
						||
| 
								 | 
							
								bool board_has_gps(void);
							 | 
						||
| 
								 | 
							
								bool board_has_gmlan(void);
							 | 
						||
| 
								 | 
							
								bool board_has_obd(void);
							 | 
						||
| 
								 | 
							
								bool board_has_lin(void);
							 | 
						||
| 
								 | 
							
								bool board_has_rtc(void);
							 | 
						||
| 
								 | 
							
								bool board_has_relay(void);
							 |