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.
		
		
		
		
			
				
					70 lines
				
				1.4 KiB
			
		
		
			
		
	
	
					70 lines
				
				1.4 KiB
			| 
								 
											6 years ago
										 
									 | 
							
								void default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
							 | 
						||
| 
								 | 
							
								  UNUSED(to_push);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int default_ign_hook(void) {
							 | 
						||
| 
								 | 
							
								  return -1; // use GPIO to determine ignition
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// *** no output safety mode ***
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static void nooutput_init(int16_t param) {
							 | 
						||
| 
								 | 
							
								  UNUSED(param);
							 | 
						||
| 
								 | 
							
								  controls_allowed = 0;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static int nooutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
							 | 
						||
| 
								 | 
							
								  UNUSED(to_send);
							 | 
						||
| 
								 | 
							
								  return false;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
							 | 
						||
| 
								 | 
							
								  UNUSED(lin_num);
							 | 
						||
| 
								 | 
							
								  UNUSED(data);
							 | 
						||
| 
								 | 
							
								  UNUSED(len);
							 | 
						||
| 
								 | 
							
								  return false;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
							 | 
						||
| 
								 | 
							
								  UNUSED(bus_num);
							 | 
						||
| 
								 | 
							
								  UNUSED(to_fwd);
							 | 
						||
| 
								 | 
							
								  return -1;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const safety_hooks nooutput_hooks = {
							 | 
						||
| 
								 | 
							
								  .init = nooutput_init,
							 | 
						||
| 
								 | 
							
								  .rx = default_rx_hook,
							 | 
						||
| 
								 | 
							
								  .tx = nooutput_tx_hook,
							 | 
						||
| 
								 | 
							
								  .tx_lin = nooutput_tx_lin_hook,
							 | 
						||
| 
								 | 
							
								  .ignition = default_ign_hook,
							 | 
						||
| 
								 | 
							
								  .fwd = default_fwd_hook,
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// *** all output safety mode ***
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static void alloutput_init(int16_t param) {
							 | 
						||
| 
								 | 
							
								  UNUSED(param);
							 | 
						||
| 
								 | 
							
								  controls_allowed = 1;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static int alloutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
							 | 
						||
| 
								 | 
							
								  UNUSED(to_send);
							 | 
						||
| 
								 | 
							
								  return true;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								static int alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
							 | 
						||
| 
								 | 
							
								  UNUSED(lin_num);
							 | 
						||
| 
								 | 
							
								  UNUSED(data);
							 | 
						||
| 
								 | 
							
								  UNUSED(len);
							 | 
						||
| 
								 | 
							
								  return true;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const safety_hooks alloutput_hooks = {
							 | 
						||
| 
								 | 
							
								  .init = alloutput_init,
							 | 
						||
| 
								 | 
							
								  .rx = default_rx_hook,
							 | 
						||
| 
								 | 
							
								  .tx = alloutput_tx_hook,
							 | 
						||
| 
								 | 
							
								  .tx_lin = alloutput_tx_lin_hook,
							 | 
						||
| 
								 | 
							
								  .ignition = default_ign_hook,
							 | 
						||
| 
								 | 
							
								  .fwd = default_fwd_hook,
							 | 
						||
| 
								 | 
							
								};
							 |