Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emilio Corigliano
Skyward Boardcore
Commits
b2a9d143
Commit
b2a9d143
authored
2 years ago
by
Alberto Nidasio
Browse files
Options
Downloads
Patches
Plain Diff
[InternalADC] Added calibration voltage definition and error if missing `V_DDA_VOLTAGE`
parent
82d41f2d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/shared/drivers/adc/InternalADC.cpp
+16
-5
16 additions, 5 deletions
src/shared/drivers/adc/InternalADC.cpp
src/shared/drivers/adc/InternalADC.h
+0
-2
0 additions, 2 deletions
src/shared/drivers/adc/InternalADC.h
with
16 additions
and
7 deletions
src/shared/drivers/adc/InternalADC.cpp
+
16
−
5
View file @
b2a9d143
...
...
@@ -25,16 +25,20 @@
#include
<drivers/timer/TimestampTimer.h>
#include
<utils/ClockUtils.h>
#define ADC_RESOLUTION 4095
#if defined(STM32F407xx) || defined(STM32F429xx)
#define TEMP30_CAL_VALUE ((uint16_t*)((uint32_t)0x1FFF7A2C))
#define TEMP110_CAL_VALUE ((uint16_t*)((uint32_t)0x1FFF7A2E))
#define TEMP30 30
#define TEMP110 110
#define CALIBRATION_V_DDA 3.3f
#elif defined(STM32F767xx) || defined(STM32F769xx)
#define TEMP30_CAL_VALUE ((uint16_t*)((uint32_t)0x1FF0F44C))
#define TEMP110_CAL_VALUE ((uint16_t*)((uint32_t)0x1FF0F44E))
#define TEMP30 30
#define TEMP110 110
#define CALIBRATION_V_DDA 3.3f
#else
#warning This micro controller does not have a calibrated temperature sensor or is not currently supported by this driver
#define WITHOUT_CALIBRATION
...
...
@@ -51,15 +55,22 @@
#define VBAT_DIV 4.0f
#endif
// Error the user if the current target is missing the V_DDA_VOLTAGE macro
// If it is missing you need to define it, preferably in the board_settings.h
// file in miosix. Check your board schematic to find the voltage value.
#ifndef V_DDA_VOLTAGE
#error Missing V_DDA_VOLTAGE definition for current target
#endif
#ifndef WITHOUT_CALIBRATION
namespace
InternalADCConsts
{
// Factory calibration values
// Read "Temperature sensor characteristics" chapter in the datasheet
static
const
float
voltage30
=
static_cast
<
float
>
(
*
TEMP30_CAL_VALUE
)
*
3.3
/
4095
;
static_cast
<
float
>
(
*
TEMP30_CAL_VALUE
)
*
CALIBRATION_V_DDA
/
ADC_RESOLUTION
;
static
const
float
voltage110
=
static_cast
<
float
>
(
*
TEMP110_CAL_VALUE
)
*
3.3
/
4095
;
static_cast
<
float
>
(
*
TEMP110_CAL_VALUE
)
*
CALIBRATION_V_DDA
/
ADC_RESOLUTION
;
static
const
float
slope
=
(
voltage110
-
voltage30
)
/
(
TEMP110
-
TEMP30
);
}
// namespace InternalADCConsts
#endif
...
...
@@ -185,7 +196,7 @@ void InternalADC::disableVbat()
InternalADCData
InternalADC
::
getVoltage
(
Channel
channel
)
{
return
{
timestamp
,
channel
,
channelsRawValues
[
channel
]
*
V_DDA_VOLTAGE
/
RESOLUTION
};
channelsRawValues
[
channel
]
*
V_DDA_VOLTAGE
/
ADC_
RESOLUTION
};
}
TemperatureData
InternalADC
::
getTemperature
()
...
...
@@ -195,7 +206,7 @@ TemperatureData InternalADC::getTemperature()
if
(
temperatureRawValue
!=
0
)
{
data
.
temperature
=
temperatureRawValue
*
V_DDA_VOLTAGE
/
RESOLUTION
;
data
.
temperature
=
temperatureRawValue
*
V_DDA_VOLTAGE
/
ADC_
RESOLUTION
;
#ifdef WITHOUT_CALIBRATION
// Default conversion
...
...
@@ -218,7 +229,7 @@ TemperatureData InternalADC::getTemperature()
InternalADCData
InternalADC
::
getVbatVoltage
()
{
return
{
timestamp
,
VBAT_CH
,
vbatVoltageRawValue
*
V_DDA_VOLTAGE
/
RESOLUTION
*
VBAT_DIV
};
vbatVoltageRawValue
*
V_DDA_VOLTAGE
/
ADC_
RESOLUTION
*
VBAT_DIV
};
}
inline
void
InternalADC
::
resetRegisters
()
...
...
This diff is collapsed.
Click to expand it.
src/shared/drivers/adc/InternalADC.h
+
0
−
2
View file @
b2a9d143
...
...
@@ -145,8 +145,6 @@ private:
uint16_t
temperatureRawValue
=
0
;
uint16_t
vbatVoltageRawValue
=
0
;
uint64_t
timestamp
=
0
;
static
constexpr
int
RESOLUTION
=
4095
;
///< 12 bits
};
}
// namespace Boardcore
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment