#include "ADBMS_Error.h"
#include "stm32h7xx_hal.h"

SlaveErrorData error_data[NUM_ERROR_KINDS] = {};
uint32_t error_sources = 0;

void set_error_source(ADBMS_Status source) {
  if (!(error_sources & (1 << source))) {
    error_data[source].errors_since = HAL_GetTick();
  }
  error_sources |= (1 << source);
}

void clear_error_source(ADBMS_Status source) {
  error_data[source].errors_since = 0;
  error_sources &= ~(1 << source);
}
