message: Protect against race conditions while setting the encoder count
diff: @@ -1382,7 +1382,20 @@ void motor_thread(void const * argument) {
  /** Function that sets the current encoder count to a desired 32-bit value. */
  void setEncoderCount(Motor_t* motor, uint32_t count){
  + bool handlerMode = false;
  + UBaseType_t uxSavedInterruptStatus;
  + if(inHandlerMode()) {
  + handlerMode = true;
  + uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
  + } else
  + taskENTER_CRITICAL();
  +
  motor->encoder.encoder_state = count;
  motor->motor_timer->Instance->CNT = count;
  motor->encoder.pll_pos = (float)count;
  +
  + if(handlerMode){
  + taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
  + } else
  + taskEXIT_CRITICAL();
  }
  \ No newline at end of file
  