|
|
|
|
@ -103,6 +103,7 @@ extern volatile uint16_t pwm_captured_ch2_value;
|
|
|
|
|
// Global variables set here in main.c
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
uint8_t backwardDrive;
|
|
|
|
|
extern volatile uint32_t buzzerTimer;
|
|
|
|
|
volatile uint32_t main_loop_counter;
|
|
|
|
|
int16_t batVoltageCalib; // global variable for calibrated battery voltage
|
|
|
|
|
int16_t board_temp_deg_c; // global variable for calibrated temperature in degrees Celsius
|
|
|
|
|
@ -157,6 +158,7 @@ static int16_t speed; // local variable for speed. -1000 to 10
|
|
|
|
|
static int32_t speedFixdt; // local fixed-point variable for speed low-pass filter
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static uint32_t buzzerTimer_prev = 0;
|
|
|
|
|
static uint32_t inactivity_timeout_counter;
|
|
|
|
|
static MultipleTap MultipleTapBrake; // define multiple tap functionality for the Brake pedal
|
|
|
|
|
|
|
|
|
|
@ -207,7 +209,7 @@ int main(void) {
|
|
|
|
|
while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { HAL_Delay(10); }
|
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
HAL_Delay(DELAY_IN_MAIN_LOOP); // delay in ms
|
|
|
|
|
if (buzzerTimer - buzzerTimer_prev > 16*DELAY_IN_MAIN_LOOP) { // 1 ms = 16 ticks buzzerTimer
|
|
|
|
|
|
|
|
|
|
readCommand(); // Read Command: input1[inIdx].cmd, input2[inIdx].cmd
|
|
|
|
|
calcAvgSpeed(); // Calculate average measured speed: speedAvg, speedAvgAbs
|
|
|
|
|
@ -524,9 +526,11 @@ int main(void) {
|
|
|
|
|
// HAL_GPIO_TogglePin(LED_PORT, LED_PIN); // This is to measure the main() loop duration with an oscilloscope connected to LED_PIN
|
|
|
|
|
// Update states
|
|
|
|
|
inIdx_prev = inIdx;
|
|
|
|
|
buzzerTimer_prev = buzzerTimer;
|
|
|
|
|
main_loop_counter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================================================
|
|
|
|
|
|