END_TEST START_TEST(check_calculate_ignition_cut) { config.rpm_stop = 5000; config.rpm_start = 4500; config.decoder.rpm = 1000; ck_assert_int_eq(ignition_cut(), 0); ck_assert_int_eq(calculated_values.rpm_limit_cut, 0); config.decoder.rpm = 5500; ck_assert_int_eq(ignition_cut(), 1); ck_assert_int_eq(calculated_values.rpm_limit_cut, 1); config.decoder.rpm = 4000; ck_assert_int_eq(ignition_cut(), 0); ck_assert_int_eq(calculated_values.rpm_limit_cut, 0); config.decoder.rpm = 4800; ck_assert_int_eq(ignition_cut(), 0); ck_assert_int_eq(calculated_values.rpm_limit_cut, 0); config.decoder.rpm = 5500; ck_assert_int_eq(ignition_cut(), 1); ck_assert_int_eq(calculated_values.rpm_limit_cut, 1); }
void shift_gear (void) { //gear_status = 1 (upshift), gear_status = 2 (downshift), gear_status = 3 (neutral - half shift) shift_posn = readADC(14); if (gear_status == 1) { if (in_neutral == 1) { while (shift_posn < neutral_posn) { P3OUT |= PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; while (shift_posn > rest_posn) { P3OUT &= ~PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; in_neutral = 0; } else if (in_neutral == 0) { if (in_neutral != 1) { ign_cut = 1; ignition_cut(); } while (shift_posn < up_posn) { P3OUT |= PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; if (in_neutral != 1) { ign_cut = 0; ignition_cut(); } while (shift_posn > rest_posn) { P3OUT &= ~PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; } } else if (gear_status == 2) { clutch_state = 1; actuate_clutch(); while (shift_posn > down_posn) { P3OUT &= ~PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; while (shift_posn < rest_posn) { P3OUT |= PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; clutch_state = 0; actuate_clutch(); } else if (gear_status == 3) { shift_posn = readADC(14); if (gear_num == 1 && in_neutral != 1) { while (shift_posn < neutral_posn) { P3OUT |= PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; while (shift_posn > rest_posn) { P3OUT &= ~PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; } else if (gear_num == 2 && in_neutral != 1) { clutch_state = 1; actuate_clutch(); while (shift_posn > shift_half) { P3OUT &= ~PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; while (shift_posn < rest_posn) { P3OUT |= PIN3; //DIR P4OUT |= PIN2; //PWMH shift_posn = readADC(14); } P4OUT &= ~PIN2; clutch_state = 0; actuate_clutch(); } in_neutral = 1; } }