Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mini v3 temperature #86

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Src/peripheral/adc/adc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#define SRC_PERIPHERY_ADC_ADC_HPP_

#include <stdint.h>
#include "peripheral/temperature_sensor/temperature_sensor.hpp"
#ifdef __cplusplus
extern "C" {
#endif
Expand Down
17 changes: 17 additions & 0 deletions Src/peripheral/adc/circuit_periphery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "params.hpp"
#include "peripheral/led/led.hpp"
#include "peripheral/iwdg/iwdg.hpp"
#ifdef STM32G0B1xx
#include "adc.h"
#endif

static const std::array<std::pair<uint16_t, uint16_t>, (int)BoardType::BOARDS_AMOUNT> hw_info = {{
{59, 69},
Expand All @@ -32,6 +35,20 @@ static const std::array<std::pair<const char*, uint16_t>, (int)BoardType::BOARDS
{"co.rl.mini.v3", 14},
}};

uint16_t CircuitPeriphery::temperature() {
auto adc_12b = AdcPeriphery::get(AdcChannel::ADC_TEMPERATURE);
uint16_t temperature_kelvin;
#ifdef STM32G0B1xx
temperature_kelvin = __HAL_ADC_CALC_TEMPERATURE(3300, adc_12b, ADC_RESOLUTION_12B) + 273;
#else // STM32F103xB
static const uint16_t TEMP_REF = 25;
static const uint16_t ADC_REF = 1750; ///< v_ref / 3.3 * 4095
static const uint16_t AVG_SLOPE = 5; ///< avg_slope/(3.3/4096)
temperature_kelvin = (ADC_REF - adc_12b) / AVG_SLOPE + TEMP_REF + 273;
#endif
return temperature_kelvin;
}

BoardType CircuitPeriphery::detect_board_type() {
auto hardware_version = CircuitPeriphery::hardware_version();

Expand Down
9 changes: 4 additions & 5 deletions Src/peripheral/adc/circuit_periphery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <stdint.h>
#include <limits>
#include <utility>
#include "peripheral/temperature_sensor/temperature_sensor.hpp"
#include "peripheral/adc/adc.hpp"

#ifdef __cplusplus
Expand All @@ -32,10 +31,10 @@ class CircuitPeriphery{
return AdcPeriphery::init();
}

static uint16_t temperature() {
uint16_t temp = AdcPeriphery::get(AdcChannel::ADC_TEMPERATURE);
return stm32TemperatureParse(temp);
}
/**
* @return Temperature, Kelvin
*/
static uint16_t temperature();

/**
* @return The current in Amperes if the hardware supports it, otherwise NaN.
Expand Down
33 changes: 0 additions & 33 deletions Src/peripheral/temperature_sensor/temperature_sensor.hpp

This file was deleted.

1 change: 0 additions & 1 deletion Src/platform/stm32f103/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ add_executable(${EXECUTABLE}
${ROOT_DIR}/Src/platform/stm32/pwm/pwm.cpp
${CMAKE_CURRENT_LIST_DIR}/pwm.cpp
${ROOT_DIR}/Src/platform/stm32/iwdg/iwdg.cpp
${CMAKE_CURRENT_LIST_DIR}/temperature_sensor.cpp
${ROOT_DIR}/Src/platform/stm32/platform_specific.cpp

${coreSources}
Expand Down
34 changes: 0 additions & 34 deletions Src/platform/stm32f103/temperature_sensor.cpp

This file was deleted.

1 change: 0 additions & 1 deletion Src/platform/stm32g0b1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ add_executable(${EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/gpio.cpp
${PLATFORM_DIR}/stm32g0b1/pwm.cpp
${ROOT_DIR}/Src/platform/stm32/iwdg/iwdg.cpp
${PLATFORM_DIR}/stm32f103/temperature_sensor.cpp
${ROOT_DIR}/Src/platform/stm32/platform_specific.cpp

${coreSources}
Expand Down
1 change: 0 additions & 1 deletion Src/platform/ubuntu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ add_executable(${EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/gpio.cpp
${CMAKE_CURRENT_LIST_DIR}/pwm.cpp
${CMAKE_CURRENT_LIST_DIR}/iwdg.cpp
${CMAKE_CURRENT_LIST_DIR}/temperature_sensor.cpp
${CMAKE_CURRENT_LIST_DIR}/platform_specific.cpp
)

Expand Down
34 changes: 0 additions & 34 deletions Src/platform/ubuntu/temperature_sensor.cpp

This file was deleted.