latest version before merge

This commit is contained in:
2026-05-05 12:25:24 +03:00
parent 01c43840a5
commit 92c33b2f46
45 changed files with 33450 additions and 27415 deletions
+4 -21
View File
@@ -1,11 +1,10 @@
#include "main.h"
#include "board.h"
#include "adc.h"
#include "tim.h"
#include "sma_filter.h"
extern ADC_HandleTypeDef hadc1;
//TODO:
//TEMP READ
// Connector temperature sensors
@@ -89,6 +88,7 @@ uint8_t GetBoardTemp(){
void Init_Peripheral(){
HAL_ADCEx_Calibration_Start(&hadc1);
ADC_ScanStart();
RELAY_Write(RELAY_AUX0, 0);
RELAY_Write(RELAY_AUX1, 0);
@@ -130,27 +130,11 @@ float calculate_NTC_resistance(int adc_value, float Vref, float Vin, float R) {
}
int16_t CONN_ReadTemp(uint8_t ch){
ADC_LockBlocking();
//TODO
if(ch)ADC_Select_Channel(ADC_CHANNEL_8);
else ADC_Select_Channel(ADC_CHANNEL_9);
// Начало конверсии
HAL_ADC_Start(&hadc1);
// Ожидание окончания конверсии
HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
// Получение значения
uint32_t adcValue = HAL_ADC_GetValue(&hadc1);
// Остановка АЦП (по желанию)
HAL_ADC_Stop(&hadc1);
uint32_t adcValue = 0u;
adcValue = ch ? adc_data.ntc2_raw : adc_data.ntc1_raw;
int32_t adc_filtered = SMAFilter_Update(&conn_temp_adc_filter[ch ? 1u : 0u], (int32_t)adcValue);
if((uint32_t)adc_filtered > 4000u) {
ADC_Unlock();
return 20; //Термодатчик не подключен
}
@@ -161,7 +145,6 @@ int16_t CONN_ReadTemp(uint8_t ch){
float temp = pt1000_to_temperature(calculate_NTC_resistance((int)adc_filtered, Vref, Vin, R));
ADC_Unlock();
return (int16_t)temp;
}