mirror of https://github.com/commaai/body.git
ignition
This commit is contained in:
parent
d3afaf06ea
commit
bfbc1e8d25
|
@ -62,7 +62,7 @@ int main(void) {
|
|||
out_enable(LED_GREEN, false);
|
||||
out_enable(LED_BLUE, false);
|
||||
|
||||
if(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
|
||||
if(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN) && (hw_type == HW_TYPE_BASE)) {
|
||||
uint16_t cnt_press = 0;
|
||||
while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
|
||||
HAL_Delay(10);
|
||||
|
|
|
@ -19,10 +19,10 @@ extern I2C_HandleTypeDef hi2c1;
|
|||
|
||||
void angle_sensor_read(uint16_t *sensor_angle) {
|
||||
uint8_t buf[2];
|
||||
if (HAL_I2C_Mem_Read(&hi2c1, (AS5048_ADDRESS_LEFT<<1), AS5048B_ANGLMSB_REG, I2C_MEMADD_SIZE_8BIT, buf, 2, 100) == HAL_OK) {
|
||||
if (HAL_I2C_Mem_Read(&hi2c1, (AS5048_ADDRESS_LEFT<<1), AS5048B_ANGLMSB_REG, I2C_MEMADD_SIZE_8BIT, buf, 2, 5) == HAL_OK) {
|
||||
sensor_angle[0] = (buf[0] << 6) | (buf[1] & 0x3F);
|
||||
}
|
||||
if (HAL_I2C_Mem_Read(&hi2c1, (AS5048_ADDRESS_RIGHT<<1), AS5048B_ANGLMSB_REG, I2C_MEMADD_SIZE_8BIT, buf, 2, 100) == HAL_OK) {
|
||||
if (HAL_I2C_Mem_Read(&hi2c1, (AS5048_ADDRESS_RIGHT<<1), AS5048B_ANGLMSB_REG, I2C_MEMADD_SIZE_8BIT, buf, 2, 5) == HAL_OK) {
|
||||
sensor_angle[1] = (buf[0] << 6) | (buf[1] & 0x3F);
|
||||
}
|
||||
}
|
||||
|
|
21
board/main.c
21
board/main.c
|
@ -100,10 +100,16 @@ int main(void) {
|
|||
|
||||
HAL_ADC_Start(&hadc);
|
||||
|
||||
out_enable(POWERSWITCH, true);
|
||||
out_enable(IGNITION, ignition);
|
||||
out_enable(TRANSCEIVER, true);
|
||||
|
||||
if (hw_type == HW_TYPE_BASE) {
|
||||
out_enable(POWERSWITCH, true);
|
||||
out_enable(IGNITION, ignition);
|
||||
out_enable(TRANSCEIVER, true);
|
||||
// Loop until button is released, only for base board
|
||||
while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { HAL_Delay(10); }
|
||||
} else {
|
||||
out_enable(POWERSWITCH, false);
|
||||
ignition = 1;
|
||||
}
|
||||
// Reset LEDs upon startup
|
||||
out_enable(LED_RED, false);
|
||||
out_enable(LED_GREEN, false);
|
||||
|
@ -125,9 +131,6 @@ int main(void) {
|
|||
uint16_t hall_angle_offset[SENSOR_COUNT] = { 0 };
|
||||
angle_sensor_read(sensor_angle);
|
||||
|
||||
// Loop until button is released
|
||||
while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { HAL_Delay(10); }
|
||||
|
||||
while(1) {
|
||||
if (buzzerTimer - buzzerTimer_prev > 16*DELAY_IN_MAIN_LOOP) { // 1 ms = 16 ticks buzzerTimer
|
||||
calcAvgSpeed();
|
||||
|
@ -299,7 +302,9 @@ int main(void) {
|
|||
}
|
||||
|
||||
process_can();
|
||||
poweroffPressCheck();
|
||||
if (hw_type == HW_TYPE_BASE) {
|
||||
poweroffPressCheck();
|
||||
}
|
||||
|
||||
if ((TEMP_POWEROFF_ENABLE && board_temp_deg_c >= TEMP_POWEROFF && speedAvgAbs < 20) || (batVoltage < BAT_DEAD && speedAvgAbs < 20)) { // poweroff before mainboard burns OR low bat 3
|
||||
poweroff();
|
||||
|
|
Loading…
Reference in New Issue