1 //*****************************************************************************
2 //
3 // fan.h - Prototypes and macros for the Fan controller.
4 //
5 // Copyright (c) 2010-2012 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 //   Redistribution and use in source and binary forms, with or without
9 //   modification, are permitted provided that the following conditions
10 //   are met:
11 //
12 //   Redistributions of source code must retain the above copyright
13 //   notice, this list of conditions and the following disclaimer.
14 //
15 //   Redistributions in binary form must reproduce the above copyright
16 //   notice, this list of conditions and the following disclaimer in the
17 //   documentation and/or other materials provided with the
18 //   distribution.
19 //
20 //   Neither the name of Texas Instruments Incorporated nor the names of
21 //   its contributors may be used to endorse or promote products derived
22 //   from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __FAN_H__
41 #define __FAN_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Fan status values that can be returned from the FanChannelStatus() function.
57 //
58 //*****************************************************************************
59 #define FAN_STATUS_STALLED      0
60 #define FAN_STATUS_CHANGING     1
61 #define FAN_STATUS_LOCKED       2
62 #define FAN_STATUS_NOATTAIN     3
63 
64 //*****************************************************************************
65 //
66 // Configuration flags to be used with FanChannelConfigManual() and
67 // FanChannelConfigAuto().
68 //
69 //*****************************************************************************
70 #define FAN_CONFIG_RESTART      (1 << 15)
71 #define FAN_CONFIG_NORESTART    (0 << 15)
72 #define FAN_CONFIG_ACCEL_FAST   (1 << 14)
73 #define FAN_CONFIG_ACCEL_SLOW   (0 << 14)
74 #define FAN_CONFIG_HYST_1       (0 << 11)
75 #define FAN_CONFIG_HYST_2       (1 << 11)
76 #define FAN_CONFIG_HYST_4       (2 << 11)
77 #define FAN_CONFIG_HYST_8       (3 << 11)
78 #define FAN_CONFIG_HYST_16      (4 << 11)
79 #define FAN_CONFIG_HYST_32      (5 << 11)
80 #define FAN_CONFIG_HYST_64      (6 << 11)
81 #define FAN_CONFIG_HYST_128     (7 << 11)
82 #define FAN_CONFIG_START_2      (0 << 8)
83 #define FAN_CONFIG_START_4      (1 << 8)
84 #define FAN_CONFIG_START_8      (2 << 8)
85 #define FAN_CONFIG_START_16     (3 << 8)
86 #define FAN_CONFIG_START_32     (4 << 8)
87 #define FAN_CONFIG_START_64     (5 << 8)
88 #define FAN_CONFIG_START_128    (6 << 8)
89 #define FAN_CONFIG_START_256    (7 << 8)
90 #define FAN_CONFIG_START_DUTY_OFF \
91                                 (0 << 6)
92 #define FAN_CONFIG_START_DUTY_50 \
93                                 (1 << 6)
94 #define FAN_CONFIG_START_DUTY_75 \
95                                 (2 << 6)
96 #define FAN_CONFIG_START_DUTY_100 \
97                                 (3 << 6)
98 #define FAN_CONFIG_AVG_NONE     (0 << 4)
99 #define FAN_CONFIG_AVG_2        (1 << 4)
100 #define FAN_CONFIG_AVG_4        (2 << 4)
101 #define FAN_CONFIG_AVG_8        (3 << 4)
102 #define FAN_CONFIG_TACH_1       (0 << 2)
103 #define FAN_CONFIG_TACH_2       (1 << 2)
104 #define FAN_CONFIG_TACH_4       (2 << 2)
105 #define FAN_CONFIG_TACH_8       (3 << 2)
106 
107 //*****************************************************************************
108 //
109 // Interrupt configuration/status flags to be used with the following
110 // functions: FanIntEnable(), FanIntDisable(), FanIntStatus(), FanIntClear().
111 //
112 //*****************************************************************************
113 #define FAN_CH5_INT_AUTO_SPEED_OK \
114                                 (1 << 22)
115 #define FAN_CH5_INT_MANUAL_SPEED_CHANGE \
116                                 (1 << 22)
117 #define FAN_CH5_INT_AUTO_SPEED_ERROR \
118                                 (1 << 21)
119 #define FAN_CH5_INT_MANUAL_SPEED_UPDATE \
120                                 (1 << 21)
121 #define FAN_CH5_INT_STALL       (1 << 20)
122 #define FAN_CH4_INT_AUTO_SPEED_OK \
123                                 (1 << 18)
124 #define FAN_CH4_INT_MANUAL_SPEED_CHANGE \
125                                 (1 << 18)
126 #define FAN_CH4_INT_AUTO_SPEED_ERROR \
127                                 (1 << 17)
128 #define FAN_CH4_INT_MANUAL_SPEED_UPDATE \
129                                 (1 << 17)
130 #define FAN_CH4_INT_STALL       (1 << 16)
131 #define FAN_CH3_INT_AUTO_SPEED_OK \
132                                 (1 << 14)
133 #define FAN_CH3_INT_MANUAL_SPEED_CHANGE \
134                                 (1 << 14)
135 #define FAN_CH3_INT_AUTO_SPEED_ERROR \
136                                 (1 << 13)
137 #define FAN_CH3_INT_MANUAL_SPEED_UPDATE \
138                                 (1 << 13)
139 #define FAN_CH3_INT_STALL       (1 << 12)
140 #define FAN_CH2_INT_AUTO_SPEED_OK \
141                                 (1 << 10)
142 #define FAN_CH2_INT_MANUAL_SPEED_CHANGE \
143                                 (1 << 10)
144 #define FAN_CH2_INT_AUTO_SPEED_ERROR \
145                                 (1 << 9)
146 #define FAN_CH2_INT_MANUAL_SPEED_UPDATE \
147                                 (1 << 9)
148 #define FAN_CH2_INT_STALL       (1 << 8)
149 #define FAN_CH1_INT_AUTO_SPEED_OK \
150                                 (1 << 6)
151 #define FAN_CH1_INT_MANUAL_SPEED_CHANGE \
152                                 (1 << 6)
153 #define FAN_CH1_INT_AUTO_SPEED_ERROR \
154                                 (1 << 5)
155 #define FAN_CH1_INT_MANUAL_SPEED_UPDATE \
156                                 (1 << 5)
157 #define FAN_CH1_INT_STALL       (1 << 4)
158 #define FAN_CH0_INT_AUTO_SPEED_OK \
159                                 (1 << 2)
160 #define FAN_CH0_INT_MANUAL_SPEED_CHANGE \
161                                 (1 << 2)
162 #define FAN_CH0_INT_AUTO_SPEED_ERROR \
163                                 (1 << 1)
164 #define FAN_CH0_INT_MANUAL_SPEED_UPDATE \
165                                 (1 << 1)
166 #define FAN_CH0_INT_STALL       (1 << 0)
167 #define FAN_CHx_INT_AUTO_SPEED_OK(x) \
168                                 (1 << (((x) * 4) + 2))
169 #define FAN_CHx_INT_MANUAL_SPEED_CHANGE(x) \
170                                 (1 << (((x) * 4) + 2))
171 #define FAN_CHx_INT_AUTO_SPEED_ERROR(x) \
172                                 (1 << (((x) * 4) + 1))
173 #define FAN_CHx_INT_MANUAL_SPEED_UPDATE(x) \
174                                 (1 << (((x) * 4) + 1))
175 #define FAN_CHx_INT_STALL(x)    (1 << ((x) * 4))
176 
177 //*****************************************************************************
178 //
179 // API Function prototypes
180 //
181 //*****************************************************************************
182 extern void FanChannelEnable(unsigned long ulBase, unsigned long ulChannel);
183 extern void FanChannelDisable(unsigned long ulBase, unsigned long ulChannel);
184 extern unsigned long FanChannelStatus(unsigned long ulBase,
185                                       unsigned long ulChannel);
186 extern void FanChannelConfigManual(unsigned long ulBase,
187                                    unsigned long ulChannel,
188                                    unsigned long ulConfig);
189 extern void FanChannelConfigAuto(unsigned long ulBase, unsigned long ulChannel,
190                                  unsigned long ulConfig);
191 extern void FanChannelDutySet(unsigned long ulBase, unsigned long ulChannel,
192                               unsigned long ulDuty);
193 extern unsigned long FanChannelDutyGet(unsigned long ulBase,
194                                        unsigned long ulChannel);
195 extern void FanChannelRPMSet(unsigned long ulBase, unsigned long ulChannel,
196                              unsigned long ulRPM);
197 extern unsigned long FanChannelRPMGet(unsigned long ulBase,
198                                       unsigned long ulChannel);
199 extern void FanIntEnable(unsigned long ulBase, unsigned long ulFlags);
200 extern void FanIntDisable(unsigned long ulBase, unsigned long ulFlags);
201 extern unsigned long FanIntStatus(unsigned long ulBase, tBoolean bMasked);
202 extern void FanIntClear(unsigned long ulBase, unsigned long ulFlags);
203 extern void FanIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
204 extern void FanIntUnregister(unsigned long ulBase);
205 extern unsigned long FanChannelsGet(unsigned long ulBase);
206 
207 //*****************************************************************************
208 //
209 // Mark the end of the C bindings section for C++ compilers.
210 //
211 //*****************************************************************************
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif //  __FAN_H__
217