1 /*
2  * Copyright (c) 2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /** ============================================================================
33  *  @file       TemperatureCC26X2.h
34  *
35  *  @brief      Temperature driver implementation for the CC26X2 family
36  *
37  *  The temperature driver on CC26X2 is a part of the battery monitoring
38  *  system in AON (always on). It periodically takes measurements of the
39  *  temperature of the chip and will issue interrupts if the configured
40  *  upper limit or lower limit is crossed.
41  *
42  *  # Standby Power Mode Behavior #
43  *  The temperature measurement is active while in standby power mode as well.
44  *  The interrupt used by the temperature module is capable of bringing the
45  *  device out of standby and into active mode to handle it. That means that
46  *  an application will not miss a change in temperature just because the device
47  *  has transitioned to standby power mode.
48  *  While in standby, the temperature will only be sampled during a VDDR
49  *  recharge pulse. This means that the sampling frequency in standby will be
50  *  determined by the temperature as leakage increases with temperature and
51  *  requires more frequent recharging of VDDR.
52  *
53  *  # Measurement Confidence Bounds
54  *  There is an inherent inaccuracy in the temperature measurements reported
55  *  by the device for any given chip temperature. This inaccuracy varies
56  *  by chip.
57  *  In order to set accurate threshold values and act upon provided
58  *  temperatures, the following table provides a 99% confidence interval for
59  *  the upper and lower bounds of the measured temperature by true
60  *  temperature. These figures are given across the range of manufacturing
61  *  variances.
62  *
63  *  | Ambient Temperature | -40 | -30 | -20 | -10 | 0  | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 110 | 120 |
64  *  |---------------------|-----|-----|-----|-----|----|----|----|----|----|----|----|----|----|----|-----|-----|-----|
65  *  | Upper               | -28 | -20 | -12 | -3  | 7  | 17 | 26 | 36 | 46 | 56 | 65 | 75 | 85 | 95 | 105 | 115 | 125 |
66  *  | Lower               | -45 | -36 | -26 | -16 | -5 | 4  | 14 | 24 | 35 | 45 | 54 | 65 | 75 | 85 | 94  | 104 | 113 |
67  *
68  *  # Measurement-to-Measurement Variations #
69  *  For each chip, there is a distribution of temperature readings each
70  *  measurement will yield for each true temperature. This means that if a
71  *  notification threshold close to the current temperature is chosen, the
72  *  hardware may cause an interrupt only for the driver to read out the
73  *  temperature again with a value that does not cross the set threshold.
74  *  In this case, the driver will not issue a notification. This does cost
75  *  cpu cycles and energy though.
76  *
77  *  Because of this measurement-to-measurement variability, it is not
78  *  recommended to set a threshold closer than 5 degrees to the current
79  *  temperature when registering a notification.
80  */
81 
82 #ifndef ti_drivers_temperature_TemperatureCC26X2__include
83 #define ti_drivers_temperature_TemperatureCC26X2__include
84 
85 #include <stdint.h>
86 #include <stdbool.h>
87 
88 #include <ti/drivers/Temperature.h>
89 
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93 
94 /*!
95  *  @brief Temperature driver configuration struct for CC26X2
96  *
97  *  This struct globally controls configuration settings for the CC26X2
98  *  Temperature driver.
99  *
100  *  The CC26X2 Temperature driver implementation links against a structure
101  *  of this type named TemperatureCC26X2_config.
102  *
103  *  This structure must be allocated and configured by the application. If
104  *  SysConfig is used, this struct will be automatically created when the
105  *  Temperature module is used in SysConfig.
106  */
107 typedef struct {
108     /*! @brief  Temperature sensor's interrupt priority.
109      *
110      *  The interrupt line is shared between the temperature sensor and the
111      *  battery voltage monitor on CC26X2
112      *
113      *  The CC26X2 uses three of the priority bits, meaning ~0 has the same
114      *  effect as (7 << 5).
115      *
116      *  (7 << 5) will apply the lowest priority.
117      *
118      *  (1 << 5) will apply the highest priority.
119      *
120      *  Setting the priority to 0 is not supported by this driver.
121      *
122      *  HWI's with priority 0 ignore the HWI dispatcher to support zero-latency
123      *  interrupts, thus invalidating the critical sections.
124      */
125     uint8_t intPriority;
126 } TemperatureCC26X2_Config;
127 
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* ti_drivers_temperature_TemperatureCC26X2__include */
134