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
Model registry
Analyze
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
Avionics
Software Development
Skyward Boardcore
Commits
fd141371
Commit
fd141371
authored
3 years ago
by
Alberto Nidasio
Browse files
Options
Downloads
Patches
Plain Diff
[InternalTemp] Added support for STM32F2
parent
ae06a031
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/InternalTemp.cpp
+8
-4
8 additions, 4 deletions
src/shared/drivers/adc/InternalTemp.cpp
src/tests/drivers/test-internal-temp.cpp
+1
-1
1 addition, 1 deletion
src/tests/drivers/test-internal-temp.cpp
with
9 additions
and
5 deletions
src/shared/drivers/adc/InternalTemp.cpp
+
8
−
4
View file @
fd141371
...
...
@@ -22,10 +22,12 @@
#include
"InternalTemp.h"
#ifdef _ARCH_CORTEXM4_STM32F4
#define TEMP30_CAL_VALUE ((uint16_t*)((uint32_t)0x1FFF7A2C))
#define TEMP110_CAL_VALUE ((uint16_t*)((uint32_t)0x1FFF7A2E))
#define TEMP30 30
#define TEMP110 110
#endif
namespace
Boardcore
{
...
...
@@ -40,7 +42,7 @@ bool InternalTemp::init()
{
bool
result
=
adc
.
init
();
#ifdef
_BOARD_STM32F4DISCOVERY
#if
def
ined(
_BOARD_STM32F4DISCOVERY
) || defined(_ARCH_CORTEXM3_STM32F2)
adc
.
addRegularChannel
(
InternalADC
::
CH16
);
#else
adc
.
addRegularChannel
(
InternalADC
::
CH18
);
...
...
@@ -56,7 +58,7 @@ bool InternalTemp::selfTest() { return adc.selfTest(); }
InternalTempData
InternalTemp
::
sampleImpl
()
{
#ifdef
_BOARD_STM32F4DISCOVERY
#if
def
ined(
_BOARD_STM32F4DISCOVERY
) || defined(_ARCH_CORTEXM3_STM32F2)
auto
adcData
=
adc
.
readChannel
(
InternalADC
::
CH16
,
sampleTime
);
#else
auto
adcData
=
adc
.
readChannel
(
InternalADC
::
CH18
,
sampleTime
);
...
...
@@ -65,14 +67,16 @@ InternalTempData InternalTemp::sampleImpl()
InternalTempData
data
;
data
.
temperatureTimestamp
=
adcData
.
voltageTimestamp
;
#ifdef _ARCH_CORTEXM3_STM32F2
// Default conversion
//
data.temperature
= ((adcData.voltage - 0.76) / 0.0025) + 25;
data
.
temperature
=
((
adcData
.
voltage
-
0.76
)
/
0.0025
)
+
25
;
#else
// Factory calibration
float
voltage30
=
static_cast
<
float
>
(
*
TEMP30_CAL_VALUE
)
*
3.3
/
4095
;
float
voltage110
=
static_cast
<
float
>
(
*
TEMP110_CAL_VALUE
)
*
3.3
/
4095
;
float
slope
=
(
voltage110
-
voltage30
)
/
(
TEMP110
-
TEMP30
);
data
.
temperature
=
((
adcData
.
voltage
-
voltage30
)
/
slope
)
+
TEMP30
;
#endif
return
data
;
}
...
...
This diff is collapsed.
Click to expand it.
src/tests/drivers/test-internal-temp.cpp
+
1
−
1
View file @
fd141371
...
...
@@ -37,7 +37,7 @@ int main()
for
(;;)
{
temp
.
sample
();
printf
(
"%2.3f
test
\n
"
,
temp
.
getLastSample
().
temperature
);
printf
(
"
Temperature:
%2.3f
\n
"
,
temp
.
getLastSample
().
temperature
);
miosix
::
delayMs
(
1000
);
}
...
...
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