iLLD_TC27xD
1.0
IfxDts_Dts.c
Go to the documentation of this file.
1
/**
2
* \file IfxDts_Dts.c
3
* \brief DTS DTS details
4
*
5
* \version iLLD_1_0_0_11_0
6
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
7
*
8
*
9
* IMPORTANT NOTICE
10
*
11
*
12
* Infineon Technologies AG (Infineon) is supplying this file for use
13
* exclusively with Infineon's microcontroller products. This file can be freely
14
* distributed within development tools that are supporting such microcontroller
15
* products.
16
*
17
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20
* INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22
*
23
*/
24
25
/******************************************************************************/
26
/*----------------------------------Includes----------------------------------*/
27
/******************************************************************************/
28
29
#include "
IfxDts_Dts.h
"
30
31
/******************************************************************************/
32
/*-------------------------Function Implementations---------------------------*/
33
/******************************************************************************/
34
35
uint16
IfxDts_Dts_convertFromCelsius
(
float32
temperatureValue)
36
{
37
sint32
dtsValue = (
sint32
)(temperatureValue + 285.5) / 0.467;
38
39
if
(dtsValue < 0)
40
{
41
dtsValue = 0;
42
}
43
else
if
(dtsValue > 1023)
44
{
45
dtsValue = 1023;
46
}
47
48
return
(
uint16
)dtsValue;
49
}
50
51
52
float32
IfxDts_Dts_convertToCelsius
(
uint16
dtsValue)
53
{
54
return
((
float32
)dtsValue * 0.467) - 285.5;
55
}
56
57
58
void
IfxDts_Dts_initModule
(
const
IfxDts_Dts_Config
*config)
59
{
60
IfxDts_enableSensor
();
61
62
/* wait for two measurements before enabling the limits */
63
{
64
int
i;
65
66
/* disable limits */
67
MODULE_SCU.DTSLIM.B.LOWER = 0;
68
MODULE_SCU.DTSLIM.B.UPPER = 1023;
69
70
/* wait until DTS is ready */
71
while
(!
IfxDts_isReady
())
72
{}
73
74
/* two dummy measurements */
75
for
(i = 0; i < 2; ++i)
76
{
77
IfxDts_Dts_startSensor
();
78
79
while
(
IfxDts_Dts_isBusy
())
80
{}
81
}
82
}
83
84
/* change to the requested limits */
85
MODULE_SCU.DTSLIM.B.LOWER =
IfxDts_Dts_convertFromCelsius
(config->
lowerTemperatureLimit
);
86
MODULE_SCU.DTSLIM.B.UPPER =
IfxDts_Dts_convertFromCelsius
(config->
upperTemperatureLimit
);
87
88
/* lock configuration? */
89
if
(config->
enableSecureLock
==
TRUE
)
90
{
91
IfxDts_disableSensorControl
();
92
}
93
else
94
{
95
/* do Nothing */
96
}
97
98
/* enable DTS IRQ */
99
if
(config->
isrPriority
> 0)
100
{
101
volatile
Ifx_SRC_SRCR *src =
IfxDts_getSrcPointer
();
102
IfxSrc_init
(src, config->
isrTypeOfService
, config->
isrPriority
);
103
IfxSrc_enable
(src);
104
}
105
}
106
107
108
void
IfxDts_Dts_initModuleConfig
(
IfxDts_Dts_Config
*config)
109
{
110
config->
sensorControlDisabled
=
FALSE
;
111
config->
lowerTemperatureLimit
= -40.0;
// Celsius
112
config->
upperTemperatureLimit
= 170.0;
// Celsius
113
114
config->
isrTypeOfService
=
IfxSrc_Tos_cpu0
;
115
config->
isrPriority
= 0;
116
117
config->
enableSecureLock
=
FALSE
;
118
}
home
mclld
Libraries
release
iLLD_1_0_0_11_0
src
ifx
TC27xD
Dts
Dts
IfxDts_Dts.c
Generated by
1.8.4