Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Proyecto Smart Watch
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
Package 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
Leonardo Martinez Hornak
Proyecto Smart Watch
Commits
86e40598
Commit
86e40598
authored
3 years ago
by
Leonardo Martinez Hornak
Browse files
Options
Downloads
Patches
Plain Diff
Temperature obtained in celsius degrees
parent
43eeac23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
firmware/include/adc.h
+2
-2
2 additions, 2 deletions
firmware/include/adc.h
firmware/include/common.h
+1
-0
1 addition, 0 deletions
firmware/include/common.h
firmware/src/adc.c
+10
-6
10 additions, 6 deletions
firmware/src/adc.c
with
13 additions
and
8 deletions
firmware/include/adc.h
+
2
−
2
View file @
86e40598
...
...
@@ -37,8 +37,8 @@ void setTempCallbackFunction(void *callback_function);
void
runADCConversion
(
void
);
/**
* @brief Obtains the last temperature reading in
mili
celsius
* @return int temperature in celsius degrees
divided by 1000
* @brief Obtains the last temperature reading in celsius
* @return int temperature in celsius degrees
*
*/
int
getTemperatureReading
(
void
);
...
...
This diff is collapsed.
Click to expand it.
firmware/include/common.h
+
1
−
0
View file @
86e40598
...
...
@@ -12,5 +12,6 @@
#define INCLUDE_COMMON_H_
//#define DEBUG
#define REF_VOLTAGE_DIV_BY_ADC_10BITS_RESOLUTION 1.17
#endif
/* INCLUDE_COMMON_H_ */
This diff is collapsed.
Click to expand it.
firmware/src/adc.c
+
10
−
6
View file @
86e40598
#include
<msp.h>
#include
"common.h"
#include
"adc.h"
#include
"fifo_function_queue.h"
...
...
@@ -55,25 +56,28 @@ void runADCConversion(){
int
getTemperatureReading
(){
int
temp
;
//Converts mVolts to miliCelsius using temperature sensor transfer function (no calibration)
float
aux
;
//Converts ADC Reading to mVolts (1.2 Volts set for reference voltage)
aux
=
(
float
)(
adcval
)
*
REF_VOLTAGE_DIV_BY_ADC_10BITS_RESOLUTION
;
//Converts mVolts to celsius using temperature sensor transfer function (no calibration)
//Using 10 bits resolution
temp
=
(
((
adcval
-
686
)
*
512
)
/
1024
)
;
temp
=
(
int
)((
aux
-
686
)
*
0
.
512
);
return
temp
;
}
void
ADC14_IRQHandler
(
void
)
{
addToFunctionQueue
(
temperature_ready_callback
);
//Reading to ADC14MEM clears the IFG
adcval
=
ADC14
->
MEM
[
0
];
ADC14
->
CTL0
&=
~
ADC14_CTL0_ENC
;
ADC14
->
CTL0
&=
~
ADC14_CTL0_ON
;
__low_power_mode_off_on_exit
();
//Disable ISRs
ADC14
->
IER0
&=
~
ADC14_IER0_IE0
;
NVIC_DisableIRQ
(
ADC14_IRQn
);
addToFunctionQueue
(
temperature_ready_callback
);
__low_power_mode_off_on_exit
();
}
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