Limit main loop to 10 Hz
This commit is contained in:
		@ -85,6 +85,19 @@ void update_status_leds() {
 | 
			
		||||
    HAL_GPIO_WritePin(STAT_LED2_GPIO_Port, STAT_LED2_Pin, GPIO_PIN_SET);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void delay_period() {
 | 
			
		||||
  static uint32_t last_it = 0;
 | 
			
		||||
  uint32_t now = HAL_GetTick();
 | 
			
		||||
  int32_t diff = now - last_it;
 | 
			
		||||
  if (diff > 100) {
 | 
			
		||||
    HAL_GPIO_WritePin(STAT_LED3_GPIO_Port, STAT_LED3_Pin, GPIO_PIN_SET);
 | 
			
		||||
  } else {
 | 
			
		||||
    HAL_GPIO_WritePin(STAT_LED3_GPIO_Port, STAT_LED3_Pin, GPIO_PIN_RESET);
 | 
			
		||||
    HAL_Delay(100 - diff);
 | 
			
		||||
  }
 | 
			
		||||
  last_it = now;
 | 
			
		||||
}
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -136,6 +149,7 @@ int main(void) {
 | 
			
		||||
    /* USER CODE BEGIN 3 */
 | 
			
		||||
    update_status_leds();
 | 
			
		||||
    afe_measure();
 | 
			
		||||
    delay_period();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE END 3 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user