Harness orientation designation fixes (#435)
* Fix orientation designations in harness.h * Fix orientation designations in black.h * Fix orientation designations in uno.h * Fix typomaster
parent
eb5020b7a9
commit
769ade0511
|
@ -99,7 +99,7 @@ void black_set_can_mode(uint8_t mode){
|
|||
switch (mode) {
|
||||
case CAN_MODE_NORMAL:
|
||||
case CAN_MODE_OBD_CAN2:
|
||||
if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_NORMAL)) {
|
||||
if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) {
|
||||
// B12,B13: disable OBD mode
|
||||
set_gpio_mode(GPIOB, 12, MODE_INPUT);
|
||||
set_gpio_mode(GPIOB, 13, MODE_INPUT);
|
||||
|
@ -198,7 +198,7 @@ void black_init(void) {
|
|||
black_set_can_mode(CAN_MODE_NORMAL);
|
||||
|
||||
// flip CAN0 and CAN2 if we are flipped
|
||||
if (car_harness_status == HARNESS_STATUS_NORMAL) {
|
||||
if (car_harness_status == HARNESS_STATUS_FLIPPED) {
|
||||
can_flip_buses(0, 2);
|
||||
}
|
||||
|
||||
|
@ -210,12 +210,12 @@ const harness_configuration black_harness_config = {
|
|||
.has_harness = true,
|
||||
.GPIO_SBU1 = GPIOC,
|
||||
.GPIO_SBU2 = GPIOC,
|
||||
.GPIO_relay_normal = GPIOC,
|
||||
.GPIO_relay_flipped = GPIOC,
|
||||
.GPIO_relay_SBU1 = GPIOC,
|
||||
.GPIO_relay_SBU2 = GPIOC,
|
||||
.pin_SBU1 = 0,
|
||||
.pin_SBU2 = 3,
|
||||
.pin_relay_normal = 10,
|
||||
.pin_relay_flipped = 11,
|
||||
.pin_relay_SBU1 = 10,
|
||||
.pin_relay_SBU2 = 11,
|
||||
.adc_channel_SBU1 = 10,
|
||||
.adc_channel_SBU2 = 13
|
||||
};
|
||||
|
|
|
@ -113,7 +113,7 @@ void uno_set_can_mode(uint8_t mode){
|
|||
switch (mode) {
|
||||
case CAN_MODE_NORMAL:
|
||||
case CAN_MODE_OBD_CAN2:
|
||||
if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_NORMAL)) {
|
||||
if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) {
|
||||
// B12,B13: disable OBD mode
|
||||
set_gpio_mode(GPIOB, 12, MODE_INPUT);
|
||||
set_gpio_mode(GPIOB, 13, MODE_INPUT);
|
||||
|
@ -230,7 +230,7 @@ void uno_init(void) {
|
|||
uno_set_can_mode(CAN_MODE_NORMAL);
|
||||
|
||||
// flip CAN0 and CAN2 if we are flipped
|
||||
if (car_harness_status == HARNESS_STATUS_NORMAL) {
|
||||
if (car_harness_status == HARNESS_STATUS_FLIPPED) {
|
||||
can_flip_buses(0, 2);
|
||||
}
|
||||
|
||||
|
@ -252,12 +252,12 @@ const harness_configuration uno_harness_config = {
|
|||
.has_harness = true,
|
||||
.GPIO_SBU1 = GPIOC,
|
||||
.GPIO_SBU2 = GPIOC,
|
||||
.GPIO_relay_normal = GPIOC,
|
||||
.GPIO_relay_flipped = GPIOC,
|
||||
.GPIO_relay_SBU1 = GPIOC,
|
||||
.GPIO_relay_SBU2 = GPIOC,
|
||||
.pin_SBU1 = 0,
|
||||
.pin_SBU2 = 3,
|
||||
.pin_relay_normal = 10,
|
||||
.pin_relay_flipped = 11,
|
||||
.pin_relay_SBU1 = 10,
|
||||
.pin_relay_SBU2 = 11,
|
||||
.adc_channel_SBU1 = 10,
|
||||
.adc_channel_SBU2 = 13
|
||||
};
|
||||
|
|
|
@ -10,12 +10,12 @@ struct harness_configuration {
|
|||
const bool has_harness;
|
||||
GPIO_TypeDef *GPIO_SBU1;
|
||||
GPIO_TypeDef *GPIO_SBU2;
|
||||
GPIO_TypeDef *GPIO_relay_normal;
|
||||
GPIO_TypeDef *GPIO_relay_flipped;
|
||||
GPIO_TypeDef *GPIO_relay_SBU1;
|
||||
GPIO_TypeDef *GPIO_relay_SBU2;
|
||||
uint8_t pin_SBU1;
|
||||
uint8_t pin_SBU2;
|
||||
uint8_t pin_relay_normal;
|
||||
uint8_t pin_relay_flipped;
|
||||
uint8_t pin_relay_SBU1;
|
||||
uint8_t pin_relay_SBU2;
|
||||
uint8_t adc_channel_SBU1;
|
||||
uint8_t adc_channel_SBU2;
|
||||
};
|
||||
|
@ -30,9 +30,9 @@ void set_intercept_relay(bool intercept) {
|
|||
}
|
||||
|
||||
if(car_harness_status == HARNESS_STATUS_NORMAL){
|
||||
set_gpio_output(current_board->harness_config->GPIO_relay_normal, current_board->harness_config->pin_relay_normal, !intercept);
|
||||
set_gpio_output(current_board->harness_config->GPIO_relay_SBU2, current_board->harness_config->pin_relay_SBU2, !intercept);
|
||||
} else {
|
||||
set_gpio_output(current_board->harness_config->GPIO_relay_flipped, current_board->harness_config->pin_relay_flipped, !intercept);
|
||||
set_gpio_output(current_board->harness_config->GPIO_relay_SBU1, current_board->harness_config->pin_relay_SBU1, !intercept);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ bool harness_check_ignition(void) {
|
|||
bool ret = false;
|
||||
switch(car_harness_status){
|
||||
case HARNESS_STATUS_NORMAL:
|
||||
ret = !get_gpio_input(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2);
|
||||
ret = !get_gpio_input(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1);
|
||||
break;
|
||||
case HARNESS_STATUS_FLIPPED:
|
||||
ret = !get_gpio_input(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1);
|
||||
ret = !get_gpio_input(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -62,11 +62,11 @@ uint8_t harness_detect_orientation(void) {
|
|||
// Detect connection and orientation
|
||||
if((sbu1_voltage < HARNESS_CONNECTED_THRESHOLD) || (sbu2_voltage < HARNESS_CONNECTED_THRESHOLD)){
|
||||
if (sbu1_voltage < sbu2_voltage) {
|
||||
// orientation normal
|
||||
ret = HARNESS_STATUS_NORMAL;
|
||||
} else {
|
||||
// orientation flipped
|
||||
// orientation flipped (PANDA_SBU1->HARNESS_SBU1(relay), PANDA_SBU2->HARNESS_SBU2(ign))
|
||||
ret = HARNESS_STATUS_FLIPPED;
|
||||
} else {
|
||||
// orientation normal (PANDA_SBU2->HARNESS_SBU1(relay), PANDA_SBU1->HARNESS_SBU2(ign))
|
||||
ret = HARNESS_STATUS_NORMAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -90,13 +90,6 @@ void harness_init(void) {
|
|||
set_gpio_mode(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1, MODE_INPUT);
|
||||
set_gpio_mode(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2, MODE_INPUT);
|
||||
|
||||
// now we have orientation, set pin ignition detection
|
||||
if(car_harness_status == HARNESS_STATUS_NORMAL){
|
||||
set_gpio_mode(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2, MODE_INPUT);
|
||||
} else {
|
||||
set_gpio_mode(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1, MODE_INPUT);
|
||||
}
|
||||
|
||||
// keep busses connected by default
|
||||
set_intercept_relay(false);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue